From 6830b05716272f1d28cfb4c28cc647209a2ada18 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 12 Oct 2004 21:28:27 +0000 Subject: [PATCH] changed indentation to use spaces only --- WINGs/Examples/colorpick.c | 18 +- WINGs/Examples/connect.c | 4 +- WINGs/Examples/fontl.c | 42 +- WINGs/Examples/puzzle.c | 245 +-- WINGs/Extras/test.c | 71 +- WINGs/Extras/wtabledelegates.c | 391 ++-- WINGs/Extras/wtabledelegates.h | 2 +- WINGs/Extras/wtableview.c | 1107 ++++++----- WINGs/Extras/wtableview.h | 76 +- WINGs/Tests/mywidget.c | 104 +- WINGs/Tests/mywidget.h | 2 +- WINGs/Tests/testmywidget.c | 19 +- WINGs/Tests/wmfile.c | 251 +-- WINGs/Tests/wmquery.c | 203 +- WINGs/Tests/wtest.c | 15 +- WINGs/WINGs/WINGs.h | 133 +- WINGs/WINGs/WINGsP.h | 19 +- WINGs/WINGs/WUtil.h | 108 +- WINGs/connection.c | 18 +- WINGs/data.c | 4 +- WINGs/dragcommon.c | 1 + WINGs/error.c | 34 +- WINGs/findfile.c | 338 ++-- WINGs/handlers.c | 127 +- WINGs/hashtable.c | 282 +-- WINGs/international.c | 2 +- WINGs/memory.c | 82 +- WINGs/notification.c | 382 ++-- WINGs/proplist.c | 12 +- WINGs/selection.c | 256 +-- WINGs/snprintf.c | 1 + WINGs/string.c | 94 +- WINGs/userdefaults.c | 118 +- WINGs/usleep.c | 4 +- WINGs/wapplication.c | 128 +- WINGs/wappresource.c | 70 +- WINGs/wballoon.c | 189 +- WINGs/wbox.c | 44 +- WINGs/wbrowser.c | 627 +++--- WINGs/wbutton.c | 560 +++--- WINGs/wcolor.c | 216 +-- WINGs/wcolorpanel.c | 3027 ++++++++++++++--------------- WINGs/wevent.c | 6 +- WINGs/wfilepanel.c | 380 ++-- WINGs/wfont_noxft.c | 2 +- WINGs/wframe.c | 1 + WINGs/widgets.c | 370 ++-- WINGs/winputmethod.c | 32 +- WINGs/wlabel.c | 118 +- WINGs/wmenuitem.c | 56 +- WINGs/wmisc.c | 320 +-- WINGs/wpanel.c | 554 +++--- WINGs/wpixmap.c | 139 +- WINGs/wpopupbutton.c | 572 +++--- WINGs/wprogressindicator.c | 178 +- WINGs/wruler.c | 15 +- WINGs/wscroller.c | 870 ++++----- WINGs/wscrollview.c | 598 +++--- WINGs/wslider.c | 434 ++--- WINGs/wsplitview.c | 601 +++--- WINGs/wtabview.c | 701 +++---- WINGs/wtext.c | 1294 +++++++------ WINGs/wtextfield.c | 1146 +++++------ WINGs/wwindow.c | 560 +++--- WPrefs.app/Appearance.c | 1706 ++++++++-------- WPrefs.app/Configurations.c | 335 ++-- WPrefs.app/Expert.c | 31 +- WPrefs.app/Focus.c | 259 +-- WPrefs.app/Font.c | 4200 ++++++++++++++++++++-------------------- WPrefs.app/Icons.c | 173 +- WPrefs.app/KeyboardSettings.c | 113 +- WPrefs.app/KeyboardShortcuts.c | 512 +++-- WPrefs.app/Menu.c | 1780 ++++++++--------- WPrefs.app/MenuPreferences.c | 151 +- WPrefs.app/MouseSettings.c | 537 ++--- WPrefs.app/Paths.c | 119 +- WPrefs.app/Preferences.c | 129 +- WPrefs.app/TexturePanel.c | 1233 ++++++------ WPrefs.app/TexturePanel.h | 20 +- WPrefs.app/Themes.c | 81 +- WPrefs.app/WPrefs.c | 632 +++--- WPrefs.app/WPrefs.h | 10 +- WPrefs.app/WindowHandling.c | 183 +- WPrefs.app/Workspace.c | 221 +-- WPrefs.app/double.c | 106 +- WPrefs.app/double.h | 1 + WPrefs.app/editmenu.c | 968 ++++----- WPrefs.app/editmenu.h | 32 +- WPrefs.app/imagebrowser.c | 82 +- WPrefs.app/imagebrowser.h | 16 +- WPrefs.app/main.c | 113 +- WPrefs.app/xmodifier.c | 540 +++--- src/GNUstep.h | 49 +- src/WindowMaker.h | 133 +- src/actions.c | 200 +- src/actions.h | 11 +- src/appicon.c | 384 ++-- src/appicon.h | 39 +- src/application.c | 232 +-- src/application.h | 35 +- src/appmenu.c | 304 +-- src/appmenu.h | 6 +- src/balloon.h | 8 +- src/client.c | 860 ++++---- src/client.h | 10 +- src/colormap.c | 107 +- src/cycling.c | 216 +-- src/def_pixmaps.h | 208 +- src/defaults.c | 8 +- src/defaults.h | 12 +- src/dialog.c | 777 ++++---- src/dialog.h | 10 +- src/dock.c | 1978 +++++++++---------- src/dock.h | 12 +- src/dockedapp.c | 343 ++-- src/event.c | 1753 ++++++++--------- src/extend_pixmaps.h | 234 +-- src/framewin.c | 3188 +++++++++++++++--------------- src/framewin.h | 80 +- src/funcs.h | 20 +- src/geomview.c | 86 +- src/geomview.h | 2 +- src/gnome.c | 545 +++--- src/gnome.h | 8 +- src/icon.c | 825 ++++---- src/icon.h | 10 +- src/keybind.h | 4 +- src/kwm.c | 1555 +++++++-------- src/kwm.h | 30 +- src/main.c | 523 ++--- src/menu.c | 2 +- src/menu.h | 74 +- src/menureader.c | 387 ++-- src/misc.c | 1048 +++++----- src/motif.c | 231 +-- src/motif.h | 8 +- src/moveres.c | 35 +- src/openlook.c | 292 +-- src/openlook.h | 8 +- src/pixmap.c | 169 +- src/pixmap.h | 14 +- src/placement.c | 475 +++-- src/properties.c | 192 +- src/properties.h | 10 +- src/resources.c | 25 +- src/resources.h | 6 +- src/rootmenu.c | 1485 +++++++------- src/rootmenu.h | 18 +- src/screen.c | 670 +++---- src/screen.h | 98 +- src/session.c | 483 ++--- src/session.h | 2 +- src/shutdown.c | 170 +- src/stacking.c | 422 ++-- src/stacking.h | 6 +- src/startup.c | 603 +++--- src/superfluous.c | 590 +++--- src/superfluous.h | 6 +- src/switchmenu.c | 409 ++-- src/text.c | 678 +++---- src/text.h | 48 +- src/texture.c | 710 +++---- src/texture.h | 18 +- src/usermenu.c | 51 +- src/usermenu.h | 2 +- src/wconfig.h.in | 44 +- src/wcore.c | 68 +- src/wcore.h | 20 +- src/wdefaults.c | 280 ++- src/wdefaults.h | 6 +- src/window.c | 2249 ++++++++++----------- src/window.h | 166 +- src/winmenu.c | 608 +++--- src/winspector.c | 1070 +++++----- src/winspector.h | 8 +- src/wmspec.h | 8 +- src/workspace.c | 808 ++++---- src/workspace.h | 10 +- src/wsound.c | 6 +- src/wsound.h | 6 +- src/xdnd.c | 164 +- src/xinerama.c | 212 +- src/xinerama.h | 6 +- src/xmodifier.c | 597 +++--- src/xmodifier.h | 4 +- src/xutil.c | 393 ++-- test/notest.c | 47 +- test/wtest.c | 86 +- util/directjpeg.c | 140 +- util/geticonset.c | 92 +- util/seticons.c | 120 +- util/setstyle.c | 7 +- util/wdread.c | 51 +- util/wdwrite.c | 50 +- util/wmagnify.c | 376 ++-- util/wmsetbg.c | 1654 ++++++++-------- util/wmsetup.c | 383 ++-- util/wxcopy.c | 194 +- util/wxpaste.c | 212 +- wmlib/WMaker.h | 58 +- wmlib/app.c | 30 +- wmlib/app.h | 13 +- wmlib/command.c | 33 +- wmlib/event.c | 63 +- wmlib/menu.c | 126 +- wmlib/menu.h | 21 +- wrlib/CmapAlloc.c | 276 ++- wrlib/CrCmap.c | 393 ++-- wrlib/DelCmap.c | 29 +- wrlib/LookupCmap.c | 265 +-- wrlib/StdCmap.c | 173 +- wrlib/alloca.c | 372 ++-- wrlib/bench.h | 136 +- wrlib/color.c | 109 +- wrlib/context.c | 869 ++++----- wrlib/convert.c | 1004 +++++----- wrlib/convolve.c | 353 ++-- wrlib/draw.c | 330 ++-- wrlib/gif.c | 279 +-- wrlib/gradient.c | 398 ++-- wrlib/jpeg.c | 119 +- wrlib/load.c | 252 +-- wrlib/misc.c | 139 +- wrlib/nxpm.c | 534 ++--- wrlib/png.c | 169 +- wrlib/ppm.c | 150 +- wrlib/raster.c | 415 ++-- wrlib/rotate.c | 507 ++--- wrlib/save.c | 12 +- wrlib/scale.c | 606 +++--- wrlib/testdraw.c | 83 +- wrlib/testgrad.c | 75 +- wrlib/testrot.c | 53 +- wrlib/tiff.c | 149 +- wrlib/view.c | 73 +- wrlib/wraster.h | 149 +- wrlib/x86_specific.c | 1516 +++++++-------- wrlib/xpixmap.c | 105 +- wrlib/xpm.c | 291 +-- wrlib/xutil.c | 256 +-- 240 files changed, 39106 insertions(+), 38928 deletions(-) rewrite WINGs/Tests/wmfile.c (76%) rewrite WINGs/Tests/wmquery.c (88%) rewrite WPrefs.app/Font.c (69%) rewrite WPrefs.app/xmodifier.c (71%) rewrite src/def_pixmaps.h (61%) rewrite src/extend_pixmaps.h (78%) rewrite src/framewin.c (62%) rewrite src/xmodifier.c (73%) rewrite src/xutil.c (64%) rewrite wrlib/bench.h (80%) rewrite wrlib/x86_specific.c (61%) diff --git a/WINGs/Examples/colorpick.c b/WINGs/Examples/colorpick.c index 143a593b..ae1695e4 100644 --- a/WINGs/Examples/colorpick.c +++ b/WINGs/Examples/colorpick.c @@ -8,7 +8,7 @@ void showSelectedColor(void *self, void *cdata) { WMColorPanel *panel= (WMColorPanel*)self; - + printf("Selected Color: %s\n", WMGetColorRGBDescription(WMGetColorPanelColor(panel))); } @@ -17,26 +17,26 @@ int main(int argc, char **argv) { Display *dpy; WMScreen *scr; - + WMInitializeApplication("wmcolorpick", &argc, argv); dpy = XOpenDisplay(""); if (!dpy) { - printf("could not open display\n"); - exit(1); + printf("could not open display\n"); + exit(1); } - + scr = WMCreateScreen(dpy, DefaultScreen(dpy)); { WMColorPanel *panel= WMGetColorPanel(scr); - + WMSetColorPanelAction(panel, showSelectedColor, NULL); - + WMShowColorPanel(panel); } - + WMScreenMainLoop(scr); - + return 0; } diff --git a/WINGs/Examples/connect.c b/WINGs/Examples/connect.c index 37d1bd2c..14a2174f 100644 --- a/WINGs/Examples/connect.c +++ b/WINGs/Examples/connect.c @@ -1,8 +1,8 @@ /* * WINGs connect.c: example how to create a network client using WMConnection - * + * * Copyright (c) 1999-2003 Dan Pascu - * + * */ diff --git a/WINGs/Examples/fontl.c b/WINGs/Examples/fontl.c index 8645ed9d..7c365b45 100644 --- a/WINGs/Examples/fontl.c +++ b/WINGs/Examples/fontl.c @@ -1,8 +1,8 @@ /* * WINGs demo: font lister - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -64,10 +64,10 @@ main(int argc, char **argv) dpy = XOpenDisplay(""); if (!dpy) { - wfatal("cant open display"); - exit(0); + wfatal("cant open display"); + exit(0); } - + scr = WMCreateSimpleApplicationScreen(dpy); win = WMCreateWindow(scr, "main"); @@ -80,25 +80,25 @@ main(int argc, char **argv) c = 0; for (y=0; y<8; y++) { - for (x=0; x<32; x++, c++) { - lab = WMCreateCustomButton(win, WBBStateLightMask); - WMResizeWidget(lab, 20, 20); - WMMoveWidget(lab, 10+x*20, 30+y*20); - sprintf(buf, "%c", c); - WMSetButtonText(lab, buf); - WMSetButtonAction(lab, show, pos); - WMHangData(lab, (void*)c); - if (c>0) { - WMGroupButtons(l0, lab); - } else { - l0 = lab; - } - } + for (x=0; x<32; x++, c++) { + lab = WMCreateCustomButton(win, WBBStateLightMask); + WMResizeWidget(lab, 20, 20); + WMMoveWidget(lab, 10+x*20, 30+y*20); + sprintf(buf, "%c", c); + WMSetButtonText(lab, buf); + WMSetButtonAction(lab, show, pos); + WMHangData(lab, (void*)c); + if (c>0) { + WMGroupButtons(l0, lab); + } else { + l0 = lab; + } + } } WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); WMScreenMainLoop(scr); - return 0; + return 0; } diff --git a/WINGs/Examples/puzzle.c b/WINGs/Examples/puzzle.c index 22f2249c..5d54d6d7 100644 --- a/WINGs/Examples/puzzle.c +++ b/WINGs/Examples/puzzle.c @@ -25,12 +25,12 @@ Bool CheckWin(void) { int i; - + for (i = 0; i < Size*Size-1; i++) { - if (Map[i] != i) - return False; + if (Map[i] != i) + return False; } - + return True; } @@ -46,37 +46,37 @@ Bool SlideButton(int button) { int x=0, y=0, done = 0; - + /* locate the button */ for (y = 0; y < Size; y++) { - for (x = 0; x < Size; x++) { - if (MAP(x,y) == button) { - done = 1; - break; - } - } - if (done) - break; + for (x = 0; x < Size; x++) { + if (MAP(x,y) == button) { + done = 1; + break; + } + } + if (done) + break; } - + if (x > 0 && MAP(x-1, y) < 0) { - MAP(x,y) = -1; - MoveButton(button, x-1, y); - MAP(x-1,y) = button; + MAP(x,y) = -1; + MoveButton(button, x-1, y); + MAP(x-1,y) = button; } else if (x < Size-1 && MAP(x+1, y) < 0) { - MAP(x,y) = -1; - MoveButton(button, x+1, y); - MAP(x+1,y) = button; + MAP(x,y) = -1; + MoveButton(button, x+1, y); + MAP(x+1,y) = button; } else if (y > 0 && MAP(x, y-1) < 0) { - MAP(x,y) = -1; - MoveButton(button, x, y-1); - MAP(x,y-1) = button; + MAP(x,y) = -1; + MoveButton(button, x, y-1); + MAP(x,y-1) = button; } else if (y < Size-1 && MAP(x, y+1) < 0) { - MAP(x,y) = -1; - MoveButton(button, x, y+1); - MAP(x,y+1) = button; + MAP(x,y) = -1; + MoveButton(button, x, y+1); + MAP(x,y+1) = button; } else { - return False; + return False; } return True; } @@ -87,46 +87,46 @@ SlideButton(int button) void ResetGame(void) { int i, x, y, ox, oy; - - + + MoveCount = 0; - + for (i = 0; i < Size*Size-1; i++) { - Map[i] = i; + Map[i] = i; } Map[i] = -1; ox = x = Size-1; oy = y = Size-1; for (i = 0; i < 1000; i++) { - int ok; - ok = 1; - switch (rand()%4) { - case 0: - if (x > 0) x--; else ok = 0; - break; - case 2: - if (x < Size-1) x++; else ok = 0; - break; - case 1: - if (y > 0) y--; else ok = 0; - break; - case 3: - if (y < Size-1) y++; else ok = 0; - break; - } - if (ok) { - MoveButton(MAP(x,y), ox, oy); - - SWAP(MAP(ox, oy), MAP(x, y)); - - while (XPending(WMScreenDisplay(WMWidgetScreen(win)))) { - XEvent ev; - WMNextEvent(WMScreenDisplay(WMWidgetScreen(win)), &ev); - WMHandleEvent(&ev); - } - ox = x; - oy = y; - } + int ok; + ok = 1; + switch (rand()%4) { + case 0: + if (x > 0) x--; else ok = 0; + break; + case 2: + if (x < Size-1) x++; else ok = 0; + break; + case 1: + if (y > 0) y--; else ok = 0; + break; + case 3: + if (y < Size-1) y++; else ok = 0; + break; + } + if (ok) { + MoveButton(MAP(x,y), ox, oy); + + SWAP(MAP(ox, oy), MAP(x, y)); + + while (XPending(WMScreenDisplay(WMWidgetScreen(win)))) { + XEvent ev; + WMNextEvent(WMScreenDisplay(WMWidgetScreen(win)), &ev); + WMHandleEvent(&ev); + } + ox = x; + oy = y; + } } } @@ -136,18 +136,18 @@ void buttonClick(WMWidget *w, void *ptr) char buffer[300]; if (SlideButton((int)ptr)) { - MoveCount++; - - if (CheckWin()) { - sprintf(buffer, "You finished the game in %i moves.", MoveCount); - - if (WMRunAlertPanel(WMWidgetScreen(w), win, "You Won!", buffer, - "Wee!", "Gah! Lemme retry!", NULL) == WAPRDefault) { - exit(0); - } - - ResetGame(); - } + MoveCount++; + + if (CheckWin()) { + sprintf(buffer, "You finished the game in %i moves.", MoveCount); + + if (WMRunAlertPanel(WMWidgetScreen(w), win, "You Won!", buffer, + "Wee!", "Gah! Lemme retry!", NULL) == WAPRDefault) { + exit(0); + } + + ResetGame(); + } } } @@ -156,17 +156,17 @@ static void resizeObserver(void *self, WMNotification *notif) { WMSize size = WMGetViewSize(WMWidgetView(win)); int x, y; - + WinSize = size.width; for (y = 0; y < Size; y++) { - for (x = 0; x < Size; x++) { - if (MAP(x,y) >= 0) { - WMResizeWidget(Button[(int)MAP(x,y)], - WinSize/Size, WinSize/Size); - WMMoveWidget(Button[(int)MAP(x,y)], - x*(WinSize/Size), y*(WinSize/Size)); - } - } + for (x = 0; x < Size; x++) { + if (MAP(x,y) >= 0) { + WMResizeWidget(Button[(int)MAP(x,y)], + WinSize/Size, WinSize/Size); + WMMoveWidget(Button[(int)MAP(x,y)], + x*(WinSize/Size), y*(WinSize/Size)); + } + } } } @@ -177,18 +177,18 @@ int main(int argc, char **argv) Display *dpy; WMScreen *scr; int x, y, i; - + WMInitializeApplication("Puzzle", &argc, argv); - + dpy = XOpenDisplay(""); if (!dpy) { - printf("could not open display\n"); - exit(1); + printf("could not open display\n"); + exit(1); } - + scr = WMCreateScreen(dpy, DefaultScreen(dpy)); - + win = WMCreateWindow(scr, "puzzle"); WMResizeWidget(win, WinSize, WinSize); WMSetWindowTitle(win, "zuPzel"); @@ -197,48 +197,49 @@ int main(int argc, char **argv) WMSetWindowResizeIncrements(win, Size, Size); WMSetViewNotifySizeChanges(WMWidgetView(win), True); WMAddNotificationObserver(resizeObserver, NULL, - WMViewSizeDidChangeNotification, - WMWidgetView(win)); - - - + WMViewSizeDidChangeNotification, + WMWidgetView(win)); + + + for (i = y = 0; y < Size && i < Size*Size-1; y++) { - for (x = 0; x < Size && i < Size*Size-1; x++) { - char buf[32]; - WMColor *color; - RColor col; - RHSVColor hsv; - - hsv.hue = i*360/(Size*Size-1); - hsv.saturation = 120; - hsv.value = 200; - - RHSVtoRGB(&hsv, &col); - - color = WMCreateRGBColor(scr, col.red<<8, col.green<<8, - col.blue<<8, False); - - MAP(x,y) = i; - Button[i] = WMCreateButton(win, WBTMomentaryLight); - WMSetWidgetBackgroundColor(Button[i], color); - WMReleaseColor(color); - WMSetButtonAction(Button[i], buttonClick, (void*)i); - WMResizeWidget(Button[i], WinSize/Size, WinSize/Size); - WMMoveWidget(Button[i], x*(WinSize/Size), y*(WinSize/Size)); - sprintf(buf, "%i", i+1); - WMSetButtonText(Button[i], buf); - WMSetButtonTextAlignment(Button[i], WACenter); - i++; - } + for (x = 0; x < Size && i < Size*Size-1; x++) { + char buf[32]; + WMColor *color; + RColor col; + RHSVColor hsv; + + hsv.hue = i*360/(Size*Size-1); + hsv.saturation = 120; + hsv.value = 200; + + RHSVtoRGB(&hsv, &col); + + color = WMCreateRGBColor(scr, col.red<<8, col.green<<8, + col.blue<<8, False); + + MAP(x,y) = i; + Button[i] = WMCreateButton(win, WBTMomentaryLight); + WMSetWidgetBackgroundColor(Button[i], color); + WMReleaseColor(color); + WMSetButtonAction(Button[i], buttonClick, (void*)i); + WMResizeWidget(Button[i], WinSize/Size, WinSize/Size); + WMMoveWidget(Button[i], x*(WinSize/Size), y*(WinSize/Size)); + sprintf(buf, "%i", i+1); + WMSetButtonText(Button[i], buf); + WMSetButtonTextAlignment(Button[i], WACenter); + i++; + } } - + WMMapSubwidgets(win); WMMapWidget(win); WMRealizeWidget(win); - + ResetGame(); WMScreenMainLoop(scr); - + return 0; } + diff --git a/WINGs/Extras/test.c b/WINGs/Extras/test.c index 3874112d..e1c0ef2f 100644 --- a/WINGs/Extras/test.c +++ b/WINGs/Extras/test.c @@ -12,61 +12,65 @@ static int col2[20]; static char *options[] = { "Option1", - "Option2", - "Option3", - "Option4", - "Option5" + "Option2", + "Option3", + "Option4", + "Option5" }; -int numberOfRows(WMTableViewDelegate *self, WMTableView *table) +int +numberOfRows(WMTableViewDelegate *self, WMTableView *table) { return 20; } -void *valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row) +void* +valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row) { /*WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column);*/ int i; if (col1[0] == 0) { - for (i = 0; i < 20; i++) { - char buf[128]; + for (i = 0; i < 20; i++) { + char buf[128]; - sprintf(buf, "Test row %i", i); + sprintf(buf, "Test row %i", i); - col1[i] = wstrdup(buf); - col2[i] = 0; - } + col1[i] = wstrdup(buf); + col2[i] = 0; + } } if ((int)WMGetTableColumnId(column) == 1) - return col1[row]; + return col1[row]; else - return (void*)col2[row]; + return (void*)col2[row]; } -void setValueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row, - void *data) +void +setValueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row, + void *data) { if ((int)WMGetTableColumnId(column) == 1) - col1[row] = data; + col1[row] = data; else - col2[row] = (int)data; + col2[row] = (int)data; } static WMTableViewDelegate delegate = { NULL, - numberOfRows, - valueForCell, - setValueForCell + numberOfRows, + valueForCell, + setValueForCell }; -void clickedTable(WMWidget *w, void *self) -{ +void +clickedTable(WMWidget *w, void *self) +{ int row = WMGetTableViewClickedRow((WMTableView*)self); WMEditTableViewRow(self, row); @@ -82,17 +86,17 @@ main(int argc, char **argv) WMTableView *table; WMTableColumn *col; WMTableColumnDelegate *colDeleg; - + WMInitializeApplication("test", &argc, argv); - + scr = WMOpenScreen(NULL); XSynchronize(WMScreenDisplay(scr), 1); - + win = WMCreateWindow(scr, "eweq"); WMResizeWidget(win, 400, 200); WMMapWidget(win); - + table = WMCreateTableView(win); WMSetTableViewHasHorizontalScroller(table, 0); WMSetViewExpandsToParent(WMWidgetView(table), 10, 10, 10, 10); @@ -101,12 +105,12 @@ main(int argc, char **argv) WMSetTableViewHeaderHeight(table, 20); WMSetTableViewDelegate(table, &delegate); WMSetTableViewAction(table, clickedTable, table); - + colDeleg = WTCreateStringEditorDelegate(table); - + col = WMCreateTableColumn("Group"); WMSetTableColumnWidth(col, 180); - WMAddTableViewColumn(table, col); + WMAddTableViewColumn(table, col); WMSetTableColumnDelegate(col, colDeleg); WMSetTableColumnId(col, (void*)1); @@ -115,15 +119,15 @@ main(int argc, char **argv) col = WMCreateTableColumn("Package"); WMSetTableColumnWidth(col, 140); - WMAddTableViewColumn(table, col); + WMAddTableViewColumn(table, col); WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)2); + WMSetTableColumnId(col, (void*)2); colDeleg = WTCreateBooleanSwitchDelegate(table); col = WMCreateTableColumn("Bool"); WMSetTableColumnWidth(col, 50); - WMAddTableViewColumn(table, col); + WMAddTableViewColumn(table, col); WMSetTableColumnDelegate(col, colDeleg); WMSetTableColumnId(col, (void*)2); @@ -133,3 +137,4 @@ main(int argc, char **argv) return 0; } + diff --git a/WINGs/Extras/wtabledelegates.c b/WINGs/Extras/wtabledelegates.c index 0a1649de..9c46e7dc 100644 --- a/WINGs/Extras/wtabledelegates.c +++ b/WINGs/Extras/wtabledelegates.c @@ -37,7 +37,7 @@ typedef struct { WMTableView *table; WMFont *font; char **options; - int count; + int count; GC gc; GC selGC; WMColor *textColor; @@ -57,9 +57,9 @@ static char *SelectionColor = "#bbbbcc"; -static void stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, - WMColor *textColor, WMFont *font, void *data, - WMRect rect, Bool selected) +static void +stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, WMColor *textColor, + WMFont *font, void *data, WMRect rect, Bool selected) { int x, y; XRectangle rects[1]; @@ -73,26 +73,27 @@ static void stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, rects[0].width = rect.size.width-1; rects[0].height = rect.size.height-1; XSetClipRectangles(dpy, gc, 0, 0, rects, 1, YXSorted); - + if (!selected) { - XFillRectangles(dpy, d, gc, rects, 1); + XFillRectangles(dpy, d, gc, rects, 1); - WMDrawString(scr, d, textColor, font, x, y, - data, strlen(data)); + WMDrawString(scr, d, textColor, font, x, y, + data, strlen(data)); } else { - XFillRectangles(dpy, d, sgc, rects, 1); + XFillRectangles(dpy, d, sgc, rects, 1); - WMDrawString(scr, d, textColor, font, x, y, - data, strlen(data)); + WMDrawString(scr, d, textColor, font, x, y, + data, strlen(data)); } - + XSetClipMask(dpy, gc, None); } -static void pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, - WMPixmap *pixmap, WMRect rect, Bool selected) +static void +pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, WMPixmap *pixmap, + WMRect rect, Bool selected) { int x, y; XRectangle rects[1]; @@ -104,29 +105,29 @@ static void pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, rects[0].width = rect.size.width-1; rects[0].height = rect.size.height-1; XSetClipRectangles(dpy, gc, 0, 0, rects, 1, YXSorted); - + if (!selected) { - XFillRectangles(dpy, d, gc, rects, 1); - - if (pixmap) { - size = WMGetPixmapSize(pixmap); - x = rect.pos.x + (rect.size.width - size.width) / 2; - y = rect.pos.y + (rect.size.height - size.height) / 2; - - WMDrawPixmap(pixmap, d, x, y); - } + XFillRectangles(dpy, d, gc, rects, 1); + + if (pixmap) { + size = WMGetPixmapSize(pixmap); + x = rect.pos.x + (rect.size.width - size.width) / 2; + y = rect.pos.y + (rect.size.height - size.height) / 2; + + WMDrawPixmap(pixmap, d, x, y); + } } else { - XFillRectangles(dpy, d, sgc, rects, 1); - - if (pixmap) { - size = WMGetPixmapSize(pixmap); - x = rect.pos.x + (rect.size.width - size.width) / 2; - y = rect.pos.y + (rect.size.height - size.height) / 2; - - WMDrawPixmap(pixmap, d, x, y); - } + XFillRectangles(dpy, d, sgc, rects, 1); + + if (pixmap) { + size = WMGetPixmapSize(pixmap); + x = rect.pos.x + (rect.size.width - size.width) / 2; + y = rect.pos.y + (rect.size.height - size.height) / 2; + + WMDrawPixmap(pixmap, d, x, y); + } } - + XSetClipMask(dpy, gc, None); } @@ -135,38 +136,40 @@ static void pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, -static void SECellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +SECellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { StringEditorData *strdata = (StringEditorData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); - + stringDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->selGC, strdata->textColor, strdata->font, - WMTableViewDataForCell(table, column, row), - WMTableViewRectForCell(table, column, row), - False); + strdata->gc, strdata->selGC, strdata->textColor, strdata->font, + WMTableViewDataForCell(table, column, row), + WMTableViewRectForCell(table, column, row), + False); } -static void selectedSECellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +selectedSECellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { StringEditorData *strdata = (StringEditorData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); - + stringDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->selGC, strdata->textColor, strdata->font, - WMTableViewDataForCell(table, column, row), - WMTableViewRectForCell(table, column, row), - True); + strdata->gc, strdata->selGC, strdata->textColor, strdata->font, + WMTableViewDataForCell(table, column, row), + WMTableViewRectForCell(table, column, row), + True); } -static void beginSECellEdit(WMTableColumnDelegate *self, - WMTableColumn *column, int row) +static void +beginSECellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row) { - StringEditorData *strdata = (StringEditorData*)self->data; + StringEditorData *strdata = (StringEditorData*)self->data; WMRect rect = WMTableViewRectForCell(strdata->table, column, row); void *data = WMTableViewDataForCell(strdata->table, column, row); @@ -178,35 +181,36 @@ static void beginSECellEdit(WMTableColumnDelegate *self, } -static void endSECellEdit(WMTableColumnDelegate *self, - WMTableColumn *column, int row) +static void +endSECellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row) { StringEditorData *strdata = (StringEditorData*)self->data; char *text; WMUnmapWidget(strdata->widget); - + text = WMGetTextFieldText(strdata->widget); WMSetTableViewDataForCell(strdata->table, column, row, (void*)text); } -WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *parent) +WMTableColumnDelegate* +WTCreateStringEditorDelegate(WMTableView *parent) { WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate)); WMScreen *scr = WMWidgetScreen(parent); StringEditorData *data = wmalloc(sizeof(StringEditorData)); - + data->widget = WMCreateTextField(parent); - W_ReparentView(WMWidgetView(data->widget), - WMGetTableViewDocumentView(parent), - 0, 0); + W_ReparentView(WMWidgetView(data->widget), + WMGetTableViewDocumentView(parent), + 0, 0); data->table = parent; data->font = WMSystemFontOfSize(scr, 12); data->gc = WMColorGC(WMWhiteColor(scr)); data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False)); data->textColor = WMBlackColor(scr); - + delegate->data = data; delegate->drawCell = SECellPainter; delegate->drawSelectedCell = selectedSECellPainter; @@ -221,47 +225,49 @@ WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *parent) /* ---------------------------------------------------------------------- */ -static void ESCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +ESCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { EnumSelectorData *strdata = (EnumSelectorData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); int i = (int)WMTableViewDataForCell(table, column, row); - + stringDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->selGC, strdata->textColor, strdata->font, - strdata->options[i], - WMTableViewRectForCell(table, column, row), - False); + strdata->gc, strdata->selGC, strdata->textColor, strdata->font, + strdata->options[i], + WMTableViewRectForCell(table, column, row), + False); } -static void selectedESCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +selectedESCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { EnumSelectorData *strdata = (EnumSelectorData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); int i = (int)WMTableViewDataForCell(table, column, row); - + stringDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->selGC, strdata->textColor, strdata->font, - strdata->options[i], - WMTableViewRectForCell(table, column, row), - True); + strdata->gc, strdata->selGC, strdata->textColor, strdata->font, + strdata->options[i], + WMTableViewRectForCell(table, column, row), + True); } -static void beginESCellEdit(WMTableColumnDelegate *self, - WMTableColumn *column, int row) +static void +beginESCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row) { - EnumSelectorData *strdata = (EnumSelectorData*)self->data; + EnumSelectorData *strdata = (EnumSelectorData*)self->data; WMRect rect = WMTableViewRectForCell(strdata->table, column, row); int data = (int)WMTableViewDataForCell(strdata->table, column, row); wassertr(data < strdata->count); - + WMSetPopUpButtonSelectedItem(strdata->widget, data); - + WMMoveWidget(strdata->widget, rect.pos.x, rect.pos.y); WMResizeWidget(strdata->widget, rect.size.width, rect.size.height+1); @@ -269,29 +275,30 @@ static void beginESCellEdit(WMTableColumnDelegate *self, } -static void endESCellEdit(WMTableColumnDelegate *self, - WMTableColumn *column, int row) +static void +endESCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row) { EnumSelectorData *strdata = (EnumSelectorData*)self->data; int option; WMUnmapWidget(strdata->widget); - + option = WMGetPopUpButtonSelectedItem(strdata->widget); WMSetTableViewDataForCell(strdata->table, column, row, (void*)option); } -WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent) +WMTableColumnDelegate* +WTCreateEnumSelectorDelegate(WMTableView *parent) { WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate)); WMScreen *scr = WMWidgetScreen(parent); EnumSelectorData *data = wmalloc(sizeof(EnumSelectorData)); - + data->widget = WMCreatePopUpButton(parent); - W_ReparentView(WMWidgetView(data->widget), - WMGetTableViewDocumentView(parent), - 0, 0); + W_ReparentView(WMWidgetView(data->widget), + WMGetTableViewDocumentView(parent), + 0, 0); data->table = parent; data->font = WMSystemFontOfSize(scr, 12); data->gc = WMColorGC(WMWhiteColor(scr)); @@ -299,7 +306,7 @@ WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent) data->textColor = WMBlackColor(scr); data->count = 0; data->options = NULL; - + delegate->data = data; delegate->drawCell = ESCellPainter; delegate->drawSelectedCell = selectedESCellPainter; @@ -310,23 +317,24 @@ WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent) } -void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate, - char **options, int count) +void +WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate, char **options, + int count) { EnumSelectorData *data = (EnumSelectorData*)delegate->data; int i; - + for (i = 0; - i < WMGetPopUpButtonNumberOfItems(data->widget); - i++) { - WMRemovePopUpButtonItem(data->widget, 0); + i < WMGetPopUpButtonNumberOfItems(data->widget); + i++) { + WMRemovePopUpButtonItem(data->widget, 0); } - + data->options = options; data->count = count; - + for (i = 0; i < count; i++) { - WMAddPopUpButtonItem(data->widget, options[i]); + WMAddPopUpButtonItem(data->widget, options[i]); } } @@ -334,51 +342,53 @@ void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate, /* ---------------------------------------------------------------------- */ -static void BSCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +BSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { BooleanSwitchData *strdata = (BooleanSwitchData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); int i = (int)WMTableViewDataForCell(table, column, row); WMScreen *scr = WMWidgetScreen(table); - + if (i) { - pixmapDraw(scr, d, - strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark), - WMTableViewRectForCell(table, column, row), False); + pixmapDraw(scr, d, + strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark), + WMTableViewRectForCell(table, column, row), False); } else { - pixmapDraw(scr, d, - strdata->gc, strdata->selGC, NULL, - WMTableViewRectForCell(table, column, row), False); + pixmapDraw(scr, d, + strdata->gc, strdata->selGC, NULL, + WMTableViewRectForCell(table, column, row), False); } } -static void selectedBSCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +selectedBSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { BooleanSwitchData *strdata = (BooleanSwitchData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); int i = (int)WMTableViewDataForCell(table, column, row); WMScreen *scr = WMWidgetScreen(table); - + if (i) { - pixmapDraw(scr, d, - strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark), - WMTableViewRectForCell(table, column, row), True); + pixmapDraw(scr, d, + strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark), + WMTableViewRectForCell(table, column, row), True); } else { - pixmapDraw(scr, d, - strdata->gc, strdata->selGC, NULL, - WMTableViewRectForCell(table, column, row), True); - } + pixmapDraw(scr, d, + strdata->gc, strdata->selGC, NULL, + WMTableViewRectForCell(table, column, row), True); + } } -static void beginBSCellEdit(WMTableColumnDelegate *self, - WMTableColumn *column, int row) +static void +beginBSCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row) { - BooleanSwitchData *strdata = (BooleanSwitchData*)self->data; + BooleanSwitchData *strdata = (BooleanSwitchData*)self->data; WMRect rect = WMTableViewRectForCell(strdata->table, column, row); int data = (int)WMTableViewDataForCell(strdata->table, column, row); @@ -390,19 +400,20 @@ static void beginBSCellEdit(WMTableColumnDelegate *self, } -static void endBSCellEdit(WMTableColumnDelegate *self, - WMTableColumn *column, int row) +static void +endBSCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row) { - BooleanSwitchData *strdata = (BooleanSwitchData*)self->data; + BooleanSwitchData *strdata = (BooleanSwitchData*)self->data; int value; - + value = WMGetButtonSelected(strdata->widget); WMSetTableViewDataForCell(strdata->table, column, row, (void*)value); WMUnmapWidget(strdata->widget); } -WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent) +WMTableColumnDelegate* +WTCreateBooleanSwitchDelegate(WMTableView *parent) { WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate)); WMScreen *scr = WMWidgetScreen(parent); @@ -410,20 +421,20 @@ WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent) WMColor *color; data->widget = WMCreateSwitchButton(parent); - W_ReparentView(WMWidgetView(data->widget), - WMGetTableViewDocumentView(parent), - 0, 0); + W_ReparentView(WMWidgetView(data->widget), + WMGetTableViewDocumentView(parent), + 0, 0); WMSetButtonText(data->widget, NULL); WMSetButtonImagePosition(data->widget, WIPImageOnly); WMSetButtonImage(data->widget, NULL); WMSetButtonAltImage(data->widget, WMGetSystemPixmap(scr, WSICheckMark)); - + data->table = parent; color = WMCreateNamedColor(scr, SelectionColor, False); - WMSetWidgetBackgroundColor(data->widget, color); + WMSetWidgetBackgroundColor(data->widget, color); data->gc = WMColorGC(WMWhiteColor(scr)); data->selGC = WMColorGC(color); - + delegate->data = data; delegate->drawCell = BSCellPainter; delegate->drawSelectedCell = selectedBSCellPainter; @@ -437,46 +448,49 @@ WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent) /* ---------------------------------------------------------------------- */ -static void SCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +SCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { StringData *strdata = (StringData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); - + stringDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->selGC, strdata->textColor, strdata->font, - WMTableViewDataForCell(table, column, row), - WMTableViewRectForCell(table, column, row), - False); + strdata->gc, strdata->selGC, strdata->textColor, strdata->font, + WMTableViewDataForCell(table, column, row), + WMTableViewRectForCell(table, column, row), + False); } -static void selectedSCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +selectedSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { StringData *strdata = (StringData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); - + stringDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->selGC, strdata->textColor, strdata->font, - WMTableViewDataForCell(table, column, row), - WMTableViewRectForCell(table, column, row), - True); + strdata->gc, strdata->selGC, strdata->textColor, strdata->font, + WMTableViewDataForCell(table, column, row), + WMTableViewRectForCell(table, column, row), + True); } -WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent) +WMTableColumnDelegate* +WTCreateStringDelegate(WMTableView *parent) { WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate)); WMScreen *scr = WMWidgetScreen(parent); StringData *data = wmalloc(sizeof(StringData)); - + data->table = parent; data->font = WMSystemFontOfSize(scr, 12); data->gc = WMColorGC(WMWhiteColor(scr)); data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False)); data->textColor = WMBlackColor(scr); - + delegate->data = data; delegate->drawCell = SCellPainter; delegate->drawSelectedCell = selectedSCellPainter; @@ -490,44 +504,47 @@ WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent) /* ---------------------------------------------------------------------- */ -static void PCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +PCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { StringData *strdata = (StringData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); - + pixmapDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->selGC, - (WMPixmap*)WMTableViewDataForCell(table, column, row), - WMTableViewRectForCell(table, column, row), - False); + strdata->gc, strdata->selGC, + (WMPixmap*)WMTableViewDataForCell(table, column, row), + WMTableViewRectForCell(table, column, row), + False); } -static void selectedPCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +selectedPCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { StringData *strdata = (StringData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); - + pixmapDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->selGC, - (WMPixmap*)WMTableViewDataForCell(table, column, row), - WMTableViewRectForCell(table, column, row), - True); + strdata->gc, strdata->selGC, + (WMPixmap*)WMTableViewDataForCell(table, column, row), + WMTableViewRectForCell(table, column, row), + True); } -WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table) +WMTableColumnDelegate* +WTCreatePixmapDelegate(WMTableView *table) { WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate)); WMScreen *scr = WMWidgetScreen(table); StringData *data = wmalloc(sizeof(StringData)); - + data->table = table; data->gc = WMColorGC(WMWhiteColor(scr)); data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False)); - + delegate->data = data; delegate->drawCell = PCellPainter; delegate->drawSelectedCell = selectedPCellPainter; @@ -541,8 +558,9 @@ WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table) /* ---------------------------------------------------------------------- */ -static void drawPSCell(WMTableColumnDelegate *self, Drawable d, - WMTableColumn *column, int row, Bool selected) +static void +drawPSCell(WMTableColumnDelegate *self, Drawable d, WMTableColumn *column, + int row, Bool selected) { StringData *strdata = (StringData*)self->data; WMTableView *table = WMGetTableColumnTableView(column); @@ -554,57 +572,60 @@ static void drawPSCell(WMTableColumnDelegate *self, Drawable d, data = WMTableViewDataForCell(table, column, row); - str = (char*)data[0]; + str = (char*)data[0]; pix = (WMPixmap*)data[1]; rect = WMTableViewRectForCell(table, column, row); - + if (pix) { - int owidth = rect.size.width; + int owidth = rect.size.width; - size = WMGetPixmapSize(pix); - rect.size.width = size.width; + size = WMGetPixmapSize(pix); + rect.size.width = size.width; - pixmapDraw(WMWidgetScreen(table), - WMViewXID(WMGetTableViewDocumentView(table)), - strdata->gc, strdata->selGC, pix, rect, - selected); + pixmapDraw(WMWidgetScreen(table), + WMViewXID(WMGetTableViewDocumentView(table)), + strdata->gc, strdata->selGC, pix, rect, + selected); - rect.pos.x += size.width-1; - rect.size.width = owidth-size.width+1; + rect.pos.x += size.width-1; + rect.size.width = owidth-size.width+1; } - + stringDraw(WMWidgetScreen(table), d, strdata->gc, strdata->selGC, strdata->textColor, strdata->font, str, rect, selected); } -static void PSCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +PSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { drawPSCell(self, d, column, row, False); } -static void selectedPSCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) +static void +selectedPSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column, + int row, Drawable d) { drawPSCell(self, d, column, row, True); } -WMTableColumnDelegate *WTCreatePixmapStringDelegate(WMTableView *parent) +WMTableColumnDelegate* +WTCreatePixmapStringDelegate(WMTableView *parent) { WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate)); WMScreen *scr = WMWidgetScreen(parent); StringData *data = wmalloc(sizeof(StringData)); - + data->table = parent; data->font = WMSystemFontOfSize(scr, 12); data->gc = WMColorGC(WMWhiteColor(scr)); data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False)); data->textColor = WMBlackColor(scr); - + delegate->data = data; delegate->drawCell = PSCellPainter; delegate->drawSelectedCell = selectedPSCellPainter; diff --git a/WINGs/Extras/wtabledelegates.h b/WINGs/Extras/wtabledelegates.h index a91f18e9..82b7c058 100644 --- a/WINGs/Extras/wtabledelegates.h +++ b/WINGs/Extras/wtabledelegates.h @@ -14,7 +14,7 @@ WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *table); WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *table); void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate, - char **options, int count); + char **options, int count); WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent); diff --git a/WINGs/Extras/wtableview.c b/WINGs/Extras/wtableview.c index 97126f7e..94a2c3bb 100644 --- a/WINGs/Extras/wtableview.c +++ b/WINGs/Extras/wtableview.c @@ -16,7 +16,7 @@ struct W_TableColumn { int width; int minWidth; int maxWidth; - + void *id; WMTableColumnDelegate *delegate; @@ -33,83 +33,90 @@ static void rearrangeHeader(WMTableView *table); static WMRange rowsInRect(WMTableView *table, WMRect rect); -WMTableColumn *WMCreateTableColumn(char *title) +WMTableColumn* +WMCreateTableColumn(char *title) { WMTableColumn *col = wmalloc(sizeof(WMTableColumn)); - + col->table = NULL; col->titleW = NULL; col->width = 50; col->minWidth = 5; col->maxWidth = 0; - + col->id = NULL; - + col->title = wstrdup(title); - + col->delegate = NULL; - + col->resizable = 1; col->editable = 0; - + return col; } -void WMSetTableColumnId(WMTableColumn *column, void *id) +void +WMSetTableColumnId(WMTableColumn *column, void *id) { column->id = id; } -void *WMGetTableColumnId(WMTableColumn *column) +void* +WMGetTableColumnId(WMTableColumn *column) { return column->id; } -void WMSetTableColumnWidth(WMTableColumn *column, unsigned width) +void +WMSetTableColumnWidth(WMTableColumn *column, unsigned width) { if (column->maxWidth == 0) - column->width = WMAX(column->minWidth, width); + column->width = WMAX(column->minWidth, width); else - column->width = WMAX(column->minWidth, WMIN(column->maxWidth, width)); + column->width = WMAX(column->minWidth, WMIN(column->maxWidth, width)); if (column->table) { - rearrangeHeader(column->table); + rearrangeHeader(column->table); } } -void WMSetTableColumnDelegate(WMTableColumn *column, - WMTableColumnDelegate *delegate) +void +WMSetTableColumnDelegate(WMTableColumn *column, WMTableColumnDelegate *delegate) { column->delegate = delegate; } -void WMSetTableColumnConstraints(WMTableColumn *column, - unsigned minWidth, unsigned maxWidth) +void +WMSetTableColumnConstraints(WMTableColumn *column, unsigned minWidth, + unsigned maxWidth) { wassertr(maxWidth == 0 || minWidth <= maxWidth); - + column->minWidth = minWidth; column->maxWidth = maxWidth; - + if (column->width < column->minWidth) - WMSetTableColumnWidth(column, column->minWidth); + WMSetTableColumnWidth(column, column->minWidth); else if (column->width > column->maxWidth && column->maxWidth != 0) - WMSetTableColumnWidth(column, column->maxWidth); + WMSetTableColumnWidth(column, column->maxWidth); } -void WMSetTableColumnEditable(WMTableColumn *column, Bool flag) +void +WMSetTableColumnEditable(WMTableColumn *column, Bool flag) { column->editable = ((flag==0) ? 0 : 1); } -WMTableView *WMGetTableColumnTableView(WMTableColumn *column) +WMTableView* +WMGetTableColumnTableView(WMTableColumn *column) { return column->table; } @@ -121,13 +128,13 @@ struct W_TableView { WMView *view; WMFrame *header; - + WMLabel *corner; WMScroller *hscroll; WMScroller *vscroll; WMView *tableView; - + WMPixmap *viewBuffer; WMArray *columns; @@ -136,30 +143,30 @@ struct W_TableView { WMArray *selectedRows; int tableWidth; - + int rows; WMColor *backColor; - + GC gridGC; WMColor *gridColor; - + Cursor splitterCursor; - + void *dataSource; WMTableViewDelegate *delegate; WMAction *action; void *clientData; - + void *clickedColumn; int clickedRow; - + int editingRow; - + unsigned headerHeight; - + unsigned rowHeight; unsigned dragging:1; @@ -177,10 +184,10 @@ static W_Class tableClass = 0; static W_ViewDelegate viewDelegate = { NULL, - NULL, - handleResize, - NULL, - NULL + NULL, + handleResize, + NULL, + NULL }; @@ -192,33 +199,35 @@ static void handleEvents(XEvent *event, void *data); static void handleTableEvents(XEvent *event, void *data); static void repaintTable(WMTableView *table); -static WMSize getTotalSize(WMTableView *table) +static WMSize +getTotalSize(WMTableView *table) { WMSize size; int i; - + /* get width from columns */ size.width = 0; for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { - WMTableColumn *column; - - column = WMGetFromArray(table->columns, i); - - size.width += column->width; + WMTableColumn *column; + + column = WMGetFromArray(table->columns, i); + + size.width += column->width; } /* get height from rows */ size.height = table->rows * table->rowHeight; - + return size; } -static WMRect getVisibleRect(WMTableView *table) +static WMRect +getVisibleRect(WMTableView *table) { WMSize size = getTotalSize(table); WMRect rect; - + if (table->vscroll) { rect.size.height = size.height * WMGetScrollerKnobProportion(table->vscroll); rect.pos.y = (size.height - rect.size.height) * WMGetScrollerValue(table->vscroll); @@ -226,7 +235,7 @@ static WMRect getVisibleRect(WMTableView *table) rect.size.height = size.height; rect.pos.y = 0; } - + if (table->hscroll) { rect.size.width = size.width * WMGetScrollerKnobProportion(table->hscroll); rect.pos.x = (size.width - rect.size.width) * WMGetScrollerValue(table->hscroll); @@ -239,12 +248,13 @@ static WMRect getVisibleRect(WMTableView *table) } -static void scrollToPoint(WMTableView *table, int x, int y) +static void +scrollToPoint(WMTableView *table, int x, int y) { WMSize size = getTotalSize(table); int i; float value, prop; - + if (table->hscroll) { if (size.width > W_VIEW_WIDTH(table->tableView)) { prop = (float)W_VIEW_WIDTH(table->tableView) / (float)size.width; @@ -270,22 +280,23 @@ static void scrollToPoint(WMTableView *table, int x, int y) if (table->editingRow >= 0) { - for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { - WMTableColumn *column; - - column = WMGetFromArray(table->columns, i); - - if (column->delegate && column->delegate->beginCellEdit) - (*column->delegate->beginCellEdit)(column->delegate, column, - table->editingRow); - } + for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { + WMTableColumn *column; + + column = WMGetFromArray(table->columns, i); + + if (column->delegate && column->delegate->beginCellEdit) + (*column->delegate->beginCellEdit)(column->delegate, column, + table->editingRow); + } } repaintTable(table); } -static void adjustScrollers(WMTableView *table) +static void +adjustScrollers(WMTableView *table) { WMSize size = getTotalSize(table); WMSize vsize = WMGetViewSize(table->tableView); @@ -301,7 +312,7 @@ static void adjustScrollers(WMTableView *table) if (oprop == 0.0) oprop = 1.0; ovalue = WMGetScrollerValue(table->hscroll); - + prop = (float)vsize.width/(float)size.width; value = prop*ovalue / oprop; } @@ -315,18 +326,19 @@ static void adjustScrollers(WMTableView *table) } else { oprop = WMGetScrollerKnobProportion(table->vscroll); if (oprop == 0.0) - oprop = 1.0; + oprop = 1.0; ovalue = WMGetScrollerValue(table->vscroll); - - prop = (float)vsize.height/(float)size.height; - value = prop*ovalue / oprop; + + prop = (float)vsize.height/(float)size.height; + value = prop*ovalue / oprop; } WMSetScrollerParameters(table->vscroll, value, prop); } } -static void doScroll(WMWidget *self, void *data) +static void +doScroll(WMWidget *self, void *data) { WMTableView *table = (WMTableView*)data; float value; @@ -337,94 +349,94 @@ static void doScroll(WMWidget *self, void *data) value = WMGetScrollerValue(self); if (table->hscroll == (WMScroller *)self) { - vpsize = W_VIEW_WIDTH(table->tableView); - size = ts.width; + vpsize = W_VIEW_WIDTH(table->tableView); + size = ts.width; } else { - vpsize = W_VIEW_HEIGHT(table->tableView); - size = ts.height; + vpsize = W_VIEW_HEIGHT(table->tableView); + size = ts.height; } switch (WMGetScrollerHitPart(self)) { - case WSDecrementWheel: - case WSDecrementLine: - value -= (float)table->rowHeight / size; - if (value < 0) - value = 0.0; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - repaintTable(table); - break; - - case WSIncrementWheel: - case WSIncrementLine: - value += (float)table->rowHeight / size; - if (value > 1.0) - value = 1.0; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - repaintTable(table); - break; - - case WSKnob: - repaintTable(table); - break; - - case WSDecrementPage: - value -= vpsize / size; - if (value < 0.0) - value = 0.0; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - repaintTable(table); + case WSDecrementWheel: + case WSDecrementLine: + value -= (float)table->rowHeight / size; + if (value < 0) + value = 0.0; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + repaintTable(table); break; - case WSIncrementPage: - value += vpsize / size; - if (value > 1.0) - value = 1.0; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - repaintTable(table); - break; + case WSIncrementWheel: + case WSIncrementLine: + value += (float)table->rowHeight / size; + if (value > 1.0) + value = 1.0; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + repaintTable(table); + break; + case WSKnob: + repaintTable(table); + break; + + case WSDecrementPage: + value -= vpsize / size; + if (value < 0.0) + value = 0.0; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + repaintTable(table); + break; + + case WSIncrementPage: + value += vpsize / size; + if (value > 1.0) + value = 1.0; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + repaintTable(table); + break; - case WSNoPart: - case WSKnobSlot: - break; + + case WSNoPart: + case WSKnobSlot: + break; } - + if (table->editingRow >= 0) { - int i; - for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { - WMTableColumn *column; - - column = WMGetFromArray(table->columns, i); - - if (column->delegate && column->delegate->beginCellEdit) - (*column->delegate->beginCellEdit)(column->delegate, column, - table->editingRow); - } + int i; + for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { + WMTableColumn *column; + + column = WMGetFromArray(table->columns, i); + + if (column->delegate && column->delegate->beginCellEdit) + (*column->delegate->beginCellEdit)(column->delegate, column, + table->editingRow); + } } - + if (table->hscroll == self) { - int x = 0; - int i; - WMRect rect = getVisibleRect(table); - - for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { - WMTableColumn *column; - WMView *splitter; - - column = WMGetFromArray(table->columns, i); - - WMMoveWidget(column->titleW, x - rect.pos.x, 0); - - x += W_VIEW_WIDTH(WMWidgetView(column->titleW)) + 1; - - splitter = WMGetFromArray(table->splitters, i); - W_MoveView(splitter, x - rect.pos.x - 1, 0); - } + int x = 0; + int i; + WMRect rect = getVisibleRect(table); + + for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { + WMTableColumn *column; + WMView *splitter; + + column = WMGetFromArray(table->columns, i); + + WMMoveWidget(column->titleW, x - rect.pos.x, 0); + + x += W_VIEW_WIDTH(WMWidgetView(column->titleW)) + 1; + + splitter = WMGetFromArray(table->splitters, i); + W_MoveView(splitter, x - rect.pos.x - 1, 0); + } } } @@ -442,76 +454,78 @@ splitterHandler(XEvent *event, void *data) Display *dpy = WMScreenDisplay(scr); int h = WMWidgetHeight(table) - 22; Window w = WMViewXID(table->view); - + pos = WMGetViewPosition(WMWidgetView(column->titleW)); offsX = pos.x + column->width; - + ox = cx = offsX; - + XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h); while (!done) { - XEvent ev; - - WMMaskEvent(dpy, ButtonMotionMask|ButtonReleaseMask, &ev); - - switch (ev.type) { - case MotionNotify: - ox = cx; - - if (column->width + ev.xmotion.x < column->minWidth) - cx = pos.x + column->minWidth; - else if (column->maxWidth > 0 - && column->width + ev.xmotion.x > column->maxWidth) - cx = pos.x + column->maxWidth; - else - cx = offsX + ev.xmotion.x; - - XDrawLine(dpy, w, gc, ox+20, 0, ox+20, h); - XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h); - break; - - case ButtonRelease: - column->width = cx - pos.x; - done = 1; - break; - } + XEvent ev; + + WMMaskEvent(dpy, ButtonMotionMask|ButtonReleaseMask, &ev); + + switch (ev.type) { + case MotionNotify: + ox = cx; + + if (column->width + ev.xmotion.x < column->minWidth) + cx = pos.x + column->minWidth; + else if (column->maxWidth > 0 + && column->width + ev.xmotion.x > column->maxWidth) + cx = pos.x + column->maxWidth; + else + cx = offsX + ev.xmotion.x; + + XDrawLine(dpy, w, gc, ox+20, 0, ox+20, h); + XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h); + break; + + case ButtonRelease: + column->width = cx - pos.x; + done = 1; + break; + } } - + XDrawLine(dpy, w, gc, cx+20, 0, cx+20, h); rearrangeHeader(table); repaintTable(table); } -static void realizeTable(void *data, WMNotification *notif) +static void +realizeTable(void *data, WMNotification *notif) { repaintTable(data); } -WMTableView *WMCreateTableView(WMWidget *parent) +WMTableView* +WMCreateTableView(WMWidget *parent) { WMTableView *table = wmalloc(sizeof(WMTableView)); WMScreen *scr = WMWidgetScreen(parent); - + memset(table, 0, sizeof(WMTableView)); if (!tableClass) { - tableClass = W_RegisterUserWidget(); + tableClass = W_RegisterUserWidget(); } table->widgetClass = tableClass; - + table->view = W_CreateView(W_VIEW(parent)); - if (!table->view) - goto error; + if (!table->view) + goto error; table->view->self = table; - + table->view->delegate = &viewDelegate; - + table->headerHeight = 20; - + table->hscroll = WMCreateScroller(table); WMSetScrollerAction(table->hscroll, doScroll, table); WMMoveWidget(table->hscroll, 1, 2+table->headerHeight); @@ -531,349 +545,366 @@ WMTableView *WMCreateTableView(WMWidget *parent) WMMoveWidget(table->header, 22, 2); WMMapWidget(table->header); WMSetFrameRelief(table->header, WRFlat); - + table->corner = WMCreateLabel(table); WMResizeWidget(table->corner, 20, table->headerHeight); WMMoveWidget(table->corner, 2, 2); WMMapWidget(table->corner); WMSetLabelRelief(table->corner, WRRaised); WMSetWidgetBackgroundColor(table->corner, scr->darkGray); - + table->tableView = W_CreateView(table->view); if (!table->tableView) - goto error; + goto error; table->tableView->self = table; W_MapView(table->tableView); - + WMAddNotificationObserver(realizeTable, table, WMViewRealizedNotification, - table->tableView); - + table->tableView); + table->tableView->flags.dontCompressExpose = 1; - + table->gridColor = WMCreateNamedColor(scr, "#cccccc", False); - /* table->gridColor = WMGrayColor(scr);*/ - + /* table->gridColor = WMGrayColor(scr);*/ + { - XGCValues gcv; - - table->backColor = WMWhiteColor(scr); - - gcv.foreground = WMColorPixel(table->gridColor); - gcv.dashes = 1; - gcv.line_style = LineOnOffDash; - table->gridGC = XCreateGC(WMScreenDisplay(scr), W_DRAWABLE(scr), - GCForeground, &gcv); + XGCValues gcv; + + table->backColor = WMWhiteColor(scr); + + gcv.foreground = WMColorPixel(table->gridColor); + gcv.dashes = 1; + gcv.line_style = LineOnOffDash; + table->gridGC = XCreateGC(WMScreenDisplay(scr), W_DRAWABLE(scr), + GCForeground, &gcv); } - + table->editingRow = -1; table->clickedRow = -1; - + table->drawsGrid = 1; table->rowHeight = 16; - + table->tableWidth = 1; - + table->columns = WMCreateArray(4); table->splitters = WMCreateArray(4); table->selectedRows = WMCreateArray(16); - + table->splitterCursor = XCreateFontCursor(WMScreenDisplay(scr), - XC_sb_h_double_arrow); - + XC_sb_h_double_arrow); + table->canSelectRow = 1; - + WMCreateEventHandler(table->view, ExposureMask|StructureNotifyMask, handleEvents, table); WMCreateEventHandler(table->tableView, ExposureMask|ButtonPressMask| - ButtonReleaseMask|ButtonMotionMask, + ButtonReleaseMask|ButtonMotionMask, handleTableEvents, table); WMResizeWidget(table, 50, 50); - + return table; - - error: - if (table->tableView) - W_DestroyView(table->tableView); - if (table->view) - W_DestroyView(table->view); - wfree(table); - return NULL; + + error: + if (table->tableView) + W_DestroyView(table->tableView); + if (table->view) + W_DestroyView(table->view); + wfree(table); + return NULL; } -void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column) +void +WMAddTableViewColumn(WMTableView *table, WMTableColumn *column) { WMScreen *scr = WMWidgetScreen(table); - + column->table = table; WMAddToArray(table->columns, column); - + if (!column->titleW) { - column->titleW = WMCreateLabel(table); - WMSetLabelRelief(column->titleW, WRRaised); - WMSetLabelFont(column->titleW, scr->boldFont); - WMSetLabelTextColor(column->titleW, scr->white); - WMSetWidgetBackgroundColor(column->titleW, scr->darkGray); - WMSetLabelText(column->titleW, column->title); - W_ReparentView(WMWidgetView(column->titleW), - WMWidgetView(table->header), 0, 0); - if (W_VIEW_REALIZED(table->view)) - WMRealizeWidget(column->titleW); - WMMapWidget(column->titleW); + column->titleW = WMCreateLabel(table); + WMSetLabelRelief(column->titleW, WRRaised); + WMSetLabelFont(column->titleW, scr->boldFont); + WMSetLabelTextColor(column->titleW, scr->white); + WMSetWidgetBackgroundColor(column->titleW, scr->darkGray); + WMSetLabelText(column->titleW, column->title); + W_ReparentView(WMWidgetView(column->titleW), + WMWidgetView(table->header), 0, 0); + if (W_VIEW_REALIZED(table->view)) + WMRealizeWidget(column->titleW); + WMMapWidget(column->titleW); } - + { - WMView *splitter = W_CreateView(WMWidgetView(table->header)); - - W_SetViewBackgroundColor(splitter, WMWhiteColor(scr)); + WMView *splitter = W_CreateView(WMWidgetView(table->header)); + + W_SetViewBackgroundColor(splitter, WMWhiteColor(scr)); - if (W_VIEW_REALIZED(table->view)) - W_RealizeView(splitter); + if (W_VIEW_REALIZED(table->view)) + W_RealizeView(splitter); - W_ResizeView(splitter, 2, table->headerHeight); - W_MapView(splitter); + W_ResizeView(splitter, 2, table->headerHeight); + W_MapView(splitter); - W_SetViewCursor(splitter, table->splitterCursor); - WMCreateEventHandler(splitter, ButtonPressMask|ButtonReleaseMask, - splitterHandler, column); + W_SetViewCursor(splitter, table->splitterCursor); + WMCreateEventHandler(splitter, ButtonPressMask|ButtonReleaseMask, + splitterHandler, column); - WMAddToArray(table->splitters, splitter); + WMAddToArray(table->splitters, splitter); } rearrangeHeader(table); } -void WMSetTableViewHeaderHeight(WMTableView *table, unsigned height) +void +WMSetTableViewHeaderHeight(WMTableView *table, unsigned height) { table->headerHeight = height; - + handleResize(NULL, table->view); } -void WMSetTableViewDelegate(WMTableView *table, WMTableViewDelegate *delegate) +void +WMSetTableViewDelegate(WMTableView *table, WMTableViewDelegate *delegate) { table->delegate = delegate; } -void WMSetTableViewAction(WMTableView *table, WMAction *action, void *clientData) +void +WMSetTableViewAction(WMTableView *table, WMAction *action, void *clientData) { table->action = action; - + table->clientData = clientData; } -void *WMGetTableViewClickedColumn(WMTableView *table) +void* +WMGetTableViewClickedColumn(WMTableView *table) { return table->clickedColumn; } -int WMGetTableViewClickedRow(WMTableView *table) +int +WMGetTableViewClickedRow(WMTableView *table) { return table->clickedRow; } -WMArray *WMGetTableViewSelectedRows(WMTableView *table) +WMArray* +WMGetTableViewSelectedRows(WMTableView *table) { return table->selectedRows; } -WMView *WMGetTableViewDocumentView(WMTableView *table) +WMView* +WMGetTableViewDocumentView(WMTableView *table) { return table->tableView; } -void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column, - int row) +void* +WMTableViewDataForCell(WMTableView *table, WMTableColumn *column, int row) { return (*table->delegate->valueForCell)(table->delegate, column, row); } -void WMSetTableViewDataForCell(WMTableView *table, WMTableColumn *column, - int row, void *data) +void +WMSetTableViewDataForCell(WMTableView *table, WMTableColumn *column, int row, + void *data) { (*table->delegate->setValueForCell)(table->delegate, column, row, data); } -WMRect WMTableViewRectForCell(WMTableView *table, WMTableColumn *column, - int row) +WMRect +WMTableViewRectForCell(WMTableView *table, WMTableColumn *column, int row) { WMRect rect; int i; - + rect.pos.x = 0; rect.pos.y = row * table->rowHeight; rect.size.height = table->rowHeight; - + for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { - WMTableColumn *col; - col = WMGetFromArray(table->columns, i); - - if (col == column) { - rect.size.width = col->width; - break; - } - - rect.pos.x += col->width; + WMTableColumn *col; + col = WMGetFromArray(table->columns, i); + + if (col == column) { + rect.size.width = col->width; + break; + } + + rect.pos.x += col->width; } - + { - WMRect r = getVisibleRect(table); - - rect.pos.y -= r.pos.y; - rect.pos.x -= r.pos.x; + WMRect r = getVisibleRect(table); + + rect.pos.y -= r.pos.y; + rect.pos.x -= r.pos.x; } - + return rect; } -void WMSetTableViewDataSource(WMTableView *table, void *source) +void +WMSetTableViewDataSource(WMTableView *table, void *source) { table->dataSource = source; } -void *WMGetTableViewDataSource(WMTableView *table) +void* +WMGetTableViewDataSource(WMTableView *table) { return table->dataSource; } -void WMSetTableViewHasHorizontalScroller(WMTableView *tPtr, Bool flag) +void +WMSetTableViewHasHorizontalScroller(WMTableView *tPtr, Bool flag) { if (flag) { - if (tPtr->hasHScroller) - return; - tPtr->hasHScroller = 1; - - tPtr->hscroll = WMCreateScroller(tPtr); - WMSetScrollerAction(tPtr->hscroll, doScroll, tPtr); - WMSetScrollerArrowsPosition(tPtr->hscroll, WSAMaxEnd); - /* make it a horiz. scroller */ - WMResizeWidget(tPtr->hscroll, 1, 2); - - if (W_VIEW_REALIZED(tPtr->view)) { - WMRealizeWidget(tPtr->hscroll); - } - - reorganizeInterior(tPtr); - - WMMapWidget(tPtr->hscroll); + if (tPtr->hasHScroller) + return; + tPtr->hasHScroller = 1; + + tPtr->hscroll = WMCreateScroller(tPtr); + WMSetScrollerAction(tPtr->hscroll, doScroll, tPtr); + WMSetScrollerArrowsPosition(tPtr->hscroll, WSAMaxEnd); + /* make it a horiz. scroller */ + WMResizeWidget(tPtr->hscroll, 1, 2); + + if (W_VIEW_REALIZED(tPtr->view)) { + WMRealizeWidget(tPtr->hscroll); + } + + reorganizeInterior(tPtr); + + WMMapWidget(tPtr->hscroll); } else { - if (!tPtr->hasHScroller) - return; - tPtr->hasHScroller = 0; - - WMUnmapWidget(tPtr->hscroll); - WMDestroyWidget(tPtr->hscroll); - tPtr->hscroll = NULL; - - reorganizeInterior(tPtr); + if (!tPtr->hasHScroller) + return; + tPtr->hasHScroller = 0; + + WMUnmapWidget(tPtr->hscroll); + WMDestroyWidget(tPtr->hscroll); + tPtr->hscroll = NULL; + + reorganizeInterior(tPtr); } } #if 0 /* not supported by now */ -void WMSetTableViewHasVerticalScroller(WMTableView *tPtr, Bool flag) +void +WMSetTableViewHasVerticalScroller(WMTableView *tPtr, Bool flag) { if (flag) { - if (tPtr->hasVScroller) - return; - tPtr->hasVScroller = 1; - - tPtr->vscroll = WMCreateScroller(tPtr); - WMSetScrollerAction(tPtr->vscroll, doScroll, tPtr); - WMSetScrollerArrowsPosition(tPtr->vscroll, WSAMaxEnd); - /* make it a vert. scroller */ - WMResizeWidget(tPtr->vscroll, 1, 2); - - if (W_VIEW_REALIZED(tPtr->view)) { - WMRealizeWidget(tPtr->vscroll); - } - - reorganizeInterior(tPtr); - - WMMapWidget(tPtr->vscroll); + if (tPtr->hasVScroller) + return; + tPtr->hasVScroller = 1; + + tPtr->vscroll = WMCreateScroller(tPtr); + WMSetScrollerAction(tPtr->vscroll, doScroll, tPtr); + WMSetScrollerArrowsPosition(tPtr->vscroll, WSAMaxEnd); + /* make it a vert. scroller */ + WMResizeWidget(tPtr->vscroll, 1, 2); + + if (W_VIEW_REALIZED(tPtr->view)) { + WMRealizeWidget(tPtr->vscroll); + } + + reorganizeInterior(tPtr); + + WMMapWidget(tPtr->vscroll); } else { - if (!tPtr->hasVScroller) - return; - tPtr->hasVScroller = 0; - - WMUnmapWidget(tPtr->vscroll); - WMDestroyWidget(tPtr->vscroll); - tPtr->vscroll = NULL; - - reorganizeInterior(tPtr); + if (!tPtr->hasVScroller) + return; + tPtr->hasVScroller = 0; + + WMUnmapWidget(tPtr->vscroll); + WMDestroyWidget(tPtr->vscroll); + tPtr->vscroll = NULL; + + reorganizeInterior(tPtr); } } #endif -void WMSetTableViewBackgroundColor(WMTableView *table, WMColor *color) +void +WMSetTableViewBackgroundColor(WMTableView *table, WMColor *color) { W_SetViewBackgroundColor(table->tableView, color); - + if (table->backColor) - WMReleaseColor(table->backColor); + WMReleaseColor(table->backColor); table->backColor = WMRetainColor(color); - + repaintTable(table); } -void WMSetTableViewGridColor(WMTableView *table, WMColor *color) +void +WMSetTableViewGridColor(WMTableView *table, WMColor *color) { WMReleaseColor(table->gridColor); table->gridColor = WMRetainColor(color); - XSetForeground(WMScreenDisplay(WMWidgetScreen(table)), table->gridGC, - WMColorPixel(color)); + XSetForeground(WMScreenDisplay(WMWidgetScreen(table)), table->gridGC, + WMColorPixel(color)); repaintTable(table); } -void WMSetTableViewRowHeight(WMTableView *table, int height) +void +WMSetTableViewRowHeight(WMTableView *table, int height) { table->rowHeight = height; - + repaintTable(table); } -void WMScrollTableViewRowToVisible(WMTableView *table, int row) +void +WMScrollTableViewRowToVisible(WMTableView *table, int row) { WMScroller *scroller; WMRange range; WMRect rect; int newY, tmp; - + rect = getVisibleRect(table); range = rowsInRect(table, rect); scroller = table->vscroll; if (row < range.position) { - newY = row * table->rowHeight - rect.size.height / 2; + newY = row * table->rowHeight - rect.size.height / 2; } else if (row >= range.position + range.count) { - newY = row * table->rowHeight - rect.size.height / 2; + newY = row * table->rowHeight - rect.size.height / 2; } else { - return; + return; } tmp = table->rows*table->rowHeight - rect.size.height; newY = WMAX(0, WMIN(newY, tmp)); @@ -883,7 +914,8 @@ void WMScrollTableViewRowToVisible(WMTableView *table, int row) -static void drawGrid(WMTableView *table, WMRect rect) +static void +drawGrid(WMTableView *table, WMRect rect) { WMScreen *scr = WMWidgetScreen(table); Display *dpy = WMScreenDisplay(scr); @@ -893,12 +925,12 @@ static void drawGrid(WMTableView *table, WMRect rect) int xx; Drawable d = WMGetPixmapXID(table->viewBuffer); GC gc = table->gridGC; - + #if 0 char dashl[1] = {1}; - + XSetDashes(dpy, gc, 0, dashl, 1); - + y1 = (rect.pos.y/table->rowHeight - 1)*table->rowHeight; y2 = y1 + (rect.size.height/table->rowHeight+2)*table->rowHeight; #endif @@ -907,72 +939,74 @@ static void drawGrid(WMTableView *table, WMRect rect) xx = -rect.pos.x; for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { - WMTableColumn *column; + WMTableColumn *column; - XDrawLine(dpy, d, gc, xx, y1, xx, y2); + XDrawLine(dpy, d, gc, xx, y1, xx, y2); - column = WMGetFromArray(table->columns, i); - xx += column->width; + column = WMGetFromArray(table->columns, i); + xx += column->width; } XDrawLine(dpy, d, gc, xx, y1, xx, y2); - + x1 = 0; x2 = rect.size.width; - + if (x2 <= x1) - return; + return; #if 0 XSetDashes(dpy, gc, (rect.pos.x&1), dashl, 1); #endif - + y1 = -rect.pos.y%table->rowHeight; y2 = y1 + rect.size.height + table->rowHeight; - + for (i = y1; i <= y2; i += table->rowHeight) { - XDrawLine(dpy, d, gc, x1, i, x2, i); - } + XDrawLine(dpy, d, gc, x1, i, x2, i); + } } -static WMRange columnsInRect(WMTableView *table, WMRect rect) +static WMRange +columnsInRect(WMTableView *table, WMRect rect) { WMTableColumn *column; int pos; int i, found; int totalColumns = WMGetArrayItemCount(table->columns); WMRange range; - + pos = 0; found = 0; for (i = 0; i < totalColumns; i++) { - column = WMGetFromArray(table->columns, i); - if (!found) { - if (rect.pos.x >= pos && rect.pos.x < pos + column->width) { + column = WMGetFromArray(table->columns, i); + if (!found) { + if (rect.pos.x >= pos && rect.pos.x < pos + column->width) { range.position = i; range.count = 1; found = 1; - } - } else { + } + } else { if (pos > rect.pos.x + rect.size.width) { break; } - range.count++; - } - pos += column->width; + range.count++; + } + pos += column->width; } range.count = WMAX(1, WMIN(range.count, totalColumns - range.position)); return range; } -static WMRange rowsInRect(WMTableView *table, WMRect rect) +static WMRange +rowsInRect(WMTableView *table, WMRect rect) { WMRange range; int rh = table->rowHeight; int dif; - + dif = rect.pos.y % rh; - + range.position = WMAX(0, (rect.pos.y - dif) / rh); range.count = WMAX(1, WMIN((rect.size.height + dif) / rh, table->rows)); @@ -980,7 +1014,8 @@ static WMRange rowsInRect(WMTableView *table, WMRect rect) } -static void drawRow(WMTableView *table, int row, WMRect clipRect) +static void +drawRow(WMTableView *table, int row, WMRect clipRect) { int i; WMRange cols = columnsInRect(table, clipRect); @@ -988,274 +1023,286 @@ static void drawRow(WMTableView *table, int row, WMRect clipRect) Drawable d = WMGetPixmapXID(table->viewBuffer); for (i = cols.position; i < cols.position+cols.count; i++) { - column = WMGetFromArray(table->columns, i); + column = WMGetFromArray(table->columns, i); - if (!column->delegate || !column->delegate->drawCell) - continue; + if (!column->delegate || !column->delegate->drawCell) + continue; - if (WMFindInArray(table->selectedRows, NULL, (void*)row) != WANotFound) - (*column->delegate->drawSelectedCell)(column->delegate, column, row, d); - else - (*column->delegate->drawCell)(column->delegate, column, row, d); + if (WMFindInArray(table->selectedRows, NULL, (void*)row) != WANotFound) + (*column->delegate->drawSelectedCell)(column->delegate, column, row, d); + else + (*column->delegate->drawCell)(column->delegate, column, row, d); } } #if 0 -static void drawFullRow(WMTableView *table, int row) +static void +drawFullRow(WMTableView *table, int row) { int i; WMTableColumn *column; Drawable d = WMGetPixmapXID(table->viewBuffer); for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { - column = WMGetFromArray(table->columns, i); + column = WMGetFromArray(table->columns, i); - if (!column->delegate || !column->delegate->drawCell) - continue; + if (!column->delegate || !column->delegate->drawCell) + continue; - if (WMFindInArray(table->selectedRows, NULL, (void*)row) != WANotFound) - (*column->delegate->drawSelectedCell)(column->delegate, column, row, d); - else - (*column->delegate->drawCell)(column->delegate, column, row, d); + if (WMFindInArray(table->selectedRows, NULL, (void*)row) != WANotFound) + (*column->delegate->drawSelectedCell)(column->delegate, column, row, d); + else + (*column->delegate->drawCell)(column->delegate, column, row, d); } } #endif -static void setRowSelected(WMTableView *table, unsigned row, Bool flag) +static void +setRowSelected(WMTableView *table, unsigned row, Bool flag) { int repaint = 0; if (WMFindInArray(table->selectedRows, NULL, (void*)row) != WANotFound) { - if (!flag) { - WMRemoveFromArray(table->selectedRows, (void*)row); - repaint = 1; - } + if (!flag) { + WMRemoveFromArray(table->selectedRows, (void*)row); + repaint = 1; + } } else { - if (flag) { - WMAddToArray(table->selectedRows, (void*)row); - repaint = 1; - } + if (flag) { + WMAddToArray(table->selectedRows, (void*)row); + repaint = 1; + } } if (repaint && row < table->rows) { - /*drawFullRow(table, row);*/ - repaintTable(table); + /*drawFullRow(table, row);*/ + repaintTable(table); } } -static void repaintTable(WMTableView *table) +static void +repaintTable(WMTableView *table) { WMRect rect; WMRange rows; WMScreen *scr = WMWidgetScreen(table); int i; - + if (!table->delegate || !W_VIEW_REALIZED(table->view)) - return; - + return; + wassertr(table->delegate->numberOfRows); - + if (!table->viewBuffer) { - table->viewBuffer = WMCreatePixmap(scr, - W_VIEW_WIDTH(table->tableView), - W_VIEW_HEIGHT(table->tableView), - WMScreenDepth(scr), 0); + table->viewBuffer = WMCreatePixmap(scr, + W_VIEW_WIDTH(table->tableView), + W_VIEW_HEIGHT(table->tableView), + WMScreenDepth(scr), 0); } XFillRectangle(scr->display, - WMGetPixmapXID(table->viewBuffer), - WMColorGC(table->backColor), 0, 0, - W_VIEW_WIDTH(table->tableView), - W_VIEW_HEIGHT(table->tableView)); + WMGetPixmapXID(table->viewBuffer), + WMColorGC(table->backColor), 0, 0, + W_VIEW_WIDTH(table->tableView), + W_VIEW_HEIGHT(table->tableView)); rect = getVisibleRect(table); if (table->drawsGrid) { - drawGrid(table, rect); + drawGrid(table, rect); } - + rows = rowsInRect(table, rect); for (i = rows.position; - i < WMIN(rows.position+rows.count + 1, table->rows); - i++) { - drawRow(table, i, rect); + i < WMIN(rows.position+rows.count + 1, table->rows); + i++) { + drawRow(table, i, rect); } XSetWindowBackgroundPixmap(scr->display, table->tableView->window, - WMGetPixmapXID(table->viewBuffer)); + WMGetPixmapXID(table->viewBuffer)); XClearWindow(scr->display, table->tableView->window); } -static void stopRowEdit(WMTableView *table, int row) +static void +stopRowEdit(WMTableView *table, int row) { int i; WMTableColumn *column; table->editingRow = -1; for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { - column = WMGetFromArray(table->columns, i); + column = WMGetFromArray(table->columns, i); - if (column->delegate && column->delegate->endCellEdit) - (*column->delegate->endCellEdit)(column->delegate, column, row); + if (column->delegate && column->delegate->endCellEdit) + (*column->delegate->endCellEdit)(column->delegate, column, row); } } -void WMEditTableViewRow(WMTableView *table, int row) +void +WMEditTableViewRow(WMTableView *table, int row) { int i; WMTableColumn *column; if (table->editingRow >= 0) { - stopRowEdit(table, table->editingRow); + stopRowEdit(table, table->editingRow); } table->editingRow = row; - + if (row < 0) - return; - + return; + for (i = 0; i < WMGetArrayItemCount(table->columns); i++) { - column = WMGetFromArray(table->columns, i); + column = WMGetFromArray(table->columns, i); - if (column->delegate && column->delegate->beginCellEdit) - (*column->delegate->beginCellEdit)(column->delegate, column, row); + if (column->delegate && column->delegate->beginCellEdit) + (*column->delegate->beginCellEdit)(column->delegate, column, row); } } -void WMSelectTableViewRow(WMTableView *table, int row) +void +WMSelectTableViewRow(WMTableView *table, int row) { if (table->clickedRow >= 0) - setRowSelected(table, table->clickedRow, False); - + setRowSelected(table, table->clickedRow, False); + if (row >= table->rows) { - return; + return; } - + setRowSelected(table, row, True); table->clickedRow = row; if (table->action) - (*table->action)(table, table->clientData); + (*table->action)(table, table->clientData); WMPostNotificationName(WMTableViewSelectionDidChangeNotification, - table, NULL); + table, NULL); } -void WMReloadTableView(WMTableView *table) +void +WMReloadTableView(WMTableView *table) { if (table->editingRow >= 0) - stopRowEdit(table, table->editingRow); + stopRowEdit(table, table->editingRow); /* when this is called, nothing in the table can be assumed to be * like the last time we accessed it (ie, rows might have disappeared) */ WMEmptyArray(table->selectedRows); - + if (table->clickedRow >= 0) { - if (table->action) - (*table->action)(table, table->clientData); - WMPostNotificationName(WMTableViewSelectionDidChangeNotification, - table, NULL); - table->clickedRow = -1; + if (table->action) + (*table->action)(table, table->clientData); + WMPostNotificationName(WMTableViewSelectionDidChangeNotification, + table, NULL); + table->clickedRow = -1; } if (table->delegate && table->delegate->numberOfRows) { - int rows; - - rows = (*table->delegate->numberOfRows)(table->delegate, table); - - if (rows != table->rows) { - table->rows = rows; - handleResize(table->view->delegate, table->view); - } else { - repaintTable(table); - } + int rows; + + rows = (*table->delegate->numberOfRows)(table->delegate, table); + + if (rows != table->rows) { + table->rows = rows; + handleResize(table->view->delegate, table->view); + } else { + repaintTable(table); + } } } -void WMNoteTableViewNumberOfRowsChanged(WMTableView *table) +void +WMNoteTableViewNumberOfRowsChanged(WMTableView *table) { WMReloadTableView(table); } -static void handleTableEvents(XEvent *event, void *data) +static void +handleTableEvents(XEvent *event, void *data) { WMTableView *table = (WMTableView*)data; int row; - + switch (event->type) { - case ButtonPress: - if (event->xbutton.button == Button1) { - WMRect rect = getVisibleRect(table); - - row = (event->xbutton.y + rect.pos.y)/table->rowHeight; - if (row != table->clickedRow) { - setRowSelected(table, table->clickedRow, False); - setRowSelected(table, row, True); - table->clickedRow = row; - table->dragging = 1; - } else { - table->dragging = 1; - } - } - break; - - case MotionNotify: - if (table->dragging && event->xmotion.y >= 0) { - WMRect rect = getVisibleRect(table); - - row = (event->xmotion.y + rect.pos.y)/table->rowHeight; - if (table->clickedRow != row && row >= 0 && row < table->rows) { - setRowSelected(table, table->clickedRow, False); - setRowSelected(table, row, True); - table->clickedRow = row; - } - } - break; - - case ButtonRelease: - if (event->xbutton.button == Button1) { - if (table->action) - (*table->action)(table, table->clientData); - WMPostNotificationName(WMTableViewSelectionDidChangeNotification, - table, NULL); - table->dragging = 0; - } - break; + case ButtonPress: + if (event->xbutton.button == Button1) { + WMRect rect = getVisibleRect(table); + + row = (event->xbutton.y + rect.pos.y)/table->rowHeight; + if (row != table->clickedRow) { + setRowSelected(table, table->clickedRow, False); + setRowSelected(table, row, True); + table->clickedRow = row; + table->dragging = 1; + } else { + table->dragging = 1; + } + } + break; + + case MotionNotify: + if (table->dragging && event->xmotion.y >= 0) { + WMRect rect = getVisibleRect(table); + + row = (event->xmotion.y + rect.pos.y)/table->rowHeight; + if (table->clickedRow != row && row >= 0 && row < table->rows) { + setRowSelected(table, table->clickedRow, False); + setRowSelected(table, row, True); + table->clickedRow = row; + } + } + break; + + case ButtonRelease: + if (event->xbutton.button == Button1) { + if (table->action) + (*table->action)(table, table->clientData); + WMPostNotificationName(WMTableViewSelectionDidChangeNotification, + table, NULL); + table->dragging = 0; + } + break; } } -static void handleEvents(XEvent *event, void *data) +static void +handleEvents(XEvent *event, void *data) { WMTableView *table = (WMTableView*)data; WMScreen *scr = WMWidgetScreen(table); - + switch (event->type) { - case Expose: - W_DrawRelief(scr, W_VIEW_DRAWABLE(table->view), 0, 0, - W_VIEW_WIDTH(table->view), W_VIEW_HEIGHT(table->view), - WRSunken); - break; + case Expose: + W_DrawRelief(scr, W_VIEW_DRAWABLE(table->view), 0, 0, + W_VIEW_WIDTH(table->view), W_VIEW_HEIGHT(table->view), + WRSunken); + break; } } -static void handleResize(W_ViewDelegate *self, WMView *view) +static void +handleResize(W_ViewDelegate *self, WMView *view) { reorganizeInterior(view->self); } -static void reorganizeInterior(WMTableView *table) +static void +reorganizeInterior(WMTableView *table) { int width; int height; @@ -1272,10 +1319,10 @@ static void reorganizeInterior(WMTableView *table) width = W_VIEW_WIDTH(view) - 2; height = W_VIEW_HEIGHT(view) - 3; - height -= table->headerHeight; /* table header */ - + height -= table->headerHeight; /* table header */ + if (table->corner) - WMResizeWidget(table->corner, 20, table->headerHeight); + WMResizeWidget(table->corner, 20, table->headerHeight); WMMoveWidget(table->vscroll, 1, table->headerHeight + 1); WMResizeWidget(table->vscroll, 20, height + 1); @@ -1286,11 +1333,11 @@ static void reorganizeInterior(WMTableView *table) } if (table->header) - WMResizeWidget(table->header, width-(vsThickness+1), table->headerHeight); - + WMResizeWidget(table->header, width-(vsThickness+1), table->headerHeight); + if (table->viewBuffer) { - WMReleasePixmap(table->viewBuffer); - table->viewBuffer = NULL; + WMReleasePixmap(table->viewBuffer); + table->viewBuffer = NULL; } width -= vsThickness; @@ -1302,39 +1349,41 @@ static void reorganizeInterior(WMTableView *table) W_MoveView(table->tableView, vsThickness+1, 1+table->headerHeight+1); W_ResizeView(table->tableView, WMAX(vw, 1), WMAX(vh, 1)+1); - + adjustScrollers(table); - - repaintTable(table); + + repaintTable(table); } -static void rearrangeHeader(WMTableView *table) +static void +rearrangeHeader(WMTableView *table) { int width; int count; - int i; + int i; /*WMRect rect = WMGetScrollViewVisibleRect(table->scrollView);*/ - + width = 0; - + count = WMGetArrayItemCount(table->columns); for (i = 0; i < count; i++) { - WMTableColumn *column = WMGetFromArray(table->columns, i); - WMView *splitter = WMGetFromArray(table->splitters, i); + WMTableColumn *column = WMGetFromArray(table->columns, i); + WMView *splitter = WMGetFromArray(table->splitters, i); - WMMoveWidget(column->titleW, width, 0); - WMResizeWidget(column->titleW, column->width-1, table->headerHeight); + WMMoveWidget(column->titleW, width, 0); + WMResizeWidget(column->titleW, column->width-1, table->headerHeight); - width += column->width; - W_MoveView(splitter, width-1, 0); + width += column->width; + W_MoveView(splitter, width-1, 0); } - + wassertr(table->delegate && table->delegate->numberOfRows); - + table->rows = table->delegate->numberOfRows(table->delegate, table); table->tableWidth = width + 1; - + handleResize(table->view->delegate, table->view); } + diff --git a/WINGs/Extras/wtableview.h b/WINGs/Extras/wtableview.h index 0e3326ca..a600b70d 100644 --- a/WINGs/Extras/wtableview.h +++ b/WINGs/Extras/wtableview.h @@ -18,98 +18,98 @@ extern const char *WMTableViewSelectionDidChangeNotification; typedef struct WMTableColumnDelegate { void *data; void (*drawCell)(struct WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d); + WMTableColumn *column, int row, Drawable d); void (*drawSelectedCell)(struct WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d); + WMTableColumn *column, int row, Drawable d); void (*beginCellEdit)(struct WMTableColumnDelegate *self, WMTableColumn *column, - int row); + int row); void (*endCellEdit)(struct WMTableColumnDelegate *self, WMTableColumn *column, - int row); + int row); } WMTableColumnDelegate; typedef struct W_TableViewDelegate { void *data; - int (*numberOfRows)(struct W_TableViewDelegate *self, - WMTableView *table); - void *(*valueForCell)(struct W_TableViewDelegate *self, - WMTableColumn *column, int row); - void (*setValueForCell)(struct W_TableViewDelegate *self, - WMTableColumn *column, int row, void *value); + int (*numberOfRows)(struct W_TableViewDelegate *self, + WMTableView *table); + void *(*valueForCell)(struct W_TableViewDelegate *self, + WMTableColumn *column, int row); + void (*setValueForCell)(struct W_TableViewDelegate *self, + WMTableColumn *column, int row, void *value); } WMTableViewDelegate; - - - + + + WMTableColumn *WMCreateTableColumn(char *title); void WMSetTableColumnWidth(WMTableColumn *column, unsigned width); -void WMSetTableColumnConstraints(WMTableColumn *column, - unsigned minWidth, unsigned maxWidth); - -void WMSetTableColumnDelegate(WMTableColumn *column, - WMTableColumnDelegate *delegate); +void WMSetTableColumnConstraints(WMTableColumn *column, + unsigned minWidth, unsigned maxWidth); + +void WMSetTableColumnDelegate(WMTableColumn *column, + WMTableColumnDelegate *delegate); WMTableView *WMGetTableColumnTableView(WMTableColumn *column); - + void WMSetTableColumnId(WMTableColumn *column, void *id); void *WMGetTableColumnId(WMTableColumn *column); - + WMTableView *WMCreateTableView(WMWidget *parent); - + void WMSetTableViewDataSource(WMTableView *table, void *source); void *WMGetTableViewDataSource(WMTableView *table); void WMSetTableViewHeaderHeight(WMTableView *table, unsigned height); - + void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column); void WMSetTableViewDelegate(WMTableView *table, WMTableViewDelegate *delegate); -void WMSetTableViewAction(WMTableView *table, WMAction *action, - void *clientData); +void WMSetTableViewAction(WMTableView *table, WMAction *action, + void *clientData); void *WMGetTableViewClickedColumn(WMTableView *table); int WMGetTableViewClickedRow(WMTableView *table); WMArray *WMGetTableViewSelectedRows(WMTableView *table); - + WMView *WMGetTableViewDocumentView(WMTableView *table); void WMEditTableViewRow(WMTableView *table, int row); void WMSelectTableViewRow(WMTableView *table, int row); -void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column, - int row); +void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column, + int row); -void WMSetTableViewDataForCell(WMTableView *table, WMTableColumn *column, - int row, void *data); - -WMRect WMTableViewRectForCell(WMTableView *table, WMTableColumn *column, - int row); +void WMSetTableViewDataForCell(WMTableView *table, WMTableColumn *column, + int row, void *data); + +WMRect WMTableViewRectForCell(WMTableView *table, WMTableColumn *column, + int row); void WMSetTableViewBackgroundColor(WMTableView *table, WMColor *color); void WMSetTableViewGridColor(WMTableView *table, WMColor *color); -void WMSetTableViewRowHeight(WMTableView *table, int height); - -void WMReloadTableView(WMTableView *table); - +void WMSetTableViewRowHeight(WMTableView *table, int height); + +void WMReloadTableView(WMTableView *table); + void WMNoteTableViewNumberOfRowsChanged(WMTableView *table); - + void WMScrollTableViewRowToVisible(WMTableView *table, int row); - + void WMSetTableViewHasHorizontalScroller(WMTableView *tPtr, Bool flag); diff --git a/WINGs/Tests/mywidget.c b/WINGs/Tests/mywidget.c index 058fba46..3bd78d77 100644 --- a/WINGs/Tests/mywidget.c +++ b/WINGs/Tests/mywidget.c @@ -2,9 +2,9 @@ * Demo user widget for WINGs * * Author: Alfredo K. Kojima - * + * * This file is in the public domain. - * + * */ @@ -12,7 +12,7 @@ * * Include the WINGs private data header. * - * + * */ #include @@ -25,14 +25,14 @@ * Define the widget "class" */ typedef struct W_MyWidget { - /* these two fields must be present in all your widgets in this + /* these two fields must be present in all your widgets in this * exact position */ W_Class widgetClass; WMView *view; - + /* put your stuff here */ char *text; - + } _MyWidget; @@ -50,16 +50,16 @@ static void handleActionEvents(XEvent *event, void *data); /* - * Delegates + * Delegates * See the source for the other widgets to see how to use. * You won't need to use this most of the time. */ static W_ViewDelegate _MyWidgetDelegate = { - NULL, - NULL, - NULL, - NULL, - NULL + NULL, + NULL, + NULL, + NULL, + NULL }; @@ -76,9 +76,9 @@ InitMyWidget(WMScreen *scr) { /* register our widget with WINGs and get our widget class ID */ if (!myWidgetClass) { - myWidgetClass = W_RegisterUserWidget(); + myWidgetClass = W_RegisterUserWidget(); } - + return myWidgetClass; } @@ -90,7 +90,7 @@ MyWidget* CreateMyWidget(WMWidget *parent) { MyWidget *mPtr; - + /* allocate some storage for our new widget instance */ mPtr = wmalloc(sizeof(MyWidget)); /* initialize it */ @@ -99,17 +99,17 @@ CreateMyWidget(WMWidget *parent) /* set the class ID */ mPtr->widgetClass = myWidgetClass; - /* + /* * Create the view for our widget. * Note: the Window for the view is only created after the view is * realized with W_RealizeView() - * + * * Consider the returned view as read-only. */ mPtr->view = W_CreateView(W_VIEW(parent)); if (!mPtr->view) { - wfree(mPtr); - return NULL; + wfree(mPtr); + return NULL; } /* always do this */ mPtr->view->self = mPtr; @@ -121,8 +121,8 @@ CreateMyWidget(WMWidget *parent) * Intercept some events for our widget, so that we can handle them. */ WMCreateEventHandler(mPtr->view, ExposureMask /* this allows us to know when we should paint */ - |StructureNotifyMask, /* this allows us to know things like when we are destroyed */ - handleEvents, mPtr); + |StructureNotifyMask, /* this allows us to know things like when we are destroyed */ + handleEvents, mPtr); /* * Intercept some other events. This could be merged with the above @@ -146,14 +146,14 @@ paintMyWidget(_MyWidget *mPtr) if (mPtr->text) { - - color = WMWhiteColor(scr); - - W_PaintText(mPtr->view, mPtr->view->window, scr->normalFont, 0, 0, - mPtr->view->size.width, WACenter, color, - False, mPtr->text, strlen(mPtr->text)); - - WMReleaseColor(color); + + color = WMWhiteColor(scr); + + W_PaintText(mPtr->view, mPtr->view->window, scr->normalFont, 0, 0, + mPtr->view->size.width, WACenter, color, + False, mPtr->text, strlen(mPtr->text)); + + WMReleaseColor(color); } } @@ -165,17 +165,17 @@ handleEvents(XEvent *event, void *data) _MyWidget *mPtr = (_MyWidget*)data; - switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintMyWidget(mPtr); - break; - - case DestroyNotify: - destroyMyWidget(mPtr); - break; - + switch (event->type) { + case Expose: + if (event->xexpose.count!=0) + break; + paintMyWidget(mPtr); + break; + + case DestroyNotify: + destroyMyWidget(mPtr); + break; + } } @@ -186,10 +186,10 @@ handleActionEvents(XEvent *event, void *data) _MyWidget *mPtr = (_MyWidget*)data; switch (event->type) { - case ButtonPress: - XBell(mPtr->view->screen->display, 100); - XBell(mPtr->view->screen->display, 100); - break; + case ButtonPress: + XBell(mPtr->view->screen->display, 100); + XBell(mPtr->view->screen->display, 100); + break; } } @@ -200,12 +200,12 @@ SetMyWidgetText(MyWidget *mPtr, char *text) CHECK_CLASS(mPtr, myWidgetClass); if (mPtr->text) - wfree(mPtr->text); - + wfree(mPtr->text); + mPtr->text = wstrdup(text); - + if (W_VIEW_MAPPED(mPtr->view)) { - paintMyWidget(mPtr); + paintMyWidget(mPtr); } } @@ -215,12 +215,12 @@ static void destroyMyWidget(_MyWidget *mPtr) { /* - * Free all data we allocated for our widget. + * Free all data we allocated for our widget. */ - + if (mPtr->text) - wfree(mPtr->text); - + wfree(mPtr->text); + wfree(mPtr); } diff --git a/WINGs/Tests/mywidget.h b/WINGs/Tests/mywidget.h index 14e79579..7c493042 100644 --- a/WINGs/Tests/mywidget.h +++ b/WINGs/Tests/mywidget.h @@ -1,7 +1,7 @@ /* * Header for demo widget. - * + * */ typedef struct W_MyWidget MyWidget; diff --git a/WINGs/Tests/testmywidget.c b/WINGs/Tests/testmywidget.c index 13e5e596..ad158685 100644 --- a/WINGs/Tests/testmywidget.c +++ b/WINGs/Tests/testmywidget.c @@ -22,30 +22,31 @@ int main(int argc, char **argv) WMInitializeApplication("Test", &argc, argv); - + if (!dpy) { - wfatal("could not open display"); - exit(1); + wfatal("could not open display"); + exit(1); } - + scr = WMCreateSimpleApplicationScreen(dpy); /* init our widget */ InitMyWidget(scr); - + win = WMCreateWindow(scr, "test"); WMResizeWidget(win, 150, 50); - + thing = CreateMyWidget(win); SetMyWidgetText(thing, "The Test"); WMResizeWidget(thing, 100, 20); WMMoveWidget(thing, 10, 10); - + WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); - + WMScreenMainLoop(scr); - + return 0; } + diff --git a/WINGs/Tests/wmfile.c b/WINGs/Tests/wmfile.c dissimilarity index 76% index 379d13db..1482ed56 100644 --- a/WINGs/Tests/wmfile.c +++ b/WINGs/Tests/wmfile.c @@ -1,125 +1,126 @@ -/* - * Author: Len Trigg - */ - -/* - Update: Franck Wolff ------------------------------------------------------------------------ - List of updated functions : - - main : - add -s option for a save panel... ------------------------------------------------------------------------ -*/ - - - -#include - -#include -#include -#include - -#include "logo.xpm" - - - - -void -wAbort() -{ - exit(1); -} - -char *ProgName; - -void usage(void) -{ - fprintf(stderr, - "usage:\n" - "\t%s [-options]\n" - "\n" - "options:\n" - " -s\t\tSave panel (default open panel)\n" - " -i \tInitial directory (default /)\n" - " -t \tQuery window title (default none)\n" - "\n" - "information:\n" - "\t%s pops up a WindowMaker style file selection panel.\n" - "\n" - "version:\n" - "\t%s\n" - ,ProgName,ProgName,__DATE__ - ); - exit(0); -} - -#define OPEN_PANEL_TYPE 0 -#define SAVE_PANEL_TYPE 1 - -int main(int argc, char **argv) -{ - Display *dpy = XOpenDisplay(""); - WMScreen *scr; - WMPixmap *pixmap; - WMOpenPanel *oPanel; - WMSavePanel *sPanel; -/* RImage *image;*/ - char *title = NULL; - char *initial = "/"; - int ch; - int panelType = OPEN_PANEL_TYPE; - extern char *optarg; - extern int optind; - - if (!dpy) { - puts("could not open display"); - exit(1); - } - - WMInitializeApplication("WMFile", &argc, argv); - - ProgName = argv[0]; - - while((ch = getopt(argc, argv, "si:ht:")) != -1) - switch(ch) - { - case 's': - panelType = SAVE_PANEL_TYPE; - break; - case 'i': - initial = optarg; - break; - case 't': - title = optarg; - break; - default: - usage(); - } - - for(; optind + */ + +/* + Update: Franck Wolff + ----------------------------------------------------------------------- + List of updated functions : + - main : + add -s option for a save panel... + ----------------------------------------------------------------------- + */ + + + +#include + +#include +#include +#include + +#include "logo.xpm" + + + + +void +wAbort() +{ + exit(1); +} + +char *ProgName; + +void usage(void) +{ + fprintf(stderr, + "usage:\n" + "\t%s [-options]\n" + "\n" + "options:\n" + " -s\t\tSave panel (default open panel)\n" + " -i \tInitial directory (default /)\n" + " -t \tQuery window title (default none)\n" + "\n" + "information:\n" + "\t%s pops up a WindowMaker style file selection panel.\n" + "\n" + "version:\n" + "\t%s\n" + ,ProgName,ProgName,__DATE__ + ); + exit(0); +} + +#define OPEN_PANEL_TYPE 0 +#define SAVE_PANEL_TYPE 1 + +int main(int argc, char **argv) +{ + Display *dpy = XOpenDisplay(""); + WMScreen *scr; + WMPixmap *pixmap; + WMOpenPanel *oPanel; + WMSavePanel *sPanel; + /* RImage *image;*/ + char *title = NULL; + char *initial = "/"; + int ch; + int panelType = OPEN_PANEL_TYPE; + extern char *optarg; + extern int optind; + + if (!dpy) { + puts("could not open display"); + exit(1); + } + + WMInitializeApplication("WMFile", &argc, argv); + + ProgName = argv[0]; + + while((ch = getopt(argc, argv, "si:ht:")) != -1) + switch(ch) + { + case 's': + panelType = SAVE_PANEL_TYPE; + break; + case 'i': + initial = optarg; + break; + case 't': + title = optarg; + break; + default: + usage(); + } + + for(; optind - */ - - -#include - -#include -#include -#include - -#include "logo.xpm" - - - - -void -wAbort() -{ - exit(1); -} - -char *ProgName; - -void usage(void) -{ - fprintf(stderr, - "usage:\n" - "\t%s [-options]\n" - "\n" - "options:\n" - " -i \tInitial entry contents (default none)\n" - " -p \tPrompt message (default none)\n" - " -t \tQuery window title (default none)\n" - "\n" - "information:\n" - "\t%s pops up a WindowMaker style input panel.\n" - "\n" - "version:\n" - "\t%s\n" - ,ProgName,ProgName,__DATE__ - ); - exit(0); -} - -int main(int argc, char **argv) -{ - Display *dpy = XOpenDisplay(""); - WMScreen *scr; - WMPixmap *pixmap; - char *title = NULL; - char *prompt = NULL; - char *initial = NULL; - char *result = NULL; - int ch; - extern char *optarg; - extern int optind; - - WMInitializeApplication("WMQuery", &argc, argv); - - ProgName = argv[0]; - - if (!dpy) { - puts("could not open display"); - exit(1); - } - - while((ch = getopt(argc, argv, "i:hp:t:")) != -1) - switch(ch) - { - case 'i': - initial = optarg; - break; - case 'p': - prompt = optarg; - break; - case 't': - title = optarg; - break; - default: - usage(); - } - - for(; optind + */ + + +#include + +#include +#include +#include + +#include "logo.xpm" + + + + +void +wAbort() +{ + exit(1); +} + +char *ProgName; + +void +usage(void) +{ + fprintf(stderr, + "usage:\n" + "\t%s [-options]\n" + "\n" + "options:\n" + " -i \tInitial entry contents (default none)\n" + " -p \tPrompt message (default none)\n" + " -t \tQuery window title (default none)\n" + "\n" + "information:\n" + "\t%s pops up a WindowMaker style input panel.\n" + "\n" + "version:\n" + "\t%s\n" + ,ProgName,ProgName,__DATE__ + ); + exit(0); +} + +int +main(int argc, char **argv) +{ + Display *dpy = XOpenDisplay(""); + WMScreen *scr; + WMPixmap *pixmap; + char *title = NULL; + char *prompt = NULL; + char *initial = NULL; + char *result = NULL; + int ch; + extern char *optarg; + extern int optind; + + WMInitializeApplication("WMQuery", &argc, argv); + + ProgName = argv[0]; + + if (!dpy) { + puts("could not open display"); + exit(1); + } + + while((ch = getopt(argc, argv, "i:hp:t:")) != -1) + switch(ch) + { + case 'i': + initial = optarg; + break; + case 'p': + prompt = optarg; + break; + case 't': + title = optarg; + break; + default: + usage(); + } + + for(; optind isNonBlocking = cPtr->wasNonBlocking; /* some way to find out if it is connected, and binded. can't find - if it listens though!!! - */ + if it listens though!!! + */ size = sizeof(clientname); n = getpeername(sock, (struct sockaddr*) &clientname, &size); @@ -830,9 +832,9 @@ WMSendConnectionData(WMConnection *cPtr, WMData *data) tPtr->handler = NULL; } /*if (cPtr->handler.write) { - WMDeleteInputHandler(cPtr->handler.write); - cPtr->handler.write = NULL; - }*/ + WMDeleteInputHandler(cPtr->handler.write); + cPtr->handler.write = NULL; + }*/ } if (cPtr->handler.write) { diff --git a/WINGs/data.c b/WINGs/data.c index 8246da9e..ed2af574 100644 --- a/WINGs/data.c +++ b/WINGs/data.c @@ -1,8 +1,8 @@ /* * WINGs WMData function library - * + * * Copyright (c) 1999-2003 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 diff --git a/WINGs/dragcommon.c b/WINGs/dragcommon.c index c877d2a4..4c152c20 100644 --- a/WINGs/dragcommon.c +++ b/WINGs/dragcommon.c @@ -272,3 +272,4 @@ W_FreeViewXdndPart(WMView *view) if (view->dragImage) WMReleasePixmap(view->dragImage); } + diff --git a/WINGs/error.c b/WINGs/error.c index 2fef9954..5d10df1d 100644 --- a/WINGs/error.c +++ b/WINGs/error.c @@ -1,8 +1,8 @@ /* * Window Maker miscelaneous function library - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -64,7 +64,7 @@ wstrerror(int errnum) /********************************************************************* * Prints a message with variable arguments - * + * * msg - message to print with optional formatting * ... - arguments to use on formatting *********************************************************************/ @@ -90,19 +90,19 @@ wmessage(const char *msg, ...) /********************************************************************* - * Prints a warning message with variable arguments - * + * Prints a warning message with variable arguments + * * msg - message to print with optional formatting * ... - arguments to use on formatting *********************************************************************/ -void +void wwarning(const char *msg, ...) { va_list args; char buf[MAXLINE]; - + va_start(args, msg); - + vsnprintf(buf, MAXLINE-3, msg, args); strcat(buf,"\n"); fflush(stdout); @@ -111,18 +111,18 @@ wwarning(const char *msg, ...) fputs(buf, stderr); fflush(stdout); fflush(stderr); - + va_end(args); } /************************************************************************** * Prints a fatal error message with variable arguments and terminates - * + * * msg - message to print with optional formatting - * ... - arguments to use on formatting + * ... - arguments to use on formatting **************************************************************************/ -void +void wfatal(const char *msg, ...) { va_list args; @@ -144,12 +144,12 @@ wfatal(const char *msg, ...) /********************************************************************* - * Prints a system error message with variable arguments - * + * Prints a system error message with variable arguments + * * msg - message to print with optional formatting * ... - arguments to use on formatting *********************************************************************/ -void +void wsyserror(const char *msg, ...) { va_list args; @@ -174,12 +174,12 @@ wsyserror(const char *msg, ...) /********************************************************************* * Prints a system error message with variable arguments, being given * the error code. - * + * * error - the error code foe which to print the message * msg - message to print with optional formatting * ... - arguments to use on formatting *********************************************************************/ -void +void wsyserrorwithcode(int error, const char *msg, ...) { va_list args; diff --git a/WINGs/findfile.c b/WINGs/findfile.c index 81f46b51..067b409a 100644 --- a/WINGs/findfile.c +++ b/WINGs/findfile.c @@ -1,8 +1,8 @@ /* * Window Maker miscelaneous function library - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -41,17 +41,17 @@ wgethomedir() struct passwd *user; if (home) - return home; - + return home; + user = getpwuid(getuid()); if (!user) { - wsyserror(_("could not get password entry for UID %i"), getuid()); - return "/"; + wsyserror(_("could not get password entry for UID %i"), getuid()); + return "/"; } if (!user->pw_dir) { - return "/"; + return "/"; } else { - return user->pw_dir; + return user->pw_dir; } } @@ -60,16 +60,16 @@ static char* getuserhomedir(char *username) { struct passwd *user; - + user = getpwnam(username); if (!user) { - wsyserror(_("could not get password entry for user %s"), username); - return NULL; + wsyserror(_("could not get password entry for user %s"), username); + return NULL; } if (!user->pw_dir) { - return "/"; + return "/"; } else { - return user->pw_dir; + return user->pw_dir; } } @@ -84,78 +84,78 @@ wexpandpath(char *path) int i; memset(buffer, 0, PATH_MAX+2); - + if (*path=='~') { - char *home; - - path++; - if (*path=='/' || *path==0) { - home = wgethomedir(); - strcat(buffer, home); - } else { - int j; - j = 0; - while (*path!=0 && *path!='/') { - buffer2[j++] = *path; - buffer2[j] = 0; - path++; - } - home = getuserhomedir(buffer2); - if (!home) - return NULL; - strcat(buffer, home); - } + char *home; + + path++; + if (*path=='/' || *path==0) { + home = wgethomedir(); + strcat(buffer, home); + } else { + int j; + j = 0; + while (*path!=0 && *path!='/') { + buffer2[j++] = *path; + buffer2[j] = 0; + path++; + } + home = getuserhomedir(buffer2); + if (!home) + return NULL; + strcat(buffer, home); + } } - + i = strlen(buffer); while (*path!=0) { - char *tmp; - - if (*path=='$') { - int j = 0; - path++; - /* expand $(HOME) or $HOME style environment variables */ - if (*path=='(') { - path++; - while (*path!=0 && *path!=')') { - buffer2[j++] = *(path++); - buffer2[j] = 0; + char *tmp; + + if (*path=='$') { + int j = 0; + path++; + /* expand $(HOME) or $HOME style environment variables */ + if (*path=='(') { + path++; + while (*path!=0 && *path!=')') { + buffer2[j++] = *(path++); + buffer2[j] = 0; } if (*path==')') path++; - tmp = getenv(buffer2); - if (!tmp) { - buffer[i] = 0; - strcat(buffer, "$("); - strcat(buffer, buffer2); - strcat(buffer, ")"); - i += strlen(buffer2)+3; - } else { - strcat(buffer, tmp); - i += strlen(tmp); - } - } else { - while (*path!=0 && *path!='/') { - buffer2[j++] = *(path++); - buffer2[j] = 0; - } - tmp = getenv(buffer2); - if (!tmp) { - strcat(buffer, "$"); - strcat(buffer, buffer2); - i += strlen(buffer2)+1; - } else { - strcat(buffer, tmp); - i += strlen(tmp); - } - } - } else { - buffer[i++] = *path; - path++; - } + tmp = getenv(buffer2); + if (!tmp) { + buffer[i] = 0; + strcat(buffer, "$("); + strcat(buffer, buffer2); + strcat(buffer, ")"); + i += strlen(buffer2)+3; + } else { + strcat(buffer, tmp); + i += strlen(tmp); + } + } else { + while (*path!=0 && *path!='/') { + buffer2[j++] = *(path++); + buffer2[j] = 0; + } + tmp = getenv(buffer2); + if (!tmp) { + strcat(buffer, "$"); + strcat(buffer, buffer2); + i += strlen(buffer2)+1; + } else { + strcat(buffer, tmp); + i += strlen(tmp); + } + } + } else { + buffer[i++] = *path; + path++; + } } - + return wstrdup(buffer); } @@ -185,17 +185,17 @@ nextchar(char *string, char tok) /* *---------------------------------------------------------------------- * findfile-- - * Finds a file in a : separated list of paths. ~ expansion is also + * Finds a file in a : separated list of paths. ~ expansion is also * done. - * + * * Returns: * The complete path for the file (in a newly allocated string) or * NULL if the file was not found. - * + * * Side effects: * A new string is allocated. It must be freed later. - * - *---------------------------------------------------------------------- + * + *---------------------------------------------------------------------- */ char* wfindfile(char *paths, char *file) @@ -206,23 +206,23 @@ wfindfile(char *paths, char *file) char *fullpath; if (!file) - return NULL; - + return NULL; + if (*file=='/' || *file=='~' || *file=='$' || !paths || *paths==0) { - if (access(file, F_OK)<0) { - fullpath = wexpandpath(file); - if (!fullpath) - return NULL; - - if (access(fullpath, F_OK)<0) { - wfree(fullpath); - return NULL; - } else { - return fullpath; - } - } else { - return wstrdup(file); - } + if (access(file, F_OK)<0) { + fullpath = wexpandpath(file); + if (!fullpath) + return NULL; + + if (access(fullpath, F_OK)<0) { + wfree(fullpath); + return NULL; + } else { + return fullpath; + } + } else { + return wstrdup(file); + } } flen = strlen(file); @@ -263,43 +263,43 @@ wfindfileinlist(char **path_list, char *file) char *fullpath; if (!file) - return NULL; - + return NULL; + if (*file=='/' || *file=='~' || !path_list) { - if (access(file, F_OK)<0) { - fullpath = wexpandpath(file); - if (!fullpath) - return NULL; - - if (access(fullpath, F_OK)<0) { - wfree(fullpath); - return NULL; - } else { - return fullpath; - } - } else { - return wstrdup(file); - } + if (access(file, F_OK)<0) { + fullpath = wexpandpath(file); + if (!fullpath) + return NULL; + + if (access(fullpath, F_OK)<0) { + wfree(fullpath); + return NULL; + } else { + return fullpath; + } + } else { + return wstrdup(file); + } } flen = strlen(file); for (i=0; path_list[i]!=NULL; i++) { - len = strlen(path_list[i]); - path = wmalloc(len+flen+2); - path = memcpy(path, path_list[i], len); - path[len]=0; - strcat(path, "/"); - strcat(path, file); - /* expand tilde */ - fullpath = wexpandpath(path); - wfree(path); - if (fullpath) { - /* check if file exists */ - if (access(fullpath, F_OK)==0) { - return fullpath; - } - wfree(fullpath); - } + len = strlen(path_list[i]); + path = wmalloc(len+flen+2); + path = memcpy(path, path_list[i], len); + path[len]=0; + strcat(path, "/"); + strcat(path, file); + /* expand tilde */ + fullpath = wexpandpath(path); + wfree(path); + if (fullpath) { + /* check if file exists */ + if (access(fullpath, F_OK)==0) { + return fullpath; + } + wfree(fullpath); + } } return NULL; } @@ -315,51 +315,51 @@ wfindfileinarray(WMPropList *array, char *file) char *fullpath; if (!file) - return NULL; - + return NULL; + if (*file=='/' || *file=='~' || !array) { - if (access(file, F_OK)<0) { - fullpath = wexpandpath(file); - if (!fullpath) - return NULL; - - if (access(fullpath, F_OK)<0) { - wfree(fullpath); - return NULL; - } else { - return fullpath; - } - } else { - return wstrdup(file); - } + if (access(file, F_OK)<0) { + fullpath = wexpandpath(file); + if (!fullpath) + return NULL; + + if (access(fullpath, F_OK)<0) { + wfree(fullpath); + return NULL; + } else { + return fullpath; + } + } else { + return wstrdup(file); + } } flen = strlen(file); for (i=0; i (t2).tv_sec) || \ - (((t1).tv_sec == (t2).tv_sec) \ - && ((t1).tv_usec > (t2).tv_usec))) + (((t1).tv_sec == (t2).tv_sec) \ + && ((t1).tv_usec > (t2).tv_usec))) #define IS_ZERO(tv) (tv.tv_sec == 0 && tv.tv_usec == 0) @@ -90,16 +91,16 @@ enqueueTimerHandler(TimerHandler *handler) /* insert callback in queue, sorted by time left */ if (!timerHandler || !IS_AFTER(handler->when, timerHandler->when)) { - /* first in the queue */ - handler->next = timerHandler; - timerHandler = handler; + /* first in the queue */ + handler->next = timerHandler; + timerHandler = handler; } else { - tmp = timerHandler; - while (tmp->next && IS_AFTER(handler->when, tmp->next->when)) { - tmp = tmp->next; - } - handler->next = tmp->next; - tmp->next = handler; + tmp = timerHandler; + while (tmp->next && IS_AFTER(handler->when, tmp->next->when)) { + tmp = tmp->next; + } + handler->next = tmp->next; + tmp->next = handler; } } @@ -116,22 +117,22 @@ delayUntilNextTimerEvent(struct timeval *delay) if (!handler) { /* The return value of this function is only valid if there _are_ timers active. */ - delay->tv_sec = 0; - delay->tv_usec = 0; - return; + delay->tv_sec = 0; + delay->tv_usec = 0; + return; } rightNow(&now); if (IS_AFTER(now, handler->when)) { - delay->tv_sec = 0; - delay->tv_usec = 0; + delay->tv_sec = 0; + delay->tv_usec = 0; } else { - delay->tv_sec = handler->when.tv_sec - now.tv_sec; - delay->tv_usec = handler->when.tv_usec - now.tv_usec; - if (delay->tv_usec < 0) { - delay->tv_usec += 1000000; - delay->tv_sec--; - } + delay->tv_sec = handler->when.tv_sec - now.tv_sec; + delay->tv_usec = handler->when.tv_usec - now.tv_usec; + if (delay->tv_usec < 0) { + delay->tv_usec += 1000000; + delay->tv_sec--; + } } } @@ -143,7 +144,7 @@ WMAddTimerHandler(int milliseconds, WMCallback *callback, void *cdata) handler = malloc(sizeof(TimerHandler)); if (!handler) - return NULL; + return NULL; rightNow(&handler->when); addmillisecs(&handler->when, milliseconds); @@ -163,7 +164,7 @@ WMAddPersistentTimerHandler(int milliseconds, WMCallback *callback, void *cdata) TimerHandler *handler = WMAddTimerHandler(milliseconds, callback, cdata); if (handler != NULL) - handler->nextDelay = milliseconds; + handler->nextDelay = milliseconds; return handler; } @@ -180,18 +181,18 @@ WMDeleteTimerWithClientData(void *cdata) tmp = timerHandler; if (tmp->clientData==cdata) { - tmp->nextDelay = 0; - if (!IS_ZERO(tmp->when)) { - timerHandler = tmp->next; - wfree(tmp); - } + tmp->nextDelay = 0; + if (!IS_ZERO(tmp->when)) { + timerHandler = tmp->next; + wfree(tmp); + } } else { while (tmp->next) { if (tmp->next->clientData==cdata) { handler = tmp->next; - handler->nextDelay = 0; - if (IS_ZERO(handler->when)) - break; + handler->nextDelay = 0; + if (IS_ZERO(handler->when)) + break; tmp->next = handler->next; wfree(handler); break; @@ -209,27 +210,27 @@ WMDeleteTimerHandler(WMHandlerID handlerID) TimerHandler *tmp, *handler=(TimerHandler*)handlerID; if (!handler || !timerHandler) - return; + return; tmp = timerHandler; handler->nextDelay = 0; if (IS_ZERO(handler->when)) - return; + return; if (tmp==handler) { - timerHandler = handler->next; - wfree(handler); + timerHandler = handler->next; + wfree(handler); } else { - while (tmp->next) { - if (tmp->next==handler) { - tmp->next=handler->next; - wfree(handler); - break; - } - tmp = tmp->next; - } + while (tmp->next) { + if (tmp->next==handler) { + tmp->next=handler->next; + wfree(handler); + break; + } + tmp = tmp->next; + } } } @@ -296,7 +297,7 @@ WMDeleteInputHandler(WMHandlerID handlerID) InputHandler *handler = (InputHandler*)handlerID; if (!handler || !inputHandler) - return; + return; WMRemoveFromArray(inputHandler, handler); } @@ -310,7 +311,7 @@ W_CheckIdleHandlers(void) WMArrayIterator iter; if (!idleHandler || WMGetArrayItemCount(idleHandler)==0) { - W_FlushIdleNotificationQueue(); + W_FlushIdleNotificationQueue(); /* make sure an observer in queue didn't added an idle handler */ return (idleHandler!=NULL && WMGetArrayItemCount(idleHandler)>0); } @@ -322,7 +323,7 @@ W_CheckIdleHandlers(void) if (WMGetFirstInArray(idleHandler, handler) == WANotFound) continue; - (*handler->callback)(handler->clientData); + (*handler->callback)(handler->clientData); WMDeleteIdleHandler(handler); } @@ -351,24 +352,24 @@ W_CheckTimerHandlers(void) handler = timerHandler; while (handler && IS_AFTER(now, handler->when)) { - if (!IS_ZERO(handler->when)) { - SET_ZERO(handler->when); - (*handler->callback)(handler->clientData); - } - handler = handler->next; + if (!IS_ZERO(handler->when)) { + SET_ZERO(handler->when); + (*handler->callback)(handler->clientData); + } + handler = handler->next; } while (timerHandler && IS_ZERO(timerHandler->when)) { - handler = timerHandler; - timerHandler = timerHandler->next; - - if (handler->nextDelay > 0) { - handler->when = now; - addmillisecs(&handler->when, handler->nextDelay); - enqueueTimerHandler(handler); - } else { - wfree(handler); - } + handler = timerHandler; + timerHandler = timerHandler->next; + + if (handler->nextDelay > 0) { + handler->when = now; + addmillisecs(&handler->when, handler->nextDelay); + enqueueTimerHandler(handler); + } else { + wfree(handler); + } } W_FlushASAPNotificationQueue(); diff --git a/WINGs/hashtable.c b/WINGs/hashtable.c index 39d0ae75..c348f23a 100644 --- a/WINGs/hashtable.c +++ b/WINGs/hashtable.c @@ -23,7 +23,7 @@ typedef struct HashItem { const void *key; const void *data; - + struct HashItem *next; /* collided item list */ } HashItem; @@ -41,13 +41,13 @@ typedef struct W_HashTable { #define HASH(table, key) (((table)->callbacks.hash ? \ - (*(table)->callbacks.hash)(key) : hashPtr(key)) % (table)->size) + (*(table)->callbacks.hash)(key) : hashPtr(key)) % (table)->size) #define DUPKEY(table, key) ((table)->callbacks.retainKey ? \ - (*(table)->callbacks.retainKey)(key) : (key)) + (*(table)->callbacks.retainKey)(key) : (key)) #define RELKEY(table, key) if ((table)->callbacks.releaseKey) \ - (*(table)->callbacks.releaseKey)(key) + (*(table)->callbacks.releaseKey)(key) @@ -59,10 +59,10 @@ hashString(const char *key) unsigned ctr = 0; while (*key) { - ret ^= *(char*)key++ << ctr; - ctr = (ctr + 1) % sizeof (char *); + ret ^= *(char*)key++ << ctr; + ctr = (ctr + 1) % sizeof (char *); } - + return ret; } @@ -106,13 +106,13 @@ rebuildTable(WMHashTable *table) table->table = wmalloc(sizeof(char*)*newSize); memset(table->table, 0, sizeof(char*)*newSize); table->size = newSize; - + for (i = 0; i < oldSize; i++) { - while (oldArray[i]!=NULL) { - next = oldArray[i]->next; - rellocateItem(table, oldArray[i]); - oldArray[i] = next; - } + while (oldArray[i]!=NULL) { + next = oldArray[i]->next; + rellocateItem(table, oldArray[i]); + oldArray[i] = next; + } } wfree(oldArray); } @@ -123,17 +123,17 @@ WMHashTable* WMCreateHashTable(WMHashTableCallbacks callbacks) { HashTable *table; - + table = wmalloc(sizeof(HashTable)); memset(table, 0, sizeof(HashTable)); - + table->callbacks = callbacks; - + table->size = INITIAL_CAPACITY; table->table = wmalloc(sizeof(HashItem*)*table->size); memset(table->table, 0, sizeof(HashItem*)*table->size); - + return table; } @@ -145,21 +145,21 @@ WMResetHashTable(WMHashTable *table) int i; for (i = 0; i < table->size; i++) { - item = table->table[i]; - while (item) { - tmp = item->next; - RELKEY(table, item->key); - wfree(item); - item = tmp; - } + item = table->table[i]; + while (item) { + tmp = item->next; + RELKEY(table, item->key); + wfree(item); + item = tmp; + } } table->itemCount = 0; - + if (table->size > INITIAL_CAPACITY) { - wfree(table->table); - table->size = INITIAL_CAPACITY; - table->table = wmalloc(sizeof(HashItem*)*table->size); + wfree(table->table); + table->size = INITIAL_CAPACITY; + table->table = wmalloc(sizeof(HashItem*)*table->size); } memset(table->table, 0, sizeof(HashItem*)*table->size); } @@ -170,15 +170,15 @@ WMFreeHashTable(WMHashTable *table) { HashItem *item, *tmp; int i; - + for (i = 0; i < table->size; i++) { - item = table->table[i]; - while (item) { - tmp = item->next; - RELKEY(table, item->key); - wfree(item); - item = tmp; - } + item = table->table[i]; + while (item) { + tmp = item->next; + RELKEY(table, item->key); + wfree(item); + item = tmp; + } } wfree(table->table); wfree(table); @@ -197,29 +197,29 @@ WMHashGet(WMHashTable *table, const void *key) { unsigned h; HashItem *item; - + h = HASH(table, key); item = table->table[h]; - + if (table->callbacks.keyIsEqual) { - while (item) { - if ((*table->callbacks.keyIsEqual)(key, item->key)) { - break; - } - item = item->next; - } + while (item) { + if ((*table->callbacks.keyIsEqual)(key, item->key)) { + break; + } + item = item->next; + } } else { - while (item) { - if (key == item->key) { - break; - } - item = item->next; - } + while (item) { + if (key == item->key) { + break; + } + item = item->next; + } } if (item) - return (void*)item->data; + return (void*)item->data; else - return NULL; + return NULL; } @@ -229,31 +229,31 @@ WMHashGetItemAndKey(WMHashTable *table, const void *key, { unsigned h; HashItem *item; - + h = HASH(table, key); item = table->table[h]; - + if (table->callbacks.keyIsEqual) { - while (item) { - if ((*table->callbacks.keyIsEqual)(key, item->key)) { - break; - } - item = item->next; - } + while (item) { + if ((*table->callbacks.keyIsEqual)(key, item->key)) { + break; + } + item = item->next; + } } else { - while (item) { - if (key == item->key) { - break; - } - item = item->next; - } + while (item) { + if (key == item->key) { + break; + } + item = item->next; + } } if (item) { if (retKey) *retKey = (void*)item->key; if (retItem) *retItem = (void*)item->data; - return True; + return True; } else { return False; } @@ -267,60 +267,60 @@ WMHashInsert(WMHashTable *table, const void *key, const void *data) unsigned h; HashItem *item; int replacing = 0; - + h = HASH(table, key); /* look for the entry */ item = table->table[h]; if (table->callbacks.keyIsEqual) { - while (item) { - if ((*table->callbacks.keyIsEqual)(key, item->key)) { - replacing = 1; - break; - } - item = item->next; - } + while (item) { + if ((*table->callbacks.keyIsEqual)(key, item->key)) { + replacing = 1; + break; + } + item = item->next; + } } else { - while (item) { - if (key == item->key) { - replacing = 1; - break; - } - item = item->next; - } + while (item) { + if (key == item->key) { + replacing = 1; + break; + } + item = item->next; + } } - + if (replacing) { - const void *old; + const void *old; - old = item->data; - item->data = data; - RELKEY(table, item->key); - item->key = DUPKEY(table, key); + old = item->data; + item->data = data; + RELKEY(table, item->key); + item->key = DUPKEY(table, key); - return (void*)old; + return (void*)old; } else { - HashItem *nitem; + HashItem *nitem; - nitem = wmalloc(sizeof(HashItem)); - nitem->key = DUPKEY(table, key); - nitem->data = data; - nitem->next = table->table[h]; - table->table[h] = nitem; + nitem = wmalloc(sizeof(HashItem)); + nitem->key = DUPKEY(table, key); + nitem->data = data; + nitem->next = table->table[h]; + table->table[h] = nitem; - table->itemCount++; + table->itemCount++; } - + /* OPTIMIZE: put this in an idle handler.*/ if (table->itemCount > table->size) { #ifdef DEBUG0 - printf("rebuilding hash table...\n"); + printf("rebuilding hash table...\n"); #endif - rebuildTable(table); + rebuildTable(table); #ifdef DEBUG0 - printf("finished rebuild.\n"); + printf("finished rebuild.\n"); #endif } - + return NULL; } @@ -329,23 +329,23 @@ static HashItem* deleteFromList(HashTable *table, HashItem *item, const void *key) { HashItem *next; - + if (item==NULL) - return NULL; - - if ((table->callbacks.keyIsEqual - && (*table->callbacks.keyIsEqual)(key, item->key)) - || (!table->callbacks.keyIsEqual && key==item->key)) { - - next = item->next; - RELKEY(table, item->key); - wfree(item); - - table->itemCount--; - - return next; + return NULL; + + if ((table->callbacks.keyIsEqual + && (*table->callbacks.keyIsEqual)(key, item->key)) + || (!table->callbacks.keyIsEqual && key==item->key)) { + + next = item->next; + RELKEY(table, item->key); + wfree(item); + + table->itemCount--; + + return next; } - + item->next = deleteFromList(table, item->next, key); return item; @@ -356,9 +356,9 @@ void WMHashRemove(WMHashTable *table, const void *key) { unsigned h; - + h = HASH(table, key); - + table->table[h] = deleteFromList(table, table->table[h], key); } @@ -367,11 +367,11 @@ WMHashEnumerator WMEnumerateHashTable(WMHashTable *table) { WMHashEnumerator enumerator; - + enumerator.table = table; enumerator.index = 0; enumerator.nextItem = table->table[0]; - + return enumerator; } @@ -382,24 +382,24 @@ WMNextHashEnumeratorItem(WMHashEnumerator *enumerator) { const void *data = NULL; - /* this assumes the table doesn't change between + /* this assumes the table doesn't change between * WMEnumerateHashTable() and WMNextHashEnumeratorItem() calls */ if (enumerator->nextItem==NULL) { - HashTable *table = enumerator->table; - while (++enumerator->index < table->size) { - if (table->table[enumerator->index]!=NULL) { - enumerator->nextItem = table->table[enumerator->index]; - break; - } - } + HashTable *table = enumerator->table; + while (++enumerator->index < table->size) { + if (table->table[enumerator->index]!=NULL) { + enumerator->nextItem = table->table[enumerator->index]; + break; + } + } } - + if (enumerator->nextItem) { - data = ((HashItem*)enumerator->nextItem)->data; - enumerator->nextItem = ((HashItem*)enumerator->nextItem)->next; + data = ((HashItem*)enumerator->nextItem)->data; + enumerator->nextItem = ((HashItem*)enumerator->nextItem)->next; } - + return (void*)data; } @@ -409,7 +409,7 @@ WMNextHashEnumeratorKey(WMHashEnumerator *enumerator) { const void *key = NULL; - /* this assumes the table doesn't change between + /* this assumes the table doesn't change between * WMEnumerateHashTable() and WMNextHashEnumeratorKey() calls */ if (enumerator->nextItem==NULL) { @@ -435,17 +435,17 @@ Bool WMNextHashEnumeratorItemAndKey(WMHashEnumerator *enumerator, void **item, void **key) { - /* this assumes the table doesn't change between + /* this assumes the table doesn't change between * WMEnumerateHashTable() and WMNextHashEnumeratorItemAndKey() calls */ if (enumerator->nextItem==NULL) { - HashTable *table = enumerator->table; - while (++enumerator->index < table->size) { - if (table->table[enumerator->index]!=NULL) { - enumerator->nextItem = table->table[enumerator->index]; - break; - } - } + HashTable *table = enumerator->table; + while (++enumerator->index < table->size) { + if (table->table[enumerator->index]!=NULL) { + enumerator->nextItem = table->table[enumerator->index]; + break; + } + } } if (enumerator->nextItem) { diff --git a/WINGs/international.c b/WINGs/international.c index 2ee0686f..a1023542 100644 --- a/WINGs/international.c +++ b/WINGs/international.c @@ -8,5 +8,5 @@ void InitI18n(Display *dpy) { - + } diff --git a/WINGs/memory.c b/WINGs/memory.c index 8ebf66a1..2250310c 100644 --- a/WINGs/memory.c +++ b/WINGs/memory.c @@ -1,8 +1,8 @@ /* * Window Maker miscelaneous function library - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -47,9 +47,9 @@ static void defaultHandler(int bla) { if (bla) - kill(getpid(), SIGABRT); + kill(getpid(), SIGABRT); else - exit(1); + exit(1); } @@ -89,23 +89,23 @@ wmalloc(size_t size) tmp = malloc(size); #endif if (tmp == NULL) { - wwarning("malloc() failed. Retrying after 2s."); - sleep(2); + wwarning("malloc() failed. Retrying after 2s."); + sleep(2); #ifdef TEST_WITH_GC tmp = GC_malloc(size); #else tmp = malloc(size); #endif - if (tmp == NULL) { - if (Aborting) { - fputs("Really Bad Error: recursive malloc() failure.", stderr); - exit(-1); - } else { - wfatal("virtual memory exhausted"); - Aborting=1; - wAbort(False); - } - } + if (tmp == NULL) { + if (Aborting) { + fputs("Really Bad Error: recursive malloc() failure.", stderr); + exit(-1); + } else { + wfatal("virtual memory exhausted"); + Aborting=1; + wAbort(False); + } + } } return tmp; } @@ -117,15 +117,15 @@ wrealloc(void *ptr, size_t newsize) void *nptr; if (!ptr) { - nptr = wmalloc(newsize); + nptr = wmalloc(newsize); } else if (newsize==0) { wfree(ptr); nptr = NULL; } else { #ifdef TEST_WITH_GC - nptr = GC_realloc(ptr, newsize); + nptr = GC_realloc(ptr, newsize); #else - nptr = realloc(ptr, newsize); + nptr = realloc(ptr, newsize); #endif if (nptr==NULL) { wwarning("realloc() failed. Retrying after 2s."); @@ -156,26 +156,26 @@ void* wretain(void *ptr) { int *refcount; - + if (!table) { - table = WMCreateHashTable(WMIntHashCallbacks); + table = WMCreateHashTable(WMIntHashCallbacks); } - + refcount = WMHashGet(table, ptr); if (!refcount) { - refcount = wmalloc(sizeof(int)); - *refcount = 1; - WMHashInsert(table, ptr, refcount); + refcount = wmalloc(sizeof(int)); + *refcount = 1; + WMHashInsert(table, ptr, refcount); #ifdef VERBOSE - printf("== %i (%p)\n", *refcount, ptr); + printf("== %i (%p)\n", *refcount, ptr); #endif } else { - (*refcount)++; + (*refcount)++; #ifdef VERBOSE - printf("+ %i (%p)\n", *refcount, ptr); + printf("+ %i (%p)\n", *refcount, ptr); #endif } - + return ptr; } @@ -197,24 +197,24 @@ void wrelease(void *ptr) { int *refcount; - + refcount = WMHashGet(table, ptr); if (!refcount) { - wwarning("trying to release unexisting data %p", ptr); + wwarning("trying to release unexisting data %p", ptr); } else { - (*refcount)--; - if (*refcount < 1) { + (*refcount)--; + if (*refcount < 1) { #ifdef VERBOSE - printf("RELEASING %p\n", ptr); + printf("RELEASING %p\n", ptr); #endif - WMHashRemove(table, ptr); - wfree(refcount); - wfree(ptr); - } + WMHashRemove(table, ptr); + wfree(refcount); + wfree(ptr); + } #ifdef VERBOSE - else { - printf("- %i (%p)\n", *refcount, ptr); - } + else { + printf("- %i (%p)\n", *refcount, ptr); + } #endif } } diff --git a/WINGs/notification.c b/WINGs/notification.c index 95bfb83c..e221b8c7 100644 --- a/WINGs/notification.c +++ b/WINGs/notification.c @@ -43,15 +43,15 @@ WMNotification* WMCreateNotification(const char *name, void *object, void *clientData) { Notification *nPtr; - + nPtr = wmalloc(sizeof(Notification)); - + nPtr->name = name; nPtr->object = object; nPtr->clientData = clientData; - + nPtr->refCount = 1; - + return nPtr; } @@ -60,9 +60,9 @@ void WMReleaseNotification(WMNotification *notification) { notification->refCount--; - + if (notification->refCount < 1) { - wfree(notification); + wfree(notification); } } @@ -71,7 +71,7 @@ WMNotification* WMRetainNotification(WMNotification *notification) { notification->refCount++; - + return notification; } @@ -95,7 +95,7 @@ typedef struct W_NotificationCenter { WMHashTable *nameTable; /* names -> observer lists */ WMHashTable *objectTable; /* object -> observer lists */ NotificationObserver *nilList; /* obervers that catch everything */ - + WMHashTable *observerTable; /* observer -> NotificationObserver */ } NotificationCenter; @@ -108,21 +108,21 @@ void W_InitNotificationCenter(void) { notificationCenter = wmalloc(sizeof(NotificationCenter)); - + notificationCenter->nameTable = WMCreateHashTable(WMStringPointerHashCallbacks); notificationCenter->objectTable = WMCreateHashTable(WMIntHashCallbacks); notificationCenter->nilList = NULL; - + notificationCenter->observerTable = WMCreateHashTable(WMIntHashCallbacks); } void WMAddNotificationObserver(WMNotificationObserverAction *observerAction, - void *observer, const char *name, void *object) + void *observer, const char *name, void *object) { NotificationObserver *oRec, *rec; - + oRec = wmalloc(sizeof(NotificationObserver)); oRec->observerAction = observerAction; oRec->observer = observer; @@ -130,42 +130,42 @@ WMAddNotificationObserver(WMNotificationObserverAction *observerAction, oRec->object = object; oRec->next = NULL; oRec->prev = NULL; - - + + /* put this action in the list of actions for this observer */ rec = (NotificationObserver*)WMHashInsert(notificationCenter->observerTable, - observer, oRec); - + observer, oRec); + if (rec) { - /* if this is not the first action for the observer */ - oRec->nextAction = rec; + /* if this is not the first action for the observer */ + oRec->nextAction = rec; } else { - oRec->nextAction = NULL; + oRec->nextAction = NULL; } if (!name && !object) { - /* catch-all */ - oRec->next = notificationCenter->nilList; - if (notificationCenter->nilList) { - notificationCenter->nilList->prev = oRec; - } - notificationCenter->nilList = oRec; + /* catch-all */ + oRec->next = notificationCenter->nilList; + if (notificationCenter->nilList) { + notificationCenter->nilList->prev = oRec; + } + notificationCenter->nilList = oRec; } else if (!name) { - /* any message coming from object */ - rec = (NotificationObserver*)WMHashInsert(notificationCenter->objectTable, - object, oRec); - oRec->next = rec; - if (rec) { - rec->prev = oRec; - } + /* any message coming from object */ + rec = (NotificationObserver*)WMHashInsert(notificationCenter->objectTable, + object, oRec); + oRec->next = rec; + if (rec) { + rec->prev = oRec; + } } else { - /* name && (object || !object) */ - rec = (NotificationObserver*)WMHashInsert(notificationCenter->nameTable, - name, oRec); - oRec->next = rec; - if (rec) { - rec->prev = oRec; - } + /* name && (object || !object) */ + rec = (NotificationObserver*)WMHashInsert(notificationCenter->nameTable, + name, oRec); + oRec->next = rec; + if (rec) { + rec->prev = oRec; + } } } @@ -176,49 +176,49 @@ WMPostNotification(WMNotification *notification) NotificationObserver *orec, *tmp; WMRetainNotification(notification); - + /* tell the observers that want to know about a particular message */ - orec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable, - notification->name); - + orec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable, + notification->name); + while (orec) { - tmp = orec->next; - - if (!orec->object || !notification->object + tmp = orec->next; + + if (!orec->object || !notification->object || orec->object == notification->object) { - /* tell the observer */ - if (orec->observerAction) { - (*orec->observerAction)(orec->observer, notification); - } - } + /* tell the observer */ + if (orec->observerAction) { + (*orec->observerAction)(orec->observer, notification); + } + } - orec = tmp; + orec = tmp; } /* tell the observers that want to know about an object */ orec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, - notification->object); - + notification->object); + while (orec) { - tmp = orec->next; - - /* tell the observer */ - if (orec->observerAction) { - (*orec->observerAction)(orec->observer, notification); - } - orec = tmp; + tmp = orec->next; + + /* tell the observer */ + if (orec->observerAction) { + (*orec->observerAction)(orec->observer, notification); + } + orec = tmp; } /* tell the catch all observers */ orec = notificationCenter->nilList; while (orec) { - tmp = orec->next; + tmp = orec->next; - /* tell the observer */ - if (orec->observerAction) { - (*orec->observerAction)(orec->observer, notification); - } - orec = tmp; + /* tell the observer */ + if (orec->observerAction) { + (*orec->observerAction)(orec->observer, notification); + } + orec = tmp; } WMReleaseNotification(notification); @@ -232,7 +232,7 @@ WMRemoveNotificationObserver(void *observer) /* get the list of actions the observer is doing */ orec = (NotificationObserver*)WMHashGet(notificationCenter->observerTable, - observer); + observer); /* * FOREACH orec IN actionlist for observer @@ -242,47 +242,47 @@ WMRemoveNotificationObserver(void *observer) * END */ while (orec) { - tmp = orec->nextAction; - - if (!orec->name && !orec->object) { - /* catch-all */ - if (notificationCenter->nilList==orec) - notificationCenter->nilList = orec->next; - } else if (!orec->name) { - /* any message coming from object */ - rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, - orec->object); - if (rec==orec) { - /* replace table entry */ - if (orec->next) { - WMHashInsert(notificationCenter->objectTable, orec->object, - orec->next); - } else { - WMHashRemove(notificationCenter->objectTable, orec->object); - } - } - } else { - /* name && (object || !object) */ - rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable, - orec->name); - if (rec==orec) { - /* replace table entry */ - if (orec->next) { - WMHashInsert(notificationCenter->nameTable, orec->name, - orec->next); - } else { - WMHashRemove(notificationCenter->nameTable, orec->name); - } - } - } - if (orec->prev) - orec->prev->next = orec->next; - if (orec->next) - orec->next->prev = orec->prev; - - wfree(orec); - - orec = tmp; + tmp = orec->nextAction; + + if (!orec->name && !orec->object) { + /* catch-all */ + if (notificationCenter->nilList==orec) + notificationCenter->nilList = orec->next; + } else if (!orec->name) { + /* any message coming from object */ + rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, + orec->object); + if (rec==orec) { + /* replace table entry */ + if (orec->next) { + WMHashInsert(notificationCenter->objectTable, orec->object, + orec->next); + } else { + WMHashRemove(notificationCenter->objectTable, orec->object); + } + } + } else { + /* name && (object || !object) */ + rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable, + orec->name); + if (rec==orec) { + /* replace table entry */ + if (orec->next) { + WMHashInsert(notificationCenter->nameTable, orec->name, + orec->next); + } else { + WMHashRemove(notificationCenter->nameTable, orec->name); + } + } + } + if (orec->prev) + orec->prev->next = orec->next; + if (orec->next) + orec->next->prev = orec->prev; + + wfree(orec); + + orec = tmp; } WMHashRemove(notificationCenter->observerTable, observer); @@ -303,66 +303,66 @@ WMRemoveNotificationObserverWithName(void *observer, const char *name, void *obj /* rebuild the list of actions for the observer */ while (orec) { - tmp = orec->nextAction; - if (orec->name == name && orec->object == object) { - if (!name && !object) { - if (notificationCenter->nilList == orec) - notificationCenter->nilList = orec->next; - } else if (!name) { - rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, orec->object); - if (rec==orec) { - assert(rec->prev==NULL); - /* replace table entry */ - if (orec->next) { - WMHashInsert(notificationCenter->objectTable, - orec->object, orec->next); - } else { - WMHashRemove(notificationCenter->objectTable, - orec->object); - } - } - } else { - rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable, - orec->name); - if (rec==orec) { - assert(rec->prev==NULL); - /* replace table entry */ - if (orec->next) { - WMHashInsert(notificationCenter->nameTable, - orec->name, orec->next); - } else { - WMHashRemove(notificationCenter->nameTable, - orec->name); - } - } - } - - if (orec->prev) - orec->prev->next = orec->next; - if (orec->next) - orec->next->prev = orec->prev; - wfree(orec); + tmp = orec->nextAction; + if (orec->name == name && orec->object == object) { + if (!name && !object) { + if (notificationCenter->nilList == orec) + notificationCenter->nilList = orec->next; + } else if (!name) { + rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, orec->object); + if (rec==orec) { + assert(rec->prev==NULL); + /* replace table entry */ + if (orec->next) { + WMHashInsert(notificationCenter->objectTable, + orec->object, orec->next); + } else { + WMHashRemove(notificationCenter->objectTable, + orec->object); + } + } + } else { + rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable, + orec->name); + if (rec==orec) { + assert(rec->prev==NULL); + /* replace table entry */ + if (orec->next) { + WMHashInsert(notificationCenter->nameTable, + orec->name, orec->next); + } else { + WMHashRemove(notificationCenter->nameTable, + orec->name); + } + } + } + + if (orec->prev) + orec->prev->next = orec->next; + if (orec->next) + orec->next->prev = orec->prev; + wfree(orec); } else { - /* append this action in the new action list */ - orec->nextAction = NULL; - if (!newList) { - newList = orec; - } else { - NotificationObserver *p; - - p = newList; - while (p->nextAction) { - p = p->nextAction; - } - p->nextAction = orec; - } - } - orec = tmp; + /* append this action in the new action list */ + orec->nextAction = NULL; + if (!newList) { + newList = orec; + } else { + NotificationObserver *p; + + p = newList; + while (p->nextAction) { + p = p->nextAction; + } + p->nextAction = orec; + } + } + orec = tmp; } /* reinsert the list to the table */ if (newList) { - WMHashInsert(notificationCenter->observerTable, observer, newList); + WMHashInsert(notificationCenter->observerTable, observer, newList); } } @@ -373,7 +373,7 @@ WMPostNotificationName(const char *name, void *object, void *clientData) WMNotification *notification; notification = WMCreateNotification(name, object, clientData); - + WMPostNotification(notification); WMReleaseNotification(notification); @@ -402,7 +402,7 @@ WMNotificationQueue* WMGetDefaultNotificationQueue(void) { if (!notificationQueue) - notificationQueue = WMCreateNotificationQueue(); + notificationQueue = WMCreateNotificationQueue(); return notificationQueue; } @@ -430,10 +430,10 @@ WMCreateNotificationQueue(void) void WMEnqueueNotification(WMNotificationQueue *queue, WMNotification *notification, - WMPostingStyle postingStyle) + WMPostingStyle postingStyle) { WMEnqueueCoalesceNotification(queue, notification, postingStyle, - WNCOnName|WNCOnSender); + WNCOnName|WNCOnSender); } @@ -465,8 +465,8 @@ matchName(void *item, void *cdata) void -WMDequeueNotificationMatching(WMNotificationQueue *queue, - WMNotification *notification, unsigned mask) +WMDequeueNotificationMatching(WMNotificationQueue *queue, + WMNotification *notification, unsigned mask) { WMMatchDataProc *matchFunc; @@ -485,27 +485,27 @@ WMDequeueNotificationMatching(WMNotificationQueue *queue, void -WMEnqueueCoalesceNotification(WMNotificationQueue *queue, - WMNotification *notification, - WMPostingStyle postingStyle, - unsigned coalesceMask) +WMEnqueueCoalesceNotification(WMNotificationQueue *queue, + WMNotification *notification, + WMPostingStyle postingStyle, + unsigned coalesceMask) { if (coalesceMask != WNCNone) - WMDequeueNotificationMatching(queue, notification, coalesceMask); + WMDequeueNotificationMatching(queue, notification, coalesceMask); switch (postingStyle) { - case WMPostNow: - WMPostNotification(notification); + case WMPostNow: + WMPostNotification(notification); WMReleaseNotification(notification); break; - case WMPostASAP: - WMAddToArray(queue->asapQueue, notification); - break; + case WMPostASAP: + WMAddToArray(queue->asapQueue, notification); + break; - case WMPostWhenIdle: - WMAddToArray(queue->idleQueue, notification); - break; + case WMPostWhenIdle: + WMAddToArray(queue->idleQueue, notification); + break; } } @@ -516,12 +516,12 @@ W_FlushASAPNotificationQueue() WMNotificationQueue *queue = notificationQueueList; while (queue) { - while (WMGetArrayItemCount(queue->asapQueue)) { + while (WMGetArrayItemCount(queue->asapQueue)) { WMPostNotification(WMGetFromArray(queue->asapQueue, 0)); WMDeleteFromArray(queue->asapQueue, 0); - } + } - queue = queue->next; + queue = queue->next; } } @@ -532,12 +532,12 @@ W_FlushIdleNotificationQueue() WMNotificationQueue *queue = notificationQueueList; while (queue) { - while (WMGetArrayItemCount(queue->idleQueue)) { - WMPostNotification(WMGetFromArray(queue->idleQueue, 0)); - WMDeleteFromArray(queue->idleQueue, 0); - } + while (WMGetArrayItemCount(queue->idleQueue)) { + WMPostNotification(WMGetFromArray(queue->idleQueue, 0)); + WMDeleteFromArray(queue->idleQueue, 0); + } - queue = queue->next; + queue = queue->next; } } diff --git a/WINGs/proplist.c b/WINGs/proplist.c index df942630..51461205 100644 --- a/WINGs/proplist.c +++ b/WINGs/proplist.c @@ -98,8 +98,8 @@ static Bool caseSensitive = True; #define CHECK_BUFFER_SIZE(buf, ptr) \ if ((ptr) >= (buf).size-1) {\ - (buf).size += BUFFERSIZE_INCREMENT;\ - (buf).str = wrealloc((buf).str, (buf).size);\ + (buf).size += BUFFERSIZE_INCREMENT;\ + (buf).str = wrealloc((buf).str, (buf).size);\ } @@ -132,9 +132,9 @@ hashPropList(WMPropList *plist) ctr = (ctr + 1) % sizeof (char *); } /*while (*key) { - ret ^= tolower(*key++) << ctr; - ctr = (ctr + 1) % sizeof (char *); - }*/ + ret ^= tolower(*key++) << ctr; + ctr = (ctr + 1) % sizeof (char *); + }*/ break; case WPLData: @@ -1269,7 +1269,7 @@ WMSubtractPLDictionaries(WMPropList *dest, WMPropList *source, Bool recursive) if (WMIsPropListEqualTo(value, dvalue)) { WMRemoveFromPLDictionary(dest, key); } else if (recursive && value->type==WPLDictionary && - dvalue->type==WPLDictionary) { + dvalue->type==WPLDictionary) { WMSubtractPLDictionaries(dvalue, value, True); } } diff --git a/WINGs/selection.c b/WINGs/selection.c index 59da2821..e5201e38 100644 --- a/WINGs/selection.c +++ b/WINGs/selection.c @@ -20,8 +20,8 @@ typedef struct SelectionHandler { void *data; struct { - unsigned delete_pending:1; - unsigned done_pending:1; + unsigned delete_pending:1; + unsigned done_pending:1; } flags; } SelectionHandler; @@ -35,8 +35,8 @@ typedef struct SelectionCallback { void *data; struct { - unsigned delete_pending:1; - unsigned done_pending:1; + unsigned delete_pending:1; + unsigned done_pending:1; } flags; } SelectionCallback; @@ -65,18 +65,18 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp) /*//printf("deleting selection handler for %d", win);*/ WM_ITERATE_ARRAY(selHandlers, handler, iter) { - if (handler->view == view - && (handler->selection == selection || selection == None) - && (handler->timestamp == timestamp || timestamp == CurrentTime)) { + if (handler->view == view + && (handler->selection == selection || selection == None) + && (handler->timestamp == timestamp || timestamp == CurrentTime)) { - if (handler->flags.done_pending) { - handler->flags.delete_pending = 1; + if (handler->flags.done_pending) { + handler->flags.delete_pending = 1; /*//puts(": postponed because still pending");*/ return; - } + } /*//printf(": found & removed");*/ WMRemoveFromArray(selHandlers, handler); - break; + break; } } @@ -84,7 +84,7 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp) XGrabServer(dpy); if (XGetSelectionOwner(dpy, selection) == win) { - XSetSelectionOwner(dpy, selection, None, timestamp); + XSetSelectionOwner(dpy, selection, None, timestamp); } XUngrabServer(dpy); } @@ -99,18 +99,18 @@ WMDeleteSelectionCallback(WMView *view, Atom selection, Time timestamp) if (!selCallbacks) return; - + WM_ITERATE_ARRAY(selCallbacks, handler, iter) { - if (handler->view == view - && (handler->selection == selection || selection == None) - && (handler->timestamp == timestamp || timestamp == CurrentTime)) { - - if (handler->flags.done_pending) { - handler->flags.delete_pending = 1; - return; - } - WMRemoveFromArray(selCallbacks, handler); - break; + if (handler->view == view + && (handler->selection == selection || selection == None) + && (handler->timestamp == timestamp || timestamp == CurrentTime)) { + + if (handler->flags.done_pending) { + handler->flags.delete_pending = 1; + return; + } + WMRemoveFromArray(selCallbacks, handler); + break; } } } @@ -127,14 +127,14 @@ handleXError(Display *dpy, XErrorEvent *ev) static Bool writeSelection(Display *dpy, Window requestor, Atom property, Atom type, - WMData *data) + WMData *data) { static void *oldHandler; int format, bpi; format = WMGetDataFormat(data); if (format == 0) - format = 8; + format = 8; bpi = format/8; @@ -171,9 +171,9 @@ notifySelection(XEvent *event, Atom prop) ev.xselection.selection = event->xselectionrequest.selection; ev.xselection.property = prop; ev.xselection.time = event->xselectionrequest.time; - - XSendEvent(event->xany.display, event->xselectionrequest.requestor, - False, 0, &ev); + + XSendEvent(event->xany.display, event->xselectionrequest.requestor, + False, 0, &ev); XFlush(event->xany.display); } @@ -188,54 +188,54 @@ handleRequestEvent(XEvent *event) WM_ITERATE_ARRAY(selHandlers, handler, iter) { - switch (event->type) { - case SelectionClear: - if (W_VIEW_DRAWABLE(handler->view) - != event->xselectionclear.window) { - break; - } - - handler->flags.done_pending = 1; - if (handler->procs.selectionLost) - handler->procs.selectionLost(handler->view, - handler->selection, - handler->data); - handler->flags.done_pending = 0; - handler->flags.delete_pending = 1; - break; - - case SelectionRequest: - if (W_VIEW_DRAWABLE(handler->view)!=event->xselectionrequest.owner) { - break; - } - - if (handler->procs.convertSelection != NULL - && handler->selection == event->xselectionrequest.selection) { - Atom atom; - WMData *data; - Atom prop; - - /* they're requesting for something old.. maybe another handler - * can handle it */ - if (event->xselectionrequest.time < handler->timestamp - && event->xselectionrequest.time != CurrentTime) { - break; - } + switch (event->type) { + case SelectionClear: + if (W_VIEW_DRAWABLE(handler->view) + != event->xselectionclear.window) { + break; + } + + handler->flags.done_pending = 1; + if (handler->procs.selectionLost) + handler->procs.selectionLost(handler->view, + handler->selection, + handler->data); + handler->flags.done_pending = 0; + handler->flags.delete_pending = 1; + break; + + case SelectionRequest: + if (W_VIEW_DRAWABLE(handler->view)!=event->xselectionrequest.owner) { + break; + } + + if (handler->procs.convertSelection != NULL + && handler->selection == event->xselectionrequest.selection) { + Atom atom; + WMData *data; + Atom prop; + + /* they're requesting for something old.. maybe another handler + * can handle it */ + if (event->xselectionrequest.time < handler->timestamp + && event->xselectionrequest.time != CurrentTime) { + break; + } handledRequest = False; - handler->flags.done_pending = 1; + handler->flags.done_pending = 1; - data = handler->procs.convertSelection(handler->view, - handler->selection, - event->xselectionrequest.target, - handler->data, - &atom); + data = handler->procs.convertSelection(handler->view, + handler->selection, + event->xselectionrequest.target, + handler->data, + &atom); - prop = event->xselectionrequest.property; - /* obsolete clients that don't set the property field */ - if (prop == None) - prop = event->xselectionrequest.target; + prop = event->xselectionrequest.property; + /* obsolete clients that don't set the property field */ + if (prop == None) + prop = event->xselectionrequest.target; if (data) { if (writeSelection(event->xselectionrequest.display, @@ -248,17 +248,17 @@ handleRequestEvent(XEvent *event) notifySelection(event, (handledRequest==True ? prop : None)); - if (handler->procs.selectionDone != NULL) { - handler->procs.selectionDone(handler->view, - handler->selection, - event->xselectionrequest.target, - handler->data); - } - - handler->flags.done_pending = 0; - } - break; - } + if (handler->procs.selectionDone != NULL) { + handler->procs.selectionDone(handler->view, + handler->selection, + event->xselectionrequest.target, + handler->data); + } + + handler->flags.done_pending = 0; + } + break; + } } /* delete handlers */ @@ -283,10 +283,10 @@ getSelectionData(Display *dpy, Window win, Atom where) unsigned long len, bytes; - if (XGetWindowProperty(dpy, win, where, 0, MAX_PROPERTY_SIZE, - False, AnyPropertyType, &rtype, &bits, &len, - &bytes, &data)!=Success) { - return NULL; + if (XGetWindowProperty(dpy, win, where, 0, MAX_PROPERTY_SIZE, + False, AnyPropertyType, &rtype, &bits, &len, + &bytes, &data)!=Success) { + return NULL; } bpi = bits/8; @@ -307,30 +307,30 @@ handleNotifyEvent(XEvent *event) WMData *data; WM_ITERATE_ARRAY(selCallbacks, handler, iter) { - - if (W_VIEW_DRAWABLE(handler->view) != event->xselection.requestor - || handler->selection != event->xselection.selection) { - continue; - } - handler->flags.done_pending = 1; - - if (event->xselection.property == None) { - data = NULL; - } else { - data = getSelectionData(event->xselection.display, - event->xselection.requestor, - event->xselection.property); - } - - (*handler->callback)(handler->view, handler->selection, - handler->target, handler->timestamp, - handler->data, data); - - if (data != NULL) { - WMReleaseData(data); - } - handler->flags.done_pending = 0; - handler->flags.delete_pending = 1; + + if (W_VIEW_DRAWABLE(handler->view) != event->xselection.requestor + || handler->selection != event->xselection.selection) { + continue; + } + handler->flags.done_pending = 1; + + if (event->xselection.property == None) { + data = NULL; + } else { + data = getSelectionData(event->xselection.display, + event->xselection.requestor, + event->xselection.property); + } + + (*handler->callback)(handler->view, handler->selection, + handler->target, handler->timestamp, + handler->data, data); + + if (data != NULL) { + WMReleaseData(data); + } + handler->flags.done_pending = 0; + handler->flags.delete_pending = 1; } /* delete callbacks */ @@ -351,20 +351,20 @@ W_HandleSelectionEvent(XEvent *event) { /*//printf("%d received selection ", event->xany.window);*/ /*//switch(event->type) { - case SelectionNotify: - puts("notify"); break; - case SelectionRequest: - puts("request"); break; - case SelectionClear: - puts("clear"); break; - default: - puts("unknown"); break; - }*/ + case SelectionNotify: + puts("notify"); break; + case SelectionRequest: + puts("request"); break; + case SelectionClear: + puts("clear"); break; + default: + puts("unknown"); break; + }*/ if (event->type == SelectionNotify) { - handleNotifyEvent(event); + handleNotifyEvent(event); } else { - handleRequestEvent(event); + handleRequestEvent(event); } } @@ -372,7 +372,7 @@ W_HandleSelectionEvent(XEvent *event) Bool WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp, - WMSelectionProcs *procs, void *cdata) + WMSelectionProcs *procs, void *cdata) { SelectionHandler *handler; Display *dpy = W_VIEW_SCREEN(view)->display; @@ -397,7 +397,7 @@ WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp, memset(&handler->flags, 0, sizeof(handler->flags)); if (selHandlers == NULL) { - selHandlers = WMCreateArrayWithDestructor(4, wfree); + selHandlers = WMCreateArrayWithDestructor(4, wfree); } WMAddToArray(selHandlers, handler); @@ -409,16 +409,16 @@ WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp, Bool WMRequestSelection(WMView *view, Atom selection, Atom target, Time timestamp, - WMSelectionCallback *callback, void *cdata) + WMSelectionCallback *callback, void *cdata) { SelectionCallback *handler; if (XGetSelectionOwner(W_VIEW_SCREEN(view)->display, selection) == None) - return False; + return False; if (!XConvertSelection(W_VIEW_SCREEN(view)->display, selection, target, - W_VIEW_SCREEN(view)->clipboardAtom, - W_VIEW_DRAWABLE(view), timestamp)) { + W_VIEW_SCREEN(view)->clipboardAtom, + W_VIEW_DRAWABLE(view), timestamp)) { return False; } @@ -433,7 +433,7 @@ WMRequestSelection(WMView *view, Atom selection, Atom target, Time timestamp, memset(&handler->flags, 0, sizeof(handler->flags)); if (selCallbacks == NULL) { - selCallbacks = WMCreateArrayWithDestructor(4, wfree); + selCallbacks = WMCreateArrayWithDestructor(4, wfree); } WMAddToArray(selCallbacks, handler); diff --git a/WINGs/snprintf.c b/WINGs/snprintf.c index b832125a..114da62d 100644 --- a/WINGs/snprintf.c +++ b/WINGs/snprintf.c @@ -935,3 +935,4 @@ int main (void) return 0; } #endif /* SNPRINTF_TEST */ + diff --git a/WINGs/string.c b/WINGs/string.c index c8abfd4e..e9f9ed3c 100644 --- a/WINGs/string.c +++ b/WINGs/string.c @@ -43,46 +43,46 @@ wtokennext(char *word, char **next) t = ret = wmalloc(strlen(word)+1); ptr = word; - + state = 0; *t = 0; while (1) { - if (*ptr==0) - ctype = PRC_EOS; - else if (*ptr=='\\') - ctype = PRC_ESCAPE; - else if (*ptr=='"') - ctype = PRC_DQUOTE; - else if (*ptr=='\'') - ctype = PRC_SQUOTE; - else if (*ptr==' ' || *ptr=='\t') - ctype = PRC_BLANK; - else - ctype = PRC_ALPHA; - - if (mtable[state][ctype].output) { - *t = *ptr; t++; - *t = 0; - } - state = mtable[state][ctype].nstate; - ptr++; - if (mtable[state][0].output<0) { - break; - } + if (*ptr==0) + ctype = PRC_EOS; + else if (*ptr=='\\') + ctype = PRC_ESCAPE; + else if (*ptr=='"') + ctype = PRC_DQUOTE; + else if (*ptr=='\'') + ctype = PRC_SQUOTE; + else if (*ptr==' ' || *ptr=='\t') + ctype = PRC_BLANK; + else + ctype = PRC_ALPHA; + + if (mtable[state][ctype].output) { + *t = *ptr; t++; + *t = 0; + } + state = mtable[state][ctype].nstate; + ptr++; + if (mtable[state][0].output<0) { + break; + } } if (*ret==0) - t = NULL; + t = NULL; else - t = wstrdup(ret); + t = wstrdup(ret); wfree(ret); - + if (ctype==PRC_EOS) - *next = NULL; + *next = NULL; else - *next = ptr; - + *next = ptr; + return t; } @@ -97,14 +97,14 @@ wtokensplit(char *command, char ***argv, int *argc) count = 0; line = command; do { - token = wtokennext(line, &line); - if (token) { - if (count == 0) - *argv = wmalloc(sizeof(char**)); - else - *argv = wrealloc(*argv, (count+1)*sizeof(char**)); - (*argv)[count++] = token; - } + token = wtokennext(line, &line); + if (token) { + if (count == 0) + *argv = wmalloc(sizeof(char**)); + else + *argv = wrealloc(*argv, (count+1)*sizeof(char**)); + (*argv)[count++] = token; + } } while (token!=NULL && line!=NULL); *argc = count; @@ -128,21 +128,21 @@ wtokenjoin(char **list, int count) j += 2; } } - + flat_string = wmalloc(j+count+1); *flat_string = 0; for (i=0; i0) - strcat(flat_string, " "); + if (list[i]!=NULL && list[i][0]!=0) { + if (i>0) + strcat(flat_string, " "); wspace = strpbrk(list[i], " \t"); if (wspace) strcat(flat_string, "\""); - strcat(flat_string, list[i]); + strcat(flat_string, list[i]); if (wspace) strcat(flat_string, "\""); - } + } } return flat_string; @@ -207,9 +207,9 @@ wstrconcat(char *str1, char *str2) char *str; if (!str1) - return wstrdup(str2); + return wstrdup(str2); else if (!str2) - return wstrdup(str1); + return wstrdup(str1); str = wmalloc(strlen(str1)+strlen(str2)+1); strcpy(str, str1); @@ -223,9 +223,9 @@ char* wstrappend(char *dst, char *src) { if (!dst) - return wstrdup(src); + return wstrdup(src); else if (!src || *src==0) - return dst; + return dst; dst = wrealloc(dst, strlen(dst)+strlen(src)+1); strcat(dst, src); diff --git a/WINGs/userdefaults.c b/WINGs/userdefaults.c index 566f8e0e..465d6bf9 100644 --- a/WINGs/userdefaults.c +++ b/WINGs/userdefaults.c @@ -57,19 +57,19 @@ wusergnusteppath() int pathlen; if (!path) { - gspath = getenv("GNUSTEP_USER_ROOT"); - if (gspath) { - gspath = wexpandpath(gspath); - pathlen = strlen(gspath) + 4; - path = wmalloc(pathlen); - strcpy(path, gspath); - wfree(gspath); - } else { - pathlen = strlen(wgethomedir()) + 10; - path = wmalloc(pathlen); - strcpy(path, wgethomedir()); - strcat(path, "/GNUstep"); - } + gspath = getenv("GNUSTEP_USER_ROOT"); + if (gspath) { + gspath = wexpandpath(gspath); + pathlen = strlen(gspath) + 4; + path = wmalloc(pathlen); + strcpy(path, gspath); + wfree(gspath); + } else { + pathlen = strlen(wgethomedir()) + 10; + path = wmalloc(pathlen); + strcpy(path, wgethomedir()); + strcat(path, "/GNUstep"); + } } return path; @@ -436,24 +436,24 @@ WMGetUDObjectForKey(WMUserDefaults *database, char *defaultName) WMPropList *object = NULL; WMPropList *key = WMCreatePLString(defaultName); int i = 0; - + while (database->searchList[i] && !object) { - domainName = database->searchList[i]; - domain = WMGetFromPLDictionary(database->defaults, domainName); - if (domain) { - object = WMGetFromPLDictionary(domain, key); - } - i++; + domainName = database->searchList[i]; + domain = WMGetFromPLDictionary(database->defaults, domainName); + if (domain) { + object = WMGetFromPLDictionary(domain, key); + } + i++; } WMReleasePropList(key); - + return object; } void WMSetUDObjectForKey(WMUserDefaults *database, WMPropList *object, - char *defaultName) + char *defaultName) { WMPropList *key = WMCreatePLString(defaultName); @@ -472,7 +472,7 @@ WMRemoveUDObjectForKey(WMUserDefaults *database, char *defaultName) database->dirty = 1; WMRemoveFromPLDictionary(database->appDomain, key); - + WMReleasePropList(key); } @@ -481,14 +481,14 @@ char* WMGetUDStringForKey(WMUserDefaults *database, char *defaultName) { WMPropList *val; - + val = WMGetUDObjectForKey(database, defaultName); if (!val) - return NULL; + return NULL; if (!WMIsPLString(val)) - return NULL; + return NULL; return WMGetFromPLString(val); } @@ -502,19 +502,19 @@ WMGetUDIntegerForKey(WMUserDefaults *database, char *defaultName) int value; val = WMGetUDObjectForKey(database, defaultName); - + if (!val) - return 0; + return 0; if (!WMIsPLString(val)) - return 0; - + return 0; + str = WMGetFromPLString(val); if (!str) - return 0; - + return 0; + if (sscanf(str, "%i", &value)!=1) - return 0; + return 0; return value; } @@ -529,15 +529,15 @@ WMGetUDFloatForKey(WMUserDefaults *database, char *defaultName) float value; val = WMGetUDObjectForKey(database, defaultName); - + if (!val || !WMIsPLString(val)) - return 0.0; + return 0.0; if (!(str = WMGetFromPLString(val))) - return 0.0; + return 0.0; if (sscanf(str, "%f", &value)!=1) - return 0.0; + return 0.0; return value; } @@ -552,25 +552,25 @@ WMGetUDBoolForKey(WMUserDefaults *database, char *defaultName) char *str; val = WMGetUDObjectForKey(database, defaultName); - + if (!val) - return False; + return False; if (!WMIsPLString(val)) - return False; - + return False; + str = WMGetFromPLString(val); if (!str) - return False; - + return False; + if (sscanf(str, "%i", &value)==1 && value!=0) - return True; + return True; if (strcasecmp(str, "YES")==0) - return True; + return True; if (strcasecmp(str, "Y")==0) - return True; + return True; return False; } @@ -584,7 +584,7 @@ WMSetUDIntegerForKey(WMUserDefaults *database, int value, char *defaultName) sprintf(buffer, "%i", value); object = WMCreatePLString(buffer); - + WMSetUDObjectForKey(database, object, defaultName); WMReleasePropList(object); } @@ -626,8 +626,8 @@ WMSetUDBoolForKey(WMUserDefaults *database, Bool value, char *defaultName) static WMPropList *yes = NULL, *no = NULL; if (!yes) { - yes = WMCreatePLString("YES"); - no = WMCreatePLString("NO"); + yes = WMCreatePLString("YES"); + no = WMCreatePLString("NO"); } WMSetUDObjectForKey(database, value ? yes : no, defaultName); @@ -645,27 +645,27 @@ void WMSetUDSearchList(WMUserDefaults *database, WMPropList *list) { int i, c; - + if (database->searchList) { - i = 0; - while (database->searchList[i]) { - WMReleasePropList(database->searchList[i]); - i++; - } - wfree(database->searchList); + i = 0; + while (database->searchList[i]) { + WMReleasePropList(database->searchList[i]); + i++; + } + wfree(database->searchList); } if (database->searchListArray) { - WMReleasePropList(database->searchListArray); + WMReleasePropList(database->searchListArray); } c = WMGetPropListItemCount(list); database->searchList = wmalloc(sizeof(WMPropList*)*(c+1)); for (i=0; isearchList[i] = WMGetFromPLArray(list, i); + database->searchList[i] = WMGetFromPLArray(list, i); } database->searchList[c] = NULL; - + database->searchListArray = WMDeepCopyPropList(list); } diff --git a/WINGs/usleep.c b/WINGs/usleep.c index 3ab784d4..69f5e9df 100644 --- a/WINGs/usleep.c +++ b/WINGs/usleep.c @@ -36,9 +36,9 @@ wusleep(unsigned int microsecs) #else /* not HAVE_SELECT */ -# ifdef HAVE_POLL +# ifdef HAVE_POLL -void +void wusleep(unsigned int microsecs) { poll((struct poll *) 0, (size_t) 0, microsecs/1000); diff --git a/WINGs/wapplication.c b/WINGs/wapplication.c index 91f835e3..1cf6e08f 100644 --- a/WINGs/wapplication.c +++ b/WINGs/wapplication.c @@ -19,7 +19,7 @@ char *_WINGS_progname = NULL; -Bool +Bool W_ApplicationInitialized(void) { return _WINGS_progname!=NULL; @@ -40,9 +40,9 @@ WMInitializeApplication(char *applicationName, int *argc, char **argv) #ifdef I18N if (getenv("NLSPATH")) - bindtextdomain("WINGs", getenv("NLSPATH")); + bindtextdomain("WINGs", getenv("NLSPATH")); else - bindtextdomain("WINGs", LOCALEDIR); + bindtextdomain("WINGs", LOCALEDIR); #endif _WINGS_progname = argv[0]; @@ -52,7 +52,7 @@ WMInitializeApplication(char *applicationName, int *argc, char **argv) WMApplication.argv = wmalloc((*argc+1)*sizeof(char*)); for (i=0; i<*argc; i++) { - WMApplication.argv[i] = wstrdup(argv[i]); + WMApplication.argv[i] = wstrdup(argv[i]); } WMApplication.argv[i] = NULL; @@ -65,7 +65,7 @@ void WMSetResourcePath(char *path) { if (WMApplication.resourcePath) - wfree(WMApplication.resourcePath); + wfree(WMApplication.resourcePath); WMApplication.resourcePath = wstrdup(path); } @@ -82,24 +82,24 @@ checkFile(char *path, char *folder, char *ext, char *resource) { char *ret; int extralen; - - extralen = (ext ? strlen(ext) : 0) + (folder ? strlen(folder) : 0) + 4; + + extralen = (ext ? strlen(ext) : 0) + (folder ? strlen(folder) : 0) + 4; ret = wmalloc(strlen(path)+strlen(resource)+extralen+8); strcpy(ret, path); if (folder) { - strcat(ret, "/"); - strcat(ret, folder); + strcat(ret, "/"); + strcat(ret, folder); } if (ext) { - strcat(ret, "/"); - strcat(ret, ext); + strcat(ret, "/"); + strcat(ret, ext); } strcat(ret, "/"); strcat(ret, resource); - + if (access(ret, F_OK)!=0) { - wfree(ret); - ret = NULL; + wfree(ret); + ret = NULL; } return ret; @@ -112,90 +112,90 @@ WMPathForResourceOfType(char *resource, char *ext) char *path = NULL; char *tmp, *appdir; int i; - - /* + + /* * Paths are searched in this order: * - resourcePath/ext * - argv[0]/ext - * - GNUSTEP_USER_ROOT/Apps/ApplicationName.app/ext + * - GNUSTEP_USER_ROOT/Apps/ApplicationName.app/ext * - ~/GNUstep/Apps/ApplicationName.app/ext * - GNUSTEP_LOCAL_ROOT/Apps/ApplicationName.app/ext * - /usr/local/GNUstep/Apps/ApplicationName.app/ext * - GNUSTEP_SYSTEM_ROOT/Apps/ApplicationName.app/ext * - /usr/GNUstep/Apps/ApplicationName.app/ext */ - + if (WMApplication.resourcePath) { - path = checkFile(WMApplication.resourcePath, NULL, ext, resource); - if (path) - return path; + path = checkFile(WMApplication.resourcePath, NULL, ext, resource); + if (path) + return path; } if (WMApplication.argv[0]) { - tmp = wstrdup(WMApplication.argv[0]); - i = strlen(tmp); - while (i > 0 && tmp[i]!='/') - i--; - tmp[i] = 0; - if (i>0) { - path = checkFile(tmp, NULL, ext, resource); - } else { - path = NULL; - } - wfree(tmp); - if (path) - return path; + tmp = wstrdup(WMApplication.argv[0]); + i = strlen(tmp); + while (i > 0 && tmp[i]!='/') + i--; + tmp[i] = 0; + if (i>0) { + path = checkFile(tmp, NULL, ext, resource); + } else { + path = NULL; + } + wfree(tmp); + if (path) + return path; } - + appdir = wmalloc(strlen(WMApplication.applicationName)+10); sprintf(appdir, "Apps/%s.app", WMApplication.applicationName); if (getenv("GNUSTEP_USER_ROOT")) { - path = checkFile(getenv("GNUSTEP_USER_ROOT"), appdir, ext, resource); - if (path) { - wfree(appdir); - return path; - } + path = checkFile(getenv("GNUSTEP_USER_ROOT"), appdir, ext, resource); + if (path) { + wfree(appdir); + return path; + } } - + tmp = wusergnusteppath(); if (tmp) { - path = checkFile(tmp, appdir, ext, resource); - if (path) { - wfree(appdir); - return path; - } + path = checkFile(tmp, appdir, ext, resource); + if (path) { + wfree(appdir); + return path; + } } - + if (getenv("GNUSTEP_LOCAL_ROOT")) { - path = checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir, ext, resource); - if (path) { - wfree(appdir); - return path; - } + path = checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir, ext, resource); + if (path) { + wfree(appdir); + return path; + } } - + path = checkFile("/usr/local/GNUstep", appdir, ext, resource); if (path) { - wfree(appdir); - return path; + wfree(appdir); + return path; } - + if (getenv("GNUSTEP_SYSTEM_ROOT")) { - path = checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir, ext, resource); - if (path) { - wfree(appdir); - return path; - } + path = checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir, ext, resource); + if (path) { + wfree(appdir); + return path; + } } path = checkFile("/usr/GNUstep", appdir, ext, resource); if (path) { - wfree(appdir); - return path; + wfree(appdir); + return path; } - + return NULL; } diff --git a/WINGs/wappresource.c b/WINGs/wappresource.c index 0f82675a..878a1297 100644 --- a/WINGs/wappresource.c +++ b/WINGs/wappresource.c @@ -19,14 +19,14 @@ WMSetApplicationIconWindow(WMScreen *scr, Window window) scr->applicationIconWindow = window; if (scr->groupLeader) { - XWMHints *hints; + XWMHints *hints; - hints = XGetWMHints(scr->display, scr->groupLeader); - hints->flags |= IconWindowHint; - hints->icon_window = window; + hints = XGetWMHints(scr->display, scr->groupLeader); + hints->flags |= IconWindowHint; + hints->icon_window = window; - XSetWMHints(scr->display, scr->groupLeader, hints); - XFree(hints); + XSetWMHints(scr->display, scr->groupLeader, hints); + XFree(hints); } } @@ -40,7 +40,7 @@ WMSetApplicationIconImage(WMScreen *scr, RImage *image) return; if (scr->applicationIconImage) - RReleaseImage(scr->applicationIconImage); + RReleaseImage(scr->applicationIconImage); scr->applicationIconImage = RRetainImage(image); @@ -66,20 +66,20 @@ WMSetApplicationIconPixmap(WMScreen *scr, WMPixmap *icon) return; if (scr->applicationIconPixmap) - WMReleasePixmap(scr->applicationIconPixmap); + WMReleasePixmap(scr->applicationIconPixmap); scr->applicationIconPixmap = WMRetainPixmap(icon); if (scr->groupLeader) { - XWMHints *hints; + XWMHints *hints; - hints = XGetWMHints(scr->display, scr->groupLeader); - hints->flags |= IconPixmapHint|IconMaskHint; + hints = XGetWMHints(scr->display, scr->groupLeader); + hints->flags |= IconPixmapHint|IconMaskHint; hints->icon_pixmap = (icon!=NULL ? icon->pixmap : None); hints->icon_mask = (icon!=NULL ? icon->mask : None); - XSetWMHints(scr->display, scr->groupLeader, hints); - XFree(hints); + XSetWMHints(scr->display, scr->groupLeader, hints); + XFree(hints); } } @@ -132,40 +132,40 @@ W_InitApplication(WMScreen *scr) XWMHints *hints; leader = XCreateSimpleWindow(scr->display, scr->rootWin, -1, -1, - 1, 1, 0, 0, 0); + 1, 1, 0, 0, 0); if (!scr->aflags.simpleApplication) { - classHint = XAllocClassHint(); - classHint->res_name = "groupLeader"; - classHint->res_class = WMApplication.applicationName; - XSetClassHint(scr->display, leader, classHint); - XFree(classHint); + classHint = XAllocClassHint(); + classHint->res_name = "groupLeader"; + classHint->res_class = WMApplication.applicationName; + XSetClassHint(scr->display, leader, classHint); + XFree(classHint); - XSetCommand(scr->display, leader, WMApplication.argv, - WMApplication.argc); + XSetCommand(scr->display, leader, WMApplication.argv, + WMApplication.argc); - hints = XAllocWMHints(); + hints = XAllocWMHints(); - hints->flags = WindowGroupHint; - hints->window_group = leader; + hints->flags = WindowGroupHint; + hints->window_group = leader; /* This code will never actually be reached, because to have * scr->applicationIconPixmap set we need to have a screen first, * but this function is called in the screen creation process. * -Dan */ - if (scr->applicationIconPixmap) { + if (scr->applicationIconPixmap) { hints->flags |= IconPixmapHint; - hints->icon_pixmap = scr->applicationIconPixmap->pixmap; - if (scr->applicationIconPixmap->mask) { - hints->flags |= IconMaskHint; - hints->icon_mask = scr->applicationIconPixmap->mask; - } - } - - XSetWMHints(scr->display, leader, hints); - - XFree(hints); + hints->icon_pixmap = scr->applicationIconPixmap->pixmap; + if (scr->applicationIconPixmap->mask) { + hints->flags |= IconMaskHint; + hints->icon_mask = scr->applicationIconPixmap->mask; + } + } + + XSetWMHints(scr->display, leader, hints); + + XFree(hints); } scr->groupLeader = leader; } diff --git a/WINGs/wballoon.c b/WINGs/wballoon.c index fb8a8247..f6547796 100644 --- a/WINGs/wballoon.c +++ b/WINGs/wballoon.c @@ -19,19 +19,19 @@ typedef struct W_Balloon { WMFont *font; WMHandlerID timer; /* timer for showing balloon */ - + WMHandlerID noDelayTimer; int delay; Window forWindow; /* window for which the balloon - * is being show in the moment */ + * is being show in the moment */ struct { - WMAlignment alignment:2; - unsigned enabled:1; + WMAlignment alignment:2; + unsigned enabled:1; - unsigned noDelay:1; + unsigned noDelay:1; } flags; } Balloon; @@ -63,8 +63,8 @@ W_CreateBalloon(WMScreen *scr) bPtr->view = W_CreateUnmanagedTopView(scr); if (!bPtr->view) { - wfree(bPtr); - return NULL; + wfree(bPtr); + return NULL; } bPtr->view->self = bPtr; @@ -101,15 +101,15 @@ WMSetBalloonTextForView(char *text, WMView *view) WMScreen *scr = view->screen; if (text) { - oldText = WMHashInsert(scr->balloon->table, view, wstrdup(text)); + oldText = WMHashInsert(scr->balloon->table, view, wstrdup(text)); } else { - oldText = WMHashGet(scr->balloon->table, view); + oldText = WMHashGet(scr->balloon->table, view); - WMHashRemove(scr->balloon->table, view); + WMHashRemove(scr->balloon->table, view); } if (oldText) { - wfree(oldText); + wfree(oldText); } } @@ -118,14 +118,14 @@ void WMSetBalloonFont(WMScreen *scr, WMFont *font) { Balloon *bPtr = scr->balloon; - + if (bPtr->font!=NULL) - WMReleaseFont(bPtr->font); + WMReleaseFont(bPtr->font); if (font) - bPtr->font = WMRetainFont(font); + bPtr->font = WMRetainFont(font); else - bPtr->font = NULL; + bPtr->font = NULL; } @@ -135,7 +135,7 @@ WMSetBalloonTextColor(WMScreen *scr, WMColor *color) Balloon *bPtr = scr->balloon; if (bPtr->textColor) - WMReleaseColor(bPtr->textColor); + WMReleaseColor(bPtr->textColor); bPtr->textColor = WMRetainColor(color); } @@ -173,17 +173,17 @@ W_BalloonHandleLeaveView(WMView *view) Balloon *bPtr = view->screen->balloon; if (bPtr->forWindow == view->window) { - if (bPtr->view->flags.mapped) { - W_UnmapView(bPtr->view); - bPtr->noDelayTimer = WMAddTimerHandler(NO_DELAY_DELAY, - clearNoDelay, bPtr); - } - if (bPtr->timer) - WMDeleteTimerHandler(bPtr->timer); + if (bPtr->view->flags.mapped) { + W_UnmapView(bPtr->view); + bPtr->noDelayTimer = WMAddTimerHandler(NO_DELAY_DELAY, + clearNoDelay, bPtr); + } + if (bPtr->timer) + WMDeleteTimerHandler(bPtr->timer); - bPtr->timer = NULL; + bPtr->timer = NULL; - bPtr->forWindow = None; + bPtr->forWindow = None; } } @@ -191,7 +191,7 @@ W_BalloonHandleLeaveView(WMView *view) /* * botar balao perto do cursor * so mapear balao se o mouse ficar parado pelo delay - * + * */ static void @@ -207,13 +207,13 @@ showBalloon(void *data) text = WMHashGet(bPtr->table, view); if (!text) - return; + return; XTranslateCoordinates(view->screen->display, view->window, - view->screen->rootWin, 0, 0, &x, &y, &foo); + view->screen->rootWin, 0, 0, &x, &y, &foo); if (!bPtr->view->flags.realized) - W_RealizeView(bPtr->view); + W_RealizeView(bPtr->view); showText(bPtr, x, y, view->size.width, view->size.height, text); @@ -229,32 +229,32 @@ W_BalloonHandleEnterView(WMView *view) char *text; if (!bPtr->flags.enabled) - return; + return; text = WMHashGet(bPtr->table, view); if (!text) { - if (bPtr->view->flags.realized) - W_UnmapView(bPtr->view); + if (bPtr->view->flags.realized) + W_UnmapView(bPtr->view); - return; + return; } if (bPtr->timer) - WMDeleteTimerHandler(bPtr->timer); + WMDeleteTimerHandler(bPtr->timer); bPtr->timer = NULL; if (bPtr->noDelayTimer) - WMDeleteTimerHandler(bPtr->noDelayTimer); + WMDeleteTimerHandler(bPtr->noDelayTimer); bPtr->noDelayTimer = NULL; bPtr->forWindow = view->window; if (bPtr->flags.noDelay) { - bPtr->timer = NULL; + bPtr->timer = NULL; - showBalloon(view); + showBalloon(view); } else { - bPtr->timer = WMAddTimerHandler(bPtr->delay, showBalloon, view); + bPtr->timer = WMAddTimerHandler(bPtr->delay, showBalloon, view); } } @@ -311,7 +311,7 @@ drawBalloon(WMScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w, if (side & BOTTOM) { pt[0].y = y+h-1; - pt[1].y = y+h-1+SPACE; + pt[1].y = y+h-1+SPACE; pt[2].y = y+h-1; ipt[0].y = pt[0].y-1; ipt[1].y = pt[1].y-1; @@ -319,7 +319,7 @@ drawBalloon(WMScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w, } else { pt[0].y = y; pt[1].y = y-SPACE; - pt[2].y = y; + pt[2].y = y; ipt[0].y = pt[0].y+1; ipt[1].y = pt[1].y+1; ipt[2].y = pt[2].y+1; @@ -329,15 +329,15 @@ drawBalloon(WMScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w, w1 = WMAX(h, 21); if (side & RIGHT) { - pt[0].x = x+w-w1+2*w1/16; + pt[0].x = x+w-w1+2*w1/16; pt[1].x = x+w-w1+11*w1/16; pt[2].x = x+w-w1+7*w1/16; - ipt[0].x = x+1+w-w1+2*(w1-1)/16; + ipt[0].x = x+1+w-w1+2*(w1-1)/16; ipt[1].x = x+1+w-w1+11*(w1-1)/16; ipt[2].x = x+1+w-w1+7*(w1-1)/16; /*ipt[0].x = pt[0].x+1; - ipt[1].x = pt[1].x; - ipt[2].x = pt[2].x;*/ + ipt[1].x = pt[1].x; + ipt[2].x = pt[2].x;*/ } else { pt[0].x = x+w1-2*w1/16; pt[1].x = x+w1-11*w1/16; @@ -346,8 +346,8 @@ drawBalloon(WMScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w, ipt[1].x = x-1+w1-11*(w1-1)/16; ipt[2].x = x-1+w1-7*(w1-1)/16; /*ipt[0].x = pt[0].x-1; - ipt[1].x = pt[1].x; - ipt[2].x = pt[2].x;*/ + ipt[1].x = pt[1].x; + ipt[2].x = pt[2].x;*/ } XFillPolygon(dpy, bitmap, bgc, pt, 3, Convex, CoordModeOrigin); @@ -380,7 +380,7 @@ makePixmap(WMScreen *scr, int width, int height, int side, Pixmap *mask) bitmap = XCreatePixmap(dpy, scr->rootWin, width+SPACE, height+SPACE, 1); - XSetForeground(dpy, scr->monoGC, 0); + XSetForeground(dpy, scr->monoGC, 0); XFillRectangle(dpy, bitmap, scr->monoGC, 0, 0, width+SPACE, height+SPACE); pixmap = XCreatePixmap(dpy, scr->rootWin, width+SPACE, height+SPACE, @@ -390,9 +390,9 @@ makePixmap(WMScreen *scr, int width, int height, int side, Pixmap *mask) height+SPACE); if (side & BOTTOM) { - y = 0; + y = 0; } else { - y = SPACE; + y = SPACE; } x = 0; @@ -422,62 +422,62 @@ showText(Balloon *bPtr, int x, int y, int w, int h, char *text) int bx, by; { - int w; - char *ptr, *ptr2; - - ptr2 = ptr = text; - width = 0; - while (ptr && ptr2) { - ptr2 = strchr(ptr, '\n'); - if (ptr2) { - w = WMWidthOfString(font, ptr, ptr2 - ptr); - } else { - w = WMWidthOfString(font, ptr, strlen(ptr)); - } - if (w > width) - width = w; - ptr = ptr2 + 1; - } + int w; + char *ptr, *ptr2; + + ptr2 = ptr = text; + width = 0; + while (ptr && ptr2) { + ptr2 = strchr(ptr, '\n'); + if (ptr2) { + w = WMWidthOfString(font, ptr, ptr2 - ptr); + } else { + w = WMWidthOfString(font, ptr, strlen(ptr)); + } + if (w > width) + width = w; + ptr = ptr2 + 1; + } } - + width += 16; textHeight = W_GetTextHeight(font, text, width, False); - + height = textHeight + 4; - + if (height < 16) - height = 16; + height = 16; if (width < height) - width = height; + width = height; if (x + width > scr->rootView->size.width) { - side = RIGHT; - bx = x - width + w/2; - if (bx < 0) - bx = 0; + side = RIGHT; + bx = x - width + w/2; + if (bx < 0) + bx = 0; } else { - side = LEFT; - bx = x + w/2; + side = LEFT; + bx = x + w/2; } if (bx + width > scr->rootView->size.width) - bx = scr->rootView->size.width - width; + bx = scr->rootView->size.width - width; if (y - (height + SPACE) < 0) { - side |= TOP; - by = y+h-1; - ty = SPACE; + side |= TOP; + by = y+h-1; + ty = SPACE; } else { - side |= BOTTOM; - by = y - (height + SPACE); - ty = 0; + side |= BOTTOM; + by = y - (height + SPACE); + ty = 0; } pixmap = makePixmap(scr, width, height, side, &mask); W_PaintText(bPtr->view, pixmap, font, 8, ty + (height - textHeight)/2, - width, bPtr->flags.alignment, - bPtr->textColor ? bPtr->textColor : scr->black, - False, text, strlen(text)); + width, bPtr->flags.alignment, + bPtr->textColor ? bPtr->textColor : scr->black, + False, text, strlen(text)); XSetWindowBackgroundPixmap(dpy, bPtr->view->window, pixmap); @@ -487,7 +487,7 @@ showText(Balloon *bPtr, int x, int y, int w, int h, char *text) #ifdef SHAPE XShapeCombineMask(dpy, bPtr->view->window, ShapeBounding, 0, 0, mask, - ShapeSet); + ShapeSet); #endif XFreePixmap(dpy, mask); @@ -502,10 +502,10 @@ handleEvents(XEvent *event, void *data) { Balloon *bPtr = (Balloon*)data; - switch (event->type) { - case DestroyNotify: - destroyBalloon(bPtr); - break; + switch (event->type) { + case DestroyNotify: + destroyBalloon(bPtr); + break; } } @@ -519,15 +519,16 @@ destroyBalloon(Balloon *bPtr) e = WMEnumerateHashTable(bPtr->table); while ((str = WMNextHashEnumeratorItem(&e))) { - wfree(str); + wfree(str); } WMFreeHashTable(bPtr->table); if (bPtr->textColor) - WMReleaseColor(bPtr->textColor); + WMReleaseColor(bPtr->textColor); if (bPtr->font) - WMReleaseFont(bPtr->font); + WMReleaseFont(bPtr->font); wfree(bPtr); } + diff --git a/WINGs/wbox.c b/WINGs/wbox.c index 00742a3c..f7aa2eef 100644 --- a/WINGs/wbox.c +++ b/WINGs/wbox.c @@ -60,8 +60,8 @@ WMCreateBox(WMWidget *parent) bPtr->view = W_CreateView(W_VIEW(parent)); if (!bPtr->view) { - wfree(bPtr); - return NULL; + wfree(bPtr); + return NULL; } bPtr->view->self = bPtr; @@ -70,7 +70,7 @@ WMCreateBox(WMWidget *parent) bPtr->subviews = WMCreateArrayWithDestructor(2, wfree); WMCreateEventHandler(bPtr->view, StructureNotifyMask, - handleEvents, bPtr); + handleEvents, bPtr); WMResizeWidget(bPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT); @@ -149,19 +149,19 @@ rearrange(WMBox *box) eData.expands = 0; if (box->horizontal) { - eData.ye = box->borderWidth; - eData.xe = WMWidgetWidth(box) - box->borderWidth; - eData.h = WMWidgetHeight(box) - 2 * box->borderWidth; - eData.total = WMWidgetWidth(box) - 2 * box->borderWidth; + eData.ye = box->borderWidth; + eData.xe = WMWidgetWidth(box) - box->borderWidth; + eData.h = WMWidgetHeight(box) - 2 * box->borderWidth; + eData.total = WMWidgetWidth(box) - 2 * box->borderWidth; } else { - eData.xe = box->borderWidth; - eData.ye = WMWidgetHeight(box) - box->borderWidth; - eData.w = WMWidgetWidth(box) - 2 * box->borderWidth; - eData.total = WMWidgetHeight(box) - 2 * box->borderWidth; + eData.xe = box->borderWidth; + eData.ye = WMWidgetHeight(box) - box->borderWidth; + eData.w = WMWidgetWidth(box) - 2 * box->borderWidth; + eData.total = WMWidgetHeight(box) - 2 * box->borderWidth; } if (eData.w <= 0 || eData.h <= 0 || eData.total <= 0) { - return; + return; } WMMapArray(box->subviews, computeExpansion, &eData); @@ -181,7 +181,7 @@ WMSetBoxBorderWidth(WMBox *box, unsigned width) void WMAddBoxSubview(WMBox *bPtr, WMView *view, Bool expand, Bool fill, - int minSize, int maxSize, int space) + int minSize, int maxSize, int space) { SubviewItem *subView; @@ -203,7 +203,7 @@ WMAddBoxSubview(WMBox *bPtr, WMView *view, Bool expand, Bool fill, void WMAddBoxSubviewAtEnd(WMBox *bPtr, WMView *view, Bool expand, Bool fill, - int minSize, int maxSize, int space) + int minSize, int maxSize, int space) { SubviewItem *subView; @@ -272,14 +272,14 @@ handleEvents(XEvent *event, void *data) CHECK_CLASS(data, WC_Box); - switch (event->type) { - case DestroyNotify: - destroyBox(bPtr); - break; - - case ConfigureNotify: - rearrange(bPtr); - break; + switch (event->type) { + case DestroyNotify: + destroyBox(bPtr); + break; + + case ConfigureNotify: + rearrange(bPtr); + break; } } diff --git a/WINGs/wbrowser.c b/WINGs/wbrowser.c index b0522899..9b22abd8 100644 --- a/WINGs/wbrowser.c +++ b/WINGs/wbrowser.c @@ -40,14 +40,14 @@ typedef struct W_Browser { char *pathSeparator; struct { - unsigned int isTitled:1; + unsigned int isTitled:1; unsigned int allowMultipleSelection:1; unsigned int allowEmptySelection:1; - unsigned int hasScroller:1; + unsigned int hasScroller:1; - /* */ - unsigned int loaded:1; - unsigned int loadingColumn:1; + /* */ + unsigned int loaded:1; + unsigned int loadingColumn:1; } flags; } Browser; @@ -68,7 +68,7 @@ typedef struct W_Browser { #define COLUMN_IS_VISIBLE(b, c) ((c) >= (b)->firstVisibleColumn \ - && (c) < (b)->firstVisibleColumn + (b)->maxVisibleColumns) + && (c) < (b)->firstVisibleColumn + (b)->maxVisibleColumns) static void handleEvents(XEvent *event, void *data); @@ -79,7 +79,7 @@ static void setupScroller(WMBrowser *bPtr); static void scrollToColumn(WMBrowser *bPtr, int column, Bool updateScroller); static void paintItem(WMList *lPtr, int index, Drawable d, char *text, - int state, WMRect *rect); + int state, WMRect *rect); static void loadColumn(WMBrowser *bPtr, int column); @@ -88,15 +88,15 @@ static void removeColumn(WMBrowser *bPtr, int column); static char* createTruncatedString(WMFont *font, char *text, int *textLen, int width); -static void willResizeBrowser(W_ViewDelegate*, WMView*, - unsigned int*, unsigned int*); +static void willResizeBrowser(W_ViewDelegate*, WMView*, + unsigned int*, unsigned int*); W_ViewDelegate _BrowserViewDelegate = { NULL, - NULL, - NULL, - NULL, - willResizeBrowser + NULL, + NULL, + NULL, + willResizeBrowser }; @@ -116,15 +116,15 @@ WMCreateBrowser(WMWidget *parent) bPtr->view = W_CreateView(W_VIEW(parent)); if (!bPtr->view) { - wfree(bPtr); - return NULL; + wfree(bPtr); + return NULL; } bPtr->view->self = bPtr; bPtr->view->delegate = &_BrowserViewDelegate; WMCreateEventHandler(bPtr->view, ExposureMask|StructureNotifyMask - |ClientMessageMask, handleEvents, bPtr); + |ClientMessageMask, handleEvents, bPtr); /* default configuration */ bPtr->flags.hasScroller = DEFAULT_HAS_SCROLLER; @@ -138,10 +138,10 @@ WMCreateBrowser(WMWidget *parent) bPtr->pathSeparator = wstrdup(DEFAULT_SEPARATOR); if (bPtr->flags.hasScroller) - setupScroller(bPtr); + setupScroller(bPtr); for (i=0; imaxVisibleColumns; i++) { - WMAddBrowserColumn(bPtr); + WMAddBrowserColumn(bPtr); } bPtr->usedColumnCount = 0; @@ -158,7 +158,7 @@ WMSetBrowserAllowMultipleSelection(WMBrowser *bPtr, Bool flag) bPtr->flags.allowMultipleSelection = ((flag==0) ? 0 : 1); for (i=0; icolumnCount; i++) { - WMSetListAllowMultipleSelection(bPtr->columns[i], flag); + WMSetListAllowMultipleSelection(bPtr->columns[i], flag); } } @@ -170,7 +170,7 @@ WMSetBrowserAllowEmptySelection(WMBrowser *bPtr, Bool flag) bPtr->flags.allowEmptySelection = ((flag==0) ? 0 : 1); for (i=0; icolumnCount; i++) { - WMSetListAllowEmptySelection(bPtr->columns[i], flag); + WMSetListAllowEmptySelection(bPtr->columns[i], flag); } } @@ -193,49 +193,49 @@ WMSetBrowserMaxVisibleColumns(WMBrowser *bPtr, int columns) columns = (columns < MIN_VISIBLE_COLUMNS) ? MIN_VISIBLE_COLUMNS : columns; columns = (columns > MAX_VISIBLE_COLUMNS) ? MAX_VISIBLE_COLUMNS : columns; if (columns == bPtr->maxVisibleColumns) { - return; + return; } curMaxVisibleColumns = bPtr->maxVisibleColumns; bPtr->maxVisibleColumns = columns; /* browser not loaded */ if (!bPtr->flags.loaded) { - if ((columns > curMaxVisibleColumns) && (columns > bPtr->columnCount)) { - int i = columns - bPtr->columnCount; - bPtr->usedColumnCount = bPtr->columnCount; - while (i--) { - WMAddBrowserColumn(bPtr); - } - bPtr->usedColumnCount = 0; - } - /* browser loaded and columns > curMaxVisibleColumns */ + if ((columns > curMaxVisibleColumns) && (columns > bPtr->columnCount)) { + int i = columns - bPtr->columnCount; + bPtr->usedColumnCount = bPtr->columnCount; + while (i--) { + WMAddBrowserColumn(bPtr); + } + bPtr->usedColumnCount = 0; + } + /* browser loaded and columns > curMaxVisibleColumns */ } else if (columns > curMaxVisibleColumns) { - if (bPtr->usedColumnCount > columns) { - newFirstVisibleColumn = bPtr->usedColumnCount - columns; - } - if (newFirstVisibleColumn > bPtr->firstVisibleColumn) { - newFirstVisibleColumn = bPtr->firstVisibleColumn; - } - if (columns > bPtr->columnCount) { - int i = columns - bPtr->columnCount; - int curUsedColumnCount = bPtr->usedColumnCount; - bPtr->usedColumnCount = bPtr->columnCount; - while (i--) { - WMAddBrowserColumn(bPtr); - } - bPtr->usedColumnCount = curUsedColumnCount; - } - /* browser loaded and columns < curMaxVisibleColumns */ + if (bPtr->usedColumnCount > columns) { + newFirstVisibleColumn = bPtr->usedColumnCount - columns; + } + if (newFirstVisibleColumn > bPtr->firstVisibleColumn) { + newFirstVisibleColumn = bPtr->firstVisibleColumn; + } + if (columns > bPtr->columnCount) { + int i = columns - bPtr->columnCount; + int curUsedColumnCount = bPtr->usedColumnCount; + bPtr->usedColumnCount = bPtr->columnCount; + while (i--) { + WMAddBrowserColumn(bPtr); + } + bPtr->usedColumnCount = curUsedColumnCount; + } + /* browser loaded and columns < curMaxVisibleColumns */ } else { - newFirstVisibleColumn = bPtr->firstVisibleColumn; - if (newFirstVisibleColumn + columns >= bPtr->usedColumnCount) { - removeColumn(bPtr, newFirstVisibleColumn + columns); - } + newFirstVisibleColumn = bPtr->firstVisibleColumn; + if (newFirstVisibleColumn + columns >= bPtr->usedColumnCount) { + removeColumn(bPtr, newFirstVisibleColumn + columns); + } } WMResizeWidget(bPtr, bPtr->view->size.width, bPtr->view->size.height); if (bPtr->flags.loaded) { - XClearArea(bPtr->view->screen->display, bPtr->view->window, 0, 0, - bPtr->view->size.width, bPtr->titleHeight, False); - scrollToColumn (bPtr, newFirstVisibleColumn, True); + XClearArea(bPtr->view->screen->display, bPtr->view->window, 0, 0, + bPtr->view->size.width, bPtr->titleHeight, False); + scrollToColumn (bPtr, newFirstVisibleColumn, True); } } @@ -250,7 +250,7 @@ void WMSetBrowserPathSeparator(WMBrowser *bPtr, char *separator) { if (bPtr->pathSeparator) - wfree(bPtr->pathSeparator); + wfree(bPtr->pathSeparator); bPtr->pathSeparator = wstrdup(separator); } @@ -265,30 +265,30 @@ drawTitleOfColumn(WMBrowser *bPtr, int column) x=(column-bPtr->firstVisibleColumn)*(bPtr->columnSize.width+COLUMN_SPACING); XFillRectangle(scr->display, bPtr->view->window, WMColorGC(scr->darkGray), x, 0, - bPtr->columnSize.width, bPtr->titleHeight); + bPtr->columnSize.width, bPtr->titleHeight); W_DrawRelief(scr, bPtr->view->window, x, 0, - bPtr->columnSize.width, bPtr->titleHeight, WRSunken); + bPtr->columnSize.width, bPtr->titleHeight, WRSunken); if (column < bPtr->usedColumnCount && bPtr->titles[column]) { - int titleLen = strlen(bPtr->titles[column]); - int widthC = bPtr->columnSize.width-8; - - if (WMWidthOfString(scr->boldFont, bPtr->titles[column], titleLen) - > widthC) { - char *titleBuf = createTruncatedString(scr->boldFont, - bPtr->titles[column], - &titleLen, widthC); - W_PaintText(bPtr->view, bPtr->view->window, scr->boldFont, x, - (bPtr->titleHeight-WMFontHeight(scr->boldFont))/2, - bPtr->columnSize.width, WACenter, scr->white, - False, titleBuf, titleLen); - wfree (titleBuf); - } else { - W_PaintText(bPtr->view, bPtr->view->window, scr->boldFont, x, - (bPtr->titleHeight-WMFontHeight(scr->boldFont))/2, - bPtr->columnSize.width, WACenter, scr->white, - False, bPtr->titles[column], titleLen); - } + int titleLen = strlen(bPtr->titles[column]); + int widthC = bPtr->columnSize.width-8; + + if (WMWidthOfString(scr->boldFont, bPtr->titles[column], titleLen) + > widthC) { + char *titleBuf = createTruncatedString(scr->boldFont, + bPtr->titles[column], + &titleLen, widthC); + W_PaintText(bPtr->view, bPtr->view->window, scr->boldFont, x, + (bPtr->titleHeight-WMFontHeight(scr->boldFont))/2, + bPtr->columnSize.width, WACenter, scr->white, + False, titleBuf, titleLen); + wfree (titleBuf); + } else { + W_PaintText(bPtr->view, bPtr->view->window, scr->boldFont, x, + (bPtr->titleHeight-WMFontHeight(scr->boldFont))/2, + bPtr->columnSize.width, WACenter, scr->white, + False, bPtr->titles[column], titleLen); + } } } @@ -297,7 +297,7 @@ WMList* WMGetBrowserListInColumn(WMBrowser *bPtr, int column) { if (column < 0 || column >= bPtr->usedColumnCount) - return NULL; + return NULL; return bPtr->columns[column]; } @@ -328,37 +328,37 @@ removeColumn(WMBrowser *bPtr, int column) column = (column < 0) ? 0 : column; if (column >= bPtr->columnCount) { - return; + return; } if (column < bPtr->maxVisibleColumns) { - clearEnd = bPtr->maxVisibleColumns; - destroyEnd = bPtr->columnCount; - bPtr->columnCount = bPtr->maxVisibleColumns; + clearEnd = bPtr->maxVisibleColumns; + destroyEnd = bPtr->columnCount; + bPtr->columnCount = bPtr->maxVisibleColumns; } else { - clearEnd = column; - destroyEnd = bPtr->columnCount; - bPtr->columnCount = column; + clearEnd = column; + destroyEnd = bPtr->columnCount; + bPtr->columnCount = column; } if (column < bPtr->usedColumnCount) { - bPtr->usedColumnCount = column; + bPtr->usedColumnCount = column; } for (i=column; i < clearEnd; i++) { - if (bPtr->titles[i]) { - wfree(bPtr->titles[i]); - bPtr->titles[i] = NULL; - } - WMClearList(bPtr->columns[i]); + if (bPtr->titles[i]) { + wfree(bPtr->titles[i]); + bPtr->titles[i] = NULL; + } + WMClearList(bPtr->columns[i]); } for (;i < destroyEnd; i++) { - if (bPtr->titles[i]) { - wfree(bPtr->titles[i]); - bPtr->titles[i] = NULL; - } + if (bPtr->titles[i]) { + wfree(bPtr->titles[i]); + bPtr->titles[i] = NULL; + } WMRemoveNotificationObserverWithName(bPtr, WMListSelectionDidChangeNotification, - bPtr->columns[i]); - WMDestroyWidget(bPtr->columns[i]); - bPtr->columns[i] = NULL; + bPtr->columns[i]); + WMDestroyWidget(bPtr->columns[i]); + bPtr->columns[i] = NULL; } clist = wmalloc(sizeof(WMList*) * (bPtr->columnCount)); tlist = wmalloc(sizeof(char*) * (bPtr->columnCount)); @@ -375,7 +375,7 @@ WMListItem* WMGetBrowserSelectedItemInColumn(WMBrowser *bPtr, int column) { if ((column < 0) || (column >= bPtr->usedColumnCount)) - return NULL; + return NULL; return WMGetListSelectedItem(bPtr->columns[column]); } @@ -393,9 +393,9 @@ int WMGetBrowserSelectedRowInColumn(WMBrowser *bPtr, int column) { if (column >= 0 && column < bPtr->columnCount) { - return WMGetListSelectedItemRow(bPtr->columns[column]); + return WMGetListSelectedItemRow(bPtr->columns[column]); } else { - return -1; + return -1; } } @@ -407,12 +407,12 @@ WMSetBrowserColumnTitle(WMBrowser *bPtr, int column, char *title) assert(column < bPtr->usedColumnCount); if (bPtr->titles[column]) - wfree(bPtr->titles[column]); + wfree(bPtr->titles[column]); bPtr->titles[column] = wstrdup(title); if (COLUMN_IS_VISIBLE(bPtr, column) && bPtr->flags.isTitled) { - drawTitleOfColumn(bPtr, column); + drawTitleOfColumn(bPtr, column); } } @@ -426,34 +426,34 @@ WMSetBrowserTitled(WMBrowser *bPtr, Bool flag) flag = ((flag==0) ? 0 : 1); if (bPtr->flags.isTitled == flag) - return; + return; columnX = 0; if (!bPtr->flags.isTitled) { - columnY = TITLE_SPACING + bPtr->titleHeight; + columnY = TITLE_SPACING + bPtr->titleHeight; - bPtr->columnSize.height -= columnY; + bPtr->columnSize.height -= columnY; - for (i=0; icolumnCount; i++) { - WMResizeWidget(bPtr->columns[i], bPtr->columnSize.width, - bPtr->columnSize.height); + for (i=0; icolumnCount; i++) { + WMResizeWidget(bPtr->columns[i], bPtr->columnSize.width, + bPtr->columnSize.height); - columnX = WMWidgetView(bPtr->columns[i])->pos.x; + columnX = WMWidgetView(bPtr->columns[i])->pos.x; - WMMoveWidget(bPtr->columns[i], columnX, columnY); - } + WMMoveWidget(bPtr->columns[i], columnX, columnY); + } } else { - bPtr->columnSize.height += TITLE_SPACING + bPtr->titleHeight; + bPtr->columnSize.height += TITLE_SPACING + bPtr->titleHeight; - for (i=0; icolumnCount; i++) { - WMResizeWidget(bPtr->columns[i], bPtr->columnSize.width, - bPtr->columnSize.height); + for (i=0; icolumnCount; i++) { + WMResizeWidget(bPtr->columns[i], bPtr->columnSize.width, + bPtr->columnSize.height); - columnX = WMWidgetView(bPtr->columns[i])->pos.x; + columnX = WMWidgetView(bPtr->columns[i])->pos.x; - WMMoveWidget(bPtr->columns[i], columnX, 0); - } + WMMoveWidget(bPtr->columns[i], columnX, 0); + } } bPtr->flags.isTitled = flag; @@ -478,13 +478,13 @@ WMSortBrowserColumnWithComparer(WMBrowser *bPtr, int column, WMListItem* WMInsertBrowserItem(WMBrowser *bPtr, int column, int row, char *text, - Bool isBranch) + Bool isBranch) { WMListItem *item; if (column < 0 || column >= bPtr->columnCount) - return NULL; - + return NULL; + item = WMInsertListItem(bPtr->columns[column], row, text); item->isBranch = isBranch; @@ -495,8 +495,8 @@ WMInsertBrowserItem(WMBrowser *bPtr, int column, int row, char *text, static void -willResizeBrowser(W_ViewDelegate *self, WMView *view, - unsigned int *width, unsigned int *height) +willResizeBrowser(W_ViewDelegate *self, WMView *view, + unsigned int *width, unsigned int *height) { WMBrowser *bPtr = (WMBrowser*)view->self; int cols = bPtr->maxVisibleColumns; @@ -510,31 +510,31 @@ willResizeBrowser(W_ViewDelegate *self, WMView *view, bPtr->columnSize.height = *height; if (bPtr->flags.isTitled) { - colY = TITLE_SPACING + bPtr->titleHeight; - bPtr->columnSize.height -= colY; + colY = TITLE_SPACING + bPtr->titleHeight; + bPtr->columnSize.height -= colY; } else { - colY = 0; + colY = 0; } if (bPtr->flags.hasScroller) { - bPtr->columnSize.height -= SCROLLER_WIDTH + 4; + bPtr->columnSize.height -= SCROLLER_WIDTH + 4; - if (bPtr->scroller) { - WMResizeWidget(bPtr->scroller, *width-2, 1); - WMMoveWidget(bPtr->scroller, 1, *height-SCROLLER_WIDTH-1); - } + if (bPtr->scroller) { + WMResizeWidget(bPtr->scroller, *width-2, 1); + WMMoveWidget(bPtr->scroller, 1, *height-SCROLLER_WIDTH-1); + } } colX = 0; for (i = 0; i < bPtr->columnCount; i++) { - WMResizeWidget(bPtr->columns[i], bPtr->columnSize.width, - bPtr->columnSize.height); + WMResizeWidget(bPtr->columns[i], bPtr->columnSize.width, + bPtr->columnSize.height); - WMMoveWidget(bPtr->columns[i], colX, colY); + WMMoveWidget(bPtr->columns[i], colX, colY); - if (COLUMN_IS_VISIBLE(bPtr, i)) { - colX += bPtr->columnSize.width+COLUMN_SPACING; - } + if (COLUMN_IS_VISIBLE(bPtr, i)) { + colX += bPtr->columnSize.width+COLUMN_SPACING; + } } } @@ -559,27 +559,27 @@ paintItem(WMList *lPtr, int index, Drawable d, char *text, int state, WMRect *re if (text) { /* Avoid overlaping... */ - int widthC = (state & WLDSIsBranch) ? width-20 : width-8; - if (WMWidthOfString(font, text, textLen) > widthC) { - char *textBuf = createTruncatedString(font, text, &textLen, widthC); + int widthC = (state & WLDSIsBranch) ? width-20 : width-8; + if (WMWidthOfString(font, text, textLen) > widthC) { + char *textBuf = createTruncatedString(font, text, &textLen, widthC); W_PaintText(view, d, font, x+4, y, widthC, - WALeft, scr->black, False, textBuf, textLen); - wfree(textBuf); - } else { - W_PaintText(view, d, font, x+4, y, widthC, - WALeft, scr->black, False, text, textLen); - } + WALeft, scr->black, False, textBuf, textLen); + wfree(textBuf); + } else { + W_PaintText(view, d, font, x+4, y, widthC, + WALeft, scr->black, False, text, textLen); + } } if (state & WLDSIsBranch) { WMColor *lineColor = ((state & WLDSSelected) ? scr->gray : scr->white); - XDrawLine(display, d, WMColorGC(scr->darkGray), x+width-11, y+3, - x+width-6, y+height/2); + XDrawLine(display, d, WMColorGC(scr->darkGray), x+width-11, y+3, + x+width-6, y+height/2); XDrawLine(display, d, WMColorGC(lineColor), x+width-11, y+height-5, x+width-6, y+height/2); - XDrawLine(display, d, WMColorGC(scr->black), x+width-12, y+3, - x+width-12, y+height-5); + XDrawLine(display, d, WMColorGC(scr->black), x+width-12, y+3, + x+width-12, y+height-5); } } @@ -594,64 +594,64 @@ scrollCallback(WMWidget *scroller, void *self) switch (WMGetScrollerHitPart(sPtr)) { case WSDecrementLine: - if (bPtr->firstVisibleColumn > 0) { - scrollToColumn(bPtr, bPtr->firstVisibleColumn-1, True); - } - break; + if (bPtr->firstVisibleColumn > 0) { + scrollToColumn(bPtr, bPtr->firstVisibleColumn-1, True); + } + break; case WSDecrementPage: case WSDecrementWheel: if (bPtr->firstVisibleColumn > 0) { - newFirst = bPtr->firstVisibleColumn - bPtr->maxVisibleColumns; + newFirst = bPtr->firstVisibleColumn - bPtr->maxVisibleColumns; - scrollToColumn(bPtr, newFirst, True); - } - break; + scrollToColumn(bPtr, newFirst, True); + } + break; case WSIncrementLine: - if (LAST_VISIBLE_COLUMN < bPtr->usedColumnCount) { - scrollToColumn(bPtr, bPtr->firstVisibleColumn+1, True); - } - break; + if (LAST_VISIBLE_COLUMN < bPtr->usedColumnCount) { + scrollToColumn(bPtr, bPtr->firstVisibleColumn+1, True); + } + break; case WSIncrementPage: case WSIncrementWheel: - if (LAST_VISIBLE_COLUMN < bPtr->usedColumnCount) { - newFirst = bPtr->firstVisibleColumn + bPtr->maxVisibleColumns; + if (LAST_VISIBLE_COLUMN < bPtr->usedColumnCount) { + newFirst = bPtr->firstVisibleColumn + bPtr->maxVisibleColumns; - if (newFirst+bPtr->maxVisibleColumns >= bPtr->columnCount) - newFirst = bPtr->columnCount - bPtr->maxVisibleColumns; + if (newFirst+bPtr->maxVisibleColumns >= bPtr->columnCount) + newFirst = bPtr->columnCount - bPtr->maxVisibleColumns; - scrollToColumn(bPtr, newFirst, True); - } - break; + scrollToColumn(bPtr, newFirst, True); + } + break; case WSKnob: - { - double floatValue; - double value = bPtr->columnCount - bPtr->maxVisibleColumns; + { + double floatValue; + double value = bPtr->columnCount - bPtr->maxVisibleColumns; - floatValue = WMGetScrollerValue(bPtr->scroller); + floatValue = WMGetScrollerValue(bPtr->scroller); - floatValue = (floatValue*value)/value; + floatValue = (floatValue*value)/value; - newFirst = rint(floatValue*(float)(bPtr->columnCount - bPtr->maxVisibleColumns)); + newFirst = rint(floatValue*(float)(bPtr->columnCount - bPtr->maxVisibleColumns)); - if (bPtr->firstVisibleColumn != newFirst) - scrollToColumn(bPtr, newFirst, False); -/* else - WMSetScrollerParameters(bPtr->scroller, floatValue, - bPtr->maxVisibleColumns/(float)bPtr->columnCount); - */ + if (bPtr->firstVisibleColumn != newFirst) + scrollToColumn(bPtr, newFirst, False); + /*else + WMSetScrollerParameters(bPtr->scroller, floatValue, + bPtr->maxVisibleColumns/(float)bPtr->columnCount); + */ - } - break; + } + break; case WSKnobSlot: case WSNoPart: - /* do nothing */ - break; + /* do nothing */ + break; } #undef LAST_VISIBLE_COLUMN } @@ -710,7 +710,7 @@ WMSetBrowserPath(WMBrowser *bPtr, char *path) /* WMLoadBrowserColumnZero must be call first */ if (!bPtr->flags.loaded) { - return False; + return False; } removeColumn(bPtr, 1); @@ -722,46 +722,46 @@ WMSetBrowserPath(WMBrowser *bPtr, char *path) str = wstrdup(path); tmp = strtok(str, bPtr->pathSeparator); while (tmp) { - /* select it in the column */ + /* select it in the column */ item = WMFindRowOfListItemWithTitle(bPtr->columns[i], tmp); - if (item<0) { + if (item<0) { retPtr = &path[(int)(tmp - str)]; - break; - } - WMSelectListItem(bPtr->columns[i], item); - WMSetListPosition(bPtr->columns[i], item); + break; + } + WMSelectListItem(bPtr->columns[i], item); + WMSetListPosition(bPtr->columns[i], item); - listItem = WMGetListItem(bPtr->columns[i], item); - if (!listItem || !listItem->isBranch) { - break; - } + listItem = WMGetListItem(bPtr->columns[i], item); + if (!listItem || !listItem->isBranch) { + break; + } - /* load next column */ - WMAddBrowserColumn(bPtr); + /* load next column */ + WMAddBrowserColumn(bPtr); - loadColumn(bPtr, i+1); + loadColumn(bPtr, i+1); - tmp = strtok(NULL, bPtr->pathSeparator); + tmp = strtok(NULL, bPtr->pathSeparator); - i++; + i++; } wfree(str); for (i = bPtr->usedColumnCount - 1; - (i > -1) && !WMGetListSelectedItem(bPtr->columns[i]); - i--); + (i > -1) && !WMGetListSelectedItem(bPtr->columns[i]); + i--); bPtr->selectedColumn = i; if (bPtr->columnCount < bPtr->maxVisibleColumns) { - int i = bPtr->maxVisibleColumns - bPtr->columnCount; - int curUsedColumnCount = bPtr->usedColumnCount; - bPtr->usedColumnCount = bPtr->columnCount; - while (i--) { - WMAddBrowserColumn(bPtr); - } - bPtr->usedColumnCount = curUsedColumnCount; + int i = bPtr->maxVisibleColumns - bPtr->columnCount; + int curUsedColumnCount = bPtr->usedColumnCount; + bPtr->usedColumnCount = bPtr->columnCount; + while (i--) { + WMAddBrowserColumn(bPtr); + } + bPtr->usedColumnCount = curUsedColumnCount; } scrollToColumn(bPtr, bPtr->columnCount - bPtr->maxVisibleColumns, True); @@ -785,7 +785,7 @@ WMGetBrowserPathToColumn(WMBrowser *bPtr, int column) WMListItem *item; if (column >= bPtr->usedColumnCount) - column = bPtr->usedColumnCount-1; + column = bPtr->usedColumnCount-1; if (column < 0) { return wstrdup(bPtr->pathSeparator); @@ -794,10 +794,10 @@ WMGetBrowserPathToColumn(WMBrowser *bPtr, int column) /* calculate size of buffer */ size = 0; for (i = 0; i <= column; i++) { - item = WMGetListSelectedItem(bPtr->columns[i]); - if (!item) - break; - size += strlen(item->text); + item = WMGetListSelectedItem(bPtr->columns[i]); + if (!item) + break; + size += strlen(item->text); } /* get the path */ @@ -805,11 +805,11 @@ WMGetBrowserPathToColumn(WMBrowser *bPtr, int column) /* ignore first / */ *path = 0; for (i = 0; i <= column; i++) { - strcat(path, bPtr->pathSeparator); - item = WMGetListSelectedItem(bPtr->columns[i]); - if (!item) - break; - strcat(path, item->text); + strcat(path, bPtr->pathSeparator); + item = WMGetListSelectedItem(bPtr->columns[i]); + if (!item) + break; + strcat(path, item->text); } return path; @@ -844,10 +844,10 @@ WMGetBrowserPaths(WMBrowser *bPtr) /* calculate size of buffer */ size = 0; for (i=0; icolumns[i]); - if (!item) - break; - size += strlen(item->text); + item = WMGetListSelectedItem(bPtr->columns[i]); + if (!item) + break; + size += strlen(item->text); } size += (column+1)*strlen(bPtr->pathSeparator)+1; @@ -898,18 +898,18 @@ loadColumn(WMBrowser *bPtr, int column) bPtr->flags.loadingColumn = 1; (*bPtr->delegate->createRowsForColumn)(bPtr->delegate, bPtr, column, - bPtr->columns[column]); + bPtr->columns[column]); bPtr->flags.loadingColumn = 0; if (bPtr->delegate->titleOfColumn) { - char *title; + char *title; - title = (*bPtr->delegate->titleOfColumn)(bPtr->delegate, bPtr, column); + title = (*bPtr->delegate->titleOfColumn)(bPtr->delegate, bPtr, column); - if (bPtr->titles[column]) - wfree(bPtr->titles[column]); + if (bPtr->titles[column]) + wfree(bPtr->titles[column]); - bPtr->titles[column] = wstrdup(title); + bPtr->titles[column] = wstrdup(title); if (COLUMN_IS_VISIBLE(bPtr, column) && bPtr->flags.isTitled) { drawTitleOfColumn(bPtr, column); @@ -924,16 +924,16 @@ paintBrowser(WMBrowser *bPtr) int i; if (!bPtr->view->flags.mapped) - return; + return; W_DrawRelief(bPtr->view->screen, bPtr->view->window, 0, - bPtr->view->size.height-SCROLLER_WIDTH-2, - bPtr->view->size.width, 22, WRSunken); + bPtr->view->size.height-SCROLLER_WIDTH-2, + bPtr->view->size.width, 22, WRSunken); if (bPtr->flags.isTitled) { - for (i=0; imaxVisibleColumns; i++) { - drawTitleOfColumn(bPtr, i+bPtr->firstVisibleColumn); - } + for (i=0; imaxVisibleColumns; i++) { + drawTitleOfColumn(bPtr, i+bPtr->firstVisibleColumn); + } } } @@ -947,13 +947,13 @@ handleEvents(XEvent *event, void *data) switch (event->type) { - case Expose: - paintBrowser(bPtr); - break; + case Expose: + paintBrowser(bPtr); + break; - case DestroyNotify: - destroyBrowser(bPtr); - break; + case DestroyNotify: + destroyBrowser(bPtr); + break; } } @@ -969,50 +969,50 @@ scrollToColumn(WMBrowser *bPtr, int column, Bool updateScroller) if (column != bPtr->firstVisibleColumn) { - notify = 1; + notify = 1; } if (column < 0) - column = 0; + column = 0; if (notify && bPtr->delegate && bPtr->delegate->willScroll) { - (*bPtr->delegate->willScroll)(bPtr->delegate, bPtr); + (*bPtr->delegate->willScroll)(bPtr->delegate, bPtr); } x = 0; bPtr->firstVisibleColumn = column; for (i = 0; i < bPtr->columnCount; i++) { - if (COLUMN_IS_VISIBLE(bPtr, i)) { - WMMoveWidget(bPtr->columns[i], x, - WMWidgetView(bPtr->columns[i])->pos.y); - if (!WMWidgetView(bPtr->columns[i])->flags.realized) - WMRealizeWidget(bPtr->columns[i]); - WMMapWidget(bPtr->columns[i]); - x += bPtr->columnSize.width + COLUMN_SPACING; - } else { - WMUnmapWidget(bPtr->columns[i]); - } + if (COLUMN_IS_VISIBLE(bPtr, i)) { + WMMoveWidget(bPtr->columns[i], x, + WMWidgetView(bPtr->columns[i])->pos.y); + if (!WMWidgetView(bPtr->columns[i])->flags.realized) + WMRealizeWidget(bPtr->columns[i]); + WMMapWidget(bPtr->columns[i]); + x += bPtr->columnSize.width + COLUMN_SPACING; + } else { + WMUnmapWidget(bPtr->columns[i]); + } } /* update the scroller */ if (updateScroller) { - if (bPtr->columnCount > bPtr->maxVisibleColumns) { - float value, proportion; - - value = bPtr->firstVisibleColumn - /(float)(bPtr->columnCount-bPtr->maxVisibleColumns); - proportion = bPtr->maxVisibleColumns/(float)bPtr->columnCount; - WMSetScrollerParameters(bPtr->scroller, value, proportion); - } else { - WMSetScrollerParameters(bPtr->scroller, 0, 1); - } + if (bPtr->columnCount > bPtr->maxVisibleColumns) { + float value, proportion; + + value = bPtr->firstVisibleColumn + /(float)(bPtr->columnCount-bPtr->maxVisibleColumns); + proportion = bPtr->maxVisibleColumns/(float)bPtr->columnCount; + WMSetScrollerParameters(bPtr->scroller, value, proportion); + } else { + WMSetScrollerParameters(bPtr->scroller, 0, 1); + } } if (bPtr->view->flags.mapped) - paintBrowser(bPtr); + paintBrowser(bPtr); if (notify && bPtr->delegate && bPtr->delegate->didScroll) { - (*bPtr->delegate->didScroll)(bPtr->delegate, bPtr); + (*bPtr->delegate->didScroll)(bPtr->delegate, bPtr); } } @@ -1037,7 +1037,7 @@ listCallback(void *self, void *clientData) } assert(icolumnCount); - bPtr->selectedColumn = i; + bPtr->selectedColumn = i; /* columns at right must be cleared */ removeColumn(bPtr, i+1); @@ -1050,14 +1050,14 @@ listCallback(void *self, void *clientData) else i = bPtr->usedColumnCount-bPtr->maxVisibleColumns; scrollToColumn(bPtr, i, True); - if (item && item->isBranch && selNo==1) { + if (item && item->isBranch && selNo==1) { loadColumn(bPtr, bPtr->usedColumnCount-1); - } + } } /* call callback for click */ if (bPtr->action) - (*bPtr->action)(bPtr, bPtr->clientData); + (*bPtr->action)(bPtr, bPtr->clientData); oldItem = item; oldSelNo = selNo; @@ -1073,11 +1073,11 @@ listDoubleCallback(void *self, void *clientData) item = WMGetListSelectedItem(lPtr); if (!item) - return; + return; /* call callback for double click */ if (bPtr->doubleAction) - (*bPtr->doubleAction)(bPtr, bPtr->doubleClientData); + (*bPtr->doubleAction)(bPtr, bPtr->doubleClientData); } @@ -1085,15 +1085,15 @@ void WMLoadBrowserColumnZero(WMBrowser *bPtr) { if (!bPtr->flags.loaded) { - /* create column 0 */ - WMAddBrowserColumn(bPtr); + /* create column 0 */ + WMAddBrowserColumn(bPtr); - loadColumn(bPtr, 0); + loadColumn(bPtr, 0); - /* make column 0 visible */ - scrollToColumn(bPtr, 0, True); + /* make column 0 visible */ + scrollToColumn(bPtr, 0, True); - bPtr->flags.loaded = 1; + bPtr->flags.loaded = 1; } } @@ -1104,19 +1104,19 @@ WMRemoveBrowserItem(WMBrowser *bPtr, int column, int row) WMList *list; if (column < 0 || column >= bPtr->usedColumnCount) - return; + return; list = WMGetBrowserListInColumn(bPtr, column); if (row < 0 || row >= WMGetListNumberOfRows(list)) - return; + return; removeColumn(bPtr, column+1); if (bPtr->usedColumnCount < bPtr->maxVisibleColumns) - scrollToColumn(bPtr, 0, True); + scrollToColumn(bPtr, 0, True); else - scrollToColumn(bPtr, bPtr->usedColumnCount-bPtr->maxVisibleColumns, - True); + scrollToColumn(bPtr, bPtr->usedColumnCount-bPtr->maxVisibleColumns, + True); WMRemoveListItem(list, row); } @@ -1136,7 +1136,7 @@ listSelectionObserver(void *observerData, WMNotification *notification) /* this can happen when a list is being cleared with WMClearList * after the column was removed */ if (column >= bPtr->usedColumnCount) { - return; + return; } if (WMGetArrayItemCount(WMGetListSelectedItems(lPtr)) == 0) @@ -1157,15 +1157,15 @@ WMAddBrowserColumn(WMBrowser *bPtr) if (bPtr->usedColumnCount < bPtr->columnCount) { - return bPtr->usedColumnCount++; + return bPtr->usedColumnCount++; } bPtr->usedColumnCount++; if (bPtr->flags.isTitled) { - colY = TITLE_SPACING + bPtr->titleHeight; + colY = TITLE_SPACING + bPtr->titleHeight; } else { - colY = 0; + colY = 0; } index = bPtr->columnCount; @@ -1175,9 +1175,9 @@ WMAddBrowserColumn(WMBrowser *bPtr) memcpy(clist, bPtr->columns, sizeof(WMList*)*(bPtr->columnCount-1)); memcpy(tlist, bPtr->titles, sizeof(char*)*(bPtr->columnCount-1)); if (bPtr->columns) - wfree(bPtr->columns); + wfree(bPtr->columns); if (bPtr->titles) - wfree(bPtr->titles); + wfree(bPtr->titles); bPtr->columns = clist; bPtr->titles = tlist; @@ -1190,23 +1190,23 @@ WMAddBrowserColumn(WMBrowser *bPtr) WMSetListDoubleAction(list, listDoubleCallback, bPtr); WMSetListUserDrawProc(list, paintItem); WMAddNotificationObserver(listSelectionObserver, bPtr, - WMListSelectionDidChangeNotification, list); + WMListSelectionDidChangeNotification, list); bPtr->columns[index] = list; WMResizeWidget(list, bPtr->columnSize.width, bPtr->columnSize.height); WMMoveWidget(list, (bPtr->columnSize.width+COLUMN_SPACING)*index, colY); if (COLUMN_IS_VISIBLE(bPtr, index)) - WMMapWidget(list); + WMMapWidget(list); /* update the scroller */ if (bPtr->columnCount > bPtr->maxVisibleColumns) { - float value, proportion; + float value, proportion; - value = bPtr->firstVisibleColumn - /(float)(bPtr->columnCount-bPtr->maxVisibleColumns); - proportion = bPtr->maxVisibleColumns/(float)bPtr->columnCount; - WMSetScrollerParameters(bPtr->scroller, value, proportion); + value = bPtr->firstVisibleColumn + /(float)(bPtr->columnCount-bPtr->maxVisibleColumns); + proportion = bPtr->maxVisibleColumns/(float)bPtr->columnCount; + WMSetScrollerParameters(bPtr->scroller, value, proportion); } return index; @@ -1220,8 +1220,8 @@ destroyBrowser(WMBrowser *bPtr) int i; for (i = 0; i < bPtr->columnCount; i++) { - if (bPtr->titles[i]) - wfree(bPtr->titles[i]); + if (bPtr->titles[i]) + wfree(bPtr->titles[i]); } wfree(bPtr->titles); @@ -1240,24 +1240,25 @@ createTruncatedString(WMFont *font, char *text, int *textLen, int width) char *textBuf = (char*)wmalloc((*textLen)+4); if (width >= 3*dLen) { - int dddLen = 3*dLen; - int tmpTextLen = *textLen; - - strcpy(textBuf, text); - while (tmpTextLen - && (WMWidthOfString(font, textBuf, tmpTextLen)+dddLen > width)) - tmpTextLen--; - strcpy(textBuf+tmpTextLen, "..."); - *textLen = tmpTextLen+3; + int dddLen = 3*dLen; + int tmpTextLen = *textLen; + + strcpy(textBuf, text); + while (tmpTextLen + && (WMWidthOfString(font, textBuf, tmpTextLen)+dddLen > width)) + tmpTextLen--; + strcpy(textBuf+tmpTextLen, "..."); + *textLen = tmpTextLen+3; } else if (width >= 2*dLen) { - strcpy(textBuf, ".."); - *textLen = 2; + strcpy(textBuf, ".."); + *textLen = 2; } else if (width >= dLen) { - strcpy(textBuf, "."); - *textLen = 1; + strcpy(textBuf, "."); + *textLen = 1; } else { - *textBuf = '\0'; - *textLen = 0; + *textBuf = '\0'; + *textLen = 0; } return textBuf; } + diff --git a/WINGs/wbutton.c b/WINGs/wbutton.c index ae6dddb1..3ea6752b 100644 --- a/WINGs/wbutton.c +++ b/WINGs/wbutton.c @@ -9,9 +9,9 @@ typedef struct W_Button { WMView *view; char *caption; - + char *altCaption; - + WMFont *font; WMColor *textColor; @@ -27,52 +27,52 @@ typedef struct W_Button { WMAction *action; int tag; - + int groupIndex; - + float periodicDelay; float periodicInterval; - + WMHandlerID *timer; /* for continuous mode */ - + struct { - WMButtonType type:4; - WMImagePosition imagePosition:4; - WMAlignment alignment:2; + WMButtonType type:4; + WMImagePosition imagePosition:4; + WMAlignment alignment:2; - unsigned int selected:1; + unsigned int selected:1; - unsigned int enabled:1; + unsigned int enabled:1; unsigned int dimsWhenDisabled:1; - unsigned int bordered:1; + unsigned int bordered:1; - unsigned int springLoaded:1; + unsigned int springLoaded:1; - unsigned int pushIn:1; /* change relief while pushed */ + unsigned int pushIn:1; /* change relief while pushed */ - unsigned int pushLight:1; /* highlight while pushed */ + unsigned int pushLight:1; /* highlight while pushed */ - unsigned int pushChange:1; /* change caption while pushed */ + unsigned int pushChange:1; /* change caption while pushed */ - unsigned int stateLight:1; /* state indicated by highlight */ + unsigned int stateLight:1; /* state indicated by highlight */ - unsigned int stateChange:1; /* state indicated by caption change */ + unsigned int stateChange:1; /* state indicated by caption change */ - unsigned int statePush:1; /* state indicated by relief */ + unsigned int statePush:1; /* state indicated by relief */ - unsigned int continuous:1; /* continually perform action */ + unsigned int continuous:1; /* continually perform action */ - unsigned int prevSelected:1; + unsigned int prevSelected:1; - unsigned int pushed:1; + unsigned int pushed:1; - unsigned int wasPushed:1; + unsigned int wasPushed:1; - unsigned int redrawPending:1; + unsigned int redrawPending:1; - unsigned int addedObserver:1; + unsigned int addedObserver:1; } flags; } Button; @@ -115,16 +115,16 @@ WMButton* WMCreateCustomButton(WMWidget *parent, int behaviourMask) { Button *bPtr; - + bPtr = wmalloc(sizeof(Button)); memset(bPtr, 0, sizeof(Button)); bPtr->widgetClass = WC_Button; - + bPtr->view = W_CreateView(W_VIEW(parent)); if (!bPtr->view) { - wfree(bPtr); - return NULL; + wfree(bPtr); + return NULL; } bPtr->view->self = bPtr; @@ -146,11 +146,11 @@ WMCreateCustomButton(WMWidget *parent, int behaviourMask) bPtr->flags.dimsWhenDisabled = 1; WMCreateEventHandler(bPtr->view, ExposureMask|StructureNotifyMask, - handleEvents, bPtr); + handleEvents, bPtr); WMCreateEventHandler(bPtr->view, ButtonPressMask|ButtonReleaseMask - |EnterWindowMask|LeaveWindowMask, - handleActionEvents, bPtr); + |EnterWindowMask|LeaveWindowMask, + handleActionEvents, bPtr); W_ResizeView(bPtr->view, DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT); bPtr->flags.alignment = DEFAULT_BUTTON_ALIGNMENT; @@ -166,68 +166,68 @@ WMCreateButton(WMWidget *parent, WMButtonType type) { W_Screen *scrPtr = W_VIEW(parent)->screen; Button *bPtr; - + switch (type) { - case WBTMomentaryPush: - bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask - |WBBPushInMask|WBBPushLightMask); - break; - - case WBTMomentaryChange: - bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask - |WBBPushChangeMask); - break; - - case WBTPushOnPushOff: - bPtr = WMCreateCustomButton(parent, WBBPushInMask|WBBStatePushMask - |WBBStateLightMask); - break; - - case WBTToggle: - bPtr = WMCreateCustomButton(parent, WBBPushInMask|WBBStateChangeMask - |WBBStatePushMask); - break; - - case WBTOnOff: - bPtr = WMCreateCustomButton(parent, WBBStateLightMask); - break; - - case WBTSwitch: - bPtr = WMCreateCustomButton(parent, WBBStateChangeMask); - bPtr->flags.bordered = 0; - bPtr->image = WMRetainPixmap(scrPtr->checkButtonImageOff); - bPtr->altImage = WMRetainPixmap(scrPtr->checkButtonImageOn); - break; - - case WBTRadio: - bPtr = WMCreateCustomButton(parent, WBBStateChangeMask); - bPtr->flags.bordered = 0; - bPtr->image = WMRetainPixmap(scrPtr->radioButtonImageOff); - bPtr->altImage = WMRetainPixmap(scrPtr->radioButtonImageOn); - break; - - default: - case WBTMomentaryLight: - bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask - |WBBPushLightMask); - bPtr->flags.bordered = 1; - break; - } - + case WBTMomentaryPush: + bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask + |WBBPushInMask|WBBPushLightMask); + break; + + case WBTMomentaryChange: + bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask + |WBBPushChangeMask); + break; + + case WBTPushOnPushOff: + bPtr = WMCreateCustomButton(parent, WBBPushInMask|WBBStatePushMask + |WBBStateLightMask); + break; + + case WBTToggle: + bPtr = WMCreateCustomButton(parent, WBBPushInMask|WBBStateChangeMask + |WBBStatePushMask); + break; + + case WBTOnOff: + bPtr = WMCreateCustomButton(parent, WBBStateLightMask); + break; + + case WBTSwitch: + bPtr = WMCreateCustomButton(parent, WBBStateChangeMask); + bPtr->flags.bordered = 0; + bPtr->image = WMRetainPixmap(scrPtr->checkButtonImageOff); + bPtr->altImage = WMRetainPixmap(scrPtr->checkButtonImageOn); + break; + + case WBTRadio: + bPtr = WMCreateCustomButton(parent, WBBStateChangeMask); + bPtr->flags.bordered = 0; + bPtr->image = WMRetainPixmap(scrPtr->radioButtonImageOff); + bPtr->altImage = WMRetainPixmap(scrPtr->radioButtonImageOn); + break; + + default: + case WBTMomentaryLight: + bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask + |WBBPushLightMask); + bPtr->flags.bordered = 1; + break; + } + bPtr->flags.type = type; if (type==WBTRadio) { - W_ResizeView(bPtr->view, DEFAULT_RADIO_WIDTH, DEFAULT_RADIO_HEIGHT); - WMSetButtonText(bPtr, DEFAULT_RADIO_TEXT); - bPtr->flags.alignment = DEFAULT_RADIO_ALIGNMENT; - bPtr->flags.imagePosition = DEFAULT_RADIO_IMAGE_POSITION; + W_ResizeView(bPtr->view, DEFAULT_RADIO_WIDTH, DEFAULT_RADIO_HEIGHT); + WMSetButtonText(bPtr, DEFAULT_RADIO_TEXT); + bPtr->flags.alignment = DEFAULT_RADIO_ALIGNMENT; + bPtr->flags.imagePosition = DEFAULT_RADIO_IMAGE_POSITION; } else if (type==WBTSwitch) { - W_ResizeView(bPtr->view, DEFAULT_SWITCH_WIDTH, DEFAULT_SWITCH_HEIGHT); - WMSetButtonText(bPtr, DEFAULT_SWITCH_TEXT); - bPtr->flags.alignment = DEFAULT_SWITCH_ALIGNMENT; - bPtr->flags.imagePosition = DEFAULT_SWITCH_IMAGE_POSITION; + W_ResizeView(bPtr->view, DEFAULT_SWITCH_WIDTH, DEFAULT_SWITCH_HEIGHT); + WMSetButtonText(bPtr, DEFAULT_SWITCH_TEXT); + bPtr->flags.alignment = DEFAULT_SWITCH_ALIGNMENT; + bPtr->flags.imagePosition = DEFAULT_SWITCH_IMAGE_POSITION; } - + return bPtr; } @@ -239,7 +239,7 @@ updateDisabledMask(WMButton *bPtr) Display *dpy = scr->display; if (bPtr->image) { - XGCValues gcv; + XGCValues gcv; if (bPtr->dimage->mask) { XFreePixmap(dpy, bPtr->dimage->mask); @@ -287,25 +287,25 @@ void WMSetButtonImage(WMButton *bPtr, WMPixmap *image) { if (bPtr->image!=NULL) - WMReleasePixmap(bPtr->image); + WMReleasePixmap(bPtr->image); bPtr->image = WMRetainPixmap(image); if (bPtr->dimage) { - bPtr->dimage->pixmap = None; - WMReleasePixmap(bPtr->dimage); - bPtr->dimage = NULL; + bPtr->dimage->pixmap = None; + WMReleasePixmap(bPtr->dimage); + bPtr->dimage = NULL; } if (image) { - bPtr->dimage = WMCreatePixmapFromXPixmaps(WMWidgetScreen(bPtr), - image->pixmap, None, - image->width, image->height, - image->depth); - updateDisabledMask(bPtr); + bPtr->dimage = WMCreatePixmapFromXPixmaps(WMWidgetScreen(bPtr), + image->pixmap, None, + image->width, image->height, + image->depth); + updateDisabledMask(bPtr); } if (bPtr->view->flags.realized) { - paintButton(bPtr); + paintButton(bPtr); } } @@ -314,12 +314,12 @@ void WMSetButtonAltImage(WMButton *bPtr, WMPixmap *image) { if (bPtr->altImage!=NULL) - WMReleasePixmap(bPtr->altImage); + WMReleasePixmap(bPtr->altImage); bPtr->altImage = WMRetainPixmap(image); - - + + if (bPtr->view->flags.realized) { - paintButton(bPtr); + paintButton(bPtr); } } @@ -328,10 +328,10 @@ void WMSetButtonImagePosition(WMButton *bPtr, WMImagePosition position) { bPtr->flags.imagePosition = position; - - + + if (bPtr->view->flags.realized) { - paintButton(bPtr); + paintButton(bPtr); } } @@ -342,10 +342,10 @@ void WMSetButtonTextAlignment(WMButton *bPtr, WMAlignment alignment) { bPtr->flags.alignment = alignment; - - + + if (bPtr->view->flags.realized) { - paintButton(bPtr); + paintButton(bPtr); } } @@ -353,17 +353,17 @@ void WMSetButtonText(WMButton *bPtr, char *text) { if (bPtr->caption) - wfree(bPtr->caption); + wfree(bPtr->caption); if (text!=NULL) { - bPtr->caption = wstrdup(text); + bPtr->caption = wstrdup(text); } else { - bPtr->caption = NULL; + bPtr->caption = NULL; } - - + + if (bPtr->view->flags.realized) { - paintButton(bPtr); + paintButton(bPtr); } } @@ -372,16 +372,16 @@ void WMSetButtonAltText(WMButton *bPtr, char *text) { if (bPtr->altCaption) - wfree(bPtr->altCaption); - + wfree(bPtr->altCaption); + if (text!=NULL) { - bPtr->altCaption = wstrdup(text); + bPtr->altCaption = wstrdup(text); } else { - bPtr->altCaption = NULL; + bPtr->altCaption = NULL; } - + if (bPtr->view->flags.realized) { - paintButton(bPtr); + paintButton(bPtr); } } @@ -390,7 +390,7 @@ void WMSetButtonTextColor(WMButton *bPtr, WMColor *color) { if (bPtr->textColor) - WMReleaseColor(bPtr->textColor); + WMReleaseColor(bPtr->textColor); bPtr->textColor = WMRetainColor(color); } @@ -400,7 +400,7 @@ void WMSetButtonAltTextColor(WMButton *bPtr, WMColor *color) { if (bPtr->altTextColor) - WMReleaseColor(bPtr->altTextColor); + WMReleaseColor(bPtr->altTextColor); bPtr->altTextColor = WMRetainColor(color); } @@ -410,7 +410,7 @@ void WMSetButtonDisabledTextColor(WMButton *bPtr, WMColor *color) { if (bPtr->disTextColor) - WMReleaseColor(bPtr->disTextColor); + WMReleaseColor(bPtr->disTextColor); bPtr->disTextColor = WMRetainColor(color); } @@ -420,12 +420,12 @@ void WMSetButtonSelected(WMButton *bPtr, int isSelected) { bPtr->flags.selected = isSelected ? 1 : 0; - + if (bPtr->view->flags.realized) { - paintButton(bPtr); - } + paintButton(bPtr); + } if (bPtr->groupIndex > 0) - WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL); + WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL); } @@ -433,7 +433,7 @@ int WMGetButtonSelected(WMButton *bPtr) { CHECK_CLASS(bPtr, WC_Button); - + return bPtr->flags.selected; } @@ -442,9 +442,9 @@ void WMSetButtonBordered(WMButton *bPtr, int isBordered) { bPtr->flags.bordered = isBordered; - + if (bPtr->view->flags.realized) { - paintButton(bPtr); + paintButton(bPtr); } } @@ -453,7 +453,7 @@ void WMSetButtonFont(WMButton *bPtr, WMFont *font) { if (bPtr->font) - WMReleaseFont(bPtr->font); + WMReleaseFont(bPtr->font); bPtr->font = WMRetainFont(font); } @@ -465,7 +465,7 @@ WMSetButtonEnabled(WMButton *bPtr, Bool flag) bPtr->flags.enabled = ((flag==0) ? 0 : 1); if (bPtr->view->flags.mapped) { - paintButton(bPtr); + paintButton(bPtr); } } @@ -501,28 +501,28 @@ WMPerformButtonClick(WMButton *bPtr) CHECK_CLASS(bPtr, WC_Button); if (!bPtr->flags.enabled) - return; + return; bPtr->flags.pushed = 1; bPtr->flags.selected = 1; - + if (bPtr->view->flags.mapped) { - paintButton(bPtr); - XFlush(WMScreenDisplay(WMWidgetScreen(bPtr))); - wusleep(20000); + paintButton(bPtr); + XFlush(WMScreenDisplay(WMWidgetScreen(bPtr))); + wusleep(20000); } - + bPtr->flags.pushed = 0; - + if (bPtr->groupIndex > 0) { - WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL); + WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL); } if (bPtr->action) - (*bPtr->action)(bPtr, bPtr->clientData); - + (*bPtr->action)(bPtr, bPtr->clientData); + if (bPtr->view->flags.mapped) - paintButton(bPtr); + paintButton(bPtr); } @@ -531,9 +531,9 @@ void WMSetButtonAction(WMButton *bPtr, WMAction *action, void *clientData) { CHECK_CLASS(bPtr, WC_Button); - + bPtr->action = action; - + bPtr->clientData = clientData; } @@ -547,11 +547,11 @@ radioPushObserver(void *observerData, WMNotification *notification) WMButton *pushedButton = (WMButton*)WMGetNotificationObject(notification); if (bPtr!=pushedButton && pushedButton->groupIndex == bPtr->groupIndex - && bPtr->groupIndex!=0) { - if (bPtr->flags.selected) { - bPtr->flags.selected = 0; - paintButton(bPtr); - } + && bPtr->groupIndex!=0) { + if (bPtr->flags.selected) { + bPtr->flags.selected = 0; + paintButton(bPtr); + } } } @@ -561,23 +561,23 @@ void WMGroupButtons(WMButton *bPtr, WMButton *newMember) { static int tagIndex = 0; - + CHECK_CLASS(bPtr, WC_Button); CHECK_CLASS(newMember, WC_Button); if (!bPtr->flags.addedObserver) { - WMAddNotificationObserver(radioPushObserver, bPtr, - WMPushedRadioNotification, NULL); - bPtr->flags.addedObserver = 1; + WMAddNotificationObserver(radioPushObserver, bPtr, + WMPushedRadioNotification, NULL); + bPtr->flags.addedObserver = 1; } if (!newMember->flags.addedObserver) { - WMAddNotificationObserver(radioPushObserver, newMember, - WMPushedRadioNotification, NULL); - newMember->flags.addedObserver = 1; + WMAddNotificationObserver(radioPushObserver, newMember, + WMPushedRadioNotification, NULL); + newMember->flags.addedObserver = 1; } - + if (bPtr->groupIndex==0) { - bPtr->groupIndex = ++tagIndex; + bPtr->groupIndex = ++tagIndex; } newMember->groupIndex = bPtr->groupIndex; } @@ -588,8 +588,8 @@ WMSetButtonContinuous(WMButton *bPtr, Bool flag) { bPtr->flags.continuous = ((flag==0) ? 0 : 1); if (bPtr->timer) { - WMDeleteTimerHandler(bPtr->timer); - bPtr->timer = NULL; + WMDeleteTimerHandler(bPtr->timer); + bPtr->timer = NULL; } } @@ -626,14 +626,14 @@ paintButton(Button *bPtr) } if (bPtr->flags.enabled || !bPtr->dimage) - image = bPtr->image; + image = bPtr->image; else - image = bPtr->dimage; + image = bPtr->dimage; offset = 0; if (bPtr->flags.bordered) - relief = WRRaised; + relief = WRRaised; else - relief = WRFlat; + relief = WRFlat; if (bPtr->flags.selected) { if (bPtr->flags.stateLight) { @@ -641,45 +641,45 @@ paintButton(Button *bPtr) textColor = scrPtr->black; } - if (bPtr->flags.stateChange) { - if (bPtr->altCaption) - caption = bPtr->altCaption; - if (bPtr->altImage) - image = bPtr->altImage; + if (bPtr->flags.stateChange) { + if (bPtr->altCaption) + caption = bPtr->altCaption; + if (bPtr->altImage) + image = bPtr->altImage; if (bPtr->altTextColor) textColor = bPtr->altTextColor; } - if (bPtr->flags.statePush && bPtr->flags.bordered) { - relief = WRSunken; - offset = 1; - } + if (bPtr->flags.statePush && bPtr->flags.bordered) { + relief = WRSunken; + offset = 1; + } } if (bPtr->flags.pushed) { - if (bPtr->flags.pushIn) { - relief = WRPushed; - offset = 1; - } + if (bPtr->flags.pushIn) { + relief = WRPushed; + offset = 1; + } if (bPtr->flags.pushLight) { backColor = scrPtr->white; textColor = scrPtr->black; } - if (bPtr->flags.pushChange) { - if (bPtr->altCaption) - caption = bPtr->altCaption; - if (bPtr->altImage) - image = bPtr->altImage; + if (bPtr->flags.pushChange) { + if (bPtr->altCaption) + caption = bPtr->altCaption; + if (bPtr->altImage) + image = bPtr->altImage; if (bPtr->altTextColor) textColor = bPtr->altTextColor; - } + } } W_PaintTextAndImage(bPtr->view, True, textColor, - (bPtr->font!=NULL ? bPtr->font : scrPtr->normalFont), - relief, caption, bPtr->flags.alignment, image, - bPtr->flags.imagePosition, backColor, offset); + (bPtr->font!=NULL ? bPtr->font : scrPtr->normalFont), + relief, caption, bPtr->flags.alignment, image, + bPtr->flags.imagePosition, backColor, offset); } @@ -693,29 +693,29 @@ handleEvents(XEvent *event, void *data) switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintButton(bPtr); - break; - - case DestroyNotify: - destroyButton(bPtr); - break; + case Expose: + if (event->xexpose.count!=0) + break; + paintButton(bPtr); + break; + + case DestroyNotify: + destroyButton(bPtr); + break; } } -static void +static void autoRepeat(void *data) { Button *bPtr = (Button*)data; if (bPtr->action && bPtr->flags.pushed) - (*bPtr->action)(bPtr, bPtr->clientData); + (*bPtr->action)(bPtr, bPtr->clientData); bPtr->timer = WMAddTimerHandler((int)(bPtr->periodicInterval*1000), - autoRepeat, bPtr); + autoRepeat, bPtr); } @@ -728,80 +728,80 @@ handleActionEvents(XEvent *event, void *data) CHECK_CLASS(data, WC_Button); if (!bPtr->flags.enabled) - return; - + return; + switch (event->type) { - case EnterNotify: - if (bPtr->groupIndex == 0) { - bPtr->flags.pushed = bPtr->flags.wasPushed; - if (bPtr->flags.pushed) { - bPtr->flags.selected = !bPtr->flags.prevSelected; - dopaint = 1; - } - } - break; - - case LeaveNotify: - if (bPtr->groupIndex == 0) { - bPtr->flags.wasPushed = bPtr->flags.pushed; - if (bPtr->flags.pushed) { - bPtr->flags.selected = bPtr->flags.prevSelected; - dopaint = 1; - } - bPtr->flags.pushed = 0; - } - break; - - case ButtonPress: - if (event->xbutton.button == Button1) { - bPtr->flags.prevSelected = bPtr->flags.selected; - bPtr->flags.wasPushed = 0; - bPtr->flags.pushed = 1; - if (bPtr->groupIndex>0) { - bPtr->flags.selected = 1; - dopaint = 1; - break; - } - bPtr->flags.selected = !bPtr->flags.selected; - dopaint = 1; - - if (bPtr->flags.continuous && !bPtr->timer) { - bPtr->timer = WMAddTimerHandler((int)(bPtr->periodicDelay*1000), - autoRepeat, bPtr); - } - } - break; - - case ButtonRelease: - if (event->xbutton.button == Button1) { - if (bPtr->flags.pushed) { - if (bPtr->groupIndex==0 || - (bPtr->flags.selected && bPtr->groupIndex > 0)) - doclick = 1; - dopaint = 1; - if (bPtr->flags.springLoaded) { - bPtr->flags.selected = bPtr->flags.prevSelected; - } - } - bPtr->flags.pushed = 0; - } - if (bPtr->timer) { - WMDeleteTimerHandler(bPtr->timer); - bPtr->timer = NULL; - } - break; + case EnterNotify: + if (bPtr->groupIndex == 0) { + bPtr->flags.pushed = bPtr->flags.wasPushed; + if (bPtr->flags.pushed) { + bPtr->flags.selected = !bPtr->flags.prevSelected; + dopaint = 1; + } + } + break; + + case LeaveNotify: + if (bPtr->groupIndex == 0) { + bPtr->flags.wasPushed = bPtr->flags.pushed; + if (bPtr->flags.pushed) { + bPtr->flags.selected = bPtr->flags.prevSelected; + dopaint = 1; + } + bPtr->flags.pushed = 0; + } + break; + + case ButtonPress: + if (event->xbutton.button == Button1) { + bPtr->flags.prevSelected = bPtr->flags.selected; + bPtr->flags.wasPushed = 0; + bPtr->flags.pushed = 1; + if (bPtr->groupIndex>0) { + bPtr->flags.selected = 1; + dopaint = 1; + break; + } + bPtr->flags.selected = !bPtr->flags.selected; + dopaint = 1; + + if (bPtr->flags.continuous && !bPtr->timer) { + bPtr->timer = WMAddTimerHandler((int)(bPtr->periodicDelay*1000), + autoRepeat, bPtr); + } + } + break; + + case ButtonRelease: + if (event->xbutton.button == Button1) { + if (bPtr->flags.pushed) { + if (bPtr->groupIndex==0 || + (bPtr->flags.selected && bPtr->groupIndex > 0)) + doclick = 1; + dopaint = 1; + if (bPtr->flags.springLoaded) { + bPtr->flags.selected = bPtr->flags.prevSelected; + } + } + bPtr->flags.pushed = 0; + } + if (bPtr->timer) { + WMDeleteTimerHandler(bPtr->timer); + bPtr->timer = NULL; + } + break; } if (dopaint) - paintButton(bPtr); - + paintButton(bPtr); + if (doclick) { - if (bPtr->flags.selected && bPtr->groupIndex > 0) { - WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL); - } + if (bPtr->flags.selected && bPtr->groupIndex > 0) { + WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL); + } - if (bPtr->action) - (*bPtr->action)(bPtr, bPtr->clientData); + if (bPtr->action) + (*bPtr->action)(bPtr, bPtr->clientData); } } @@ -811,20 +811,20 @@ static void destroyButton(Button *bPtr) { if (bPtr->flags.addedObserver) { - WMRemoveNotificationObserver(bPtr); + WMRemoveNotificationObserver(bPtr); } if (bPtr->timer) - WMDeleteTimerHandler(bPtr->timer); - + WMDeleteTimerHandler(bPtr->timer); + if (bPtr->font) - WMReleaseFont(bPtr->font); - + WMReleaseFont(bPtr->font); + if (bPtr->caption) - wfree(bPtr->caption); + wfree(bPtr->caption); if (bPtr->altCaption) - wfree(bPtr->altCaption); + wfree(bPtr->altCaption); if (bPtr->textColor) WMReleaseColor(bPtr->textColor); @@ -836,16 +836,16 @@ destroyButton(Button *bPtr) WMReleaseColor(bPtr->disTextColor); if (bPtr->image) - WMReleasePixmap(bPtr->image); + WMReleasePixmap(bPtr->image); if (bPtr->dimage) { - /* yuck.. kluge */ - bPtr->dimage->pixmap = None; + /* yuck.. kluge */ + bPtr->dimage->pixmap = None; - WMReleasePixmap(bPtr->dimage); + WMReleasePixmap(bPtr->dimage); } if (bPtr->altImage) - WMReleasePixmap(bPtr->altImage); + WMReleasePixmap(bPtr->altImage); wfree(bPtr); } diff --git a/WINGs/wcolor.c b/WINGs/wcolor.c index 5f6d9ea0..bca13a7a 100644 --- a/WINGs/wcolor.c +++ b/WINGs/wcolor.c @@ -8,12 +8,12 @@ #define LIGHT_STIPPLE_WIDTH 4 #define LIGHT_STIPPLE_HEIGHT 4 static unsigned char LIGHT_STIPPLE_BITS[] = { - 0x05, 0x0a, 0x05, 0x0a}; + 0x05, 0x0a, 0x05, 0x0a}; #define DARK_STIPPLE_WIDTH 4 #define DARK_STIPPLE_HEIGHT 4 static unsigned char DARK_STIPPLE_BITS[] = { - 0x0a, 0x04, 0x0a, 0x01}; + 0x0a, 0x04, 0x0a, 0x01}; static WMColor *createRGBAColor(WMScreen *scr, unsigned short red, @@ -28,8 +28,8 @@ static WMColor *createRGBAColor(WMScreen *scr, unsigned short red, */ static WMColor* -findCloseColor(WMScreen *scr, unsigned short red, unsigned short green, - unsigned short blue, unsigned short alpha) +findCloseColor(WMScreen *scr, unsigned short red, unsigned short green, + unsigned short blue, unsigned short alpha) { WMColor *color; XColor xcolor; @@ -41,10 +41,10 @@ findCloseColor(WMScreen *scr, unsigned short red, unsigned short green, rcolor.alpha = alpha>>8; if (!RGetClosestXColor(scr->rcontext, &rcolor, &xcolor)) - return NULL; - + return NULL; + if (!XAllocColor(scr->display, scr->colormap, &xcolor)) - return NULL; + return NULL; color = wmalloc(sizeof(WMColor)); @@ -72,7 +72,7 @@ createRGBAColor(WMScreen *scr, unsigned short red, unsigned short green, xcolor.blue = blue; xcolor.flags = DoRed|DoGreen|DoBlue; if (!XAllocColor(scr->display, scr->colormap, &xcolor)) - return NULL; + return NULL; color = wmalloc(sizeof(WMColor)); @@ -88,16 +88,16 @@ createRGBAColor(WMScreen *scr, unsigned short red, unsigned short green, WMColor* -WMCreateRGBColor(WMScreen *scr, unsigned short red, unsigned short green, - unsigned short blue, Bool exact) +WMCreateRGBColor(WMScreen *scr, unsigned short red, unsigned short green, + unsigned short blue, Bool exact) { WMColor *color = NULL; if (!exact || !(color=createRGBAColor(scr, red, green, blue, 0xffff))) { - color = findCloseColor(scr, red, green, blue, 0xffff); + color = findCloseColor(scr, red, green, blue, 0xffff); } if (!color) - color = WMBlackColor(scr); + color = WMBlackColor(scr); return color; } @@ -108,12 +108,12 @@ WMCreateRGBAColor(WMScreen *scr, unsigned short red, unsigned short green, unsigned short blue, unsigned short alpha, Bool exact) { WMColor *color = NULL; - + if (!exact || !(color=createRGBAColor(scr, red, green, blue, alpha))) { - color = findCloseColor(scr, red, green, blue, alpha); + color = findCloseColor(scr, red, green, blue, alpha); } if (!color) - color = WMBlackColor(scr); + color = WMBlackColor(scr); return color; } @@ -124,16 +124,16 @@ WMCreateNamedColor(WMScreen *scr, char *name, Bool exact) { WMColor *color; XColor xcolor; - + if (!XParseColor(scr->display, scr->colormap, name, &xcolor)) - return NULL; + return NULL; if (scr->visual->class == TrueColor) - exact = True; + exact = True; if (!exact || !(color=createRGBAColor(scr, xcolor.red, xcolor.green, xcolor.blue, 0xffff))) { - color = findCloseColor(scr, xcolor.red, xcolor.green, xcolor.blue, 0xffff); + color = findCloseColor(scr, xcolor.red, xcolor.green, xcolor.blue, 0xffff); } return color; } @@ -144,9 +144,9 @@ WMColor* WMRetainColor(WMColor *color) { assert(color!=NULL); - + color->refCount++; - + return color; } @@ -155,13 +155,13 @@ void WMReleaseColor(WMColor *color) { color->refCount--; - + if (color->refCount < 1) { - XFreeColors(color->screen->display, color->screen->colormap, - &(color->color.pixel), 1, 0); - if (color->gc) - XFreeGC(color->screen->display, color->gc); - wfree(color); + XFreeColors(color->screen->display, color->screen->colormap, + &(color->color.pixel), 1, 0); + if (color->gc) + XFreeGC(color->screen->display, color->gc); + wfree(color); } } @@ -175,10 +175,10 @@ WMSetColorAlpha(WMColor *color, unsigned short alpha) void WMPaintColorSwatch(WMColor *color, Drawable d, int x, int y, - unsigned int width, unsigned int height) + unsigned int width, unsigned int height) { - XFillRectangle(color->screen->display, d, WMColorGC(color), - x, y, width, height); + XFillRectangle(color->screen->display, d, WMColorGC(color), + x, y, width, height); } @@ -193,20 +193,20 @@ GC WMColorGC(WMColor *color) { if (!color->gc) { - XGCValues gcv; - WMScreen *scr = color->screen; + XGCValues gcv; + WMScreen *scr = color->screen; - gcv.foreground = color->color.pixel; - gcv.graphics_exposures = False; - color->gc = XCreateGC(scr->display, scr->rcontext->drawable, - GCForeground|GCGraphicsExposures, &gcv); + gcv.foreground = color->color.pixel; + gcv.graphics_exposures = False; + color->gc = XCreateGC(scr->display, scr->rcontext->drawable, + GCForeground|GCGraphicsExposures, &gcv); } return color->gc; } -void +void WMSetColorInGC(WMColor *color, GC gc) { XSetForeground(color->screen->display, gc, color->color.pixel); @@ -219,9 +219,9 @@ WMColor* WMWhiteColor(WMScreen *scr) { if (!scr->white) { - scr->white = WMCreateRGBColor(scr, 0xffff, 0xffff, 0xffff, True); - if (!scr->white->flags.exact) - wwarning(_("could not allocate %s color"), _("white")); + scr->white = WMCreateRGBColor(scr, 0xffff, 0xffff, 0xffff, True); + if (!scr->white->flags.exact) + wwarning(_("could not allocate %s color"), _("white")); } return WMRetainColor(scr->white); } @@ -231,9 +231,9 @@ WMColor* WMBlackColor(WMScreen *scr) { if (!scr->black) { - scr->black = WMCreateRGBColor(scr, 0, 0, 0, True); - if (!scr->black->flags.exact) - wwarning(_("could not allocate %s color"), _("black")); + scr->black = WMCreateRGBColor(scr, 0, 0, 0, True); + if (!scr->black->flags.exact) + wwarning(_("could not allocate %s color"), _("black")); } return WMRetainColor(scr->black); } @@ -244,37 +244,37 @@ WMColor* WMGrayColor(WMScreen *scr) { if (!scr->gray) { - WMColor *color; - - if (scr->depth == 1) { - Pixmap stipple; - WMColor *white = WMWhiteColor(scr); - WMColor *black = WMBlackColor(scr); - XGCValues gcv; - - stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr), - LIGHT_STIPPLE_BITS, LIGHT_STIPPLE_WIDTH, - LIGHT_STIPPLE_HEIGHT); - - color = createRGBAColor(scr, 0xffff, 0xffff, 0xffff, 0xffff); - - gcv.foreground = white->color.pixel; - gcv.background = black->color.pixel; - gcv.fill_style = FillStippled; - gcv.stipple = stipple; - color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground - |GCBackground|GCStipple|GCFillStyle - |GCGraphicsExposures, &gcv); - - XFreePixmap(scr->display, stipple); - WMReleaseColor(white); - WMReleaseColor(black); - } else { - color = WMCreateRGBColor(scr, 0xaeba, 0xaaaa, 0xaeba, True); - if (!color->flags.exact) - wwarning(_("could not allocate %s color"), _("gray")); - } - scr->gray = color; + WMColor *color; + + if (scr->depth == 1) { + Pixmap stipple; + WMColor *white = WMWhiteColor(scr); + WMColor *black = WMBlackColor(scr); + XGCValues gcv; + + stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr), + LIGHT_STIPPLE_BITS, LIGHT_STIPPLE_WIDTH, + LIGHT_STIPPLE_HEIGHT); + + color = createRGBAColor(scr, 0xffff, 0xffff, 0xffff, 0xffff); + + gcv.foreground = white->color.pixel; + gcv.background = black->color.pixel; + gcv.fill_style = FillStippled; + gcv.stipple = stipple; + color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground + |GCBackground|GCStipple|GCFillStyle + |GCGraphicsExposures, &gcv); + + XFreePixmap(scr->display, stipple); + WMReleaseColor(white); + WMReleaseColor(black); + } else { + color = WMCreateRGBColor(scr, 0xaeba, 0xaaaa, 0xaeba, True); + if (!color->flags.exact) + wwarning(_("could not allocate %s color"), _("gray")); + } + scr->gray = color; } return WMRetainColor(scr->gray); } @@ -285,37 +285,37 @@ WMColor* WMDarkGrayColor(WMScreen *scr) { if (!scr->darkGray) { - WMColor *color; - - if (scr->depth == 1) { - Pixmap stipple; - WMColor *white = WMWhiteColor(scr); - WMColor *black = WMBlackColor(scr); - XGCValues gcv; - - stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr), - DARK_STIPPLE_BITS, DARK_STIPPLE_WIDTH, - DARK_STIPPLE_HEIGHT); - - color = createRGBAColor(scr, 0, 0, 0, 0xffff); - - gcv.foreground = white->color.pixel; - gcv.background = black->color.pixel; - gcv.fill_style = FillStippled; - gcv.stipple = stipple; - color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground - |GCBackground|GCStipple|GCFillStyle - |GCGraphicsExposures, &gcv); - - XFreePixmap(scr->display, stipple); - WMReleaseColor(white); - WMReleaseColor(black); - } else { - color = WMCreateRGBColor(scr, 0x5144, 0x5555, 0x5144, True); - if (!color->flags.exact) - wwarning(_("could not allocate %s color"), _("dark gray")); - } - scr->darkGray = color; + WMColor *color; + + if (scr->depth == 1) { + Pixmap stipple; + WMColor *white = WMWhiteColor(scr); + WMColor *black = WMBlackColor(scr); + XGCValues gcv; + + stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr), + DARK_STIPPLE_BITS, DARK_STIPPLE_WIDTH, + DARK_STIPPLE_HEIGHT); + + color = createRGBAColor(scr, 0, 0, 0, 0xffff); + + gcv.foreground = white->color.pixel; + gcv.background = black->color.pixel; + gcv.fill_style = FillStippled; + gcv.stipple = stipple; + color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground + |GCBackground|GCStipple|GCFillStyle + |GCGraphicsExposures, &gcv); + + XFreePixmap(scr->display, stipple); + WMReleaseColor(white); + WMReleaseColor(black); + } else { + color = WMCreateRGBColor(scr, 0x5144, 0x5555, 0x5144, True); + if (!color->flags.exact) + wwarning(_("could not allocate %s color"), _("dark gray")); + } + scr->darkGray = color; } return WMRetainColor(scr->darkGray); } @@ -353,10 +353,10 @@ char* WMGetColorRGBDescription(WMColor *color) { char *str = wmalloc(32); - + sprintf(str, "#%02x%02x%02x", color->color.red>>8, color->color.green>>8, - color->color.blue>>8); - + color->color.blue>>8); + return str; } diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index 48167269..0da49fbe 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -2,11 +2,11 @@ * ColorPanel for WINGs * * by ]d : Original idea and basic initial code - * Pascal Hofstee : Code for wheeldrawing and calculating + * Pascal Hofstee : Code for wheeldrawing and calculating * colors from it. * Primary coder of this Color Panel. * Alban Hertroys : Optimizations for algorithms for color- - * wheel. Also custom ColorPalettes and + * wheel. Also custom ColorPalettes and * magnifying glass. Secondary coder ;) * Alfredo K. Kojima : For pointing out memory-allocation * problems and similair code-issues @@ -38,15 +38,15 @@ /* BUG There's something fishy with shaped windows */ /* Whithout shape extension the magnified image is completely broken -Dan */ #if 0 - #ifdef SHAPE - #define SHAPE_WAS_DEFINED - #undef SHAPE - #endif +# ifdef SHAPE +# define SHAPE_WAS_DEFINED +# undef SHAPE +# endif #endif #ifdef SHAPE -#include +# include #endif @@ -69,39 +69,39 @@ char *WMColorPanelColorChangedNotification = "WMColorPanelColorChangedNotificati #define Cursor_height 32 static unsigned char Cursor_bits[] = { 0x00,0x7e,0x00,0x00,0xc0,0x81,0x03,0x00,0x20,0x00,0x04,0x00,0x10,0x00,0x08, - 0x00,0x08,0x00,0x10,0x00,0x04,0x00,0x20,0x00,0x02,0x00,0x40,0x00,0x02,0x00, - 0x40,0x00,0x02,0x00,0x40,0x00,0x01,0x42,0x80,0x00,0x01,0x24,0x80,0x00,0x01, - 0x00,0x80,0x00,0x01,0x00,0x80,0x00,0x01,0x24,0x80,0x00,0x01,0x42,0x80,0x00, - 0x02,0x00,0x40,0x00,0x02,0x00,0x40,0x00,0x02,0x00,0x40,0x00,0x04,0x00,0x20, - 0x00,0x08,0x00,0x50,0x00,0x10,0x00,0x88,0x00,0x20,0x00,0x5c,0x01,0xc0,0x81, - 0x3b,0x02,0x00,0x7e,0x70,0x05,0x00,0x00,0xe0,0x08,0x00,0x00,0xc0,0x15,0x00, - 0x00,0x80,0x23,0x00,0x00,0x00,0x57,0x00,0x00,0x00,0x8e,0x00,0x00,0x00,0x5c, - 0x00,0x00,0x00,0xb8,0x00,0x00,0x00,0x70}; + 0x00,0x08,0x00,0x10,0x00,0x04,0x00,0x20,0x00,0x02,0x00,0x40,0x00,0x02,0x00, + 0x40,0x00,0x02,0x00,0x40,0x00,0x01,0x42,0x80,0x00,0x01,0x24,0x80,0x00,0x01, + 0x00,0x80,0x00,0x01,0x00,0x80,0x00,0x01,0x24,0x80,0x00,0x01,0x42,0x80,0x00, + 0x02,0x00,0x40,0x00,0x02,0x00,0x40,0x00,0x02,0x00,0x40,0x00,0x04,0x00,0x20, + 0x00,0x08,0x00,0x50,0x00,0x10,0x00,0x88,0x00,0x20,0x00,0x5c,0x01,0xc0,0x81, + 0x3b,0x02,0x00,0x7e,0x70,0x05,0x00,0x00,0xe0,0x08,0x00,0x00,0xc0,0x15,0x00, + 0x00,0x80,0x23,0x00,0x00,0x00,0x57,0x00,0x00,0x00,0x8e,0x00,0x00,0x00,0x5c, + 0x00,0x00,0x00,0xb8,0x00,0x00,0x00,0x70}; /* Cursor shape-mask */ #define Cursor_shape_width 32 #define Cursor_shape_height 32 static unsigned char Cursor_shape_bits[] = { 0x00,0x7e,0x00,0x00,0xc0,0x81,0x03,0x00,0x20,0x00,0x04,0x00,0x10,0x00,0x08, - 0x00,0x08,0x00,0x10,0x00,0x04,0x00,0x20,0x00,0x02,0x00,0x40,0x00,0x02,0x00, - 0x40,0x00,0x02,0x00,0x40,0x00,0x01,0x42,0x80,0x00,0x01,0x24,0x80,0x00,0x01, - 0x00,0x80,0x00,0x01,0x00,0x80,0x00,0x01,0x24,0x80,0x00,0x01,0x42,0x80,0x00, - 0x02,0x00,0x40,0x00,0x02,0x00,0x40,0x00,0x02,0x00,0x40,0x00,0x04,0x00,0x20, - 0x00,0x08,0x00,0x70,0x00,0x10,0x00,0xf8,0x00,0x20,0x00,0xfc,0x01,0xc0,0x81, - 0xfb,0x03,0x00,0x7e,0xf0,0x07,0x00,0x00,0xe0,0x0f,0x00,0x00,0xc0,0x1f,0x00, - 0x00,0x80,0x3f,0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0xfc, - 0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x70}; + 0x00,0x08,0x00,0x10,0x00,0x04,0x00,0x20,0x00,0x02,0x00,0x40,0x00,0x02,0x00, + 0x40,0x00,0x02,0x00,0x40,0x00,0x01,0x42,0x80,0x00,0x01,0x24,0x80,0x00,0x01, + 0x00,0x80,0x00,0x01,0x00,0x80,0x00,0x01,0x24,0x80,0x00,0x01,0x42,0x80,0x00, + 0x02,0x00,0x40,0x00,0x02,0x00,0x40,0x00,0x02,0x00,0x40,0x00,0x04,0x00,0x20, + 0x00,0x08,0x00,0x70,0x00,0x10,0x00,0xf8,0x00,0x20,0x00,0xfc,0x01,0xc0,0x81, + 0xfb,0x03,0x00,0x7e,0xf0,0x07,0x00,0x00,0xe0,0x0f,0x00,0x00,0xc0,0x1f,0x00, + 0x00,0x80,0x3f,0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0xfc, + 0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x70}; /* Clip-mask for magnified pixels */ #define Cursor_mask_width 24 #define Cursor_mask_height 24 static unsigned char Cursor_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0xc0, 0xff, 0x03, 0xe0, 0xff, 0x07, - 0xf0, 0xff, 0x0f, 0xf8, 0xff, 0x1f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, - 0xfc, 0xff, 0x3f, 0xfe, 0xff, 0x7f, 0xfe, 0xff, 0x7f, 0xfe, 0xff, 0x7f, - 0xfe, 0xff, 0x7f, 0xfe, 0xff, 0x7f, 0xfe, 0xff, 0x7f, 0xfc, 0xff, 0x3f, - 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xf8, 0xff, 0x1f, 0xf0, 0xff, 0x0f, - 0xe0, 0xff, 0x07, 0xc0, 0xff, 0x03, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0xc0, 0xff, 0x03, 0xe0, 0xff, 0x07, + 0xf0, 0xff, 0x0f, 0xf8, 0xff, 0x1f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, + 0xfc, 0xff, 0x3f, 0xfe, 0xff, 0x7f, 0xfe, 0xff, 0x7f, 0xfe, 0xff, 0x7f, + 0xfe, 0xff, 0x7f, 0xfe, 0xff, 0x7f, 0xfe, 0xff, 0x7f, 0xfc, 0xff, 0x3f, + 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xf8, 0xff, 0x1f, 0xf0, 0xff, 0x0f, + 0xe0, 0xff, 0x07, 0xc0, 0xff, 0x03, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00}; typedef struct MovingView { @@ -117,12 +117,12 @@ typedef struct CPColor { RColor rgb; /* The RGB values of the color */ RHSVColor hsv; /* The HSV values of the color */ enum { /* Which one was last set ? */ - cpNone, - cpRGB, - cpHSV + cpNone, + cpRGB, + cpHSV } set; } CPColor; - + typedef struct WheelMatrix { unsigned int width, height; /* Size of the colorwheel */ @@ -136,7 +136,7 @@ typedef struct W_ColorPanel { WMFont *font12; void *clientData; WMAction2 *action; - + /* Common Stuff */ WMColorWell *colorWell; WMButton *magnifyBtn; @@ -144,15 +144,15 @@ typedef struct W_ColorPanel { WMButton *slidersBtn; WMButton *customPaletteBtn; WMButton *colorListBtn; - + /* Magnifying Glass */ MovingView *magnifyGlass; - + /* ColorWheel Panel */ WMFrame *wheelFrm; WMSlider *wheelBrightnessS; WMView *wheelView; - + /* Slider Panels */ WMFrame *slidersFrm; WMFrame *seperatorFrm; @@ -167,7 +167,7 @@ typedef struct W_ColorPanel { WMSlider *grayBrightnessS; WMTextField *grayBrightnessT; WMButton *grayPresetBtn[7]; - + /* RGB Panel */ WMFrame *rgbFrm; WMLabel *rgbMinL; @@ -178,7 +178,7 @@ typedef struct W_ColorPanel { WMTextField *rgbRedT; WMTextField *rgbGreenT; WMTextField *rgbBlueT; - + /* CMYK Panel */ WMFrame *cmykFrm; WMLabel *cmykMinL; @@ -191,7 +191,7 @@ typedef struct W_ColorPanel { WMTextField *cmykMagentaT; WMTextField *cmykYellowT; WMTextField *cmykBlackT; - + /* HSB Panel */ WMFrame *hsbFrm; WMSlider *hsbHueS; @@ -200,21 +200,21 @@ typedef struct W_ColorPanel { WMTextField *hsbHueT; WMTextField *hsbSaturationT; WMTextField *hsbBrightnessT; - + /* Custom Palette Panel*/ WMFrame *customPaletteFrm; WMPopUpButton *customPaletteHistoryBtn; WMFrame *customPaletteContentFrm; WMPopUpButton *customPaletteMenuBtn; WMView *customPaletteContentView; - + /* Color List Panel */ WMFrame *colorListFrm; WMPopUpButton *colorListHistoryBtn; WMList *colorListContentLst; WMPopUpButton *colorListColorMenuBtn; WMPopUpButton *colorListListMenuBtn; - + /* Look-Up Tables and Images */ wheelMatrix *wheelMtrx; Pixmap wheelImg; @@ -222,39 +222,39 @@ typedef struct W_ColorPanel { Pixmap selectionBackImg; RImage *customPaletteImg; char *lastBrowseDir; - + /* Common Data Fields */ CPColor color; /* Current color */ WMColorPanelMode mode; /* Current color selection mode */ WMColorPanelMode slidersmode; /* Current color sel. mode sliders panel */ WMColorPanelMode lastChanged; /* Panel that last changed the color */ int colx, coly; /* (x,y) of sel.-marker in WheelMode */ - int palx, paly; /* (x,y) of sel.-marker in - CustomPaletteMode */ - double palXRatio, palYRatio; /* Ratios in x & y between - original and scaled - palettesize */ + int palx, paly; /* (x,y) of sel.-marker in + CustomPaletteMode */ + double palXRatio, palYRatio; /* Ratios in x & y between + original and scaled + palettesize */ int currentPalette; char *configurationPath; - + struct { - unsigned int continuous:1; - unsigned int dragging:1; + unsigned int continuous:1; + unsigned int dragging:1; } flags; } W_ColorPanel; enum { CPmenuNewFromFile, - CPmenuRename, - CPmenuRemove, - CPmenuCopy, - CPmenuNewFromClipboard + CPmenuRename, + CPmenuRemove, + CPmenuCopy, + CPmenuNewFromClipboard } customPaletteMenuItem; enum { CLmenuAdd, - CLmenuRename, - CLmenuRemove + CLmenuRename, + CLmenuRemove } colorListMenuItem; @@ -289,7 +289,7 @@ enum { #endif static int fetchFile(char* toPath, char *imageSrcFile, - char *imageDestFileName); + char *imageDestFileName); char *generateNewFilename(char *curName); void convertCPColor(CPColor *color); RColor ulongToRColor(WMScreen *scr, unsigned long value); @@ -306,7 +306,7 @@ static Cursor magnifyGrabPointer(W_ColorPanel *panel); static WMPoint magnifyInitialize(W_ColorPanel *panel); static void magnifyPutCursor(WMWidget *w, void *data); static Pixmap magnifyCreatePixmap(WMColorPanel *panel); -static void magnifyGetImageStored(W_ColorPanel *panel, int x1, int y1, +static void magnifyGetImageStored(W_ColorPanel *panel, int x1, int y1, int x2, int y2); static XImage* magnifyGetImage(WMScreen *scr, XImage *image, int x, int y, int w, int h); @@ -332,20 +332,20 @@ static void wheelUpdateBrightnessGradient(W_ColorPanel *panel, CPColor topColor) static void grayBrightnessSliderCallback(WMWidget *w, void *data); static void grayPresetButtonCallback(WMWidget *w, void *data); -static void grayBrightnessTextFieldCallback(void *observerData, - WMNotification *notification); +static void grayBrightnessTextFieldCallback(void *observerData, + WMNotification *notification); static void rgbSliderCallback(WMWidget *w, void *data); -static void rgbTextFieldCallback(void *observerData, - WMNotification *notification); +static void rgbTextFieldCallback(void *observerData, + WMNotification *notification); static void cmykSliderCallback(WMWidget *w, void *data); -static void cmykTextFieldCallback(void *observerData, - WMNotification *notification); +static void cmykTextFieldCallback(void *observerData, + WMNotification *notification); static void hsbSliderCallback(WMWidget *w, void *data); -static void hsbTextFieldCallback(void *observerData, - WMNotification *notification); +static void hsbTextFieldCallback(void *observerData, + WMNotification *notification); static void hsbUpdateBrightnessGradient(W_ColorPanel *panel); static void hsbUpdateSaturationGradient(W_ColorPanel *panel); static void hsbUpdateHueGradient(W_ColorPanel *panel); @@ -355,8 +355,8 @@ static void customSetPalette(W_ColorPanel *panel); static void customPaletteHandleEvents(XEvent *event, void *data); static void customPaletteHandleActionEvents(XEvent *event, void *data); static void customPalettePositionSelection(W_ColorPanel *panel, int x, int y); -static void customPalettePositionSelectionOutBounds(W_ColorPanel *panel, - int x, int y); +static void customPalettePositionSelectionOutBounds(W_ColorPanel *panel, + int x, int y); static void customPaletteMenuCallback(WMWidget *w, void *data); static void customPaletteHistoryCallback(WMWidget *w, void *data); @@ -364,8 +364,8 @@ static void customPaletteMenuNewFromFile(W_ColorPanel *panel); static void customPaletteMenuRename(W_ColorPanel *panel); static void customPaletteMenuRemove(W_ColorPanel *panel); -static void colorListPaintItem(WMList *lPtr, int index, Drawable d, char *text, - int state, WMRect *rect); +static void colorListPaintItem(WMList *lPtr, int index, Drawable d, char *text, + int state, WMRect *rect); static void colorListSelect(WMWidget *w, void *data); static void colorListColorMenuCallback(WMWidget *w, void *data); static void colorListListMenuCallback(WMWidget *w, void *data); @@ -398,11 +398,11 @@ makeColorPanel(WMScreen *scrPtr, char *name) int i; GC bgc = WMColorGC(scrPtr->black); GC wgc = WMColorGC(scrPtr->white); - - + + panel = wmalloc(sizeof(WMColorPanel)); memset(panel, 0, sizeof(WMColorPanel)); - + panel->color.rgb.red = 0; panel->color.rgb.green = 0; panel->color.rgb.blue = 0; @@ -410,56 +410,56 @@ makeColorPanel(WMScreen *scrPtr, char *name) panel->color.hsv.saturation = 0; panel->color.hsv.value = 0; panel->color.set = cpNone; /* Color has not been set yet */ - + panel->font8 = WMSystemFontOfSize(scrPtr, 8); panel->font12 = WMSystemFontOfSize(scrPtr, 12); - + panel->win = WMCreateWindowWithStyle(scrPtr, name, - WMTitledWindowMask | WMClosableWindowMask | WMResizableWindowMask); + WMTitledWindowMask | WMClosableWindowMask | WMResizableWindowMask); WMResizeWidget(panel->win, PWIDTH, PHEIGHT); WMSetWindowTitle(panel->win, _("Colors")); WMSetWindowCloseAction(panel->win, closeWindowCallback, panel); - - + + /* Set Default ColorPanel Mode(s) */ panel->mode = WMWheelModeColorPanel; panel->lastChanged = 0; panel->slidersmode = WMRGBModeColorPanel; - panel->configurationPath = wstrconcat(wusergnusteppath(), - "/Library/Colors/"); - + panel->configurationPath = wstrconcat(wusergnusteppath(), + "/Library/Colors/"); + /* Some General Purpose Widgets */ panel->colorWell = WMCreateColorWell(panel->win); WMResizeWidget(panel->colorWell, 134, 36); WSetColorWellBordered(panel->colorWell, False); WMMoveWidget(panel->colorWell, 56, 4); - + panel->magnifyBtn = WMCreateCustomButton(panel->win, - WBBStateLightMask|WBBStateChangeMask); + WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->magnifyBtn, 46, 36); WMMoveWidget(panel->magnifyBtn, 6,4); WMSetButtonAction(panel->magnifyBtn, magnifyPutCursor, panel); WMSetButtonImagePosition(panel->magnifyBtn, WIPImageOnly); WMSetButtonImage(panel->magnifyBtn, scrPtr->magnifyIcon); - + panel->wheelBtn = WMCreateCustomButton(panel->win, - WBBStateLightMask|WBBStateChangeMask); + WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->wheelBtn, 46, 32); WMMoveWidget(panel->wheelBtn, 6, 44); WMSetButtonAction(panel->wheelBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->wheelBtn, WIPImageOnly); WMSetButtonImage(panel->wheelBtn, scrPtr->wheelIcon); - + panel->slidersBtn = WMCreateCustomButton(panel->win, - WBBStateLightMask|WBBStateChangeMask); + WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->slidersBtn, 46, 32); WMMoveWidget(panel->slidersBtn, 52, 44); WMSetButtonAction(panel->slidersBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->slidersBtn, WIPImageOnly); WMSetButtonImage(panel->slidersBtn, scrPtr->rgbIcon); - + panel->customPaletteBtn = WMCreateCustomButton(panel->win, - WBBStateLightMask|WBBStateChangeMask); + WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->customPaletteBtn, 46, 32); WMMoveWidget(panel->customPaletteBtn, 98, 44); WMSetButtonAction(panel->customPaletteBtn, modeButtonCallback, panel); @@ -467,7 +467,7 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetButtonImage(panel->customPaletteBtn, scrPtr->customPaletteIcon); panel->colorListBtn = WMCreateCustomButton(panel->win, - WBBStateLightMask|WBBStateChangeMask); + WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->colorListBtn, 46, 32); WMMoveWidget(panel->colorListBtn, 144, 44); WMSetButtonAction(panel->colorListBtn, modeButtonCallback, panel); @@ -477,96 +477,96 @@ makeColorPanel(WMScreen *scrPtr, char *name) /* Let's Group some of them together */ WMGroupButtons(panel->wheelBtn, panel->slidersBtn); WMGroupButtons(panel->wheelBtn, panel->customPaletteBtn); - WMGroupButtons(panel->wheelBtn, panel->colorListBtn); + WMGroupButtons(panel->wheelBtn, panel->colorListBtn); /* Widgets for the ColorWheel Panel */ panel->wheelFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->wheelFrm, WRFlat); WMResizeWidget(panel->wheelFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->wheelFrm, 5, 80); - + panel->wheelView = W_CreateView(W_VIEW(panel->wheelFrm)); /* XXX Can we create a view ? */ W_ResizeView(panel->wheelView, colorWheelSize+4, colorWheelSize+4); W_MoveView(panel->wheelView, 0, 0); - + /* Create an event handler to handle expose/click events in ColorWheel */ - WMCreateEventHandler(panel->wheelView, - ButtonPressMask|ButtonReleaseMask|EnterWindowMask| - LeaveWindowMask|ButtonMotionMask, wheelHandleActionEvents, panel); - - WMCreateEventHandler(panel->wheelView, ExposureMask, wheelHandleEvents, - panel); - + WMCreateEventHandler(panel->wheelView, + ButtonPressMask|ButtonReleaseMask|EnterWindowMask| + LeaveWindowMask|ButtonMotionMask, wheelHandleActionEvents, panel); + + WMCreateEventHandler(panel->wheelView, ExposureMask, wheelHandleEvents, + panel); + panel->wheelBrightnessS = WMCreateSlider(panel->wheelFrm); WMResizeWidget(panel->wheelBrightnessS, 16, 153); WMMoveWidget(panel->wheelBrightnessS, 5+colorWheelSize+14, 1); WMSetSliderMinValue(panel->wheelBrightnessS, 0); WMSetSliderMaxValue(panel->wheelBrightnessS, 255); - WMSetSliderAction(panel->wheelBrightnessS, wheelBrightnessSliderCallback, - panel); + WMSetSliderAction(panel->wheelBrightnessS, wheelBrightnessSliderCallback, + panel); WMSetSliderKnobThickness(panel->wheelBrightnessS, knobThickness); - + panel->wheelMtrx = wheelCreateMatrix(colorWheelSize+4, colorWheelSize+4); wheelInitMatrix(panel); - - + + /* Widgets for the Slider Panels */ panel->slidersFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->slidersFrm, WRFlat); WMResizeWidget(panel->slidersFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->slidersFrm, 4, 80); - + panel->seperatorFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->seperatorFrm, WRPushed); WMResizeWidget(panel->seperatorFrm, PWIDTH - 8, 2); WMMoveWidget(panel->seperatorFrm, 0, 1); - + panel->grayBtn = WMCreateCustomButton(panel->slidersFrm, - WBBStateLightMask|WBBStateChangeMask); + WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->grayBtn, 46, 24); WMMoveWidget(panel->grayBtn, 1, 8); WMSetButtonAction(panel->grayBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->grayBtn, WIPImageOnly); WMSetButtonImage(panel->grayBtn, scrPtr->grayIcon); - + panel->rgbBtn = WMCreateCustomButton(panel->slidersFrm, - WBBStateLightMask|WBBStateChangeMask); + WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->rgbBtn, 46, 24); WMMoveWidget(panel->rgbBtn, 47, 8); WMSetButtonAction(panel->rgbBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->rgbBtn, WIPImageOnly); WMSetButtonImage(panel->rgbBtn, scrPtr->rgbIcon); - + panel->cmykBtn = WMCreateCustomButton(panel->slidersFrm, - WBBStateLightMask|WBBStateChangeMask); + WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->cmykBtn, 46, 24); WMMoveWidget(panel->cmykBtn, 93, 8); WMSetButtonAction(panel->cmykBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->cmykBtn, WIPImageOnly); WMSetButtonImage(panel->cmykBtn, scrPtr->cmykIcon); - + panel->hsbBtn = WMCreateCustomButton(panel->slidersFrm, - WBBStateLightMask|WBBStateChangeMask); + WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->hsbBtn, 46, 24); WMMoveWidget(panel->hsbBtn, 139, 8); WMSetButtonAction(panel->hsbBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->hsbBtn, WIPImageOnly); WMSetButtonImage(panel->hsbBtn, scrPtr->hsbIcon); - + /* Let's Group the Slider Panel Buttons Together */ WMGroupButtons(panel->grayBtn, panel->rgbBtn); WMGroupButtons(panel->grayBtn, panel->cmykBtn); WMGroupButtons(panel->grayBtn, panel->hsbBtn); - + textcolor = WMDarkGrayColor(scrPtr); - + /* Widgets for GrayScale Panel */ panel->grayFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->grayFrm, WRFlat); WMResizeWidget(panel->grayFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->grayFrm, 0, 34); - + panel->grayMinL = WMCreateLabel(panel->grayFrm); WMResizeWidget(panel->grayMinL, 20, 10); WMMoveWidget(panel->grayMinL, 2, 2); @@ -574,7 +574,7 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetLabelTextAlignment(panel->grayMinL, WALeft); WMSetLabelTextColor(panel->grayMinL, textcolor); WMSetLabelFont(panel->grayMinL, panel->font8); - + panel->grayMaxL = WMCreateLabel(panel->grayFrm); WMResizeWidget(panel->grayMaxL, 40, 10); WMMoveWidget(panel->grayMaxL, 104, 2); @@ -582,72 +582,72 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetLabelTextAlignment(panel->grayMaxL, WARight); WMSetLabelTextColor(panel->grayMaxL, textcolor); WMSetLabelFont(panel->grayMaxL, panel->font8); - + panel->grayBrightnessS = WMCreateSlider(panel->grayFrm); WMResizeWidget(panel->grayBrightnessS, 141, 16); WMMoveWidget(panel->grayBrightnessS, 2, 14); WMSetSliderMinValue(panel->grayBrightnessS, 0); WMSetSliderMaxValue(panel->grayBrightnessS, 100); WMSetSliderKnobThickness(panel->grayBrightnessS, knobThickness); - WMSetSliderAction(panel->grayBrightnessS, grayBrightnessSliderCallback, - panel); - + WMSetSliderAction(panel->grayBrightnessS, grayBrightnessSliderCallback, + panel); + from.red = 0; from.green = 0; from.blue = 0; - + to.red = 255; to.green = 255; to.blue = 255; - + image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RReleaseImage(image); - + if (pixmap) - W_PaintText(W_VIEW(panel->grayBrightnessS), pixmap->pixmap, - panel->font12, 2, 0, 100, WALeft, scrPtr->white, - False, _("Brightness"), strlen(_("Brightness"))); + W_PaintText(W_VIEW(panel->grayBrightnessS), pixmap->pixmap, + panel->font12, 2, 0, 100, WALeft, scrPtr->white, + False, _("Brightness"), strlen(_("Brightness"))); else - wwarning(_("Color Panel: Could not allocate memory")); + wwarning(_("Color Panel: Could not allocate memory")); WMSetSliderImage(panel->grayBrightnessS, pixmap); WMReleasePixmap(pixmap); - + panel->grayBrightnessT = WMCreateTextField(panel->grayFrm); WMResizeWidget(panel->grayBrightnessT, 40, 18); WMMoveWidget(panel->grayBrightnessT, 146, 13); WMSetTextFieldAlignment(panel->grayBrightnessT, WALeft); WMAddNotificationObserver(grayBrightnessTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->grayBrightnessT); - + WMTextDidEndEditingNotification, panel->grayBrightnessT); + for (i=0; i < 7; i++) { - pixmap = WMCreatePixmap(scrPtr, 13, 13, scrPtr->depth, False); - - graybuttoncolor = WMCreateRGBColor(scrPtr, (255/6)*i << 8, - (255/6)*i << 8, (255/6)*i << 8, True); - WMPaintColorSwatch(graybuttoncolor, pixmap->pixmap, 0, 0, 15, 15); - WMReleaseColor(graybuttoncolor); - - panel->grayPresetBtn[i] = WMCreateCommandButton(panel->grayFrm); - WMResizeWidget(panel->grayPresetBtn[i], 20, 24); - WMMoveWidget(panel->grayPresetBtn[i], 2+(i*20), 34); - WMSetButtonAction(panel->grayPresetBtn[i], - grayPresetButtonCallback, panel); - WMSetButtonImage(panel->grayPresetBtn[i], pixmap); - WMSetButtonImagePosition(panel->grayPresetBtn[i], WIPImageOnly); - WMReleasePixmap(pixmap); + pixmap = WMCreatePixmap(scrPtr, 13, 13, scrPtr->depth, False); + + graybuttoncolor = WMCreateRGBColor(scrPtr, (255/6)*i << 8, + (255/6)*i << 8, (255/6)*i << 8, True); + WMPaintColorSwatch(graybuttoncolor, pixmap->pixmap, 0, 0, 15, 15); + WMReleaseColor(graybuttoncolor); + + panel->grayPresetBtn[i] = WMCreateCommandButton(panel->grayFrm); + WMResizeWidget(panel->grayPresetBtn[i], 20, 24); + WMMoveWidget(panel->grayPresetBtn[i], 2+(i*20), 34); + WMSetButtonAction(panel->grayPresetBtn[i], + grayPresetButtonCallback, panel); + WMSetButtonImage(panel->grayPresetBtn[i], pixmap); + WMSetButtonImagePosition(panel->grayPresetBtn[i], WIPImageOnly); + WMReleasePixmap(pixmap); } - + /* End of GrayScale Panel */ - + /* Widgets for RGB Panel */ panel->rgbFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->rgbFrm, WRFlat); WMResizeWidget(panel->rgbFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->rgbFrm, 0, 34); - + panel->rgbMinL = WMCreateLabel(panel->rgbFrm); WMResizeWidget(panel->rgbMinL, 20, 10); WMMoveWidget(panel->rgbMinL, 2, 2); @@ -655,7 +655,7 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetLabelTextAlignment(panel->rgbMinL, WALeft); WMSetLabelTextColor(panel->rgbMinL, textcolor); WMSetLabelFont(panel->rgbMinL, panel->font8); - + panel->rgbMaxL = WMCreateLabel(panel->rgbFrm); WMResizeWidget(panel->rgbMaxL, 40, 10); WMMoveWidget(panel->rgbMaxL, 104, 2); @@ -663,7 +663,7 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetLabelTextAlignment(panel->rgbMaxL, WARight); WMSetLabelTextColor(panel->rgbMaxL, textcolor); WMSetLabelFont(panel->rgbMaxL, panel->font8); - + panel->rgbRedS = WMCreateSlider(panel->rgbFrm); WMResizeWidget(panel->rgbRedS, 141, 16); WMMoveWidget(panel->rgbRedS, 2, 14); @@ -671,32 +671,32 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderMaxValue(panel->rgbRedS, 255); WMSetSliderKnobThickness(panel->rgbRedS, knobThickness); WMSetSliderAction(panel->rgbRedS, rgbSliderCallback, panel); - + to.red = 255; to.green = 0; to.blue = 0; - + image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RReleaseImage(image); if (pixmap) - W_PaintText(W_VIEW(panel->rgbRedS), pixmap->pixmap, panel->font12, + W_PaintText(W_VIEW(panel->rgbRedS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, scrPtr->white, False, _("Red"), strlen(_("Red"))); else - wwarning(_("Color Panel: Could not allocate memory")); + wwarning(_("Color Panel: Could not allocate memory")); WMSetSliderImage(panel->rgbRedS, pixmap); WMReleasePixmap(pixmap); - + panel->rgbRedT = WMCreateTextField(panel->rgbFrm); WMResizeWidget(panel->rgbRedT, 40, 18); WMMoveWidget(panel->rgbRedT, 146, 13); WMSetTextFieldAlignment(panel->rgbRedT, WALeft); WMAddNotificationObserver(rgbTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->rgbRedT); - + WMTextDidEndEditingNotification, panel->rgbRedT); + panel->rgbGreenS = WMCreateSlider(panel->rgbFrm); WMResizeWidget(panel->rgbGreenS, 141, 16); WMMoveWidget(panel->rgbGreenS, 2, 36); @@ -704,33 +704,33 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderMaxValue(panel->rgbGreenS, 255); WMSetSliderKnobThickness(panel->rgbGreenS, knobThickness); WMSetSliderAction(panel->rgbGreenS, rgbSliderCallback, panel); - + to.red = 0; to.green = 255; to.blue = 0; - + image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RReleaseImage(image); if (pixmap) - W_PaintText(W_VIEW(panel->rgbGreenS), pixmap->pixmap, panel->font12, + W_PaintText(W_VIEW(panel->rgbGreenS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, scrPtr->white, False, _("Green"), strlen(_("Green"))); else - wwarning(_("Color Panel: Could not allocate memory")); - + wwarning(_("Color Panel: Could not allocate memory")); + WMSetSliderImage(panel->rgbGreenS, pixmap); WMReleasePixmap(pixmap); - + panel->rgbGreenT = WMCreateTextField(panel->rgbFrm); WMResizeWidget(panel->rgbGreenT, 40, 18); WMMoveWidget(panel->rgbGreenT, 146, 35); WMSetTextFieldAlignment(panel->rgbGreenT, WALeft); WMAddNotificationObserver(rgbTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->rgbGreenT); - - + WMTextDidEndEditingNotification, panel->rgbGreenT); + + panel->rgbBlueS = WMCreateSlider(panel->rgbFrm); WMResizeWidget(panel->rgbBlueS, 141, 16); WMMoveWidget(panel->rgbBlueS, 2, 58); @@ -738,39 +738,39 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderMaxValue(panel->rgbBlueS, 255); WMSetSliderKnobThickness(panel->rgbBlueS, knobThickness); WMSetSliderAction(panel->rgbBlueS, rgbSliderCallback, panel); - + to.red = 0; to.green = 0; to.blue = 255; - + image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RReleaseImage(image); if (pixmap) - W_PaintText(W_VIEW(panel->rgbBlueS), pixmap->pixmap, panel->font12, + W_PaintText(W_VIEW(panel->rgbBlueS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, scrPtr->white, False, _("Blue"), strlen(_("Blue"))); else - wwarning(_("Color Panel: Could not allocate memory")); - + wwarning(_("Color Panel: Could not allocate memory")); + WMSetSliderImage(panel->rgbBlueS, pixmap); WMReleasePixmap(pixmap); - + panel->rgbBlueT = WMCreateTextField(panel->rgbFrm); WMResizeWidget(panel->rgbBlueT, 40, 18); WMMoveWidget(panel->rgbBlueT, 146, 57); WMSetTextFieldAlignment(panel->rgbBlueT, WALeft); WMAddNotificationObserver(rgbTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->rgbBlueT); + WMTextDidEndEditingNotification, panel->rgbBlueT); /* End of RGB Panel */ - + /* Widgets for CMYK Panel */ panel->cmykFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->cmykFrm, WRFlat); WMResizeWidget(panel->cmykFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->cmykFrm, 0, 34); - + panel->cmykMinL = WMCreateLabel(panel->cmykFrm); WMResizeWidget(panel->cmykMinL, 20, 10); WMMoveWidget(panel->cmykMinL, 2, 2); @@ -778,7 +778,7 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetLabelTextAlignment(panel->cmykMinL, WALeft); WMSetLabelTextColor(panel->cmykMinL, textcolor); WMSetLabelFont(panel->cmykMinL, panel->font8); - + panel->cmykMaxL = WMCreateLabel(panel->cmykFrm); WMResizeWidget(panel->cmykMaxL, 40, 10); WMMoveWidget(panel->cmykMaxL, 104, 2); @@ -786,7 +786,7 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetLabelTextAlignment(panel->cmykMaxL, WARight); WMSetLabelTextColor(panel->cmykMaxL, textcolor); WMSetLabelFont(panel->cmykMaxL, panel->font8); - + panel->cmykCyanS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykCyanS, 141, 16); WMMoveWidget(panel->cmykCyanS, 2, 14); @@ -794,37 +794,37 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderMaxValue(panel->cmykCyanS, 100); WMSetSliderKnobThickness(panel->cmykCyanS, knobThickness); WMSetSliderAction(panel->cmykCyanS, cmykSliderCallback, panel); - + from.red = 255; from.green = 255; from.blue = 255; - + to.red = 0; to.green = 255; to.blue = 255; - + image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RReleaseImage(image); if (pixmap) - W_PaintText(W_VIEW(panel->cmykCyanS), pixmap->pixmap, panel->font12, + W_PaintText(W_VIEW(panel->cmykCyanS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, scrPtr->black, False, _("Cyan"), strlen(_("Cyan"))); else - wwarning(_("Color Panel: Could not allocate memory")); - + wwarning(_("Color Panel: Could not allocate memory")); + WMSetSliderImage(panel->cmykCyanS, pixmap); WMReleasePixmap(pixmap); - + panel->cmykCyanT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykCyanT, 40, 18); WMMoveWidget(panel->cmykCyanT, 146, 13); WMSetTextFieldAlignment(panel->cmykCyanT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->cmykCyanT); - - + WMTextDidEndEditingNotification, panel->cmykCyanT); + + panel->cmykMagentaS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykMagentaS, 141, 16); WMMoveWidget(panel->cmykMagentaS, 2, 36); @@ -832,33 +832,33 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderMaxValue(panel->cmykMagentaS, 100); WMSetSliderKnobThickness(panel->cmykMagentaS, knobThickness); WMSetSliderAction(panel->cmykMagentaS, cmykSliderCallback, panel); - + to.red = 255; to.green = 0; to.blue = 255; - + image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RReleaseImage(image); if (pixmap) - W_PaintText(W_VIEW(panel->cmykMagentaS), pixmap->pixmap, panel->font12, + W_PaintText(W_VIEW(panel->cmykMagentaS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, scrPtr->black, False, _("Magenta"), strlen(_("Magenta"))); else - wwarning(_("Color Panel: Could not allocate memory")); + wwarning(_("Color Panel: Could not allocate memory")); WMSetSliderImage(panel->cmykMagentaS, pixmap); WMReleasePixmap(pixmap); - + panel->cmykMagentaT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykMagentaT, 40, 18); WMMoveWidget(panel->cmykMagentaT, 146, 35); WMSetTextFieldAlignment(panel->cmykMagentaT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->cmykMagentaT); - - + WMTextDidEndEditingNotification, panel->cmykMagentaT); + + panel->cmykYellowS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykYellowS, 141, 16); WMMoveWidget(panel->cmykYellowS, 2, 58); @@ -866,33 +866,33 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderMaxValue(panel->cmykYellowS, 100); WMSetSliderKnobThickness(panel->cmykYellowS, knobThickness); WMSetSliderAction(panel->cmykYellowS, cmykSliderCallback, panel); - + to.red = 255; to.green = 255; to.blue = 0; - + image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RReleaseImage(image); if (pixmap) - W_PaintText(W_VIEW(panel->cmykYellowS), pixmap->pixmap, panel->font12, + W_PaintText(W_VIEW(panel->cmykYellowS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, scrPtr->black, False, _("Yellow"), strlen(_("Yellow"))); else - wwarning(_("Color Panel: Could not allocate memory")); - + wwarning(_("Color Panel: Could not allocate memory")); + WMSetSliderImage(panel->cmykYellowS, pixmap); WMReleasePixmap(pixmap); - + panel->cmykYellowT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykYellowT, 40, 18); WMMoveWidget(panel->cmykYellowT, 146, 57); WMSetTextFieldAlignment(panel->cmykYellowT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->cmykYellowT); - - + WMTextDidEndEditingNotification, panel->cmykYellowT); + + panel->cmykBlackS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykBlackS, 141, 16); WMMoveWidget(panel->cmykBlackS, 2, 80); @@ -901,39 +901,39 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderValue(panel->cmykBlackS, 0); WMSetSliderKnobThickness(panel->cmykBlackS, knobThickness); WMSetSliderAction(panel->cmykBlackS, cmykSliderCallback, panel); - + to.red = 0; to.green = 0; to.blue = 0; - + image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RReleaseImage(image); if (pixmap) - W_PaintText(W_VIEW(panel->cmykBlackS), pixmap->pixmap, panel->font12, + W_PaintText(W_VIEW(panel->cmykBlackS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, scrPtr->black, False, _("Black"), strlen(_("Black"))); else - wwarning(_("Color Panel: Could not allocate memory")); + wwarning(_("Color Panel: Could not allocate memory")); WMSetSliderImage(panel->cmykBlackS, pixmap); WMReleasePixmap(pixmap); - + panel->cmykBlackT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykBlackT, 40, 18); WMMoveWidget(panel->cmykBlackT, 146, 79); WMSetTextFieldAlignment(panel->cmykBlackT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->cmykBlackT); + WMTextDidEndEditingNotification, panel->cmykBlackT); /* End of CMYK Panel */ - + /* Widgets for HSB Panel */ panel->hsbFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->hsbFrm, WRFlat); WMResizeWidget(panel->hsbFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->hsbFrm, 0, 34); - + panel->hsbHueS = WMCreateSlider(panel->hsbFrm); WMResizeWidget(panel->hsbHueS, 141, 16); WMMoveWidget(panel->hsbHueS, 2, 14); @@ -941,15 +941,15 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderMaxValue(panel->hsbHueS, 359); WMSetSliderKnobThickness(panel->hsbHueS, knobThickness); WMSetSliderAction(panel->hsbHueS, hsbSliderCallback, panel); - + panel->hsbHueT = WMCreateTextField(panel->hsbFrm); WMResizeWidget(panel->hsbHueT, 40, 18); WMMoveWidget(panel->hsbHueT, 146, 13); WMSetTextFieldAlignment(panel->hsbHueT, WALeft); WMAddNotificationObserver(hsbTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->hsbHueT); - - + WMTextDidEndEditingNotification, panel->hsbHueT); + + panel->hsbSaturationS = WMCreateSlider(panel->hsbFrm); WMResizeWidget(panel->hsbSaturationS, 141, 16); WMMoveWidget(panel->hsbSaturationS, 2, 36); @@ -957,15 +957,15 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderMaxValue(panel->hsbSaturationS, 100); WMSetSliderKnobThickness(panel->hsbSaturationS, knobThickness); WMSetSliderAction(panel->hsbSaturationS, hsbSliderCallback, panel); - + panel->hsbSaturationT = WMCreateTextField(panel->hsbFrm); WMResizeWidget(panel->hsbSaturationT, 40, 18); WMMoveWidget(panel->hsbSaturationT, 146, 35); WMSetTextFieldAlignment(panel->hsbSaturationT, WALeft); WMAddNotificationObserver(hsbTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->hsbSaturationT); - - + WMTextDidEndEditingNotification, panel->hsbSaturationT); + + panel->hsbBrightnessS = WMCreateSlider(panel->hsbFrm); WMResizeWidget(panel->hsbBrightnessS, 141, 16); WMMoveWidget(panel->hsbBrightnessS, 2, 58); @@ -973,138 +973,138 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMSetSliderMaxValue(panel->hsbBrightnessS, 100); WMSetSliderKnobThickness(panel->hsbBrightnessS, knobThickness); WMSetSliderAction(panel->hsbBrightnessS, hsbSliderCallback, panel); - + panel->hsbBrightnessT = WMCreateTextField(panel->hsbFrm); WMResizeWidget(panel->hsbBrightnessT, 40, 18); WMMoveWidget(panel->hsbBrightnessT, 146, 57); WMSetTextFieldAlignment(panel->hsbBrightnessT, WALeft); WMAddNotificationObserver(hsbTextFieldCallback, panel, - WMTextDidEndEditingNotification, panel->hsbBrightnessT); + WMTextDidEndEditingNotification, panel->hsbBrightnessT); /* End of HSB Panel */ - - + + WMReleaseColor(textcolor); - + /* Widgets for the CustomPalette Panel */ panel->customPaletteFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->customPaletteFrm, WRFlat); WMResizeWidget(panel->customPaletteFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->customPaletteFrm, 5, 80); - + panel->customPaletteHistoryBtn = WMCreatePopUpButton( - panel->customPaletteFrm); + panel->customPaletteFrm); WMAddPopUpButtonItem(panel->customPaletteHistoryBtn, _("Spectrum")); - WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, - WMGetPopUpButtonNumberOfItems(panel->customPaletteHistoryBtn)-1); - WMSetPopUpButtonAction(panel->customPaletteHistoryBtn, - customPaletteHistoryCallback, panel); + WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, + WMGetPopUpButtonNumberOfItems(panel->customPaletteHistoryBtn)-1); + WMSetPopUpButtonAction(panel->customPaletteHistoryBtn, + customPaletteHistoryCallback, panel); WMResizeWidget(panel->customPaletteHistoryBtn, PWIDTH - 8, 20); WMMoveWidget(panel->customPaletteHistoryBtn, 0, 0); - + panel->customPaletteContentFrm = WMCreateFrame(panel->customPaletteFrm); WMSetFrameRelief(panel->customPaletteContentFrm, WRSunken); WMResizeWidget(panel->customPaletteContentFrm, PWIDTH - 8, PHEIGHT - 156); WMMoveWidget(panel->customPaletteContentFrm, 0, 23); - + panel->customPaletteContentView = W_CreateView( - W_VIEW(panel->customPaletteContentFrm)); + W_VIEW(panel->customPaletteContentFrm)); /* XXX Test if we can create a view */ - W_ResizeView(panel->customPaletteContentView, customPaletteWidth, - customPaletteHeight); + W_ResizeView(panel->customPaletteContentView, customPaletteWidth, + customPaletteHeight); W_MoveView(panel->customPaletteContentView, 2, 2); - + /* Create event handler to handle expose/click events in CustomPalette */ - WMCreateEventHandler(panel->customPaletteContentView, - ButtonPressMask|ButtonReleaseMask|EnterWindowMask| LeaveWindowMask | - ButtonMotionMask, customPaletteHandleActionEvents, panel); - - WMCreateEventHandler(panel->customPaletteContentView, ExposureMask, - customPaletteHandleEvents, panel); - + WMCreateEventHandler(panel->customPaletteContentView, + ButtonPressMask|ButtonReleaseMask|EnterWindowMask| LeaveWindowMask | + ButtonMotionMask, customPaletteHandleActionEvents, panel); + + WMCreateEventHandler(panel->customPaletteContentView, ExposureMask, + customPaletteHandleEvents, panel); + panel->customPaletteMenuBtn = WMCreatePopUpButton(panel->customPaletteFrm); WMSetPopUpButtonPullsDown(panel->customPaletteMenuBtn, 1); WMSetPopUpButtonText(panel->customPaletteMenuBtn, _("Palette")); - WMSetPopUpButtonAction(panel->customPaletteMenuBtn, - customPaletteMenuCallback, panel); + WMSetPopUpButtonAction(panel->customPaletteMenuBtn, + customPaletteMenuCallback, panel); WMResizeWidget(panel->customPaletteMenuBtn, PWIDTH - 8, 20); WMMoveWidget(panel->customPaletteMenuBtn, 0, PHEIGHT - 130); - + WMAddPopUpButtonItem(panel->customPaletteMenuBtn, _("New from File...")); WMAddPopUpButtonItem(panel->customPaletteMenuBtn, _("Rename...")); WMAddPopUpButtonItem(panel->customPaletteMenuBtn, _("Remove")); WMAddPopUpButtonItem(panel->customPaletteMenuBtn, _("Copy")); WMAddPopUpButtonItem(panel->customPaletteMenuBtn, _("New from Clipboard")); - + WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRename, 0); WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRemove, 0); WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuCopy, 0); - WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, - CPmenuNewFromClipboard, 0); - + WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, + CPmenuNewFromClipboard, 0); + customRenderSpectrum(panel); panel->currentPalette = 0; panel->palx = customPaletteWidth/2; panel->paly = customPaletteHeight/2; - + /* Widgets for the ColorList Panel */ panel->colorListFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->colorListFrm, WRFlat); WMResizeWidget(panel->colorListFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->colorListFrm, 5, 80); - + panel->colorListHistoryBtn = WMCreatePopUpButton(panel->colorListFrm); WMAddPopUpButtonItem(panel->colorListHistoryBtn, _("X11-Colors")); - WMSetPopUpButtonSelectedItem(panel->colorListHistoryBtn, - WMGetPopUpButtonNumberOfItems(panel->colorListHistoryBtn)-1); - /* WMSetPopUpButtonAction(panel->colorListHistoryBtn, - * colorListHistoryCallback, panel); */ + WMSetPopUpButtonSelectedItem(panel->colorListHistoryBtn, + WMGetPopUpButtonNumberOfItems(panel->colorListHistoryBtn)-1); + /* WMSetPopUpButtonAction(panel->colorListHistoryBtn, + * colorListHistoryCallback, panel); */ WMResizeWidget(panel->colorListHistoryBtn, PWIDTH - 8, 20); WMMoveWidget(panel->colorListHistoryBtn, 0, 0); - + panel->colorListContentLst = WMCreateList(panel->colorListFrm); WMSetListAction(panel->colorListContentLst, colorListSelect, panel); WMSetListUserDrawProc(panel->colorListContentLst, colorListPaintItem); WMResizeWidget(panel->colorListContentLst, PWIDTH - 8, PHEIGHT - 156); WMMoveWidget(panel->colorListContentLst, 0, 23); WMHangData(panel->colorListContentLst, panel); - + panel->colorListColorMenuBtn = WMCreatePopUpButton(panel->colorListFrm); WMSetPopUpButtonPullsDown(panel->colorListColorMenuBtn, 1); WMSetPopUpButtonText(panel->colorListColorMenuBtn, _("Color")); - WMSetPopUpButtonAction(panel->colorListColorMenuBtn, - colorListColorMenuCallback, panel); + WMSetPopUpButtonAction(panel->colorListColorMenuBtn, + colorListColorMenuCallback, panel); WMResizeWidget(panel->colorListColorMenuBtn, (PWIDTH - 16)/2, 20); WMMoveWidget(panel->colorListColorMenuBtn, 0, PHEIGHT - 130); - + WMAddPopUpButtonItem(panel->colorListColorMenuBtn, _("Add...")); WMAddPopUpButtonItem(panel->colorListColorMenuBtn, _("Rename...")); WMAddPopUpButtonItem(panel->colorListColorMenuBtn, _("Remove")); - + WMSetPopUpButtonItemEnabled(panel->colorListColorMenuBtn, CLmenuAdd, 0); WMSetPopUpButtonItemEnabled(panel->colorListColorMenuBtn, CLmenuRename, 0); WMSetPopUpButtonItemEnabled(panel->colorListColorMenuBtn, CLmenuRemove, 0); - + panel->colorListListMenuBtn = WMCreatePopUpButton(panel->colorListFrm); WMSetPopUpButtonPullsDown(panel->colorListListMenuBtn, 1); WMSetPopUpButtonText(panel->colorListListMenuBtn, _("List")); - WMSetPopUpButtonAction(panel->colorListListMenuBtn, - colorListListMenuCallback, panel); + WMSetPopUpButtonAction(panel->colorListListMenuBtn, + colorListListMenuCallback, panel); WMResizeWidget(panel->colorListListMenuBtn, (PWIDTH - 16)/2, 20); - WMMoveWidget(panel->colorListListMenuBtn, (PWIDTH - 16)/2 + 8, - PHEIGHT - 130); - + WMMoveWidget(panel->colorListListMenuBtn, (PWIDTH - 16)/2 + 8, + PHEIGHT - 130); + WMAddPopUpButtonItem(panel->colorListListMenuBtn, _("New...")); WMAddPopUpButtonItem(panel->colorListListMenuBtn, _("Rename...")); WMAddPopUpButtonItem(panel->colorListListMenuBtn, _("Remove")); - + WMSetPopUpButtonItemEnabled(panel->colorListListMenuBtn, CLmenuAdd, 0); WMSetPopUpButtonItemEnabled(panel->colorListListMenuBtn, CLmenuRename, 0); WMSetPopUpButtonItemEnabled(panel->colorListListMenuBtn, CLmenuRemove, 0); - + WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win); - + WMMapSubwidgets(panel->wheelFrm); WMMapSubwidgets(panel->slidersFrm); WMMapSubwidgets(panel->grayFrm); @@ -1114,18 +1114,18 @@ makeColorPanel(WMScreen *scrPtr, char *name) WMMapSubwidgets(panel->customPaletteFrm); WMMapSubwidgets(panel->customPaletteContentFrm); WMMapSubwidgets(panel->colorListFrm); - + /* Pixmap to indicate selection positions * wheelframe MUST be mapped. */ panel->selectionImg = XCreatePixmap(scrPtr->display, - WMWidgetXID(panel->win), 4, 4, scrPtr->depth); + WMWidgetXID(panel->win), 4, 4, scrPtr->depth); XFillRectangle(scrPtr->display, panel->selectionImg, bgc, 0, 0, 4, 4); XFillRectangle(scrPtr->display, panel->selectionImg, wgc, 1, 1, 2, 2); - + readConfiguration(panel); readXColors(panel); - + return panel; } @@ -1134,14 +1134,14 @@ WMColorPanel* WMGetColorPanel(WMScreen *scrPtr) { WMColorPanel *panel; - + if (scrPtr->sharedColorPanel) - return scrPtr->sharedColorPanel; - + return scrPtr->sharedColorPanel; + panel = makeColorPanel(scrPtr, "colorPanel"); - + scrPtr->sharedColorPanel = panel; - + return panel; } @@ -1150,39 +1150,39 @@ void WMFreeColorPanel(WMColorPanel *panel) { W_Screen *scr = WMWidgetScreen(panel->win); - + if (panel == scr->sharedColorPanel) { - scr->sharedColorPanel = NULL; + scr->sharedColorPanel = NULL; } - + if (!panel) - return; - + return; + WMRemoveNotificationObserver(panel); WMUnmapWidget(panel->win); - + /* fonts */ - WMReleaseFont(panel->font8); - WMReleaseFont(panel->font12); - + WMReleaseFont(panel->font8); + WMReleaseFont(panel->font12); + /* pixmaps */ - wheelDestroyMatrix(panel->wheelMtrx); + wheelDestroyMatrix(panel->wheelMtrx); if (panel->wheelImg) - XFreePixmap(scr->display, panel->wheelImg); + XFreePixmap(scr->display, panel->wheelImg); if (panel->selectionImg) - XFreePixmap(scr->display, panel->selectionImg); + XFreePixmap(scr->display, panel->selectionImg); if (panel->selectionBackImg) - XFreePixmap(scr->display, panel->selectionBackImg); - RReleaseImage(panel->customPaletteImg); - + XFreePixmap(scr->display, panel->selectionBackImg); + RReleaseImage(panel->customPaletteImg); + /* structs */ if (panel->lastBrowseDir) - wfree(panel->lastBrowseDir); + wfree(panel->lastBrowseDir); if (panel->configurationPath) - wfree(panel->configurationPath); - + wfree(panel->configurationPath); + WMDestroyWidget(panel->win); - + wfree(panel); } @@ -1199,13 +1199,13 @@ WMShowColorPanel(WMColorPanel *panel) { WMScreen *scr = WMWidgetScreen(panel->win); WMColor *white = WMWhiteColor(scr); - + if (panel->color.set == cpNone) - WMSetColorPanelColor(panel, white); + WMSetColorPanelColor(panel, white); WMReleaseColor(white); - + if (panel->mode != WMWheelModeColorPanel) - WMPerformButtonClick(panel->wheelBtn); + WMPerformButtonClick(panel->wheelBtn); WMMapWidget(panel->win); } @@ -1215,7 +1215,7 @@ static void closeWindowCallback(WMWidget *w, void *data) { W_ColorPanel *panel = (W_ColorPanel*)data; - + WMCloseColorPanel(panel); } @@ -1224,48 +1224,48 @@ static void readConfiguration(W_ColorPanel *panel) { /* XXX Doesn't take care of "invalid" files */ - + DIR *dPtr; struct dirent *dp; struct stat stat_buf; int item; - + if (stat(panel->configurationPath, &stat_buf)!=0) { - if (mkdir(panel->configurationPath, - S_IRWXU|S_IRGRP|S_IROTH|S_IXGRP|S_IXOTH)!=0) { - wsyserror(_("Color Panel: Could not create directory %s needed" - " to store configurations"), panel->configurationPath); - WMSetPopUpButtonEnabled(panel->customPaletteMenuBtn, False); - WMSetPopUpButtonEnabled(panel->colorListColorMenuBtn, False); - WMSetPopUpButtonEnabled(panel->colorListListMenuBtn, False); - WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win, - _("File Error"), - _("Could not create ColorPanel configuration directory"), - _("OK"), NULL, NULL); - } - return; + if (mkdir(panel->configurationPath, + S_IRWXU|S_IRGRP|S_IROTH|S_IXGRP|S_IXOTH)!=0) { + wsyserror(_("Color Panel: Could not create directory %s needed" + " to store configurations"), panel->configurationPath); + WMSetPopUpButtonEnabled(panel->customPaletteMenuBtn, False); + WMSetPopUpButtonEnabled(panel->colorListColorMenuBtn, False); + WMSetPopUpButtonEnabled(panel->colorListListMenuBtn, False); + WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win, + _("File Error"), + _("Could not create ColorPanel configuration directory"), + _("OK"), NULL, NULL); + } + return; } - + if (!(dPtr = opendir(panel->configurationPath))) { - wwarning(_("Color Panel: Could not find file"), "%s", panel->configurationPath); - return; + wwarning(_("Color Panel: Could not find file"), "%s", panel->configurationPath); + return; } - + while ((dp = readdir(dPtr)) != NULL) { - unsigned int perm_mask; - char *path = wstrconcat(panel->configurationPath, - dp->d_name); - - if (dp->d_name[0] != '.') { - item = WMGetPopUpButtonNumberOfItems( - panel->customPaletteHistoryBtn); - WMAddPopUpButtonItem(panel->customPaletteHistoryBtn, dp->d_name); - - perm_mask = (access(path, R_OK) == 0); - WMSetPopUpButtonItemEnabled(panel->customPaletteHistoryBtn, - item, perm_mask); - } - wfree(path); + unsigned int perm_mask; + char *path = wstrconcat(panel->configurationPath, + dp->d_name); + + if (dp->d_name[0] != '.') { + item = WMGetPopUpButtonNumberOfItems( + panel->customPaletteHistoryBtn); + WMAddPopUpButtonItem(panel->customPaletteHistoryBtn, dp->d_name); + + perm_mask = (access(path, R_OK) == 0); + WMSetPopUpButtonItemEnabled(panel->customPaletteHistoryBtn, + item, perm_mask); + } + wfree(path); } (void)closedir(dPtr); } @@ -1281,28 +1281,28 @@ readXColors(W_ColorPanel *panel) char name[48]; RColor *color; WMListItem *item; - + if (stat(RGBTXT, &stat_buf) != 0) { - wsyserror(_("Color Panel: Could not find file"), " %s", RGBTXT); - return; + wsyserror(_("Color Panel: Could not find file"), " %s", RGBTXT); + return; } else { - if ((rgbtxt = fopen(RGBTXT, "rb"))) { - while (fgets(line, MAX_LENGTH, rgbtxt)) { - if (sscanf(line, "%d%d%d %[^\n]", &red, &green, &blue, name)) { - color = wmalloc(sizeof(RColor)); - color->red = (unsigned char)red; - color->green = (unsigned char)green; - color->blue = (unsigned char)blue; - item = WMAddListItem(panel->colorListContentLst, name); - item->clientData = (void *)color; - } - } - fclose(rgbtxt); - } - else { - wsyserror(_("Color Panel: Could not find file"), "%s", RGBTXT); - } + if ((rgbtxt = fopen(RGBTXT, "rb"))) { + while (fgets(line, MAX_LENGTH, rgbtxt)) { + if (sscanf(line, "%d%d%d %[^\n]", &red, &green, &blue, name)) { + color = wmalloc(sizeof(RColor)); + color->red = (unsigned char)red; + color->green = (unsigned char)green; + color->blue = (unsigned char)blue; + item = WMAddListItem(panel->colorListContentLst, name); + item->clientData = (void *)color; + } + } + fclose(rgbtxt); + } + else { + wsyserror(_("Color Panel: Could not find file"), "%s", RGBTXT); + } } } @@ -1313,83 +1313,83 @@ WMSetColorPanelPickerMode(WMColorPanel *panel, WMColorPanelMode mode) W_Screen *scr = WMWidgetScreen(panel->win); if (mode != WMWheelModeColorPanel) { - WMUnmapWidget(panel->wheelFrm); - if (panel->selectionBackImg) { - XFreePixmap(WMWidgetScreen(panel->win)->display, - panel->selectionBackImg); - panel->selectionBackImg = None; - } + WMUnmapWidget(panel->wheelFrm); + if (panel->selectionBackImg) { + XFreePixmap(WMWidgetScreen(panel->win)->display, + panel->selectionBackImg); + panel->selectionBackImg = None; + } } if (mode != WMGrayModeColorPanel) - WMUnmapWidget(panel->grayFrm); + WMUnmapWidget(panel->grayFrm); if (mode != WMRGBModeColorPanel) - WMUnmapWidget(panel->rgbFrm); + WMUnmapWidget(panel->rgbFrm); if (mode != WMCMYKModeColorPanel) - WMUnmapWidget(panel->cmykFrm); + WMUnmapWidget(panel->cmykFrm); if (mode != WMHSBModeColorPanel) - WMUnmapWidget(panel->hsbFrm); + WMUnmapWidget(panel->hsbFrm); if (mode != WMCustomPaletteModeColorPanel) { - WMUnmapWidget(panel->customPaletteFrm); - if (panel->selectionBackImg) { - XFreePixmap(WMWidgetScreen(panel->win)->display, - panel->selectionBackImg); - panel->selectionBackImg = None; - } + WMUnmapWidget(panel->customPaletteFrm); + if (panel->selectionBackImg) { + XFreePixmap(WMWidgetScreen(panel->win)->display, + panel->selectionBackImg); + panel->selectionBackImg = None; + } } if (mode != WMColorListModeColorPanel) - WMUnmapWidget(panel->colorListFrm); + WMUnmapWidget(panel->colorListFrm); if ((mode != WMGrayModeColorPanel) && (mode != WMRGBModeColorPanel) && - (mode != WMCMYKModeColorPanel) && (mode != WMHSBModeColorPanel)) - WMUnmapWidget(panel->slidersFrm); + (mode != WMCMYKModeColorPanel) && (mode != WMHSBModeColorPanel)) + WMUnmapWidget(panel->slidersFrm); else - panel->slidersmode = mode; - + panel->slidersmode = mode; + if (mode == WMWheelModeColorPanel) { - WMMapWidget(panel->wheelFrm); - WMSetButtonSelected(panel->wheelBtn, True); - if (panel->lastChanged != WMWheelModeColorPanel) - wheelInit(panel); - wheelRender(panel); - wheelPaint(panel); + WMMapWidget(panel->wheelFrm); + WMSetButtonSelected(panel->wheelBtn, True); + if (panel->lastChanged != WMWheelModeColorPanel) + wheelInit(panel); + wheelRender(panel); + wheelPaint(panel); } else if (mode == WMGrayModeColorPanel) { - WMMapWidget(panel->slidersFrm); - WMSetButtonSelected(panel->slidersBtn, True); - WMMapWidget(panel->grayFrm); - WMSetButtonSelected(panel->grayBtn, True); - WMSetButtonImage(panel->slidersBtn, scr->grayIcon); - if (panel->lastChanged != WMGrayModeColorPanel) - grayInit(panel); + WMMapWidget(panel->slidersFrm); + WMSetButtonSelected(panel->slidersBtn, True); + WMMapWidget(panel->grayFrm); + WMSetButtonSelected(panel->grayBtn, True); + WMSetButtonImage(panel->slidersBtn, scr->grayIcon); + if (panel->lastChanged != WMGrayModeColorPanel) + grayInit(panel); } else if (mode == WMRGBModeColorPanel) { - WMMapWidget(panel->slidersFrm); - WMSetButtonSelected(panel->slidersBtn, True); - WMMapWidget(panel->rgbFrm); - WMSetButtonSelected(panel->rgbBtn, True); - WMSetButtonImage(panel->slidersBtn, scr->rgbIcon); - if (panel->lastChanged != WMRGBModeColorPanel) - rgbInit(panel); + WMMapWidget(panel->slidersFrm); + WMSetButtonSelected(panel->slidersBtn, True); + WMMapWidget(panel->rgbFrm); + WMSetButtonSelected(panel->rgbBtn, True); + WMSetButtonImage(panel->slidersBtn, scr->rgbIcon); + if (panel->lastChanged != WMRGBModeColorPanel) + rgbInit(panel); } else if (mode == WMCMYKModeColorPanel) { - WMMapWidget(panel->slidersFrm); - WMSetButtonSelected(panel->slidersBtn, True); - WMMapWidget(panel->cmykFrm); - WMSetButtonSelected(panel->cmykBtn, True); - WMSetButtonImage(panel->slidersBtn, scr->cmykIcon); - if (panel->lastChanged != WMCMYKModeColorPanel) - cmykInit(panel); + WMMapWidget(panel->slidersFrm); + WMSetButtonSelected(panel->slidersBtn, True); + WMMapWidget(panel->cmykFrm); + WMSetButtonSelected(panel->cmykBtn, True); + WMSetButtonImage(panel->slidersBtn, scr->cmykIcon); + if (panel->lastChanged != WMCMYKModeColorPanel) + cmykInit(panel); } else if (mode == WMHSBModeColorPanel) { - WMMapWidget(panel->slidersFrm); - WMSetButtonSelected(panel->slidersBtn, True); - WMMapWidget(panel->hsbFrm); - WMSetButtonSelected(panel->hsbBtn, True); - WMSetButtonImage(panel->slidersBtn, scr->hsbIcon); - if (panel->lastChanged != WMHSBModeColorPanel) - hsbInit(panel); + WMMapWidget(panel->slidersFrm); + WMSetButtonSelected(panel->slidersBtn, True); + WMMapWidget(panel->hsbFrm); + WMSetButtonSelected(panel->hsbBtn, True); + WMSetButtonImage(panel->slidersBtn, scr->hsbIcon); + if (panel->lastChanged != WMHSBModeColorPanel) + hsbInit(panel); } else if (mode == WMCustomPaletteModeColorPanel) { - WMMapWidget(panel->customPaletteFrm); - WMSetButtonSelected(panel->customPaletteBtn, True); - customSetPalette(panel); + WMMapWidget(panel->customPaletteFrm); + WMSetButtonSelected(panel->customPaletteBtn, True); + customSetPalette(panel); } else if (mode == WMColorListModeColorPanel) { - WMMapWidget(panel->colorListFrm); - WMSetButtonSelected(panel->colorListBtn, True); + WMMapWidget(panel->colorListFrm); + WMSetButtonSelected(panel->colorListBtn, True); } panel->mode = mode; @@ -1407,14 +1407,14 @@ void WMSetColorPanelColor(WMColorPanel *panel, WMColor *color) { WMSetColorWellColor(panel->colorWell, color); - + panel->color.rgb.red = color->color.red >> 8; panel->color.rgb.green = color->color.green >> 8; panel->color.rgb.blue = color->color.blue >> 8; panel->color.set = cpRGB; if (panel->mode == panel->lastChanged) - panel->lastChanged = 0; + panel->lastChanged = 0; WMSetColorPanelPickerMode(panel, panel->mode); } @@ -1425,25 +1425,25 @@ updateSwatch(WMColorPanel *panel, CPColor color) { WMScreen *scr = WMWidgetScreen(panel->win); WMColor *wellcolor; - + if (color.set != cpRGB) - convertCPColor(&color); + convertCPColor(&color); panel->color = color; - + wellcolor = WMCreateRGBColor(scr, color.rgb.red << 8, - color.rgb.green << 8, - color.rgb.blue << 8, True); - + color.rgb.green << 8, + color.rgb.blue << 8, True); + WMSetColorWellColor(panel->colorWell, wellcolor); WMReleaseColor(wellcolor); if (!panel->flags.dragging || panel->flags.continuous) { - if (panel->action) - (*panel->action)(panel, panel->clientData); + if (panel->action) + (*panel->action)(panel, panel->clientData); - WMPostNotificationName(WMColorPanelColorChangedNotification, panel, - NULL); + WMPostNotificationName(WMColorPanelColorChangedNotification, panel, + NULL); } } @@ -1451,57 +1451,57 @@ static void modeButtonCallback(WMWidget *w, void *data) { W_ColorPanel *panel = (W_ColorPanel*)(data); - + if (w == panel->wheelBtn) - WMSetColorPanelPickerMode(panel, WMWheelModeColorPanel); + WMSetColorPanelPickerMode(panel, WMWheelModeColorPanel); else if (w == panel->slidersBtn) - WMSetColorPanelPickerMode(panel, panel->slidersmode); + WMSetColorPanelPickerMode(panel, panel->slidersmode); else if (w == panel->customPaletteBtn) - WMSetColorPanelPickerMode(panel, WMCustomPaletteModeColorPanel); + WMSetColorPanelPickerMode(panel, WMCustomPaletteModeColorPanel); else if (w == panel->colorListBtn) - WMSetColorPanelPickerMode(panel, WMColorListModeColorPanel); + WMSetColorPanelPickerMode(panel, WMColorListModeColorPanel); else if (w == panel->grayBtn) - WMSetColorPanelPickerMode(panel, WMGrayModeColorPanel); + WMSetColorPanelPickerMode(panel, WMGrayModeColorPanel); else if (w == panel->rgbBtn) - WMSetColorPanelPickerMode(panel, WMRGBModeColorPanel); + WMSetColorPanelPickerMode(panel, WMRGBModeColorPanel); else if (w == panel->cmykBtn) - WMSetColorPanelPickerMode(panel, WMCMYKModeColorPanel); + WMSetColorPanelPickerMode(panel, WMCMYKModeColorPanel); else if (w == panel->hsbBtn) - WMSetColorPanelPickerMode(panel, WMHSBModeColorPanel); + WMSetColorPanelPickerMode(panel, WMHSBModeColorPanel); } /****************** Magnifying Cursor Functions *******************/ static XImage* -magnifyGetImage(WMScreen *scr, XImage *image, int x, int y, int w, int h) +magnifyGetImage(WMScreen *scr, XImage *image, int x, int y, int w, int h) { - int x0 = 0, y0 = 0, w0 = w, h0 = h; + int x0 = 0, y0 = 0, w0 = w, h0 = h; const int displayWidth = DisplayWidth(scr->display, scr->screen), - displayHeight = DisplayHeight(scr->display, scr->screen); - + displayHeight = DisplayHeight(scr->display, scr->screen); + if (!(image && image->data)) { - /* The image in panel->magnifyGlass->image does not exist yet. - * Grab one from the screen (not beyond) and use it from now on. - */ - if (!(image = XGetImage(scr->display, scr->rootWin, - x - Cursor_x_hot, - y - Cursor_y_hot, - w, h, AllPlanes, ZPixmap))) - wwarning(_("Color Panel: X failed request")); - - return image; + /* The image in panel->magnifyGlass->image does not exist yet. + * Grab one from the screen (not beyond) and use it from now on. + */ + if (!(image = XGetImage(scr->display, scr->rootWin, + x - Cursor_x_hot, + y - Cursor_y_hot, + w, h, AllPlanes, ZPixmap))) + wwarning(_("Color Panel: X failed request")); + + return image; } - - /* Coordinate correction for back pixmap - * if magnifying glass is at screen-borders + + /* Coordinate correction for back pixmap + * if magnifying glass is at screen-borders */ - + /* Figure 1: Shifting of rectangle-to-grab at top/left screen borders * Hatched area is beyond screen border. - * + * * |<-Cursor_x_hot->| - * ________________|_____ + * ________________|_____ * |/ / / / / / /| | | * | / / / / / / |(x,y) | * |/_/_/_/_/_/_/|________| @@ -1514,7 +1514,7 @@ magnifyGetImage(WMScreen *scr, XImage *image, int x, int y, int w, int h) * Hatched area is beyond screen border * * |<-Cursor_x_hot->| - * ________________|_______________ + * ________________|_______________ * | | | / / / / / /| * | (x,y)|/ / / / / / | * |___________________|_/_/_/_/_/_/| @@ -1523,38 +1523,38 @@ magnifyGetImage(WMScreen *scr, XImage *image, int x, int y, int w, int h) * | | * x0 Displaywidth-1 */ - + if (x < Cursor_x_hot) { /* see fig. 1 */ - x0 = Cursor_x_hot - x; - w0 = w - x0; + x0 = Cursor_x_hot - x; + w0 = w - x0; } - + if (displayWidth -1 < x - Cursor_x_hot + w) { /* see fig. 2 */ - w0 = (displayWidth) - (x - Cursor_x_hot); + w0 = (displayWidth) - (x - Cursor_x_hot); } - + if (y < Cursor_y_hot) { /* see fig. 1 */ - y0 = Cursor_y_hot - y; - h0 = h - y0; + y0 = Cursor_y_hot - y; + h0 = h - y0; } - + if (displayHeight -1 < y - Cursor_y_hot + h) { /* see fig. 2 */ - h0 = (displayHeight) - (y - Cursor_y_hot); + h0 = (displayHeight) - (y - Cursor_y_hot); } /* end of coordinate correction */ - - - /* Grab an image from the screen, clipped if necessary, + + + /* Grab an image from the screen, clipped if necessary, * and put it in the existing panel->magnifyGlass->image * with the corresponding clipping offset. */ - if (!XGetSubImage(scr->display, scr->rootWin, - x - Cursor_x_hot + x0, - y - Cursor_y_hot + y0, - w0, h0, AllPlanes, ZPixmap, - image, x0, y0)) - wwarning(_("Color Panel: X failed request")); - + if (!XGetSubImage(scr->display, scr->rootWin, + x - Cursor_x_hot + x0, + y - Cursor_y_hot + y0, + w0, h0, AllPlanes, ZPixmap, + image, x0, y0)) + wwarning(_("Color Panel: X failed request")); + return NULL; } @@ -1562,42 +1562,42 @@ magnifyGetImage(WMScreen *scr, XImage *image, int x, int y, int w, int h) static void magnifyGetImageStored(WMColorPanel *panel, int x1, int y1, int x2, int y2) { - /* (x1, y1) = topleft corner of existing rectangle + /* (x1, y1) = topleft corner of existing rectangle * (x2, y2) = topleft corner of new position */ - + W_Screen *scr = WMWidgetScreen(panel->win); int xa = 0, ya = 0, xb = 0, yb = 0; int width, height; const int dx = abs(x2 - x1), - dy = abs(y2 - y1); + dy = abs(y2 - y1); XImage *image; const int x_min = Cursor_x_hot, - y_min = Cursor_y_hot, - x_max = DisplayWidth(scr->display, scr->screen) -1 - - (Cursor_mask_width - Cursor_x_hot), - y_max = DisplayHeight(scr->display, scr->screen) -1 - - (Cursor_mask_height - Cursor_y_hot); + y_min = Cursor_y_hot, + x_max = DisplayWidth(scr->display, scr->screen) -1 - + (Cursor_mask_width - Cursor_x_hot), + y_max = DisplayHeight(scr->display, scr->screen) -1 - + (Cursor_mask_height - Cursor_y_hot); if ((dx == 0) && (dy == 0) && panel->magnifyGlass->image) - return; /* No movement */ - + return; /* No movement */ + if (x1 < x2) - xa = dx; + xa = dx; else - xb = dx; - + xb = dx; + if (y1 < y2) - ya = dy; + ya = dy; else - yb = dy; + yb = dy; width = Cursor_mask_width - dx; height = Cursor_mask_height - dy; - /* If the traversed distance is larger than the size of the magnifying + /* If the traversed distance is larger than the size of the magnifying * glass contents, there is no need to do dirty rectangles. A whole new - * rectangle can be grabbed (unless that rectangle falls partially + * rectangle can be grabbed (unless that rectangle falls partially * off screen). * Destroying the image and setting it to NULL will achieve that later on. * @@ -1606,50 +1606,50 @@ magnifyGetImageStored(WMColorPanel *panel, int x1, int y1, int x2, int y2) * is grabbed, but there is no need for dirty rectangles. */ if ((width <= 0) || (height <= 0)) { - if ((x2 >= x_min) && (y2 >= y_min) && (x2 <= x_max) && (y2 <= y_max)) { - if (panel->magnifyGlass->image) - XDestroyImage(panel->magnifyGlass->image); - panel->magnifyGlass->image = NULL; - } + if ((x2 >= x_min) && (y2 >= y_min) && (x2 <= x_max) && (y2 <= y_max)) { + if (panel->magnifyGlass->image) + XDestroyImage(panel->magnifyGlass->image); + panel->magnifyGlass->image = NULL; + } } else { - if (panel->magnifyGlass->image) { - /* Get dirty rectangle from panel->magnifyGlass->image */ - panel->magnifyGlass->dirtyRect = - XSubImage(panel->magnifyGlass->image, xa, ya, width, height); - if (!panel->magnifyGlass->dirtyRect) { - wwarning(_("Color Panel: X failed request")); - return; /* X returned a NULL from XSubImage */ - } - } + if (panel->magnifyGlass->image) { + /* Get dirty rectangle from panel->magnifyGlass->image */ + panel->magnifyGlass->dirtyRect = + XSubImage(panel->magnifyGlass->image, xa, ya, width, height); + if (!panel->magnifyGlass->dirtyRect) { + wwarning(_("Color Panel: X failed request")); + return; /* X returned a NULL from XSubImage */ + } + } } - + /* Get image from screen */ image = magnifyGetImage(scr, panel->magnifyGlass->image, x2, y2, - Cursor_mask_width, Cursor_mask_height); + Cursor_mask_width, Cursor_mask_height); if (image) { /* Only reassign if a *new* image was grabbed */ - panel->magnifyGlass->image = image; - return; + panel->magnifyGlass->image = image; + return; } /* Copy previously stored rectangle on covered part of image */ if (panel->magnifyGlass->image && panel->magnifyGlass->dirtyRect) { - int old_height; - - /* "width" and "height" are used as coordinates here, - * and run from [0...width-1] and [0...height-1] respectively. - */ - width--; - height--; - old_height = height; - - for (; width >= 0; width--) - for (height = old_height; height >= 0; height--) - XPutPixel(panel->magnifyGlass->image, xb + width, yb + height, - XGetPixel(panel->magnifyGlass->dirtyRect, width, height)); - XDestroyImage(panel->magnifyGlass->dirtyRect); - panel->magnifyGlass->dirtyRect = NULL; + int old_height; + + /* "width" and "height" are used as coordinates here, + * and run from [0...width-1] and [0...height-1] respectively. + */ + width--; + height--; + old_height = height; + + for (; width >= 0; width--) + for (height = old_height; height >= 0; height--) + XPutPixel(panel->magnifyGlass->image, xb + width, yb + height, + XGetPixel(panel->magnifyGlass->dirtyRect, width, height)); + XDestroyImage(panel->magnifyGlass->dirtyRect); + panel->magnifyGlass->dirtyRect = NULL; } - + return; } @@ -1663,55 +1663,55 @@ magnifyCreatePixmap(WMColorPanel *panel) Pixmap pixmap; #endif unsigned long color; - + if (!panel->magnifyGlass->image) - return None; - + return None; + if (!panel->magnifyGlass->magPix) - return None; - + return None; + /* - * Copy an area of only 5x5 pixels from the center of the image. + * Copy an area of only 5x5 pixels from the center of the image. */ for (u = 0; u < 5; u++) { - for (v = 0; v < 5; v++) { - color = XGetPixel(panel->magnifyGlass->image, u + 9, v + 9); - - XSetForeground(scr->display, scr->copyGC, color); - - if ((u == 2) && (v == 2)) /* (2,2) is center pixel (unmagn.) */ - panel->magnifyGlass->color = ulongToRColor(scr, color); - - /* The center square must eventually be centered around the - * hotspot. The image needs shifting to achieve this. The amount of - * shifting is (Cursor_mask_width/2 - 2 * square_size) = 11-10 = 1 - * _ _ _ _ _ - * |_|_|_|_|_| - * ^------- center of center square == Cursor_x_hot - */ - XFillRectangle(scr->display, panel->magnifyGlass->magPix, - scr->copyGC, - u * 5 + (u == 0 ? 0 : -1), v * 5 + (v == 0 ? 0 : -1), - (u == 0 ? 4 : 5), (v == 0 ? 4 : 5)); - } + for (v = 0; v < 5; v++) { + color = XGetPixel(panel->magnifyGlass->image, u + 9, v + 9); + + XSetForeground(scr->display, scr->copyGC, color); + + if ((u == 2) && (v == 2)) /* (2,2) is center pixel (unmagn.) */ + panel->magnifyGlass->color = ulongToRColor(scr, color); + + /* The center square must eventually be centered around the + * hotspot. The image needs shifting to achieve this. The amount of + * shifting is (Cursor_mask_width/2 - 2 * square_size) = 11-10 = 1 + * _ _ _ _ _ + * |_|_|_|_|_| + * ^------- center of center square == Cursor_x_hot + */ + XFillRectangle(scr->display, panel->magnifyGlass->magPix, + scr->copyGC, + u * 5 + (u == 0 ? 0 : -1), v * 5 + (v == 0 ? 0 : -1), + (u == 0 ? 4 : 5), (v == 0 ? 4 : 5)); + } } - + #ifdef SHAPE return panel->magnifyGlass->magPix; #else pixmap = XCreatePixmap(scr->display, W_DRAWABLE(scr), Cursor_mask_width, - Cursor_mask_height, scr->depth); + Cursor_mask_height, scr->depth); if (!pixmap) - return None; + return None; + + XPutImage(scr->display, pixmap, scr->copyGC, panel->magnifyGlass->image, + 0, 0, 0, 0, Cursor_mask_width, Cursor_mask_height); - XPutImage(scr->display, pixmap, scr->copyGC, panel->magnifyGlass->image, - 0, 0, 0, 0, Cursor_mask_width, Cursor_mask_height); - /* Copy the magnified pixmap, with the clip mask, to background pixmap */ XCopyArea(scr->display, panel->magnifyGlass->magPix, pixmap, - scr->clipGC, 0, 0, Cursor_mask_width, Cursor_mask_height, 0, 0); + scr->clipGC, 0, 0, Cursor_mask_width, Cursor_mask_height, 0, 0); /* (2,2) puts center pixel on center of glass */ - + return pixmap; #endif @@ -1723,21 +1723,21 @@ magnifyCreateView(W_ColorPanel *panel) { W_Screen *scr = WMWidgetScreen(panel->win); WMView *magView; - + magView = W_CreateTopView(scr); if (!magView) - return NULL; - + return NULL; + magView->self = panel->win; magView->flags.topLevel = 1; magView->attribFlags |= CWOverrideRedirect | CWSaveUnder; magView->attribs.override_redirect = True; magView->attribs.save_under = True; - + W_ResizeView(magView, Cursor_mask_width, Cursor_mask_height); - + W_RealizeView(magView); - + return magView; } @@ -1750,27 +1750,27 @@ magnifyGrabPointer(W_ColorPanel *panel) Cursor magCursor; XColor fgColor = {0, 0,0,0, DoRed|DoGreen|DoBlue}; XColor bgColor = {0, 0xbf00, 0xa000, 0x5000, DoRed|DoGreen|DoBlue}; - + /* Cursor creation stuff */ - magPixmap = XCreatePixmapFromBitmapData(scr->display, W_DRAWABLE(scr), - (char *)Cursor_bits, Cursor_width, Cursor_height, 1, 0, 1); + magPixmap = XCreatePixmapFromBitmapData(scr->display, W_DRAWABLE(scr), + (char *)Cursor_bits, Cursor_width, Cursor_height, 1, 0, 1); magPixmap2 = XCreatePixmapFromBitmapData(scr->display, W_DRAWABLE(scr), - (char *)Cursor_shape_bits, Cursor_width, Cursor_height, 1, 0, 1); - - magCursor = XCreatePixmapCursor(scr->display, magPixmap, magPixmap2, - &fgColor, &bgColor, Cursor_x_hot, Cursor_y_hot); - + (char *)Cursor_shape_bits, Cursor_width, Cursor_height, 1, 0, 1); + + magCursor = XCreatePixmapCursor(scr->display, magPixmap, magPixmap2, + &fgColor, &bgColor, Cursor_x_hot, Cursor_y_hot); + XFreePixmap(scr->display, magPixmap); XFreePixmap(scr->display, magPixmap2); - + XRecolorCursor(scr->display, magCursor, &fgColor, &bgColor); - + /* Set up Pointer */ - XGrabPointer (scr->display, panel->magnifyGlass->view->window, True, - PointerMotionMask | ButtonPressMask, - GrabModeAsync, GrabModeAsync, - scr->rootWin, magCursor, CurrentTime); - + XGrabPointer (scr->display, panel->magnifyGlass->view->window, True, + PointerMotionMask | ButtonPressMask, + GrabModeAsync, GrabModeAsync, + scr->rootWin, magCursor, CurrentTime); + return magCursor; } @@ -1786,20 +1786,20 @@ magnifyInitialize(W_ColorPanel *panel) Window root_return, child_return; clip_mask = XCreatePixmapFromBitmapData(scr->display, W_DRAWABLE(scr), - (char *)Cursor_mask_bits, Cursor_mask_width, Cursor_mask_height, - 1, 0, 1); - panel->magnifyGlass->magPix = XCreatePixmap(scr->display, W_DRAWABLE(scr), - 5*5 -1, 5*5 -1, scr->depth); - + (char *)Cursor_mask_bits, Cursor_mask_width, Cursor_mask_height, + 1, 0, 1); + panel->magnifyGlass->magPix = XCreatePixmap(scr->display, W_DRAWABLE(scr), + 5*5 -1, 5*5 -1, scr->depth); + XQueryPointer(scr->display, scr->rootWin, &root_return, &child_return, - &x, &y, &u, &v, &mask); - + &x, &y, &u, &v, &mask); + panel->magnifyGlass->image = NULL; - + /* Clipmask to make magnified view-contents circular */ #ifdef SHAPE XShapeCombineMask(scr->display, WMViewXID(panel->magnifyGlass->view), - ShapeBounding, 0, 0, clip_mask, ShapeSet); + ShapeBounding, 0, 0, clip_mask, ShapeSet); #else /* Clip circle in glass cursor */ XSetClipMask(scr->display, scr->clipGC, clip_mask); @@ -1807,24 +1807,24 @@ magnifyInitialize(W_ColorPanel *panel) #endif XFreePixmap(scr->display, clip_mask); - + /* Draw initial magnifying glass contents */ magnifyGetImageStored(panel, x, y, x, y); - + pixmap = magnifyCreatePixmap(panel); XSetWindowBackgroundPixmap(scr->display, - WMViewXID(panel->magnifyGlass->view), - pixmap); + WMViewXID(panel->magnifyGlass->view), + pixmap); XClearWindow(scr->display, WMViewXID(panel->magnifyGlass->view)); XFlush(scr->display); - -#ifndef SHAPE + +#ifndef SHAPE XFreePixmap(scr->display, pixmap); #endif - + point.x = x; point.y = y; - + return point; } @@ -1838,160 +1838,160 @@ magnifyPutCursor(WMWidget *w, void *data) Pixmap pixmap; XEvent event; WMPoint initialPosition; - + /* Destroy wheelBackImg, so it'll update properly */ if (panel->selectionBackImg) { - XFreePixmap(WMWidgetScreen(panel->win)->display, - panel->selectionBackImg); - panel->selectionBackImg = None; + XFreePixmap(WMWidgetScreen(panel->win)->display, + panel->selectionBackImg); + panel->selectionBackImg = None; } - + /* Create magnifying glass */ panel->magnifyGlass = wmalloc(sizeof(MovingView)); panel->magnifyGlass->view = magnifyCreateView(panel); if (!panel->magnifyGlass->view) - return; + return; initialPosition = magnifyInitialize(panel); panel->magnifyGlass->x = initialPosition.x; panel->magnifyGlass->y = initialPosition.y; - - W_MoveView(panel->magnifyGlass->view, - panel->magnifyGlass->x - Cursor_x_hot, - panel->magnifyGlass->y - Cursor_y_hot); + + W_MoveView(panel->magnifyGlass->view, + panel->magnifyGlass->x - Cursor_x_hot, + panel->magnifyGlass->y - Cursor_y_hot); W_MapView(panel->magnifyGlass->view); - + magCursor = magnifyGrabPointer(panel); - - while (panel->magnifyGlass->image) + + while (panel->magnifyGlass->image) { - WMNextEvent(scr->display, &event); + WMNextEvent(scr->display, &event); - /* Pack motion events */ + /* Pack motion events */ while (XCheckTypedEvent(scr->display, MotionNotify, &event)) { } - - switch (event.type) - { - case ButtonPress: - XDestroyImage(panel->magnifyGlass->image); - panel->magnifyGlass->image = NULL; - - if (event.xbutton.button == Button1) { - panel->color.rgb = panel->magnifyGlass->color; - panel->color.set = cpRGB; - updateSwatch(panel, panel->color); - } - switch (panel->mode) { - case WMWheelModeColorPanel: - wheelInit(panel); - wheelRender(panel); - wheelPaint(panel); - break; - case WMGrayModeColorPanel: - grayInit(panel); - break; - case WMRGBModeColorPanel: - rgbInit(panel); - break; - case WMCMYKModeColorPanel: - cmykInit(panel); - break; - case WMHSBModeColorPanel: - hsbInit(panel); - break; - default: - break; - } - panel->lastChanged = panel->mode; - - WMSetButtonSelected(panel->magnifyBtn, False); - break; - - case MotionNotify: - while (XPending(event.xmotion.display)) { - XEvent ev; - XPeekEvent(event.xmotion.display, &ev); - if (ev.type == MotionNotify) - XNextEvent(event.xmotion.display, &event); - else - break; - } - - /* Get a "dirty rectangle" */ - magnifyGetImageStored( panel, - panel->magnifyGlass->x, panel->magnifyGlass->y, - event.xmotion.x_root, event.xmotion.y_root); - - /* Update coordinates */ - panel->magnifyGlass->x = event.xmotion.x_root; - panel->magnifyGlass->y = event.xmotion.y_root; - - /* Move view */ - W_MoveView(panel->magnifyGlass->view, - panel->magnifyGlass->x - Cursor_x_hot, - panel->magnifyGlass->y - Cursor_y_hot); - - /* Put new image (with magn.) in view */ - pixmap = magnifyCreatePixmap(panel); - if (pixmap != None) { - /* Change the window background */ - XSetWindowBackgroundPixmap(scr->display, - WMViewXID(panel->magnifyGlass->view), pixmap); - /* Force an Expose (handled by X) */ - XClearWindow(scr->display, - WMViewXID(panel->magnifyGlass->view)); - /* Synchronize the event queue, so the Expose is handled NOW */ - XFlush(scr->display); -#ifndef SHAPE - XFreePixmap(scr->display, pixmap); + + switch (event.type) + { + case ButtonPress: + XDestroyImage(panel->magnifyGlass->image); + panel->magnifyGlass->image = NULL; + + if (event.xbutton.button == Button1) { + panel->color.rgb = panel->magnifyGlass->color; + panel->color.set = cpRGB; + updateSwatch(panel, panel->color); + } + switch (panel->mode) { + case WMWheelModeColorPanel: + wheelInit(panel); + wheelRender(panel); + wheelPaint(panel); + break; + case WMGrayModeColorPanel: + grayInit(panel); + break; + case WMRGBModeColorPanel: + rgbInit(panel); + break; + case WMCMYKModeColorPanel: + cmykInit(panel); + break; + case WMHSBModeColorPanel: + hsbInit(panel); + break; + default: + break; + } + panel->lastChanged = panel->mode; + + WMSetButtonSelected(panel->magnifyBtn, False); + break; + + case MotionNotify: + while (XPending(event.xmotion.display)) { + XEvent ev; + XPeekEvent(event.xmotion.display, &ev); + if (ev.type == MotionNotify) + XNextEvent(event.xmotion.display, &event); + else + break; + } + + /* Get a "dirty rectangle" */ + magnifyGetImageStored( panel, + panel->magnifyGlass->x, panel->magnifyGlass->y, + event.xmotion.x_root, event.xmotion.y_root); + + /* Update coordinates */ + panel->magnifyGlass->x = event.xmotion.x_root; + panel->magnifyGlass->y = event.xmotion.y_root; + + /* Move view */ + W_MoveView(panel->magnifyGlass->view, + panel->magnifyGlass->x - Cursor_x_hot, + panel->magnifyGlass->y - Cursor_y_hot); + + /* Put new image (with magn.) in view */ + pixmap = magnifyCreatePixmap(panel); + if (pixmap != None) { + /* Change the window background */ + XSetWindowBackgroundPixmap(scr->display, + WMViewXID(panel->magnifyGlass->view), pixmap); + /* Force an Expose (handled by X) */ + XClearWindow(scr->display, + WMViewXID(panel->magnifyGlass->view)); + /* Synchronize the event queue, so the Expose is handled NOW */ + XFlush(scr->display); +#ifndef SHAPE + XFreePixmap(scr->display, pixmap); #endif - } - break; + } + break; - /* Try XQueryPointer for this !!! It returns windows that the pointer - * is over. Note: We found this solving the invisible donkey cap bug - */ + /* Try XQueryPointer for this !!! It returns windows that the pointer + * is over. Note: We found this solving the invisible donkey cap bug + */ #if 0 /* As it is impossible to make this work in all cases, - * we consider it confusing. Therefore we disabled it. - */ - case FocusOut: /* fall through */ - case FocusIn: - /* - * Color Panel window (panel->win) lost or received focus. - * We need to update the pixmap in the magnifying glass. - * - * BUG Doesn't work with focus switches between two windows - * if none of them is the color panel. - */ - XUngrabPointer(scr->display, CurrentTime); - W_UnmapView(panel->magnifyGlass->view); - - magnifyInitialize(panel); - - W_MapView(panel->magnifyGlass->view); - XGrabPointer (scr->display, panel->magnifyGlass->view->window, - True, PointerMotionMask | ButtonPressMask, - GrabModeAsync, GrabModeAsync, - scr->rootWin, magCursor, CurrentTime); - break; -#endif - default: - WMHandleEvent(&event); - break; - } /* of switch */ + * we consider it confusing. Therefore we disabled it. + */ + case FocusOut: /* fall through */ + case FocusIn: + /* + * Color Panel window (panel->win) lost or received focus. + * We need to update the pixmap in the magnifying glass. + * + * BUG Doesn't work with focus switches between two windows + * if none of them is the color panel. + */ + XUngrabPointer(scr->display, CurrentTime); + W_UnmapView(panel->magnifyGlass->view); + + magnifyInitialize(panel); + + W_MapView(panel->magnifyGlass->view); + XGrabPointer (scr->display, panel->magnifyGlass->view->window, + True, PointerMotionMask | ButtonPressMask, + GrabModeAsync, GrabModeAsync, + scr->rootWin, magCursor, CurrentTime); + break; +#endif + default: + WMHandleEvent(&event); + break; + } /* of switch */ } - + XUngrabPointer(scr->display, CurrentTime); XFreeCursor(scr->display, magCursor); - + XFreePixmap(scr->display, panel->magnifyGlass->magPix); panel->magnifyGlass->magPix = None; W_UnmapView(panel->magnifyGlass->view); W_DestroyView(panel->magnifyGlass->view); panel->magnifyGlass->view = NULL; - + wfree(panel->magnifyGlass); } @@ -2004,18 +2004,18 @@ wheelCreateMatrix(unsigned int width, unsigned int height) { wheelMatrix *matrix = NULL; int i; - + assert((width > 0) && (height > 0)); - + matrix = wmalloc(sizeof(wheelMatrix)); memset(matrix, 0, sizeof(wheelMatrix)); matrix->width = width; matrix->height = height; for (i = 0; i < 3; i++) { - matrix->data[i] = wmalloc(width*height*sizeof(unsigned char)); + matrix->data[i] = wmalloc(width*height*sizeof(unsigned char)); } - + return matrix; } @@ -2024,13 +2024,13 @@ static void wheelDestroyMatrix(wheelMatrix *matrix) { int i; - + if (!matrix) - return; - + return; + for (i = 0; i < 3; i++) { - if (matrix->data[i]) - wfree(matrix->data[i]); + if (matrix->data[i]) + wfree(matrix->data[i]); } wfree(matrix); } @@ -2048,20 +2048,20 @@ wheelInitMatrix(W_ColorPanel *panel) unsigned short sat; int dhue[4]; const int cw_halfsize = (colorWheelSize + 4)/2, - cw_sqsize = (colorWheelSize +4) * (colorWheelSize +4), - uchar_shift = getShift(sizeof(unsigned char)); - + cw_sqsize = (colorWheelSize +4) * (colorWheelSize +4), + uchar_shift = getShift(sizeof(unsigned char)); + if (!panel->wheelMtrx) - return; - + return; + cpColor.hsv.value = 255; cpColor.set = cpHSV; - + ofs[0] = -1; ofs[1] = -(colorWheelSize + 4); - + /* offsets are counterclockwise (in triangles). - * + * * ofs[0] ----> * _______________________________________ * [1] |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| o @@ -2076,79 +2076,79 @@ wheelInitMatrix(W_ColorPanel *panel) * | /\ | * |/__\| */ - + for (y = 0; y < cw_halfsize; y++) { - for (x = y; x < (colorWheelSize+4-y); x++) { - /* (xcor, ycor) is (x,y) relative to center of matrix */ - xcor = 2 * x - 4 - colorWheelSize; - ycor = 2 * y - 4 - colorWheelSize; - - /* RColor.saturation is unsigned char and will wrap after 255 */ - sat = rint(255.0 * sqrt(xcor*xcor + ycor*ycor) / colorWheelSize); - - cpColor.hsv.saturation = (unsigned char)sat; - - ofs[0]++; /* top quarter of matrix*/ - ofs[1] += colorWheelSize + 4; /* left quarter */ - ofs[2] = cw_sqsize - 1 - ofs[0]; /* bottom quarter */ - ofs[3] = cw_sqsize - 1 - ofs[1]; /* right quarter */ - - if (sat < 256) { - if (xcor != 0) - dhue[0] = rint(atan((double)ycor / (double)xcor) * - (180.0 / M_PI)) + (xcor < 0 ? 180.0 : 0.0); - else - dhue[0] = 270; - - dhue[0] = 360 - dhue[0]; /* Reverse direction of ColorWheel */ - dhue[1] = 270 - dhue[0] + (dhue[0] > 270 ? 360 : 0); - dhue[2] = dhue[0] - 180 + (dhue[0] < 180 ? 360 : 0); - dhue[3] = 90 - dhue[0] + (dhue[0] > 90 ? 360 : 0); - - for (i = 0; i < 4; i++) { - rp = panel->wheelMtrx->data[0] + (ofs[i] << uchar_shift); - gp = panel->wheelMtrx->data[1] + (ofs[i] << uchar_shift); - bp = panel->wheelMtrx->data[2] + (ofs[i] << uchar_shift); - - cpColor.hsv.hue = dhue[i]; - convertCPColor(&cpColor); - - *rp = (unsigned char)(cpColor.rgb.red); - *gp = (unsigned char)(cpColor.rgb.green); - *bp = (unsigned char)(cpColor.rgb.blue); - } - } - else { - for (i = 0; i < 4; i++) { - rp = panel->wheelMtrx->data[0] + (ofs[i] << uchar_shift); - gp = panel->wheelMtrx->data[1] + (ofs[i] << uchar_shift); - bp = panel->wheelMtrx->data[2] + (ofs[i] << uchar_shift); - - *rp = (unsigned char)0; - *gp = (unsigned char)0; - *bp = (unsigned char)0; - } - } - } - - ofs[0] += 2*y+1; - ofs[1] += 1 - (colorWheelSize + 4) * (colorWheelSize + 4 - 1 - 2*y); + for (x = y; x < (colorWheelSize+4-y); x++) { + /* (xcor, ycor) is (x,y) relative to center of matrix */ + xcor = 2 * x - 4 - colorWheelSize; + ycor = 2 * y - 4 - colorWheelSize; + + /* RColor.saturation is unsigned char and will wrap after 255 */ + sat = rint(255.0 * sqrt(xcor*xcor + ycor*ycor) / colorWheelSize); + + cpColor.hsv.saturation = (unsigned char)sat; + + ofs[0]++; /* top quarter of matrix*/ + ofs[1] += colorWheelSize + 4; /* left quarter */ + ofs[2] = cw_sqsize - 1 - ofs[0]; /* bottom quarter */ + ofs[3] = cw_sqsize - 1 - ofs[1]; /* right quarter */ + + if (sat < 256) { + if (xcor != 0) + dhue[0] = rint(atan((double)ycor / (double)xcor) * + (180.0 / M_PI)) + (xcor < 0 ? 180.0 : 0.0); + else + dhue[0] = 270; + + dhue[0] = 360 - dhue[0]; /* Reverse direction of ColorWheel */ + dhue[1] = 270 - dhue[0] + (dhue[0] > 270 ? 360 : 0); + dhue[2] = dhue[0] - 180 + (dhue[0] < 180 ? 360 : 0); + dhue[3] = 90 - dhue[0] + (dhue[0] > 90 ? 360 : 0); + + for (i = 0; i < 4; i++) { + rp = panel->wheelMtrx->data[0] + (ofs[i] << uchar_shift); + gp = panel->wheelMtrx->data[1] + (ofs[i] << uchar_shift); + bp = panel->wheelMtrx->data[2] + (ofs[i] << uchar_shift); + + cpColor.hsv.hue = dhue[i]; + convertCPColor(&cpColor); + + *rp = (unsigned char)(cpColor.rgb.red); + *gp = (unsigned char)(cpColor.rgb.green); + *bp = (unsigned char)(cpColor.rgb.blue); + } + } + else { + for (i = 0; i < 4; i++) { + rp = panel->wheelMtrx->data[0] + (ofs[i] << uchar_shift); + gp = panel->wheelMtrx->data[1] + (ofs[i] << uchar_shift); + bp = panel->wheelMtrx->data[2] + (ofs[i] << uchar_shift); + + *rp = (unsigned char)0; + *gp = (unsigned char)0; + *bp = (unsigned char)0; + } + } + } + + ofs[0] += 2*y+1; + ofs[1] += 1 - (colorWheelSize + 4) * (colorWheelSize + 4 - 1 - 2*y); } } - + static void wheelCalculateValues(W_ColorPanel *panel, int maxvalue) { unsigned int i; unsigned int v; - + for (i = 0; i < 256; i++) { - /* We divide by 128 in advance, and check whether that number divides - * by 2 properly. If not, we add one to round the number correctly - */ - v = (i*maxvalue) >> 7; - panel->wheelMtrx->values[i] = (unsigned char)((v >> 1) +(v & 0x01)); + /* We divide by 128 in advance, and check whether that number divides + * by 2 properly. If not, we add one to round the number correctly + */ + v = (i*maxvalue) >> 7; + panel->wheelMtrx->values[i] = (unsigned char)((v >> 1) +(v & 0x01)); } } @@ -2163,52 +2163,52 @@ wheelRender(W_ColorPanel *panel) RColor gray; unsigned long ofs = 0; /*unsigned char shift = getShift(sizeof(unsigned char));*/ - + image = RCreateImage(colorWheelSize+4, colorWheelSize+4, True); if (!image) { - wwarning(_("Color Panel: Could not allocate memory")); - return; + wwarning(_("Color Panel: Could not allocate memory")); + return; } - + ptr = image->data; - + /* TODO Make this transparent istead of gray */ gray.red = gray.blue = 0xae; gray.green = 0xaa; - + for (y = 0; y < colorWheelSize+4; y++) { - for (x = 0; x < colorWheelSize+4; x++) { - if (wheelInsideColorWheel(panel, ofs)) { - *(ptr++) = (unsigned char)(panel->wheelMtrx->values[ - panel->wheelMtrx->data[0][ofs] ]); - *(ptr++) = (unsigned char)(panel->wheelMtrx->values[ - panel->wheelMtrx->data[1][ofs] ]); - *(ptr++) = (unsigned char)(panel->wheelMtrx->values[ - panel->wheelMtrx->data[2][ofs] ]); - *(ptr++) = 0; - } - else { - *(ptr++) = (unsigned char)(gray.red); - *(ptr++) = (unsigned char)(gray.green); - *(ptr++) = (unsigned char)(gray.blue); - *(ptr++) = 255; - } - ofs++; - } + for (x = 0; x < colorWheelSize+4; x++) { + if (wheelInsideColorWheel(panel, ofs)) { + *(ptr++) = (unsigned char)(panel->wheelMtrx->values[ + panel->wheelMtrx->data[0][ofs] ]); + *(ptr++) = (unsigned char)(panel->wheelMtrx->values[ + panel->wheelMtrx->data[1][ofs] ]); + *(ptr++) = (unsigned char)(panel->wheelMtrx->values[ + panel->wheelMtrx->data[2][ofs] ]); + *(ptr++) = 0; + } + else { + *(ptr++) = (unsigned char)(gray.red); + *(ptr++) = (unsigned char)(gray.green); + *(ptr++) = (unsigned char)(gray.blue); + *(ptr++) = 255; + } + ofs++; + } } - + if (panel->wheelImg) - XFreePixmap(scr->display, panel->wheelImg); - + XFreePixmap(scr->display, panel->wheelImg); + RConvertImage(scr->rcontext, image, &panel->wheelImg); RReleaseImage(image); - + /* Check if backimage exists. If it doesn't, allocate and fill it */ if (!panel->selectionBackImg) { - panel->selectionBackImg = XCreatePixmap(scr->display, - W_VIEW(panel->wheelFrm)->window, 4, 4, scr->depth); - XCopyArea(scr->display, panel->wheelImg, panel->selectionBackImg, - scr->copyGC, panel->colx -2, panel->coly -2, 4, 4, 0, 0); - /* -2 is hot spot correction */ + panel->selectionBackImg = XCreatePixmap(scr->display, + W_VIEW(panel->wheelFrm)->window, 4, 4, scr->depth); + XCopyArea(scr->display, panel->wheelImg, panel->selectionBackImg, + scr->copyGC, panel->colx -2, panel->coly -2, 4, 4, 0, 0); + /* -2 is hot spot correction */ } } @@ -2217,8 +2217,8 @@ static Bool wheelInsideColorWheel(W_ColorPanel *panel, unsigned long ofs) { return ((panel->wheelMtrx->data[0][ofs] != 0) && - (panel->wheelMtrx->data[1][ofs] != 0) && - (panel->wheelMtrx->data[2][ofs] != 0)); + (panel->wheelMtrx->data[1][ofs] != 0) && + (panel->wheelMtrx->data[2][ofs] != 0)); } @@ -2226,13 +2226,13 @@ static void wheelPaint (W_ColorPanel *panel) { W_Screen *scr = WMWidgetScreen(panel->win); - - XCopyArea(scr->display, panel->wheelImg, panel->wheelView->window, - scr->copyGC, 0, 0, colorWheelSize+4, colorWheelSize+4, 0, 0); - + + XCopyArea(scr->display, panel->wheelImg, panel->wheelView->window, + scr->copyGC, 0, 0, colorWheelSize+4, colorWheelSize+4, 0, 0); + /* Draw selection image */ - XCopyArea(scr->display, panel->selectionImg, panel->wheelView->window, - scr->copyGC, 0, 0, 4, 4, panel->colx -2, panel->coly -2); + XCopyArea(scr->display, panel->selectionImg, panel->wheelView->window, + scr->copyGC, 0, 0, 4, 4, panel->colx -2, panel->coly -2); } @@ -2240,13 +2240,13 @@ static void wheelHandleEvents(XEvent *event, void *data) { W_ColorPanel *panel = (W_ColorPanel*)data; - + switch (event->type) { - case Expose: - if (event->xexpose.count != 0) /* TODO Improve */ - break; - wheelPaint(panel); - break; + case Expose: + if (event->xexpose.count != 0) /* TODO Improve */ + break; + wheelPaint(panel); + break; } } @@ -2255,39 +2255,39 @@ static void wheelHandleActionEvents(XEvent *event, void *data) { W_ColorPanel *panel = (W_ColorPanel*)data; - + switch (event->type) { - case ButtonPress: - if (getPickerPart(panel, event->xbutton.x, event->xbutton.y) == - COLORWHEEL_PART) { - - panel->lastChanged = WMWheelModeColorPanel; - panel->flags.dragging = 1; - - wheelPositionSelection(panel, event->xbutton.x, event->xbutton.y); - } - break; - - case ButtonRelease: - panel->flags.dragging = 0; - if (!panel->flags.continuous) { - if (panel->action) - (*panel->action)(panel, panel->clientData); - } - break; - - case MotionNotify: - if (panel->flags.dragging) { - if (getPickerPart(panel, event->xmotion.x, event->xmotion.y) == - COLORWHEEL_PART) { - wheelPositionSelection(panel, event->xmotion.x, - event->xmotion.y); - } - else - wheelPositionSelectionOutBounds(panel, event->xmotion.x, - event->xmotion.y); - } - break; + case ButtonPress: + if (getPickerPart(panel, event->xbutton.x, event->xbutton.y) == + COLORWHEEL_PART) { + + panel->lastChanged = WMWheelModeColorPanel; + panel->flags.dragging = 1; + + wheelPositionSelection(panel, event->xbutton.x, event->xbutton.y); + } + break; + + case ButtonRelease: + panel->flags.dragging = 0; + if (!panel->flags.continuous) { + if (panel->action) + (*panel->action)(panel, panel->clientData); + } + break; + + case MotionNotify: + if (panel->flags.dragging) { + if (getPickerPart(panel, event->xmotion.x, event->xmotion.y) == + COLORWHEEL_PART) { + wheelPositionSelection(panel, event->xmotion.x, + event->xmotion.y); + } + else + wheelPositionSelectionOutBounds(panel, event->xmotion.x, + event->xmotion.y); + } + break; } } @@ -2297,28 +2297,28 @@ getPickerPart(W_ColorPanel *panel, int x, int y) { int lx, ly; unsigned long ofs; - + lx = x; ly = y; - + if (panel->mode == WMWheelModeColorPanel) { - if ((lx >= 2) && (lx <= 2+colorWheelSize) && (ly >= 2) && - (ly <= 2+colorWheelSize)) { - - ofs = ly*panel->wheelMtrx->width+lx; - - if (wheelInsideColorWheel(panel, ofs)) - return COLORWHEEL_PART; - } + if ((lx >= 2) && (lx <= 2+colorWheelSize) && (ly >= 2) && + (ly <= 2+colorWheelSize)) { + + ofs = ly*panel->wheelMtrx->width+lx; + + if (wheelInsideColorWheel(panel, ofs)) + return COLORWHEEL_PART; + } } - + if (panel->mode == WMCustomPaletteModeColorPanel) { - if ((lx >= 2) && (lx < customPaletteWidth-2) && (ly >= 2) && - (ly < customPaletteHeight-2)) { - return CUSTOMPALETTE_PART; - } + if ((lx >= 2) && (lx < customPaletteWidth-2) && (ly >= 2) && + (ly < customPaletteHeight-2)) { + return CUSTOMPALETTE_PART; + } } - + return 0; } @@ -2327,20 +2327,20 @@ static void wheelBrightnessSliderCallback(WMWidget *w, void *data) { int value; - + W_ColorPanel *panel = (W_ColorPanel*)data; - + value = 255-WMGetSliderValue(panel->wheelBrightnessS); - + wheelCalculateValues(panel, value); - + if (panel->color.set == cpRGB) { - convertCPColor(&panel->color); - panel->color.set = cpHSV; + convertCPColor(&panel->color); + panel->color.set = cpHSV; } - + panel->color.hsv.value = value; - + wheelRender(panel); wheelPaint(panel); wheelUpdateSelection(panel); @@ -2351,16 +2351,16 @@ static void wheelUpdateSelection(W_ColorPanel *panel) { W_Screen *scr = WMWidgetScreen(panel->win); - + updateSwatch(panel, panel->color); panel->lastChanged = WMWheelModeColorPanel; - + /* Redraw color selector (and make a backup of the part it will cover) */ - XCopyArea(scr->display, panel->wheelImg, panel->selectionBackImg, - scr->copyGC, panel->colx -2, panel->coly -2, 4, 4, 0, 0); + XCopyArea(scr->display, panel->wheelImg, panel->selectionBackImg, + scr->copyGC, panel->colx -2, panel->coly -2, 4, 4, 0, 0); /* "-2" is correction for hotspot location */ - XCopyArea(scr->display, panel->selectionImg, panel->wheelView->window, - scr->copyGC, 0, 0, 4, 4, panel->colx -2, panel->coly -2); + XCopyArea(scr->display, panel->selectionImg, panel->wheelView->window, + scr->copyGC, 0, 0, 4, 4, panel->colx -2, panel->coly -2); /* see above */ } @@ -2369,9 +2369,9 @@ static void wheelUndrawSelection(W_ColorPanel *panel) { W_Screen *scr = WMWidgetScreen(panel->win); - + XCopyArea(scr->display, panel->selectionBackImg, panel->wheelView->window, - scr->copyGC, 0, 0, 4, 4, panel->colx -2, panel->coly -2); + scr->copyGC, 0, 0, 4, 4, panel->colx -2, panel->coly -2); /* see above */ } @@ -2379,22 +2379,22 @@ static void wheelPositionSelection(W_ColorPanel *panel, int x, int y) { unsigned long ofs = (y * panel->wheelMtrx->width)+ x; - - panel->color.rgb.red = panel->wheelMtrx->values[ - panel->wheelMtrx->data[0][ofs] ]; - - panel->color.rgb.green = panel->wheelMtrx->values[ - panel->wheelMtrx->data[1][ofs] ]; - - panel->color.rgb.blue = panel->wheelMtrx->values[ - panel->wheelMtrx->data[2][ofs] ]; + + panel->color.rgb.red = panel->wheelMtrx->values[ + panel->wheelMtrx->data[0][ofs] ]; + + panel->color.rgb.green = panel->wheelMtrx->values[ + panel->wheelMtrx->data[1][ofs] ]; + + panel->color.rgb.blue = panel->wheelMtrx->values[ + panel->wheelMtrx->data[2][ofs] ]; panel->color.set = cpRGB; - + wheelUndrawSelection(panel); - + panel->colx = x; panel->coly = y; - + wheelUpdateSelection(panel); wheelUpdateBrightnessGradientFromLocation(panel); } @@ -2405,40 +2405,40 @@ wheelPositionSelectionOutBounds(W_ColorPanel *panel, int x, int y) int hue; int xcor, ycor; CPColor cpColor; - + xcor = x * 2 - colorWheelSize - 4; ycor = y * 2 - colorWheelSize - 4; - + panel->color.hsv.saturation = 255; panel->color.hsv.value = 255 - WMGetSliderValue(panel->wheelBrightnessS); - + if (xcor != 0) - hue = rint(atan(- (double)ycor / (double)xcor) * (180.0/M_PI)); + hue = rint(atan(- (double)ycor / (double)xcor) * (180.0/M_PI)); else { - if (ycor < 0) - hue = 90; - else - hue = 270; + if (ycor < 0) + hue = 90; + else + hue = 270; } if (xcor < 0) - hue += 180; + hue += 180; if ((xcor > 0) && (ycor > 0)) - hue += 360; - + hue += 360; + panel->color.hsv.hue = hue; panel->color.set = cpHSV; convertCPColor(&panel->color); - + wheelUndrawSelection(panel); - - panel->colx = 2 + rint((colorWheelSize * (1.0 + - cos( panel->color.hsv.hue * (M_PI/180.0) ))) / 2.0); + + panel->colx = 2 + rint((colorWheelSize * (1.0 + + cos( panel->color.hsv.hue * (M_PI/180.0) ))) / 2.0); /* "+2" because of "colorWheelSize + 4" */ - panel->coly = 2 + rint((colorWheelSize * (1.0 + - sin(- panel->color.hsv.hue * (M_PI/180.0) ))) / 2.0); - + panel->coly = 2 + rint((colorWheelSize * (1.0 + + sin(- panel->color.hsv.hue * (M_PI/180.0) ))) / 2.0); + wheelUpdateSelection(panel); cpColor = panel->color; wheelUpdateBrightnessGradient(panel, cpColor); @@ -2449,14 +2449,14 @@ wheelUpdateBrightnessGradientFromLocation(W_ColorPanel *panel) { CPColor from; unsigned long ofs; - + ofs = panel->coly * panel->wheelMtrx->width + panel->colx; - + from.rgb.red = panel->wheelMtrx->data[0][ofs]; from.rgb.green = panel->wheelMtrx->data[1][ofs]; from.rgb.blue = panel->wheelMtrx->data[2][ofs]; from.set = cpRGB; - + wheelUpdateBrightnessGradient(panel, from); } @@ -2466,15 +2466,15 @@ wheelUpdateBrightnessGradient(W_ColorPanel *panel, CPColor topColor) RColor to; RImage *sliderImg; WMPixmap *sliderPxmp; - + to.red = to.green = to.blue = 0; if (topColor.set == cpHSV) - convertCPColor(&topColor); - + convertCPColor(&topColor); + sliderImg = RRenderGradient(16, 153, &(topColor.rgb), &to, RGRD_VERTICAL); - sliderPxmp = WMCreatePixmapFromRImage(WMWidgetScreen(panel->win), - sliderImg, 0); + sliderPxmp = WMCreatePixmapFromRImage(WMWidgetScreen(panel->win), + sliderImg, 0); RReleaseImage(sliderImg); WMSetSliderImage(panel->wheelBrightnessS, sliderPxmp); WMReleasePixmap(sliderPxmp); @@ -2489,15 +2489,15 @@ grayBrightnessSliderCallback(WMWidget *w, void *data) int value; char tmp[4]; W_ColorPanel *panel = (W_ColorPanel*)data; - + value = WMGetSliderValue(panel->grayBrightnessS); - + sprintf(tmp, "%d", value); - + WMSetTextFieldText(panel->grayBrightnessT, tmp); cpColor.rgb.red = cpColor.rgb.green = cpColor.rgb.blue = rint(2.55*value); cpColor.set = cpRGB; - + updateSwatch(panel, cpColor); panel->lastChanged = WMGrayModeColorPanel; } @@ -2510,50 +2510,50 @@ grayPresetButtonCallback(WMWidget *w, void *data) int value; int i=0; W_ColorPanel *panel = (W_ColorPanel*)data; - + while (i < 7) { - if (w == panel->grayPresetBtn[i]) - break; - i++; + if (w == panel->grayPresetBtn[i]) + break; + i++; } - + value = rint((100.0*i)/6.0); sprintf(tmp, "%d", value); - + WMSetTextFieldText(panel->grayBrightnessT, tmp); cpColor.rgb.red = cpColor.rgb.green = cpColor.rgb.blue = - rint((255.0*i)/6.0); + rint((255.0*i)/6.0); cpColor.set = cpRGB; - + WMSetSliderValue(panel->grayBrightnessS, rint((100.0*i)/6.0)); - + updateSwatch(panel, cpColor); panel->lastChanged = WMGrayModeColorPanel; } static void -grayBrightnessTextFieldCallback(void *observerData, - WMNotification *notification) +grayBrightnessTextFieldCallback(void *observerData, + WMNotification *notification) { CPColor cpColor; char tmp[4]; int value; W_ColorPanel *panel = (W_ColorPanel*)observerData; - + value = atoi(WMGetTextFieldText(panel->grayBrightnessT)); if (value > 100) - value = 100; + value = 100; if (value < 0) - value = 0; - + value = 0; + sprintf(tmp, "%d", value); WMSetTextFieldText(panel->grayBrightnessT, tmp); WMSetSliderValue(panel->grayBrightnessS, value); - + cpColor.rgb.red = cpColor.rgb.green = cpColor.rgb.blue = - rint((255.0*value)/100.0); + rint((255.0*value)/100.0); cpColor.set = cpRGB; - + updateSwatch(panel, cpColor); panel->lastChanged = WMGrayModeColorPanel; } @@ -2567,23 +2567,23 @@ rgbSliderCallback(WMWidget *w, void *data) int value[3]; char tmp[4]; W_ColorPanel *panel = (W_ColorPanel*)data; - + value[0] = WMGetSliderValue(panel->rgbRedS); value[1] = WMGetSliderValue(panel->rgbGreenS); value[2] = WMGetSliderValue(panel->rgbBlueS); - + sprintf(tmp, "%d", value[0]); WMSetTextFieldText(panel->rgbRedT, tmp); sprintf(tmp, "%d", value[1]); WMSetTextFieldText(panel->rgbGreenT, tmp); sprintf(tmp, "%d", value[2]); WMSetTextFieldText(panel->rgbBlueT, tmp); - + cpColor.rgb.red = value[0]; cpColor.rgb.green = value[1]; cpColor.rgb.blue = value[2]; cpColor.set = cpRGB; - + updateSwatch(panel, cpColor); panel->lastChanged = WMRGBModeColorPanel; } @@ -2596,34 +2596,34 @@ rgbTextFieldCallback(void *observerData, WMNotification *notification) char tmp[4]; int n; W_ColorPanel *panel = (W_ColorPanel*)observerData; - + value[0] = atoi(WMGetTextFieldText(panel->rgbRedT)); value[1] = atoi(WMGetTextFieldText(panel->rgbGreenT)); value[2] = atoi(WMGetTextFieldText(panel->rgbBlueT)); - + for (n=0; n < 3; n++) { - if (value[n] > 255) - value[n] = 255; - if (value[n] < 0) - value[n] = 0; + if (value[n] > 255) + value[n] = 255; + if (value[n] < 0) + value[n] = 0; } - + sprintf(tmp, "%d", value[0]); WMSetTextFieldText(panel->rgbRedT, tmp); sprintf(tmp, "%d", value[1]); WMSetTextFieldText(panel->rgbGreenT, tmp); sprintf(tmp, "%d", value[2]); WMSetTextFieldText(panel->rgbBlueT, tmp); - + WMSetSliderValue(panel->rgbRedS, value[0]); WMSetSliderValue(panel->rgbGreenS, value[1]); WMSetSliderValue(panel->rgbBlueS, value[2]); - + cpColor.rgb.red = value[0]; cpColor.rgb.green = value[1]; cpColor.rgb.blue = value[2]; cpColor.set = cpRGB; - + updateSwatch(panel, cpColor); panel->lastChanged = WMRGBModeColorPanel; } @@ -2639,12 +2639,12 @@ cmykSliderCallback(WMWidget *w, void *data) char tmp[4]; W_ColorPanel *panel = (W_ColorPanel*)data; double scale; - + value[0] = WMGetSliderValue(panel->cmykCyanS); value[1] = WMGetSliderValue(panel->cmykMagentaS); value[2] = WMGetSliderValue(panel->cmykYellowS); value[3] = WMGetSliderValue(panel->cmykBlackS); - + sprintf(tmp, "%d", value[0]); WMSetTextFieldText(panel->cmykCyanT, tmp); sprintf(tmp, "%d", value[1]); @@ -2653,13 +2653,13 @@ cmykSliderCallback(WMWidget *w, void *data) WMSetTextFieldText(panel->cmykYellowT, tmp); sprintf(tmp, "%d", value[3]); WMSetTextFieldText(panel->cmykBlackT, tmp); - + scale = 2.55 * (1.0 - (value[3] / 100.0)); cpColor.rgb.red = rint((100.0 - value[0]) * scale); cpColor.rgb.green = rint((100.0 - value[1]) * scale); cpColor.rgb.blue = rint((100.0 - value[2]) * scale); cpColor.set = cpRGB; - + updateSwatch(panel, cpColor); panel->lastChanged = WMCMYKModeColorPanel; } @@ -2673,42 +2673,42 @@ cmykTextFieldCallback(void *observerData, WMNotification *notification) int n; double scale; W_ColorPanel *panel = (W_ColorPanel*)observerData; - + value[0] = atoi(WMGetTextFieldText(panel->cmykCyanT)); value[1] = atoi(WMGetTextFieldText(panel->cmykMagentaT)); value[2] = atoi(WMGetTextFieldText(panel->cmykYellowT)); value[3] = atoi(WMGetTextFieldText(panel->cmykBlackT)); - + for (n=0; n < 4; n++) { - if (value[n] > 100) - value[n] = 100; - if (value[n] < 0) - value[n] = 0; + if (value[n] > 100) + value[n] = 100; + if (value[n] < 0) + value[n] = 0; } - + sprintf(tmp, "%d", value[0]); WMSetTextFieldText(panel->cmykCyanT, tmp); - + sprintf(tmp, "%d", value[1]); WMSetTextFieldText(panel->cmykMagentaT, tmp); - + sprintf(tmp, "%d", value[2]); WMSetTextFieldText(panel->cmykYellowT, tmp); sprintf(tmp, "%d", value[3]); WMSetTextFieldText(panel->cmykBlackT, tmp); - + WMSetSliderValue(panel->cmykCyanS, value[0]); WMSetSliderValue(panel->cmykMagentaS, value[1]); WMSetSliderValue(panel->cmykYellowS, value[2]); WMSetSliderValue(panel->cmykBlackS, value[3]); - + scale = 2.55 * (1.0 - (value[3] / 100.0)); cpColor.rgb.red = rint((100.0 - value[0]) * scale); cpColor.rgb.green = rint((100.0 - value[1]) * scale); cpColor.rgb.blue = rint((100.0 - value[2]) * scale); cpColor.set = cpRGB; - + updateSwatch(panel, cpColor); panel->lastChanged = WMCMYKModeColorPanel; } @@ -2722,34 +2722,34 @@ hsbSliderCallback(WMWidget *w, void *data) int value[3]; char tmp[4]; W_ColorPanel *panel = (W_ColorPanel*)data; - + value[0] = WMGetSliderValue(panel->hsbHueS); value[1] = WMGetSliderValue(panel->hsbSaturationS); value[2] = WMGetSliderValue(panel->hsbBrightnessS); - + sprintf(tmp, "%d", value[0]); WMSetTextFieldText(panel->hsbHueT, tmp); sprintf(tmp, "%d", value[1]); WMSetTextFieldText(panel->hsbSaturationT, tmp); sprintf(tmp, "%d", value[2]); WMSetTextFieldText(panel->hsbBrightnessT, tmp); - + cpColor.hsv.hue = value[0]; cpColor.hsv.saturation = value[1]*2.55; cpColor.hsv.value = value[2]*2.55; cpColor.set = cpHSV; - + convertCPColor(&cpColor); - + panel->lastChanged = WMHSBModeColorPanel; updateSwatch(panel, cpColor); - + if (w != panel->hsbBrightnessS) - hsbUpdateBrightnessGradient(panel); + hsbUpdateBrightnessGradient(panel); if (w != panel->hsbSaturationS) - hsbUpdateSaturationGradient(panel); + hsbUpdateSaturationGradient(panel); if (w != panel->hsbHueS) - hsbUpdateHueGradient(panel); + hsbUpdateHueGradient(panel); } static void @@ -2760,44 +2760,44 @@ hsbTextFieldCallback(void *observerData, WMNotification *notification) char tmp[4]; int n; W_ColorPanel *panel = (W_ColorPanel*)observerData; - + value[0] = atoi(WMGetTextFieldText(panel->hsbHueT)); value[1] = atoi(WMGetTextFieldText(panel->hsbSaturationT)); value[2] = atoi(WMGetTextFieldText(panel->hsbBrightnessT)); - + if (value[0] > 359) - value[0] = 359; + value[0] = 359; if (value[0] < 0) - value[0] = 0; - + value[0] = 0; + for (n=1; n < 3; n++) { - if (value[n] > 100) - value[n] = 100; - if (value[n] < 0) - value[n] = 0; + if (value[n] > 100) + value[n] = 100; + if (value[n] < 0) + value[n] = 0; } - + sprintf(tmp, "%d", value[0]); WMSetTextFieldText(panel->hsbHueT, tmp); sprintf(tmp, "%d", value[1]); WMSetTextFieldText(panel->hsbSaturationT, tmp); sprintf(tmp, "%d", value[2]); WMSetTextFieldText(panel->hsbBrightnessT, tmp); - + WMSetSliderValue(panel->hsbHueS, value[0]); WMSetSliderValue(panel->hsbSaturationS, value[1]); WMSetSliderValue(panel->hsbBrightnessS, value[2]); - + cpColor.hsv.hue = value[0]; cpColor.hsv.saturation = value[1]*2.55; cpColor.hsv.value = value[2]*2.55; cpColor.set = cpHSV; - + convertCPColor(&cpColor); - + panel->lastChanged = WMHSBModeColorPanel; updateSwatch(panel, cpColor); - + hsbUpdateBrightnessGradient(panel); hsbUpdateSaturationGradient(panel); hsbUpdateHueGradient(panel); @@ -2811,24 +2811,24 @@ hsbUpdateBrightnessGradient(W_ColorPanel *panel) CPColor to; RImage *sliderImg; WMPixmap *sliderPxmp; - + from.red = from.green = from.blue = 0; to.hsv = panel->color.hsv; to.hsv.value = 255; to.set = cpHSV; - + convertCPColor(&to); - + sliderImg = RRenderGradient(141, 16, &from, &(to.rgb), RGRD_HORIZONTAL); sliderPxmp = WMCreatePixmapFromRImage(scr, sliderImg, 0); RReleaseImage(sliderImg); if (sliderPxmp) - W_PaintText(W_VIEW(panel->hsbBrightnessS), sliderPxmp->pixmap, - panel->font12, 2, 0, 100, WALeft, scr->white, - False, _("Brightness"), strlen(_("Brightness"))); + W_PaintText(W_VIEW(panel->hsbBrightnessS), sliderPxmp->pixmap, + panel->font12, 2, 0, 100, WALeft, scr->white, + False, _("Brightness"), strlen(_("Brightness"))); else - wwarning(_("Color Panel: Could not allocate memory")); + wwarning(_("Color Panel: Could not allocate memory")); WMSetSliderImage(panel->hsbBrightnessS, sliderPxmp); WMReleasePixmap(sliderPxmp); @@ -2842,30 +2842,30 @@ hsbUpdateSaturationGradient(W_ColorPanel *panel) CPColor to; RImage *sliderImg; WMPixmap *sliderPxmp; - + from.hsv = panel->color.hsv; from.hsv.saturation = 0; from.set = cpHSV; convertCPColor(&from); - + to.hsv = panel->color.hsv; to.hsv.saturation = 255; to.set = cpHSV; convertCPColor(&to); - + sliderImg = RRenderGradient(141, 16, &(from.rgb), &(to.rgb), - RGRD_HORIZONTAL); + RGRD_HORIZONTAL); sliderPxmp = WMCreatePixmapFromRImage(scr, sliderImg, 0); RReleaseImage(sliderImg); if (sliderPxmp) - W_PaintText(W_VIEW(panel->hsbSaturationS), sliderPxmp->pixmap, + W_PaintText(W_VIEW(panel->hsbSaturationS), sliderPxmp->pixmap, panel->font12, 2, 0, 100, WALeft, from.hsv.value < 128 ? scr->white : scr->black, False, - _("Saturation"), strlen(_("Saturation"))); + _("Saturation"), strlen(_("Saturation"))); else - wwarning(_("Color Panel: Could not allocate memory")); - + wwarning(_("Color Panel: Could not allocate memory")); + WMSetSliderImage(panel->hsbSaturationS, sliderPxmp); WMReleasePixmap(sliderPxmp); } @@ -2879,36 +2879,36 @@ hsbUpdateHueGradient(W_ColorPanel *panel) RImage *sliderImg; WMPixmap *sliderPxmp; int i; - + hsvcolor = panel->color.hsv; - + colors = wmalloc(sizeof(RColor*)*(8)); for (i=0; i<7; i++) { - hsvcolor.hue = (360*i)/6; - colors[i] = wmalloc(sizeof(RColor)); - RHSVtoRGB(&hsvcolor, colors[i]); + hsvcolor.hue = (360*i)/6; + colors[i] = wmalloc(sizeof(RColor)); + RHSVtoRGB(&hsvcolor, colors[i]); } colors[7] = NULL; - + sliderImg = RRenderMultiGradient(141, 16, colors, RGRD_HORIZONTAL); sliderPxmp = WMCreatePixmapFromRImage(scr, sliderImg, 0); RReleaseImage(sliderImg); if (sliderPxmp) - W_PaintText(W_VIEW(panel->hsbHueS), sliderPxmp->pixmap, + W_PaintText(W_VIEW(panel->hsbHueS), sliderPxmp->pixmap, panel->font12, 2, 0, 100, WALeft, hsvcolor.value < 128 ? scr->white : scr->black, False, - _("Hue"), strlen(_("Hue"))); + _("Hue"), strlen(_("Hue"))); else - wwarning(_("Color Panel: Could not allocate memory")); - + wwarning(_("Color Panel: Could not allocate memory")); + WMSetSliderImage(panel->hsbHueS, sliderPxmp); WMReleasePixmap(sliderPxmp); - + for (i=0; i<7; i++) - wfree(colors[i]); - - wfree(colors); + wfree(colors[i]); + + wfree(colors); } /*************** Custom Palette Functions ****************/ @@ -2920,34 +2920,34 @@ customRenderSpectrum(W_ColorPanel *panel) int x,y; unsigned char *ptr; CPColor cpColor; - + spectrum = RCreateImage(SPECTRUM_WIDTH, SPECTRUM_HEIGHT, False); - + ptr = spectrum->data; - + for (y = 0; y < SPECTRUM_HEIGHT; y++) { - cpColor.hsv.hue = y; - cpColor.hsv.saturation = 0; - cpColor.hsv.value = 255; - cpColor.set = cpHSV; - - for (x = 0; x < SPECTRUM_WIDTH; x++) { - convertCPColor(&cpColor); - - *(ptr++) = (unsigned char)cpColor.rgb.red; - *(ptr++) = (unsigned char)cpColor.rgb.green; - *(ptr++) = (unsigned char)cpColor.rgb.blue; - - if (x < (SPECTRUM_WIDTH/2)) - cpColor.hsv.saturation++; - - if (x > (SPECTRUM_WIDTH/2)) - cpColor.hsv.value--; - } + cpColor.hsv.hue = y; + cpColor.hsv.saturation = 0; + cpColor.hsv.value = 255; + cpColor.set = cpHSV; + + for (x = 0; x < SPECTRUM_WIDTH; x++) { + convertCPColor(&cpColor); + + *(ptr++) = (unsigned char)cpColor.rgb.red; + *(ptr++) = (unsigned char)cpColor.rgb.green; + *(ptr++) = (unsigned char)cpColor.rgb.blue; + + if (x < (SPECTRUM_WIDTH/2)) + cpColor.hsv.saturation++; + + if (x > (SPECTRUM_WIDTH/2)) + cpColor.hsv.value--; + } } if (panel->customPaletteImg) { - RReleaseImage(panel->customPaletteImg); - panel->customPaletteImg = NULL; + RReleaseImage(panel->customPaletteImg); + panel->customPaletteImg = NULL; } panel->customPaletteImg = spectrum; } @@ -2961,35 +2961,35 @@ customSetPalette(W_ColorPanel *panel) RImage *scaledImg; Pixmap image; int item; - - image = XCreatePixmap(scr->display, W_DRAWABLE(scr), customPaletteWidth, - customPaletteHeight, scr->depth); - scaledImg = RScaleImage(panel->customPaletteImg, customPaletteWidth, - customPaletteHeight); + + image = XCreatePixmap(scr->display, W_DRAWABLE(scr), customPaletteWidth, + customPaletteHeight, scr->depth); + scaledImg = RScaleImage(panel->customPaletteImg, customPaletteWidth, + customPaletteHeight); RConvertImage(scr->rcontext, scaledImg, &image); RReleaseImage(scaledImg); - - XCopyArea(scr->display, image, panel->customPaletteContentView->window, - scr->copyGC, 0, 0, customPaletteWidth, customPaletteHeight, 0, 0); - + + XCopyArea(scr->display, image, panel->customPaletteContentView->window, + scr->copyGC, 0, 0, customPaletteWidth, customPaletteHeight, 0, 0); + /* Check backimage exists. If it doesn't, allocate and fill it */ if (!panel->selectionBackImg) { - panel->selectionBackImg = XCreatePixmap(scr->display, - panel->customPaletteContentView->window, 4, 4, scr->depth); + panel->selectionBackImg = XCreatePixmap(scr->display, + panel->customPaletteContentView->window, 4, 4, scr->depth); } - - XCopyArea(scr->display, image, panel->selectionBackImg, scr->copyGC, - panel->palx-2, panel->paly-2, 4, 4, 0, 0); - XCopyArea(scr->display, panel->selectionImg, - panel->customPaletteContentView->window, scr->copyGC, 0 , 0, 4, 4, - panel->palx-2, panel->paly-2); + + XCopyArea(scr->display, image, panel->selectionBackImg, scr->copyGC, + panel->palx-2, panel->paly-2, 4, 4, 0, 0); + XCopyArea(scr->display, panel->selectionImg, + panel->customPaletteContentView->window, scr->copyGC, 0 , 0, 4, 4, + panel->palx-2, panel->paly-2); XFreePixmap(scr->display, image); - - panel->palXRatio = (double)(panel->customPaletteImg->width) / - (double)(customPaletteWidth); - panel->palYRatio = (double)(panel->customPaletteImg->height) / - (double)(customPaletteHeight); - + + panel->palXRatio = (double)(panel->customPaletteImg->width) / + (double)(customPaletteWidth); + panel->palYRatio = (double)(panel->customPaletteImg->height) / + (double)(customPaletteHeight); + item = WMGetPopUpButtonSelectedItem (panel->customPaletteHistoryBtn); } @@ -2999,34 +2999,34 @@ customPalettePositionSelection(W_ColorPanel *panel, int x, int y) { W_Screen *scr = WMWidgetScreen(panel->win); unsigned long ofs; - - + + /* undraw selection */ - XCopyArea(scr->display, panel->selectionBackImg, - panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4, - panel->palx-2, panel->paly-2); - + XCopyArea(scr->display, panel->selectionBackImg, + panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4, + panel->palx-2, panel->paly-2); + panel->palx = x; panel->paly = y; - - ofs = (rint(x * panel->palXRatio) + rint(y * panel->palYRatio) * - panel->customPaletteImg->width) * 3; - + + ofs = (rint(x * panel->palXRatio) + rint(y * panel->palYRatio) * + panel->customPaletteImg->width) * 3; + panel->color.rgb.red = panel->customPaletteImg->data[ofs]; panel->color.rgb.green = panel->customPaletteImg->data[ofs+1]; panel->color.rgb.blue = panel->customPaletteImg->data[ofs+2]; panel->color.set = cpRGB; - + updateSwatch(panel, panel->color); panel->lastChanged = WMCustomPaletteModeColorPanel; - + /* Redraw color selector (and make a backup of the part it will cover) */ - XCopyArea(scr->display, panel->customPaletteContentView->window, - panel->selectionBackImg, scr->copyGC, panel->palx-2, panel->paly-2, - 4, 4, 0, 0); /* "-2" is correction for hotspot location */ - XCopyArea(scr->display, panel->selectionImg, - panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4, - panel->palx-2, panel->paly-2); /* see above */ + XCopyArea(scr->display, panel->customPaletteContentView->window, + panel->selectionBackImg, scr->copyGC, panel->palx-2, panel->paly-2, + 4, 4, 0, 0); /* "-2" is correction for hotspot location */ + XCopyArea(scr->display, panel->selectionImg, + panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4, + panel->palx-2, panel->paly-2); /* see above */ } @@ -3034,14 +3034,14 @@ static void customPalettePositionSelectionOutBounds(W_ColorPanel *panel, int x, int y) { if (x < 2) - x = 2; + x = 2; if (y < 2) - y = 2; + y = 2; if (x >= customPaletteWidth) - x = customPaletteWidth -2; + x = customPaletteWidth -2; if (y >= customPaletteHeight) - y = customPaletteHeight -2; - + y = customPaletteHeight -2; + customPalettePositionSelection(panel, x, y); } @@ -3050,13 +3050,13 @@ static void customPaletteHandleEvents(XEvent *event, void *data) { W_ColorPanel *panel = (W_ColorPanel*)data; - + switch (event->type) { - case Expose: - if (event->xexpose.count != 0) /* TODO Improve. */ - break; - customSetPalette(panel); - break; + case Expose: + if (event->xexpose.count != 0) /* TODO Improve. */ + break; + customSetPalette(panel); + break; } } @@ -3065,38 +3065,38 @@ customPaletteHandleActionEvents(XEvent *event, void *data) { W_ColorPanel *panel = (W_ColorPanel*)data; int x, y; - + switch (event->type) { - case ButtonPress: - x = event->xbutton.x; - y = event->xbutton.y; - - if (getPickerPart(panel, x, y) == CUSTOMPALETTE_PART) { - panel->flags.dragging = 1; - customPalettePositionSelection(panel, x, y); - } - break; - - case ButtonRelease: - panel->flags.dragging = 0; - if (!panel->flags.continuous) { - if (panel->action) - (*panel->action)(panel, panel->clientData); - } - break; - - case MotionNotify: - x = event->xmotion.x; - y = event->xmotion.y; - - if (panel->flags.dragging) { - if (getPickerPart(panel, x, y) == CUSTOMPALETTE_PART) { - customPalettePositionSelection(panel, x, y); - } - else - customPalettePositionSelectionOutBounds(panel, x, y); - } - break; + case ButtonPress: + x = event->xbutton.x; + y = event->xbutton.y; + + if (getPickerPart(panel, x, y) == CUSTOMPALETTE_PART) { + panel->flags.dragging = 1; + customPalettePositionSelection(panel, x, y); + } + break; + + case ButtonRelease: + panel->flags.dragging = 0; + if (!panel->flags.continuous) { + if (panel->action) + (*panel->action)(panel, panel->clientData); + } + break; + + case MotionNotify: + x = event->xmotion.x; + y = event->xmotion.y; + + if (panel->flags.dragging) { + if (getPickerPart(panel, x, y) == CUSTOMPALETTE_PART) { + customPalettePositionSelection(panel, x, y); + } + else + customPalettePositionSelectionOutBounds(panel, x, y); + } + break; } } @@ -3106,21 +3106,21 @@ customPaletteMenuCallback(WMWidget *w, void *data) { W_ColorPanel *panel = (W_ColorPanel*)data; int item = WMGetPopUpButtonSelectedItem(panel->customPaletteMenuBtn); - + switch (item) { - case CPmenuNewFromFile: - customPaletteMenuNewFromFile(panel); - break; - case CPmenuRename: - customPaletteMenuRename(panel); - break; - case CPmenuRemove: - customPaletteMenuRemove(panel); - break; - case CPmenuCopy: - break; - case CPmenuNewFromClipboard: - break; + case CPmenuNewFromFile: + customPaletteMenuNewFromFile(panel); + break; + case CPmenuRename: + customPaletteMenuRename(panel); + break; + case CPmenuRemove: + customPaletteMenuRemove(panel); + break; + case CPmenuCopy: + break; + case CPmenuNewFromClipboard: + break; } } @@ -3136,94 +3136,94 @@ customPaletteMenuNewFromFile(W_ColorPanel *panel) char *tmp; int i; RImage *tmpImg = NULL; - + if ((!panel->lastBrowseDir) || (strcmp(panel->lastBrowseDir,"\0") == 0)) - spath = wexpandpath(wgethomedir()); + spath = wexpandpath(wgethomedir()); else - spath = wexpandpath(panel->lastBrowseDir); - + spath = wexpandpath(panel->lastBrowseDir); + browseP = WMGetOpenPanel(scr); WMSetFilePanelCanChooseDirectories(browseP, 0); WMSetFilePanelCanChooseFiles(browseP, 1); - + /* Get a filename */ - if (WMRunModalFilePanelForDirectory(browseP, panel->win, spath, - _("Open Palette"), RSupportedFileFormats()) ) { - filepath = WMGetFilePanelFileName(browseP); - - /* Get seperation position between path and filename */ - i = strrchr(filepath, '/') - filepath + 1; - if (i > strlen(filepath)) - i = strlen(filepath); - - /* Store last browsed path */ - if (panel->lastBrowseDir) - wfree(panel->lastBrowseDir); - panel->lastBrowseDir = wmalloc((i+1)*sizeof(char)); - strncpy(panel->lastBrowseDir, filepath, i); - panel->lastBrowseDir[i] = '\0'; - - /* Get filename from path */ - filename = wstrdup(filepath + i); - - /* Check for duplicate files, and rename it if there are any */ - tmp = wstrconcat(panel->configurationPath, filename); - while (access (tmp, F_OK) == 0) { - char *newName; - - wfree(tmp); - - newName = generateNewFilename(filename); - wfree(filename); - filename = newName; - - tmp = wstrconcat(panel->configurationPath, filename); - } - wfree(tmp); - - /* Copy image to $(gnustepdir)/Library/Colors/ & - * Add filename to history menu */ - if (fetchFile (panel->configurationPath, filepath, filename) == 0) { - - /* filepath is a "local" path now the file has been copied */ - wfree(filepath); - filepath = wstrconcat(panel->configurationPath, filename); - - /* load the image & add menu entries */ - tmpImg = RLoadImage(scr->rcontext, filepath, 0); - if (tmpImg) { - if (panel->customPaletteImg) - RReleaseImage(panel->customPaletteImg); - panel->customPaletteImg = tmpImg; - - customSetPalette(panel); - WMAddPopUpButtonItem(panel->customPaletteHistoryBtn, filename); - - panel->currentPalette = WMGetPopUpButtonNumberOfItems( - panel->customPaletteHistoryBtn)-1; - - WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, - panel->currentPalette); - } - } else { - tmp = wstrconcat(panel->configurationPath, filename); - - i = remove(tmp); /* Delete the file, it doesn't belong here */ - WMRunAlertPanel(scr, panel->win, _("File Error"), - _("Invalid file format !"), _("OK"), NULL, NULL); - if (i != 0) { - wsyserror(_("can't remove file %s"), tmp); - WMRunAlertPanel(scr, panel->win, _("File Error"), - _("Couldn't remove file from Configuration Directory !"), - _("OK"), NULL, NULL); - } - wfree(tmp); - } - wfree(filepath); - wfree(filename); + if (WMRunModalFilePanelForDirectory(browseP, panel->win, spath, + _("Open Palette"), RSupportedFileFormats()) ) { + filepath = WMGetFilePanelFileName(browseP); + + /* Get seperation position between path and filename */ + i = strrchr(filepath, '/') - filepath + 1; + if (i > strlen(filepath)) + i = strlen(filepath); + + /* Store last browsed path */ + if (panel->lastBrowseDir) + wfree(panel->lastBrowseDir); + panel->lastBrowseDir = wmalloc((i+1)*sizeof(char)); + strncpy(panel->lastBrowseDir, filepath, i); + panel->lastBrowseDir[i] = '\0'; + + /* Get filename from path */ + filename = wstrdup(filepath + i); + + /* Check for duplicate files, and rename it if there are any */ + tmp = wstrconcat(panel->configurationPath, filename); + while (access (tmp, F_OK) == 0) { + char *newName; + + wfree(tmp); + + newName = generateNewFilename(filename); + wfree(filename); + filename = newName; + + tmp = wstrconcat(panel->configurationPath, filename); + } + wfree(tmp); + + /* Copy image to $(gnustepdir)/Library/Colors/ & + * Add filename to history menu */ + if (fetchFile (panel->configurationPath, filepath, filename) == 0) { + + /* filepath is a "local" path now the file has been copied */ + wfree(filepath); + filepath = wstrconcat(panel->configurationPath, filename); + + /* load the image & add menu entries */ + tmpImg = RLoadImage(scr->rcontext, filepath, 0); + if (tmpImg) { + if (panel->customPaletteImg) + RReleaseImage(panel->customPaletteImg); + panel->customPaletteImg = tmpImg; + + customSetPalette(panel); + WMAddPopUpButtonItem(panel->customPaletteHistoryBtn, filename); + + panel->currentPalette = WMGetPopUpButtonNumberOfItems( + panel->customPaletteHistoryBtn)-1; + + WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, + panel->currentPalette); + } + } else { + tmp = wstrconcat(panel->configurationPath, filename); + + i = remove(tmp); /* Delete the file, it doesn't belong here */ + WMRunAlertPanel(scr, panel->win, _("File Error"), + _("Invalid file format !"), _("OK"), NULL, NULL); + if (i != 0) { + wsyserror(_("can't remove file %s"), tmp); + WMRunAlertPanel(scr, panel->win, _("File Error"), + _("Couldn't remove file from Configuration Directory !"), + _("OK"), NULL, NULL); + } + wfree(tmp); + } + wfree(filepath); + wfree(filename); } WMFreeFilePanel(browseP); - + wfree(spath); } @@ -3237,71 +3237,71 @@ customPaletteMenuRename(W_ColorPanel *panel) char *toPath, *fromPath; int item; int index; - + item = WMGetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn); fromName = WMGetPopUpButtonItem(panel->customPaletteHistoryBtn, item); - - toName = WMRunInputPanel(scr, panel->win, _("Rename"), _("Rename palette to:"), - fromName, _("OK"), _("Cancel")); - + + toName = WMRunInputPanel(scr, panel->win, _("Rename"), _("Rename palette to:"), + fromName, _("OK"), _("Cancel")); + if (toName) { - - /* As some people do certain stupid things... */ - if (strcmp(toName, fromName) == 0) { - wfree(toName); - return; - } - - /* For normal people */ - fromPath = wstrconcat(panel->configurationPath, fromName); - toPath = wstrconcat(panel->configurationPath, toName); - - if (access (toPath, F_OK) == 0) { - /* Careful, this palette exists already */ - if (WMRunAlertPanel(scr, panel->win, _("Warning"), - _("Palette already exists !\n\nOverwrite ?"), _("No"), _("Yes"), - NULL) == 1) { - /* "No" = 0, "Yes" = 1 */ - int items = WMGetPopUpButtonNumberOfItems( - panel->customPaletteHistoryBtn); - - remove(toPath); - - /* Remove from History list too */ - index = 1; - while ((index < items) && (strcmp(WMGetPopUpButtonItem( - panel->customPaletteHistoryBtn, index), - toName) != 0 )) - index++; - - if (index < items) { - WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, - index); - if (index < item) - item--; - } - - } else { - wfree(fromPath); - wfree(toName); - wfree(toPath); - - return; - } - } - - if ( rename(fromPath, toPath) != 0) - wsyserror(_("Couldn't rename palette %s to %s\n"), fromName, toName); - else { - WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, item); - WMInsertPopUpButtonItem(panel->customPaletteHistoryBtn, item, - toName); - - WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, item); - } - wfree(fromPath); - wfree(toPath); - wfree(toName); + + /* As some people do certain stupid things... */ + if (strcmp(toName, fromName) == 0) { + wfree(toName); + return; + } + + /* For normal people */ + fromPath = wstrconcat(panel->configurationPath, fromName); + toPath = wstrconcat(panel->configurationPath, toName); + + if (access (toPath, F_OK) == 0) { + /* Careful, this palette exists already */ + if (WMRunAlertPanel(scr, panel->win, _("Warning"), + _("Palette already exists !\n\nOverwrite ?"), _("No"), _("Yes"), + NULL) == 1) { + /* "No" = 0, "Yes" = 1 */ + int items = WMGetPopUpButtonNumberOfItems( + panel->customPaletteHistoryBtn); + + remove(toPath); + + /* Remove from History list too */ + index = 1; + while ((index < items) && (strcmp(WMGetPopUpButtonItem( + panel->customPaletteHistoryBtn, index), + toName) != 0 )) + index++; + + if (index < items) { + WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, + index); + if (index < item) + item--; + } + + } else { + wfree(fromPath); + wfree(toName); + wfree(toPath); + + return; + } + } + + if ( rename(fromPath, toPath) != 0) + wsyserror(_("Couldn't rename palette %s to %s\n"), fromName, toName); + else { + WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, item); + WMInsertPopUpButtonItem(panel->customPaletteHistoryBtn, item, + toName); + + WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, item); + } + wfree(fromPath); + wfree(toPath); + wfree(toName); } } @@ -3314,41 +3314,41 @@ customPaletteMenuRemove(W_ColorPanel *panel) char *tmp; int choice; int item; - + item = WMGetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn); - - tmp = wstrconcat( _("This will permanently remove the palette "), - WMGetPopUpButtonItem(panel->customPaletteHistoryBtn, item )); - text = wstrconcat( tmp, - _(".\n\nAre you sure you want to remove this palette ?")); + + tmp = wstrconcat( _("This will permanently remove the palette "), + WMGetPopUpButtonItem(panel->customPaletteHistoryBtn, item )); + text = wstrconcat( tmp, + _(".\n\nAre you sure you want to remove this palette ?")); wfree(tmp); - + choice = WMRunAlertPanel(scr, panel->win, _("Remove"), text, _("Yes"), _("No"), - NULL); + NULL); /* returns 0 (= "Yes") or 1 (="No") */ wfree(text); - + if (choice == 0) { - - tmp = wstrconcat(panel->configurationPath, - WMGetPopUpButtonItem(panel->customPaletteHistoryBtn, item )); - - if ( remove(tmp) == 0) { - /* item-1 always exists */ - WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, - item-1); - - customPaletteHistoryCallback(panel->customPaletteHistoryBtn, - panel); - customSetPalette(panel); - - WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, item); + + tmp = wstrconcat(panel->configurationPath, + WMGetPopUpButtonItem(panel->customPaletteHistoryBtn, item )); + + if ( remove(tmp) == 0) { + /* item-1 always exists */ + WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, + item-1); + + customPaletteHistoryCallback(panel->customPaletteHistoryBtn, + panel); + customSetPalette(panel); + + WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, item); } else { wsyserror(_("Couldn't remove palette %s\n"), tmp); } - wfree(tmp); + wfree(tmp); } } @@ -3362,66 +3362,66 @@ customPaletteHistoryCallback(WMWidget *w, void *data) char *filename; RImage *tmp = NULL; unsigned char perm_mask; - + item = WMGetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn); if (item == panel->currentPalette) - return; - + return; + if (item == 0) { - customRenderSpectrum(panel); - - WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRename, - False ); - WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRemove, - False ); + customRenderSpectrum(panel); + + WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRename, + False ); + WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRemove, + False ); } else { - /* Load file from configpath */ - filename = wstrconcat( panel->configurationPath, - WMGetPopUpButtonItem(panel->customPaletteHistoryBtn, item) ); - - /* If the file corresponding to the item does not exist, - * remove it from the history list and select the next one. - */ - perm_mask = (access(filename, F_OK) == 0); - if (!perm_mask) { - /* File does not exist */ - wfree(filename); - WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, - item-1); - WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, item); - customPaletteHistoryCallback(w, data); - return; - } - - /* Get the image */ - tmp = RLoadImage(scr->rcontext, filename, 0); - if (tmp) { - if (panel->customPaletteImg) { - RReleaseImage(panel->customPaletteImg); - panel->customPaletteImg = NULL; - } - panel->customPaletteImg = tmp; - } - - /* If the image is not writable, don't allow removing/renaming */ - perm_mask = (access(filename, W_OK) == 0); - WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRename, - perm_mask); - WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRemove, - perm_mask); - - wfree(filename); + /* Load file from configpath */ + filename = wstrconcat( panel->configurationPath, + WMGetPopUpButtonItem(panel->customPaletteHistoryBtn, item) ); + + /* If the file corresponding to the item does not exist, + * remove it from the history list and select the next one. + */ + perm_mask = (access(filename, F_OK) == 0); + if (!perm_mask) { + /* File does not exist */ + wfree(filename); + WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, + item-1); + WMRemovePopUpButtonItem(panel->customPaletteHistoryBtn, item); + customPaletteHistoryCallback(w, data); + return; + } + + /* Get the image */ + tmp = RLoadImage(scr->rcontext, filename, 0); + if (tmp) { + if (panel->customPaletteImg) { + RReleaseImage(panel->customPaletteImg); + panel->customPaletteImg = NULL; + } + panel->customPaletteImg = tmp; + } + + /* If the image is not writable, don't allow removing/renaming */ + perm_mask = (access(filename, W_OK) == 0); + WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRename, + perm_mask); + WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, CPmenuRemove, + perm_mask); + + wfree(filename); } customSetPalette(panel); - + panel->currentPalette = item; } /************************* ColorList Panel Functions **********************/ static void -colorListPaintItem(WMList *lPtr, int index, Drawable d, char *text, - int state, WMRect *rect) +colorListPaintItem(WMList *lPtr, int index, Drawable d, char *text, + int state, WMRect *rect) { WMScreen *scr = WMWidgetScreen(lPtr); Display *dpy = WMScreenDisplay(scr); @@ -3430,23 +3430,23 @@ colorListPaintItem(WMList *lPtr, int index, Drawable d, char *text, W_ColorPanel *panel = WMGetHangedData(lPtr); int width, height, x, y; WMColor *fillColor; - + width = rect->size.width; height = rect->size.height; x = rect->pos.x; y = rect->pos.y; - + if (state & WLDSSelected) XFillRectangle(dpy, d, WMColorGC(scr->white), x, y, width, height); else XFillRectangle(dpy, d, WMColorGC(view->backColor), x, y, width, height); - + fillColor = WMCreateRGBColor(scr, color.red<<8, color.green<<8, color.blue<<8, True); - + XFillRectangle(dpy, d, WMColorGC(fillColor), x, y, 15, height); WMReleaseColor(fillColor); - + WMDrawString(scr, d, scr->black, panel->font12, x+18, y, text, strlen(text)); } @@ -3456,10 +3456,10 @@ colorListSelect(WMWidget *w, void *data) { W_ColorPanel *panel = (W_ColorPanel *)data; CPColor cpColor; - + cpColor.rgb = *((RColor *)WMGetListSelectedItem(w)->clientData); cpColor.set = cpRGB; - + panel->lastChanged = WMColorListModeColorPanel; updateSwatch(panel, cpColor); } @@ -3470,14 +3470,14 @@ colorListColorMenuCallback(WMWidget *w, void *data) { W_ColorPanel *panel = (W_ColorPanel *)data; int item = WMGetPopUpButtonSelectedItem(panel->colorListColorMenuBtn); - + switch (item) { - case CLmenuAdd: - break; - case CLmenuRename: - break; - case CLmenuRemove: - break; + case CLmenuAdd: + break; + case CLmenuRename: + break; + case CLmenuRemove: + break; } } @@ -3487,16 +3487,16 @@ colorListListMenuCallback(WMWidget *w, void *data) { W_ColorPanel *panel = (W_ColorPanel *)data; int item = WMGetPopUpButtonSelectedItem(panel->colorListListMenuBtn); - + switch (item) { - case CLmenuAdd: - /* New Color List */ - colorListListMenuNew(panel); - break; - case CLmenuRename: - break; - case CLmenuRemove: - break; + case CLmenuAdd: + /* New Color List */ + colorListListMenuNew(panel); + break; + case CLmenuRename: + break; + case CLmenuRemove: + break; } } @@ -3504,7 +3504,7 @@ colorListListMenuCallback(WMWidget *w, void *data) static void colorListListMenuNew(W_ColorPanel *panel) { - + } @@ -3514,21 +3514,21 @@ static void wheelInit(W_ColorPanel *panel) { CPColor cpColor; - + if (panel->color.set != cpHSV) - convertCPColor(&panel->color); + convertCPColor(&panel->color); WMSetSliderValue(panel->wheelBrightnessS, 255 - panel->color.hsv.value); - + panel->colx = 2 + rint((colorWheelSize / 2.0) * - (1 + ( panel->color.hsv.saturation/255.0) * - cos( panel->color.hsv.hue * M_PI/180.0))); + (1 + ( panel->color.hsv.saturation/255.0) * + cos( panel->color.hsv.hue * M_PI/180.0))); panel->coly = 2 + rint((colorWheelSize / 2.0) * - (1 + ( panel->color.hsv.saturation/255.0) * - sin(- panel->color.hsv.hue*M_PI/180.0))); - + (1 + ( panel->color.hsv.saturation/255.0) * + sin(- panel->color.hsv.hue*M_PI/180.0))); + wheelCalculateValues(panel, panel->color.hsv.value); - + cpColor = panel->color; cpColor.hsv.value = 255; cpColor.set = cpHSV; @@ -3541,13 +3541,13 @@ grayInit(W_ColorPanel *panel) { int value; char tmp[4]; - + if (panel->color.set != cpHSV) - convertCPColor(&panel->color); + convertCPColor(&panel->color); - value = rint(panel->color.hsv.value/2.55); + value = rint(panel->color.hsv.value/2.55); WMSetSliderValue(panel->grayBrightnessS, value); - + sprintf(tmp, "%d", value); WMSetTextFieldText(panel->grayBrightnessT, tmp); } @@ -3557,14 +3557,14 @@ static void rgbInit(W_ColorPanel *panel) { char tmp[4]; - + if (panel->color.set != cpRGB) - convertCPColor(&panel->color); - + convertCPColor(&panel->color); + WMSetSliderValue(panel->rgbRedS, panel->color.rgb.red); WMSetSliderValue(panel->rgbGreenS, panel->color.rgb.green); WMSetSliderValue(panel->rgbBlueS, panel->color.rgb.blue); - + sprintf(tmp, "%d", panel->color.rgb.red); WMSetTextFieldText(panel->rgbRedT, tmp); sprintf(tmp, "%d", panel->color.rgb.green); @@ -3579,19 +3579,19 @@ cmykInit(W_ColorPanel *panel) { int value[3]; char tmp[4]; - + if (panel->color.set != cpRGB) - convertCPColor(&panel->color); - + convertCPColor(&panel->color); + value[0] = rint((255-panel->color.rgb.red)/2.55); value[1] = rint((255-panel->color.rgb.green)/2.55); value[2] = rint((255-panel->color.rgb.blue)/2.55); - + WMSetSliderValue(panel->cmykCyanS, value[0]); WMSetSliderValue(panel->cmykMagentaS, value[1]); WMSetSliderValue(panel->cmykYellowS, value[2]); WMSetSliderValue(panel->cmykBlackS, 0); - + sprintf(tmp, "%d", value[0]); WMSetTextFieldText(panel->cmykCyanT, tmp); sprintf(tmp, "%d", value[1]); @@ -3607,25 +3607,25 @@ hsbInit(W_ColorPanel *panel) { int value[3]; char tmp[4]; - + if (panel->color.set != cpHSV) - convertCPColor(&panel->color); - + convertCPColor(&panel->color); + value[0] = panel->color.hsv.hue; value[1] = rint(panel->color.hsv.saturation/2.55); value[2] = rint(panel->color.hsv.value/2.55); - + WMSetSliderValue(panel->hsbHueS,value[0]); WMSetSliderValue(panel->hsbSaturationS,value[1]); WMSetSliderValue(panel->hsbBrightnessS,value[2]); - + sprintf(tmp, "%d", value[0]); WMSetTextFieldText(panel->hsbHueT, tmp); sprintf(tmp, "%d", value[1]); WMSetTextFieldText(panel->hsbSaturationT, tmp); sprintf(tmp, "%d", value[2]); WMSetTextFieldText(panel->hsbBrightnessT, tmp); - + hsbUpdateBrightnessGradient(panel); hsbUpdateSaturationGradient(panel); hsbUpdateHueGradient(panel); @@ -3642,31 +3642,31 @@ fetchFile(char *toPath, char *srcFile, char *destFile) int n; char *tmp; char buf[BUFSIZE]; - + if ((src = open(srcFile, O_RDONLY|O_BINARY)) == 0) { - wsyserror(_("Could not open %s"), srcFile); - return -1; + wsyserror(_("Could not open %s"), srcFile); + return -1; } - + tmp = wstrconcat(toPath, destFile); - if ((dest = open( tmp, O_RDWR|O_CREAT|O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) - == 0) { - wsyserror(_("Could not create %s"), tmp); - wfree(tmp); - return -1; + if ((dest = open( tmp, O_RDWR|O_CREAT|O_BINARY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) + == 0) { + wsyserror(_("Could not create %s"), tmp); + wfree(tmp); + return -1; } wfree(tmp); - - + + /* Copy the file */ while ((n = read(src, buf, BUFSIZE)) > 0) { - if (write (dest, buf, n) != n) { - wsyserror(_("Write error on file %s"), destFile); - return -1; - } + if (write (dest, buf, n) != n) { + wsyserror(_("Write error on file %s"), destFile); + return -1; + } } - + return 0; } @@ -3679,23 +3679,23 @@ generateNewFilename(char *curName) int baseLen; char *ptr; char *newName; - - + + assert(curName); - - ptr = curName; - + + ptr = curName; + if (((ptr = strrchr(ptr, '{'))==0) || sscanf(ptr, "{%i}%c", &n, &c)!=1) - return wstrconcat(curName, " {1}"); - + return wstrconcat(curName, " {1}"); + baseLen = ptr - curName -1; - + newName = wmalloc(baseLen + 16); strncpy(newName, curName, baseLen); newName[baseLen] = 0; - + sprintf(&newName[baseLen], " {%i}", n+1); - + return newName; } @@ -3704,33 +3704,33 @@ void convertCPColor(CPColor *color) { unsigned short old_hue = 0; - + switch (color->set) { - case cpNone: - wwarning(_("Color Panel: Color unspecified")); - return; - case cpRGB: - old_hue = color->hsv.hue; - RRGBtoHSV(&(color->rgb), &(color->hsv)); - - /* In black the hue is undefined, and may change by conversion - * Same for white. */ - if ( - ((color->rgb.red == 0) && - (color->rgb.green == 0) && - (color->rgb.blue == 0)) || - ((color->rgb.red == 0) && - (color->rgb.green == 0) && - (color->rgb.blue == 255)) - ) - color->hsv.hue = old_hue; - break; - case cpHSV: - RHSVtoRGB(&(color->hsv), &(color->rgb)); - break; + case cpNone: + wwarning(_("Color Panel: Color unspecified")); + return; + case cpRGB: + old_hue = color->hsv.hue; + RRGBtoHSV(&(color->rgb), &(color->hsv)); + + /* In black the hue is undefined, and may change by conversion + * Same for white. */ + if ( + ((color->rgb.red == 0) && + (color->rgb.green == 0) && + (color->rgb.blue == 0)) || + ((color->rgb.red == 0) && + (color->rgb.green == 0) && + (color->rgb.blue == 255)) + ) + color->hsv.hue = old_hue; + break; + case cpHSV: + RHSVtoRGB(&(color->hsv), &(color->rgb)); + break; } } - + #define ABS_SHIFT(val, shift) \ (((shift) > 0) ? (val) >> (shift) : (val) << -(shift)) @@ -3740,15 +3740,15 @@ ulongToRColor(WMScreen *scr, unsigned long value) { RColor color; XColor *xcolor = NULL; - + if (!(xcolor = wmalloc(sizeof(XColor)) )) { - wwarning(_("Color Panel: Could not allocate memory")); - color.red = 0; - color.green = 0; - color.blue = 0; - return color; + wwarning(_("Color Panel: Could not allocate memory")); + color.red = 0; + color.green = 0; + color.blue = 0; + return color; } - + xcolor->pixel = value; XQueryColor(scr->display, scr->rcontext->cmap, xcolor); @@ -3757,7 +3757,7 @@ ulongToRColor(WMScreen *scr, unsigned long value) color.blue = xcolor->blue >> 8; wfree(xcolor); - + return color; } @@ -3768,11 +3768,11 @@ getShift(unsigned char value) unsigned char i = -1; if (value == 0) - return 0; + return 0; while (value) { - value >>= 1; - i++; + value >>= 1; + i++; } return i; @@ -3784,3 +3784,4 @@ getShift(unsigned char value) #undef SHAPE_WAS_DEFINED #define SHAPE #endif + diff --git a/WINGs/wevent.c b/WINGs/wevent.c index f1a62a38..f3b2cfef 100644 --- a/WINGs/wevent.c +++ b/WINGs/wevent.c @@ -16,9 +16,9 @@ static unsigned long eventMasks[] = { ButtonPressMask, /* ButtonPress */ ButtonReleaseMask, /* ButtonRelease */ PointerMotionMask|PointerMotionHintMask|ButtonMotionMask - |Button1MotionMask|Button2MotionMask|Button3MotionMask - |Button4MotionMask|Button5MotionMask, - /* MotionNotify */ + |Button1MotionMask|Button2MotionMask|Button3MotionMask + |Button4MotionMask|Button5MotionMask, + /* MotionNotify */ EnterWindowMask, /* EnterNotify */ LeaveWindowMask, /* LeaveNotify */ FocusChangeMask, /* FocusIn */ diff --git a/WINGs/wfilepanel.c b/WINGs/wfilepanel.c index 0ac07ba2..b2ddea4e 100644 --- a/WINGs/wfilepanel.c +++ b/WINGs/wfilepanel.c @@ -16,18 +16,18 @@ typedef struct W_FilePanel { WMWindow *win; - + WMLabel *iconLabel; WMLabel *titleLabel; - + WMFrame *line; WMLabel *nameLabel; WMBrowser *browser; - + WMButton *okButton; WMButton *cancelButton; - + WMButton *homeButton; WMButton *trashcanButton; WMButton *createDirButton; @@ -37,20 +37,20 @@ typedef struct W_FilePanel { WMView *accessoryView; WMTextField *fileField; - + char **fileTypes; struct { - unsigned int canExit:1; - unsigned int canceled:1; /* clicked on cancel */ - unsigned int filtered:1; - unsigned int canChooseFiles:1; - unsigned int canChooseDirectories:1; - unsigned int autoCompletion:1; - unsigned int showAllFiles:1; - unsigned int canFreeFileTypes:1; - unsigned int fileMustExist:1; - unsigned int panelType:1; + unsigned int canExit:1; + unsigned int canceled:1; /* clicked on cancel */ + unsigned int filtered:1; + unsigned int canChooseFiles:1; + unsigned int canChooseDirectories:1; + unsigned int autoCompletion:1; + unsigned int showAllFiles:1; + unsigned int canFreeFileTypes:1; + unsigned int fileMustExist:1; + unsigned int panelType:1; } flags; } W_FilePanel; @@ -67,7 +67,7 @@ static void browserClick(); static void browserDClick(); static void fillColumn(WMBrowserDelegate *self, WMBrowser *bPtr, int column, - WMList *list); + WMList *list); static void deleteFile(); @@ -89,10 +89,10 @@ static void handleEvents(XEvent *event, void *data); static WMBrowserDelegate browserDelegate = { NULL, /* data */ - fillColumn, /* createRowsForColumn */ - NULL, /* titleOfColumn */ - NULL, /* didScroll */ - NULL /* willScroll */ + fillColumn, /* createRowsForColumn */ + NULL, /* titleOfColumn */ + NULL, /* didScroll */ + NULL /* willScroll */ }; @@ -104,15 +104,15 @@ closestListItem(WMList *list, char *text, Bool exact) int i, len = strlen(text); if (len==0) - return -1; + return -1; for(i=0; itext) >= len && ((exact && strcmp(item->text, text)==0) || (!exact && strncmp(item->text, text, len)==0))) { - return i; - } + return i; + } } return -1; @@ -129,7 +129,7 @@ textChangedObserver(void *observerData, WMNotification *notification) int i, textEvent; if (!(list = WMGetBrowserListInColumn(panel->browser, col))) - return; + return; text = WMGetTextFieldText(panel->fileField); textEvent = (int)WMGetNotificationClientData(notification); @@ -144,19 +144,19 @@ textChangedObserver(void *observerData, WMNotification *notification) WMListItem *item = WMGetListItem(list, i); int textLen = strlen(text), itemTextLen = strlen(item->text); int visibleItems = WMWidgetHeight(list)/WMGetListItemHeight(list); - + WMSetListPosition(list, i - visibleItems/2); - + if (textEvent!=WMDeleteTextEvent) { WMRange range; - WMInsertTextFieldText(panel->fileField, &item->text[textLen], + WMInsertTextFieldText(panel->fileField, &item->text[textLen], textLen); - range.position = textLen; - range.count = itemTextLen - textLen; - WMSelectTextFieldRange(panel->fileField, range); + range.position = textLen; + range.count = itemTextLen - textLen; + WMSelectTextFieldRange(panel->fileField, range); /*WMSetTextFieldCursorPosition(panel->fileField, itemTextLen);*/ - } + } } wfree(text); @@ -169,7 +169,7 @@ textEditedObserver(void *observerData, WMNotification *notification) W_FilePanel *panel = (W_FilePanel*)observerData; if ((int)WMGetNotificationClientData(notification)==WMReturnTextMovement) { - WMPerformButtonClick(panel->okButton); + WMPerformButtonClick(panel->okButton); } } @@ -186,7 +186,7 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title) memset(fPtr, 0, sizeof(WMFilePanel)); fPtr->win = WMCreateWindowWithStyle(scrPtr, name, WMTitledWindowMask - |WMResizableWindowMask); + |WMResizableWindowMask); WMResizeWidget(fPtr->win, PWIDTH, PHEIGHT); WMSetWindowTitle(fPtr->win, ""); @@ -206,7 +206,7 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title) } else { WMSetLabelImage(fPtr->iconLabel, scrPtr->applicationIconPixmap); } - + fPtr->titleLabel = WMCreateLabel(fPtr->win); WMResizeWidget(fPtr->titleLabel, PWIDTH-64, 64); WMMoveWidget(fPtr->titleLabel, 64, 0); @@ -214,7 +214,7 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title) WMSetLabelFont(fPtr->titleLabel, largeFont); WMReleaseFont(largeFont); WMSetLabelText(fPtr->titleLabel, title); - + fPtr->line = WMCreateFrame(fPtr->win); WMMoveWidget(fPtr->line, 0, 64); WMResizeWidget(fPtr->line, PWIDTH, 2); @@ -233,17 +233,17 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title) WMMoveWidget(fPtr->nameLabel, 7, 282); WMResizeWidget(fPtr->nameLabel, 55, 14); WMSetLabelText(fPtr->nameLabel, _("Name:")); - + fPtr->fileField = WMCreateTextField(fPtr->win); WMMoveWidget(fPtr->fileField, 60, 278); WMResizeWidget(fPtr->fileField, PWIDTH-60-10, 24); WMAddNotificationObserver(textEditedObserver, fPtr, - WMTextDidEndEditingNotification, - fPtr->fileField); + WMTextDidEndEditingNotification, + fPtr->fileField); WMAddNotificationObserver(textChangedObserver, fPtr, - WMTextDidChangeNotification, - fPtr->fileField); - + WMTextDidChangeNotification, + fPtr->fileField); + fPtr->okButton = WMCreateCommandButton(fPtr->win); WMMoveWidget(fPtr->okButton, 245, 325); WMResizeWidget(fPtr->okButton, 75, 28); @@ -252,7 +252,7 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title) WMSetButtonAltImage(fPtr->okButton, scrPtr->pushedButtonArrow); WMSetButtonImagePosition(fPtr->okButton, WIPRight); WMSetButtonAction(fPtr->okButton, buttonClick, fPtr); - + fPtr->cancelButton = WMCreateCommandButton(fPtr->win); WMMoveWidget(fPtr->cancelButton, 165, 325); WMResizeWidget(fPtr->cancelButton, 75, 28); @@ -308,10 +308,10 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title) WMSetTextFieldCursorPosition(fPtr->fileField, 0); WMLoadBrowserColumnZero(fPtr->browser); - + WMSetWindowInitialPosition(fPtr->win, - (scrPtr->rootView->size.width - WMWidgetWidth(fPtr->win))/2, - (scrPtr->rootView->size.height - WMWidgetHeight(fPtr->win))/2); + (scrPtr->rootView->size.width - WMWidgetWidth(fPtr->win))/2, + (scrPtr->rootView->size.height - WMWidgetHeight(fPtr->win))/2); fPtr->flags.canChooseFiles = 1; fPtr->flags.canChooseDirectories = 1; @@ -325,9 +325,9 @@ WMOpenPanel* WMGetOpenPanel(WMScreen *scrPtr) { WMFilePanel *panel; - + if (scrPtr->sharedOpenPanel) - return scrPtr->sharedOpenPanel; + return scrPtr->sharedOpenPanel; panel = makeFilePanel(scrPtr, "openFilePanel", _("Open")); panel->flags.fileMustExist = 1; @@ -345,7 +345,7 @@ WMGetSavePanel(WMScreen *scrPtr) WMFilePanel *panel; if (scrPtr->sharedSavePanel) - return scrPtr->sharedSavePanel; + return scrPtr->sharedSavePanel; panel = makeFilePanel(scrPtr, "saveFilePanel", _("Save")); panel->flags.fileMustExist = 0; @@ -361,10 +361,10 @@ void WMFreeFilePanel(WMFilePanel *panel) { if (panel == WMWidgetScreen(panel->win)->sharedSavePanel) { - WMWidgetScreen(panel->win)->sharedSavePanel = NULL; + WMWidgetScreen(panel->win)->sharedSavePanel = NULL; } if (panel == WMWidgetScreen(panel->win)->sharedOpenPanel) { - WMWidgetScreen(panel->win)->sharedOpenPanel = NULL; + WMWidgetScreen(panel->win)->sharedOpenPanel = NULL; } WMRemoveNotificationObserver(panel); WMUnmapWidget(panel->win); @@ -412,7 +412,7 @@ WMRunModalFilePanelForDirectory(WMFilePanel *panel, WMWindow *owner, WMRunModalLoop(scr, W_VIEW(panel->win)); /* Must withdraw window because the next time we map - * it, it might have a different transient owner. + * it, it might have a different transient owner. */ WMCloseWindow(panel->win); @@ -447,7 +447,7 @@ WMSetFilePanelDirectory(WMFilePanel *panel, char *path) } } - + void WMSetFilePanelCanChooseDirectories(WMFilePanel *panel, Bool flag) { @@ -501,21 +501,21 @@ static char* get_name_from_path(char *path) { int size; - + assert(path!=NULL); - + size = strlen(path); /* remove trailing / */ while (size > 0 && path[size-1]=='/') - size--; + size--; /* directory was root */ if (size == 0) - return wstrdup("/"); + return wstrdup("/"); while (size > 0 && path[size-1] != '/') - size--; - + size--; + return wstrdup(&(path[size])); } @@ -532,9 +532,9 @@ static int comparer(const void *a, const void *b) { if (CAST(a)->isBranch == CAST(b)->isBranch) - return (strcmp(CAST(a)->text, CAST(b)->text)); + return (strcmp(CAST(a)->text, CAST(b)->text)); if (CAST(a)->isBranch) - return (-1); + return (-1); return (1); } #undef CAST @@ -557,40 +557,40 @@ listDirectoryOnColumn(WMFilePanel *panel, int column, char *path) name = get_name_from_path(path); WMSetBrowserColumnTitle(bPtr, column, name); wfree(name); - + dir = opendir(path); - + if (!dir) { #ifdef VERBOSE - printf(_("WINGs: could not open directory %s\n"), path); + printf(_("WINGs: could not open directory %s\n"), path); #endif - return; + return; } /* list contents in the column */ - while ((dentry = readdir(dir))) { - if (strcmp(dentry->d_name, ".")==0 || - strcmp(dentry->d_name, "..")==0) - continue; + while ((dentry = readdir(dir))) { + if (strcmp(dentry->d_name, ".")==0 || + strcmp(dentry->d_name, "..")==0) + continue; - strcpy(pbuf, path); - if (strcmp(path, "/")!=0) - strcat(pbuf, "/"); - strcat(pbuf, dentry->d_name); + strcpy(pbuf, path); + if (strcmp(path, "/")!=0) + strcat(pbuf, "/"); + strcat(pbuf, dentry->d_name); - if (stat(pbuf, &stat_buf)!=0) { + if (stat(pbuf, &stat_buf)!=0) { #ifdef VERBOSE - printf(_("WINGs: could not stat %s\n"), pbuf); + printf(_("WINGs: could not stat %s\n"), pbuf); #endif - continue; - } else { - int isDirectory; - - isDirectory = S_ISDIR(stat_buf.st_mode); - - if (filterFileName(panel, dentry->d_name, isDirectory)) - WMInsertBrowserItem(bPtr, column, -1, dentry->d_name, isDirectory); - } + continue; + } else { + int isDirectory; + + isDirectory = S_ISDIR(stat_buf.st_mode); + + if (filterFileName(panel, dentry->d_name, isDirectory)) + WMInsertBrowserItem(bPtr, column, -1, dentry->d_name, isDirectory); + } } WMSortBrowserColumnWithComparer(bPtr, column, comparer); @@ -603,11 +603,11 @@ fillColumn(WMBrowserDelegate *self, WMBrowser *bPtr, int column, WMList *list) { char *path; WMFilePanel *panel; - + if (column > 0) { - path = WMGetBrowserPathToColumn(bPtr, column-1); + path = WMGetBrowserPathToColumn(bPtr, column-1); } else { - path = wstrdup("/"); + path = wstrdup("/"); } panel = WMGetHangedData(bPtr); @@ -616,22 +616,22 @@ fillColumn(WMBrowserDelegate *self, WMBrowser *bPtr, int column, WMList *list) } -static void +static void browserDClick(WMBrowser *bPtr, WMFilePanel *panel) { WMPerformButtonClick(panel->okButton); } -static void +static void browserClick(WMBrowser *bPtr, WMFilePanel *panel) { int col = WMGetBrowserSelectedColumn(bPtr); WMListItem *item = WMGetBrowserSelectedItemInColumn(bPtr, col); if (!item || item->isBranch) - WMSetTextFieldText(panel->fileField, NULL); + WMSetTextFieldText(panel->fileField, NULL); else { - WMSetTextFieldText(panel->fileField, item->text); + WMSetTextFieldText(panel->fileField, item->text); } } @@ -694,14 +694,14 @@ createDir(WMButton *bPre, WMFilePanel *panel) if (mkdir(file,0xfff) != 0) { switch (errno) { - case EACCES: - showError(scr, panel->win, _("Permission denied."), NULL); - break; - case EEXIST: - showError(scr, panel->win, _("'%s' already exists."), file); - break; - case ENOENT: - showError(scr, panel->win, _("Path does not exist."), NULL); + case EACCES: + showError(scr, panel->win, _("Permission denied."), NULL); + break; + case EEXIST: + showError(scr, panel->win, _("'%s' already exists."), file); + break; + case ENOENT: + showError(scr, panel->win, _("Path does not exist."), NULL); } } else WMSetFilePanelDirectory(panel, file); @@ -730,54 +730,54 @@ deleteFile(WMButton *bPre, WMFilePanel *panel) if (stat(file,&filestat)) { switch (errno) { - case ENOENT: - showError(scr, panel->win, _("'%s' does not exist."), file); - break; - case EACCES: - showError(scr, panel->win, _("Permission denied."), NULL); - break; - case ENOMEM: - showError(scr, panel->win, - _("Insufficient memory available."), NULL); - break; - case EROFS: - showError(scr, panel->win, - _("'%s' is on a read-only filesystem."), file); - break; - default: - showError(scr, panel->win, _("Can not delete '%s'."), file); + case ENOENT: + showError(scr, panel->win, _("'%s' does not exist."), file); + break; + case EACCES: + showError(scr, panel->win, _("Permission denied."), NULL); + break; + case ENOMEM: + showError(scr, panel->win, + _("Insufficient memory available."), NULL); + break; + case EROFS: + showError(scr, panel->win, + _("'%s' is on a read-only filesystem."), file); + break; + default: + showError(scr, panel->win, _("Can not delete '%s'."), file); } wfree(file); return; } else if (S_ISDIR(filestat.st_mode)) { - int len = strlen(file)+20; + int len = strlen(file)+20; buffer = wmalloc(len); snprintf(buffer,len,_("Delete directory %s ?"),file); } else { - int len = strlen(file)+15; + int len = strlen(file)+15; buffer = wmalloc(len); snprintf(buffer,len,_("Delete file %s ?"),file); } if (!WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win, - _("Warning"), buffer, _("OK"), _("Cancel"), NULL)) { + _("Warning"), buffer, _("OK"), _("Cancel"), NULL)) { if (S_ISDIR(filestat.st_mode)) { if (rmdir(file) != 0) { switch (errno) { - case EACCES: - showError(scr, panel->win, _("Permission denied."), NULL); - break; - case ENOENT: - showError(scr, panel->win, _("Directory '%s' does not exist."), file); - break; - case ENOTEMPTY: - showError(scr, panel->win, _("Directory '%s' is not empty."), file); - break; - case EBUSY: - showError(scr, panel->win, _("Directory '%s' is busy."), file); - break; - default: - showError(scr, panel->win, _("Can not delete '%s'."), file); + case EACCES: + showError(scr, panel->win, _("Permission denied."), NULL); + break; + case ENOENT: + showError(scr, panel->win, _("Directory '%s' does not exist."), file); + break; + case ENOTEMPTY: + showError(scr, panel->win, _("Directory '%s' is not empty."), file); + break; + case EBUSY: + showError(scr, panel->win, _("Directory '%s' is busy."), file); + break; + default: + showError(scr, panel->win, _("Can not delete '%s'."), file); } } else { char *s = strrchr(file,'/'); @@ -786,25 +786,25 @@ deleteFile(WMButton *bPre, WMFilePanel *panel) } } else if (remove(file) != 0) { switch (errno) { - case EISDIR: - showError(scr, panel->win, _("'%s' is a directory."), file); - break; - case ENOENT: - showError(scr, panel->win, _("'%s' does not exist."), file); - break; - case EACCES: - showError(scr, panel->win, _("Permission denied."), NULL); - break; - case ENOMEM: - showError(scr, panel->win, - _("Insufficient memory available."), NULL); - break; - case EROFS: - showError(scr, panel->win, - _("'%s' is on a read-only filesystem."), file); - break; - default: - showError(scr, panel->win, _("Can not delete '%s'."), file); + case EISDIR: + showError(scr, panel->win, _("'%s' is a directory."), file); + break; + case ENOENT: + showError(scr, panel->win, _("'%s' does not exist."), file); + break; + case EACCES: + showError(scr, panel->win, _("Permission denied."), NULL); + break; + case ENOMEM: + showError(scr, panel->win, + _("Insufficient memory available."), NULL); + break; + case EROFS: + showError(scr, panel->win, + _("'%s' is on a read-only filesystem."), file); + break; + default: + showError(scr, panel->win, _("Can not delete '%s'."), file); } } else { char *s = strrchr(file,'/'); @@ -837,7 +837,7 @@ goFloppy(WMButton *bPtr, WMFilePanel *panel) WINGsConfiguration.floppyPath); return; } - + WMSetFilePanelDirectory(panel, WINGsConfiguration.floppyPath); } @@ -850,13 +850,13 @@ goHome(WMButton *bPtr, WMFilePanel *panel) /* home is statically allocated. Don't free it! */ home = wgethomedir(); if (!home) - return; - + return; + WMSetFilePanelDirectory(panel, home); } -static void +static void handleEvents(XEvent *event, void *data) { W_FilePanel *pPtr = (W_FilePanel*)data; @@ -867,7 +867,7 @@ handleEvents(XEvent *event, void *data) || event->xconfigure.height != view->size.height) { unsigned int newWidth = event->xconfigure.width; unsigned int newHeight = event->xconfigure.height; - int newColumnCount; + int newColumnCount; W_ResizeView(view, newWidth, newHeight); WMResizeWidget(pPtr->line, newWidth, 2); @@ -877,9 +877,9 @@ handleEvents(XEvent *event, void *data) WMMoveWidget(pPtr->nameLabel, 7, newHeight-(PHEIGHT-282)); WMMoveWidget(pPtr->fileField, 60, newHeight-(PHEIGHT-278)); WMMoveWidget(pPtr->okButton, newWidth-(PWIDTH-245), - newHeight-(PHEIGHT-325)); + newHeight-(PHEIGHT-325)); WMMoveWidget(pPtr->cancelButton, newWidth-(PWIDTH-165), - newHeight-(PHEIGHT-325)); + newHeight-(PHEIGHT-325)); WMMoveWidget(pPtr->trashcanButton, 7, newHeight-(PHEIGHT-325)); WMMoveWidget(pPtr->createDirButton, 37, newHeight-(PHEIGHT-325)); @@ -887,8 +887,8 @@ handleEvents(XEvent *event, void *data) WMMoveWidget(pPtr->disketteButton, 97, newHeight-(PHEIGHT-325)); WMMoveWidget(pPtr->unmountButton, 127, newHeight-(PHEIGHT-325)); - newColumnCount = (newWidth - 14) / 140; - WMSetBrowserMaxVisibleColumns(pPtr->browser, newColumnCount); + newColumnCount = (newWidth - 14) / 140; + WMSetBrowserMaxVisibleColumns(pPtr->browser, newColumnCount); } } } @@ -901,24 +901,24 @@ getCurrentFileName(WMFilePanel *panel) char *file; char *tmp; int len; - + path = WMGetBrowserPath(panel->browser); - + len = strlen(path); if (path[len-1]=='/') { - file = WMGetTextFieldText(panel->fileField); - tmp = wmalloc(strlen(path)+strlen(file)+8); + file = WMGetTextFieldText(panel->fileField); + tmp = wmalloc(strlen(path)+strlen(file)+8); if (file[0]!='/') { - strcpy(tmp, path); - strcat(tmp, file); + strcpy(tmp, path); + strcat(tmp, file); } else - strcpy(tmp, file); + strcpy(tmp, file); - wfree(file); - wfree(path); - return tmp; + wfree(file); + wfree(path); + return tmp; } else { - return path; + return path; } } @@ -938,16 +938,16 @@ validOpenFile(WMFilePanel *panel) col = WMGetBrowserSelectedColumn(panel->browser); item = WMGetBrowserSelectedItemInColumn(panel->browser, col); if (item) { - if (item->isBranch && !panel->flags.canChooseDirectories && !haveFile) - return False; - else if (!item->isBranch && !panel->flags.canChooseFiles) + if (item->isBranch && !panel->flags.canChooseDirectories && !haveFile) + return False; + else if (!item->isBranch && !panel->flags.canChooseFiles) return False; else return True; } else { /* we compute for / here */ - if (!panel->flags.canChooseDirectories && !haveFile) - return False; + if (!panel->flags.canChooseDirectories && !haveFile) + return False; else return True; } @@ -964,22 +964,22 @@ buttonClick(WMButton *bPtr, WMFilePanel *panel) if (bPtr == panel->okButton) { if (!validOpenFile(panel)) return; - if (panel->flags.fileMustExist) { - char *file; - - file = getCurrentFileName(panel); - if (access(file, F_OK)!=0) { - WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win, - _("Error"), _("File does not exist."), - _("OK"), NULL, NULL); - wfree(file); - return; - } - wfree(file); - } - panel->flags.canceled = 0; + if (panel->flags.fileMustExist) { + char *file; + + file = getCurrentFileName(panel); + if (access(file, F_OK)!=0) { + WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win, + _("Error"), _("File does not exist."), + _("OK"), NULL, NULL); + wfree(file); + return; + } + wfree(file); + } + panel->flags.canceled = 0; } else - panel->flags.canceled = 1; + panel->flags.canceled = 1; range.count = range.position = 0; WMSelectTextFieldRange(panel->fileField, range); diff --git a/WINGs/wfont_noxft.c b/WINGs/wfont_noxft.c index ffd817c7..af7990b0 100644 --- a/WINGs/wfont_noxft.c +++ b/WINGs/wfont_noxft.c @@ -273,7 +273,7 @@ WMCreateFontWithFlags(WMScreen *scrPtr, char *fontName, WMFontFlags flags) multiByte = False; } - } else if (multiByte) { + if (multiByte) { font = WMCreateFontSet(scrPtr, fontName); } else { font = WMCreateNormalFont(scrPtr, fontName); diff --git a/WINGs/wframe.c b/WINGs/wframe.c index 5d286c96..8cc5acc4 100644 --- a/WINGs/wframe.c +++ b/WINGs/wframe.c @@ -275,3 +275,4 @@ destroyFrame(Frame *fPtr) wfree(fPtr); } + diff --git a/WINGs/widgets.c b/WINGs/widgets.c index 1bc5b6e3..100ad4ad 100644 --- a/WINGs/widgets.c +++ b/WINGs/widgets.c @@ -21,96 +21,96 @@ #define CHECK_BUTTON_ON_HEIGHT 16 static char *CHECK_BUTTON_ON[] = { -" %", -" .............%#", -" ........... .%#", -" .......... #.%#", -" ......... #%.%#", -" ........ #%..%#", -" ... #.. #%...%#", -" ... #% #%....%#", -" ... % #%.....%#", -" ... #%......%#", -" ... #%.......%#", -" ...#%........%#", -" .............%#", -" .............%#", -" %%%%%%%%%%%%%%#", -"%###############"}; + " %", + " .............%#", + " ........... .%#", + " .......... #.%#", + " ......... #%.%#", + " ........ #%..%#", + " ... #.. #%...%#", + " ... #% #%....%#", + " ... % #%.....%#", + " ... #%......%#", + " ... #%.......%#", + " ...#%........%#", + " .............%#", + " .............%#", + " %%%%%%%%%%%%%%#", + "%###############"}; #define CHECK_BUTTON_OFF_WIDTH 16 #define CHECK_BUTTON_OFF_HEIGHT 16 static char *CHECK_BUTTON_OFF[] = { -" %", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" .............%#", -" %%%%%%%%%%%%%%#", -"%###############"}; + " %", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " .............%#", + " %%%%%%%%%%%%%%#", + "%###############"}; #define RADIO_BUTTON_ON_WIDTH 15 #define RADIO_BUTTON_ON_HEIGHT 15 static char *RADIO_BUTTON_ON[] = { -".....%%%%%.....", -"...%%#####%%...", -"..%##.....%.%..", -".%#%.. .....", -".%#. ...", -"%#.. .. ", -"%#. . ", -"%#. . ", -"%#. . ", -"%#. . ", -".%%. . .", -".%.. . .", -"..%... .. ..", -".... ..... ...", -"..... .....", + ".....%%%%%.....", + "...%%#####%%...", + "..%##.....%.%..", + ".%#%.. .....", + ".%#. ...", + "%#.. .. ", + "%#. . ", + "%#. . ", + "%#. . ", + "%#. . ", + ".%%. . .", + ".%.. . .", + "..%... .. ..", + ".... ..... ...", + "..... .....", }; #define RADIO_BUTTON_OFF_WIDTH 15 #define RADIO_BUTTON_OFF_HEIGHT 15 static char *RADIO_BUTTON_OFF[] = { -".....%%%%%.....", -"...%%#####%%...", -"..%##.......%..", -".%#%...........", -".%#............", -"%#............ ", -"%#............ ", -"%#............ ", -"%#............ ", -"%#............ ", -".%%.......... .", -".%........... .", -"..%......... ..", -".... ..... ...", -"..... .....", + ".....%%%%%.....", + "...%%#####%%...", + "..%##.......%..", + ".%#%...........", + ".%#............", + "%#............ ", + "%#............ ", + "%#............ ", + "%#............ ", + "%#............ ", + ".%%.......... .", + ".%........... .", + "..%......... ..", + ".... ..... ...", + "..... .....", }; static char *BUTTON_ARROW[] = { -"..................", -"....##....#### ...", -"...#.%....#... ...", -"..#..%#####... ...", -".#............ ...", -"#............. ...", -".#............ ...", -"..#.. ...", -"...#. ............", -"....# ............" + "..................", + "....##....#### ...", + "...#.%....#... ...", + "..#..%#####... ...", + ".#............ ...", + "#............. ...", + ".#............ ...", + "..#.. ...", + "...#. ............", + "....# ............" }; #define BUTTON_ARROW_WIDTH 18 @@ -118,16 +118,16 @@ static char *BUTTON_ARROW[] = { static char *BUTTON_ARROW2[] = { -" ", -" ## ####. ", -" # % # . ", -" # %##### . ", -" # . ", -"# . ", -" # . ", -" # .......... ", -" # . ", -" #. " + " ", + " ## ####. ", + " # % # . ", + " # %##### . ", + " # . ", + "# . ", + " # . ", + " # .......... ", + " # . ", + " #. " }; #define BUTTON_ARROW2_WIDTH 18 @@ -135,12 +135,12 @@ static char *BUTTON_ARROW2[] = { static char *SCROLLER_DIMPLE[] = { -".%###.", -"%#%%%%", -"#%%...", -"#%.. ", -"#%. ", -".%. ." + ".%###.", + "%#%%%%", + "#%%...", + "#%.. ", + "#%. ", + ".%. ." }; #define SCROLLER_DIMPLE_WIDTH 6 @@ -148,27 +148,27 @@ static char *SCROLLER_DIMPLE[] = { static char *SCROLLER_ARROW_UP[] = { -"....%....", -"....#....", -"...%#%...", -"...###...", -"..%###%..", -"..#####..", -".%#####%.", -".#######.", -"%#######%" + "....%....", + "....#....", + "...%#%...", + "...###...", + "..%###%..", + "..#####..", + ".%#####%.", + ".#######.", + "%#######%" }; static char *HI_SCROLLER_ARROW_UP[] = { -" % ", -" % ", -" %%% ", -" %%% ", -" %%%%% ", -" %%%%% ", -" %%%%%%% ", -" %%%%%%% ", -"%%%%%%%%%" + " % ", + " % ", + " %%% ", + " %%% ", + " %%%%% ", + " %%%%% ", + " %%%%%%% ", + " %%%%%%% ", + "%%%%%%%%%" }; #define SCROLLER_ARROW_UP_WIDTH 9 @@ -176,27 +176,27 @@ static char *HI_SCROLLER_ARROW_UP[] = { static char *SCROLLER_ARROW_DOWN[] = { -"%#######%", -".#######.", -".%#####%.", -"..#####..", -"..%###%..", -"...###...", -"...%#%...", -"....#....", -"....%...." + "%#######%", + ".#######.", + ".%#####%.", + "..#####..", + "..%###%..", + "...###...", + "...%#%...", + "....#....", + "....%...." }; static char *HI_SCROLLER_ARROW_DOWN[] = { -"%%%%%%%%%", -" %%%%%%% ", -" %%%%%%% ", -" %%%%% ", -" %%%%% ", -" %%% ", -" %%% ", -" % ", -" % " + "%%%%%%%%%", + " %%%%%%% ", + " %%%%%%% ", + " %%%%% ", + " %%%%% ", + " %%% ", + " %%% ", + " % ", + " % " }; #define SCROLLER_ARROW_DOWN_WIDTH 9 @@ -205,27 +205,27 @@ static char *HI_SCROLLER_ARROW_DOWN[] = { static char *SCROLLER_ARROW_LEFT[] = { -"........%", -"......%##", -"....%####", -"..%######", -"%########", -"..%######", -"....%####", -"......%##", -"........%" + "........%", + "......%##", + "....%####", + "..%######", + "%########", + "..%######", + "....%####", + "......%##", + "........%" }; static char *HI_SCROLLER_ARROW_LEFT[] = { -" %", -" %%%", -" %%%%%", -" %%%%%%%", -"%%%%%%%%%", -" %%%%%%%", -" %%%%%", -" %%%", -" %" + " %", + " %%%", + " %%%%%", + " %%%%%%%", + "%%%%%%%%%", + " %%%%%%%", + " %%%%%", + " %%%", + " %" }; #define SCROLLER_ARROW_LEFT_WIDTH 9 @@ -233,27 +233,27 @@ static char *HI_SCROLLER_ARROW_LEFT[] = { static char *SCROLLER_ARROW_RIGHT[] = { -"%........", -"##%......", -"####%....", -"######%..", -"########%", -"######%..", -"####%....", -"##%......", -"%........" + "%........", + "##%......", + "####%....", + "######%..", + "########%", + "######%..", + "####%....", + "##%......", + "%........" }; static char *HI_SCROLLER_ARROW_RIGHT[] = { -"% ", -"%%% ", -"%%%%% ", -"%%%%%%% ", -"%%%%%%%%%", -"%%%%%%% ", -"%%%%% ", -"%%% ", -"% " + "% ", + "%%% ", + "%%%%% ", + "%%%%%%% ", + "%%%%%%%%%", + "%%%%%%% ", + "%%%%% ", + "%%% ", + "% " }; #define SCROLLER_ARROW_RIGHT_WIDTH 9 @@ -261,14 +261,14 @@ static char *HI_SCROLLER_ARROW_RIGHT[] = { static char *POPUP_INDICATOR[] = { -" #==", -" ......%#==", -" ......%#%%", -" ......%#%%", -" %%%%%%%#%%", -"#########%%", -"==%%%%%%%%%", -"==%%%%%%%%%" + " #==", + " ......%#==", + " ......%#%%", + " ......%#%%", + " %%%%%%%#%%", + "#########%%", + "==%%%%%%%%%", + "==%%%%%%%%%" }; #define POPUP_INDICATOR_WIDTH 11 @@ -277,13 +277,13 @@ static char *POPUP_INDICATOR[] = { static char *PULLDOWN_INDICATOR[] = { -"=#######=", -"=%===== =", -"==%=== ==", -"==%=== ==", -"===%= ===", -"===%= ===", -"====%====" + "=#######=", + "=%===== =", + "==%=== ==", + "==%=== ==", + "===%= ===", + "===%= ===", + "====%====" }; #define PULLDOWN_INDICATOR_WIDTH 9 #define PULLDOWN_INDICATOR_HEIGHT 7 @@ -293,16 +293,16 @@ static char *PULLDOWN_INDICATOR[] = { #define CHECK_MARK_HEIGHT 10 static char *CHECK_MARK[] = { -"======== ", -"======= #", -"====== #%", -"===== #%=", -" #== #%==", -" #% #%===", -" % #%====", -" #%=====", -" #%======", -"#%======="}; + "======== ", + "======= #", + "====== #%", + "===== #%=", + " #== #%==", + " #% #%===", + " % #%====", + " #%=====", + " #%======", + "#%======="}; #define STIPPLE_WIDTH 8 diff --git a/WINGs/winputmethod.c b/WINGs/winputmethod.c index eb91211d..b8149094 100644 --- a/WINGs/winputmethod.c +++ b/WINGs/winputmethod.c @@ -8,7 +8,7 @@ typedef struct W_IMContext { XIM xim; - + struct W_ICContext *icList; } WMIMContext; @@ -17,7 +17,7 @@ typedef struct W_ICContext { struct W_ICContext *next; struct W_ICContext *prev; - XIC xic; + XIC xic; } WMICContext; @@ -26,27 +26,27 @@ Bool W_InitIMStuff(WMScreen *scr) { WMIMContext *ctx; - + ctx = scr->imctx = wmalloc(sizeof(WMIMContext)); - + ctx->xim = XOpenIM(scr->display, NULL, NULL, NULL); if (ctx->xim == NULL) { - wwarning("could not open IM"); - return False; + wwarning("could not open IM"); + return False; } - -// XGetIMValues(scr->display, + + //XGetIMValues(scr->display, } void W_CloseIMStuff(WMScreen *scr) { - if (!scr->imctx) - return; + if (!scr->imctx) + return; if (scr->imctx->xim) - XCloseIM(scr->imctx->xim); + XCloseIM(scr->imctx->xim); wfree(scr->imctx); scr->imctx = NULL; } @@ -58,11 +58,11 @@ W_CreateIC(WMView *view) { WMScreen *scr = W_VIEW_SCREEN(view); WMICContext *ctx; - + ctx->prev = NULL; ctx->next = scr->imctx->icList; if (scr->imctx->icList) - scr->imctx->icList->prev = ctx; + scr->imctx->icList->prev = ctx; //scr->imctx = ctx; } @@ -71,8 +71,8 @@ void W_DestroyIC(WMICContext *ctx) { XDestroyIC(ctx->xic); - - + + } @@ -80,7 +80,7 @@ int W_LookupString(WMView *view, XKeyEvent *event, char buffer, int bufsize, KeySym ksym) { - + } diff --git a/WINGs/wlabel.c b/WINGs/wlabel.c index fd51a464..bb08e5d4 100644 --- a/WINGs/wlabel.c +++ b/WINGs/wlabel.c @@ -9,22 +9,22 @@ typedef struct W_Label { W_Class widgetClass; W_View *view; - + char *caption; WMColor *textColor; WMFont *font; /* if NULL, use default */ - + W_Pixmap *image; struct { - WMReliefType relief:3; - WMImagePosition imagePosition:4; - WMAlignment alignment:2; - - unsigned int noWrap:1; + WMReliefType relief:3; + WMImagePosition imagePosition:4; + WMAlignment alignment:2; - unsigned int redrawPending:1; + unsigned int noWrap:1; + + unsigned int redrawPending:1; } flags; } Label; @@ -47,23 +47,23 @@ WMLabel* WMCreateLabel(WMWidget *parent) { Label *lPtr; - + lPtr = wmalloc(sizeof(Label)); memset(lPtr, 0, sizeof(Label)); lPtr->widgetClass = WC_Label; - + lPtr->view = W_CreateView(W_VIEW(parent)); if (!lPtr->view) { - wfree(lPtr); - return NULL; + wfree(lPtr); + return NULL; } lPtr->view->self = lPtr; - + lPtr->textColor = WMRetainColor(lPtr->view->screen->black); - + WMCreateEventHandler(lPtr->view, ExposureMask|StructureNotifyMask, - handleEvents, lPtr); + handleEvents, lPtr); W_ResizeView(lPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT); lPtr->flags.alignment = DEFAULT_ALIGNMENT; @@ -78,16 +78,16 @@ WMCreateLabel(WMWidget *parent) void WMSetLabelImage(WMLabel *lPtr, WMPixmap *image) { - if (lPtr->image!=NULL) - WMReleasePixmap(lPtr->image); - + if (lPtr->image!=NULL) + WMReleasePixmap(lPtr->image); + if (image) - lPtr->image = WMRetainPixmap(image); + lPtr->image = WMRetainPixmap(image); else - lPtr->image = NULL; + lPtr->image = NULL; if (lPtr->view->flags.realized) { - paintLabel(lPtr); + paintLabel(lPtr); } } @@ -111,17 +111,17 @@ WMSetLabelImagePosition(WMLabel *lPtr, WMImagePosition position) { lPtr->flags.imagePosition = position; if (lPtr->view->flags.realized) { - paintLabel(lPtr); + paintLabel(lPtr); } } - + void WMSetLabelTextAlignment(WMLabel *lPtr, WMAlignment alignment) { lPtr->flags.alignment = alignment; if (lPtr->view->flags.realized) { - paintLabel(lPtr); + paintLabel(lPtr); } } @@ -131,7 +131,7 @@ WMSetLabelRelief(WMLabel *lPtr, WMReliefType relief) { lPtr->flags.relief = relief; if (lPtr->view->flags.realized) { - paintLabel(lPtr); + paintLabel(lPtr); } } @@ -140,15 +140,15 @@ void WMSetLabelText(WMLabel *lPtr, char *text) { if (lPtr->caption) - wfree(lPtr->caption); - + wfree(lPtr->caption); + if (text!=NULL) { - lPtr->caption = wstrdup(text); + lPtr->caption = wstrdup(text); } else { - lPtr->caption = NULL; + lPtr->caption = NULL; } if (lPtr->view->flags.realized) { - paintLabel(lPtr); + paintLabel(lPtr); } } @@ -162,16 +162,16 @@ WMGetLabelFont(WMLabel *lPtr) void WMSetLabelFont(WMLabel *lPtr, WMFont *font) -{ +{ if (lPtr->font!=NULL) - WMReleaseFont(lPtr->font); + WMReleaseFont(lPtr->font); if (font) - lPtr->font = WMRetainFont(font); + lPtr->font = WMRetainFont(font); else - lPtr->font = NULL; + lPtr->font = NULL; if (lPtr->view->flags.realized) { - paintLabel(lPtr); + paintLabel(lPtr); } } @@ -180,11 +180,11 @@ void WMSetLabelTextColor(WMLabel *lPtr, WMColor *color) { if (lPtr->textColor) - WMReleaseColor(lPtr->textColor); + WMReleaseColor(lPtr->textColor); lPtr->textColor = WMRetainColor(color); if (lPtr->view->flags.realized) { - paintLabel(lPtr); + paintLabel(lPtr); } } @@ -194,9 +194,9 @@ WMSetLabelWraps(WMLabel *lPtr, Bool flag) { flag = ((flag==0) ? 0 : 1); if (lPtr->flags.noWrap != !flag) { - lPtr->flags.noWrap = !flag; - if (lPtr->view->flags.realized) - paintLabel(lPtr); + lPtr->flags.noWrap = !flag; + if (lPtr->view->flags.realized) + paintLabel(lPtr); } } @@ -208,10 +208,10 @@ paintLabel(Label *lPtr) W_PaintTextAndImage(lPtr->view, !lPtr->flags.noWrap, lPtr->textColor ? lPtr->textColor : scrPtr->black, - (lPtr->font!=NULL ? lPtr->font : scrPtr->normalFont), - lPtr->flags.relief, lPtr->caption, - lPtr->flags.alignment, lPtr->image, - lPtr->flags.imagePosition, NULL, 0); + (lPtr->font!=NULL ? lPtr->font : scrPtr->normalFont), + lPtr->flags.relief, lPtr->caption, + lPtr->flags.alignment, lPtr->image, + lPtr->flags.imagePosition, NULL, 0); } @@ -225,15 +225,15 @@ handleEvents(XEvent *event, void *data) switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintLabel(lPtr); - break; - - case DestroyNotify: - destroyLabel(lPtr); - break; + case Expose: + if (event->xexpose.count!=0) + break; + paintLabel(lPtr); + break; + + case DestroyNotify: + destroyLabel(lPtr); + break; } } @@ -242,16 +242,18 @@ static void destroyLabel(Label *lPtr) { if (lPtr->textColor) - WMReleaseColor(lPtr->textColor); - + WMReleaseColor(lPtr->textColor); + if (lPtr->caption) - wfree(lPtr->caption); + wfree(lPtr->caption); if (lPtr->font) - WMReleaseFont(lPtr->font); + WMReleaseFont(lPtr->font); if (lPtr->image) - WMReleasePixmap(lPtr->image); + WMReleasePixmap(lPtr->image); wfree(lPtr); } + + diff --git a/WINGs/wmenuitem.c b/WINGs/wmenuitem.c index 718e09f2..d57a9300 100644 --- a/WINGs/wmenuitem.c +++ b/WINGs/wmenuitem.c @@ -20,14 +20,14 @@ typedef struct W_MenuItem { struct W_Menu *submenu; void *object; - + WMPixmap *onStateImage; WMPixmap *offStateImage; WMPixmap *mixedStateImage; struct { - unsigned enabled:1; - unsigned state:2; + unsigned enabled:1; + unsigned state:2; } flags; } MenuItem; @@ -53,12 +53,12 @@ WMMenuItem* WMCreateMenuItem(void) { WMMenuItem *item; - + item = wmalloc(sizeof(WMMenuItem)); memset(item, 0, sizeof(WMMenuItem)); item->flags.enabled = 1; - + return item; } @@ -67,22 +67,22 @@ void WMDestroyMenuItem(WMMenuItem *item) { if (item->title) - wfree(item->title); + wfree(item->title); if (item->image) - WMReleasePixmap(item->image); + WMReleasePixmap(item->image); if (item->shortcutKey) - wfree(item->shortcutKey); - + wfree(item->shortcutKey); + if (item->onStateImage) - WMReleasePixmap(item->onStateImage); - + WMReleasePixmap(item->onStateImage); + if (item->offStateImage) - WMReleasePixmap(item->offStateImage); - + WMReleasePixmap(item->offStateImage); + if (item->mixedStateImage) - WMReleasePixmap(item->mixedStateImage); + WMReleasePixmap(item->mixedStateImage); } @@ -119,7 +119,7 @@ void WMSetMenuItemShortcut(WMMenuItem *item, char *shortcut) { if (item->shortcutKey) - wfree(item->shortcutKey); + wfree(item->shortcutKey); item->shortcutKey = wstrdup(shortcut); } @@ -172,12 +172,12 @@ void WMSetMenuItemTitle(WMMenuItem *item, char *title) { if (item->title) - wfree(item->title); - + wfree(item->title); + if (title) - item->title = wstrdup(title); + item->title = wstrdup(title); else - item->title = NULL; + item->title = NULL; } @@ -206,7 +206,7 @@ void WMSetMenuItemPixmap(WMMenuItem *item, WMPixmap *pixmap) { if (item->image) - WMReleasePixmap(item->image); + WMReleasePixmap(item->image); item->image = WMRetainPixmap(pixmap); } @@ -223,8 +223,8 @@ void WMSetMenuItemOnStatePixmap(WMMenuItem *item, WMPixmap *pixmap) { if (item->onStateImage) - WMReleasePixmap(item->onStateImage); - + WMReleasePixmap(item->onStateImage); + item->onStateImage = WMRetainPixmap(pixmap); } @@ -240,8 +240,8 @@ void WMSetMenuItemOffStatePixmap(WMMenuItem *item, WMPixmap *pixmap) { if (item->offStateImage) - WMReleasePixmap(item->offStateImage); - + WMReleasePixmap(item->offStateImage); + item->offStateImage = WMRetainPixmap(pixmap); } @@ -258,8 +258,8 @@ void WMSetMenuItemMixedStatePixmap(WMMenuItem *item, WMPixmap *pixmap) { if (item->mixedStateImage) - WMReleasePixmap(item->mixedStateImage); - + WMReleasePixmap(item->mixedStateImage); + item->mixedStateImage = WMRetainPixmap(pixmap); } @@ -271,7 +271,7 @@ WMGetMenuItemMixedStatePixmap(WMMenuItem *item) } -/* +#if 0 void WMSetMenuItemSubmenu(WMMenuItem *item, WMMenu *submenu) { @@ -292,5 +292,5 @@ WMGetMenuItemHasSubmenu(WMMenuItem *item) { return item->submenu != NULL; } +#endif -*/ diff --git a/WINGs/wmisc.c b/WINGs/wmisc.c index 41e50791..f6f48057 100644 --- a/WINGs/wmisc.c +++ b/WINGs/wmisc.c @@ -7,18 +7,18 @@ void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width, - unsigned int height, WMReliefType relief) + unsigned int height, WMReliefType relief) { W_DrawReliefWithGC(scr, d, x, y, width, height, relief, - WMColorGC(scr->black), WMColorGC(scr->darkGray), - WMColorGC(scr->gray), WMColorGC(scr->white)); + WMColorGC(scr->black), WMColorGC(scr->darkGray), + WMColorGC(scr->gray), WMColorGC(scr->white)); } void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y, unsigned int width, - unsigned int height, WMReliefType relief, - GC black, GC dark, GC light, GC white) + unsigned int height, WMReliefType relief, + GC black, GC dark, GC light, GC white) { Display *dpy = scr->display; GC bgc; @@ -27,62 +27,62 @@ W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y, unsigned int width, GC dgc; switch (relief) { - case WRSimple: - XDrawRectangle(dpy, d, black, x, y, width-1, height-1); - return; - - case WRRaised: - bgc = black; - dgc = dark; - wgc = white; - lgc = light; - break; - - case WRSunken: - wgc = dark; - lgc = black; - bgc = white; - dgc = light; - break; - - case WRPushed: - lgc = wgc = black; - dgc = bgc = white; - break; - - case WRRidge: - lgc = bgc = dark; - dgc = wgc = white; - break; - - case WRGroove: - wgc = dgc = dark; - lgc = bgc = white; - break; - - default: - return; + case WRSimple: + XDrawRectangle(dpy, d, black, x, y, width-1, height-1); + return; + + case WRRaised: + bgc = black; + dgc = dark; + wgc = white; + lgc = light; + break; + + case WRSunken: + wgc = dark; + lgc = black; + bgc = white; + dgc = light; + break; + + case WRPushed: + lgc = wgc = black; + dgc = bgc = white; + break; + + case WRRidge: + lgc = bgc = dark; + dgc = wgc = white; + break; + + case WRGroove: + wgc = dgc = dark; + lgc = bgc = white; + break; + + default: + return; } /* top left */ XDrawLine(dpy, d, wgc, x, y, x+width-1, y); if (width > 2 && relief != WRRaised && relief!=WRPushed) { - XDrawLine(dpy, d, lgc, x+1, y+1, x+width-3, y+1); + XDrawLine(dpy, d, lgc, x+1, y+1, x+width-3, y+1); } XDrawLine(dpy, d, wgc, x, y, x, y+height-1); if (height > 2 && relief != WRRaised && relief!=WRPushed) { - XDrawLine(dpy, d, lgc, x+1, y+1, x+1, y+height-3); + XDrawLine(dpy, d, lgc, x+1, y+1, x+1, y+height-3); } /* bottom right */ XDrawLine(dpy, d, bgc, x, y+height-1, x+width-1, y+height-1); if (width > 2 && relief!=WRPushed) { - XDrawLine(dpy, d, dgc, x+1, y+height-2, x+width-2, y+height-2); + XDrawLine(dpy, d, dgc, x+1, y+height-2, x+width-2, y+height-2); } XDrawLine(dpy, d, bgc, x+width-1, y, x+width-1, y+height-1); if (height > 2 && relief!=WRPushed) { - XDrawLine(dpy, d, dgc, x+width-2, y+1, x+width-2, y+height-2); + XDrawLine(dpy, d, dgc, x+width-2, y+1, x+width-2, y+height-2); } } @@ -156,29 +156,29 @@ fitText(char *text, WMFont *font, int width, int wrap) int w; if (text[0]==0) - return 0; + return 0; i = 0; if (wrap) { - if (text[0]=='\n') - return 0; - - do { - i++; - w = WMWidthOfString(font, text, i); - } while (w < width && text[i]!='\n' && text[i]!=0); - - if (text[i]=='\n') - return i; - - /* keep words complete */ - if (!isspace(text[i])) { - j = i; - while (j>1 && !isspace(text[j]) && text[j]!=0) - j--; - if (j>1) - i = j; - } + if (text[0]=='\n') + return 0; + + do { + i++; + w = WMWidthOfString(font, text, i); + } while (w < width && text[i]!='\n' && text[i]!=0); + + if (text[i]=='\n') + return i; + + /* keep words complete */ + if (!isspace(text[i])) { + j = i; + while (j>1 && !isspace(text[j]) && text[j]!=0) + j--; + if (j>1) + i = j; + } } else { i = strcspn(text, "\n\r"); } @@ -198,15 +198,15 @@ W_GetTextHeight(WMFont *font, char *text, int width, int wrap) h = 0; while (length > 0) { - count = fitText(ptr, font, width, wrap); + count = fitText(ptr, font, width, wrap); - h += fheight; + h += fheight; - if (isspace(ptr[count])) - count++; + if (isspace(ptr[count])) + count++; - ptr += count; - length -= count; + ptr += count; + length -= count; } return h; } @@ -214,8 +214,8 @@ W_GetTextHeight(WMFont *font, char *text, int width, int wrap) void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y, - int width, WMAlignment alignment, WMColor *color, - int wrap, char *text, int length) + int width, WMAlignment alignment, WMColor *color, + int wrap, char *text, int length) { char *ptr = text; int line_width; @@ -224,17 +224,17 @@ W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y, int fheight = WMFontHeight(font); while (length > 0) { - count = fitText(ptr, font, width, wrap); + count = fitText(ptr, font, width, wrap); - line_width = WMWidthOfString(font, ptr, count); - if (alignment==WALeft) - line_x = x; - else if (alignment==WARight) - line_x = x + width - line_width; - else - line_x = x + (width - line_width) / 2; + line_width = WMWidthOfString(font, ptr, count); + if (alignment==WALeft) + line_x = x; + else if (alignment==WARight) + line_x = x + width - line_width; + else + line_x = x + (width - line_width) / 2; - WMDrawString(view->screen, d, color, font, line_x, y, ptr, count); + WMDrawString(view->screen, d, color, font, line_x, y, ptr, count); if (wrap && ptr[count]!='\n') y += fheight; @@ -244,17 +244,17 @@ W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y, count++; } - ptr += count; - length -= count; + ptr += count; + length -= count; } } void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font, - WMReliefType relief, char *text, - WMAlignment alignment, W_Pixmap *image, - WMImagePosition position, WMColor *backColor, int ofs) + WMReliefType relief, char *text, + WMAlignment alignment, W_Pixmap *image, + WMImagePosition position, WMColor *backColor, int ofs) { W_Screen *screen = view->screen; int ix, iy; @@ -264,101 +264,101 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font, #ifdef DOUBLE_BUFFER d = XCreatePixmap(screen->display, view->window, - view->size.width, view->size.height, screen->depth); + view->size.width, view->size.height, screen->depth); #endif /* background */ if (backColor) { - XFillRectangle(screen->display, d, WMColorGC(backColor), - 0, 0, view->size.width, view->size.height); + XFillRectangle(screen->display, d, WMColorGC(backColor), + 0, 0, view->size.width, view->size.height); } else { #ifndef DOUBLE_BUFFER - XClearWindow(screen->display, d); + XClearWindow(screen->display, d); #else - XSetForeground(screen->display, screen->copyGC, - view->attribs.background_pixel); - XFillRectangle(screen->display, d, screen->copyGC, 0, 0, - view->size.width, view->size.height); + XSetForeground(screen->display, screen->copyGC, + view->attribs.background_pixel); + XFillRectangle(screen->display, d, screen->copyGC, 0, 0, + view->size.width, view->size.height); #endif } if (relief == WRFlat) { - x = 0; - y = 0; - w = view->size.width; - h = view->size.height; + x = 0; + y = 0; + w = view->size.width; + h = view->size.height; } else { - x = 1; - y = 1; - w = view->size.width - 3; - h = view->size.height - 3; + x = 1; + y = 1; + w = view->size.width - 3; + h = view->size.height - 3; } /* calc. image alignment */ if (position!=WIPNoImage && image!=NULL) { - switch (position) { - case WIPOverlaps: - case WIPImageOnly: - ix = (view->size.width - image->width) / 2; - iy = (view->size.height - image->height) / 2; - /* - x = 2; - y = 0; - */ - break; - - case WIPLeft: - ix = x; - iy = y + (h - image->height) / 2; - x = x + image->width + 5; - y = 0; - w -= image->width + 5; - break; - - case WIPRight: - ix = view->size.width - image->width - x; - iy = y + (h - image->height) / 2; - w -= image->width + 5; - break; - - case WIPBelow: - ix = (view->size.width - image->width) / 2; - iy = h - image->height; - y = 0; - h -= image->height; - break; - - default: - case WIPAbove: - ix = (view->size.width - image->width) / 2; - iy = y; - y = image->height; - h -= image->height; - break; - } - - ix += ofs; - iy += ofs; - - XSetClipOrigin(screen->display, screen->clipGC, ix, iy); - XSetClipMask(screen->display, screen->clipGC, image->mask); - - if (image->depth==1) - XCopyPlane(screen->display, image->pixmap, d, screen->clipGC, - 0, 0, image->width, image->height, ix, iy, 1); - else - XCopyArea(screen->display, image->pixmap, d, screen->clipGC, - 0, 0, image->width, image->height, ix, iy); + switch (position) { + case WIPOverlaps: + case WIPImageOnly: + ix = (view->size.width - image->width) / 2; + iy = (view->size.height - image->height) / 2; + /* + x = 2; + y = 0; + */ + break; + + case WIPLeft: + ix = x; + iy = y + (h - image->height) / 2; + x = x + image->width + 5; + y = 0; + w -= image->width + 5; + break; + + case WIPRight: + ix = view->size.width - image->width - x; + iy = y + (h - image->height) / 2; + w -= image->width + 5; + break; + + case WIPBelow: + ix = (view->size.width - image->width) / 2; + iy = h - image->height; + y = 0; + h -= image->height; + break; + + default: + case WIPAbove: + ix = (view->size.width - image->width) / 2; + iy = y; + y = image->height; + h -= image->height; + break; + } + + ix += ofs; + iy += ofs; + + XSetClipOrigin(screen->display, screen->clipGC, ix, iy); + XSetClipMask(screen->display, screen->clipGC, image->mask); + + if (image->depth==1) + XCopyPlane(screen->display, image->pixmap, d, screen->clipGC, + 0, 0, image->width, image->height, ix, iy, 1); + else + XCopyArea(screen->display, image->pixmap, d, screen->clipGC, + 0, 0, image->width, image->height, ix, iy); } /* draw text */ if (position != WIPImageOnly && text!=NULL) { - int textHeight; + int textHeight; - textHeight = W_GetTextHeight(font, text, w-8, wrap); - W_PaintText(view, d, font, x+ofs+4, y+ofs + (h-textHeight)/2, w-8, - alignment, textColor, wrap, text, strlen(text)); + textHeight = W_GetTextHeight(font, text, w-8, wrap); + W_PaintText(view, d, font, x+ofs+4, y+ofs + (h-textHeight)/2, w-8, + alignment, textColor, wrap, text, strlen(text)); } @@ -367,7 +367,7 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font, #ifdef DOUBLE_BUFFER XCopyArea(screen->display, d, view->window, screen->copyGC, 0, 0, - view->size.width, view->size.height, 0, 0); + view->size.width, view->size.height, 0, 0); XFreePixmap(screen->display, d); #endif } diff --git a/WINGs/wpanel.c b/WINGs/wpanel.c index e7f0988b..d6f21bfe 100644 --- a/WINGs/wpanel.c +++ b/WINGs/wpanel.c @@ -13,11 +13,11 @@ alertPanelOnClick(WMWidget *self, void *clientData) WMBreakModalLoop(WMWidgetScreen(self)); if (self == panel->defBtn) { - panel->result = WAPRDefault; + panel->result = WAPRDefault; } else if (self == panel->othBtn) { - panel->result = WAPROther; + panel->result = WAPROther; } else if (self == panel->altBtn) { - panel->result = WAPRAlternate; + panel->result = WAPRAlternate; } } @@ -27,61 +27,61 @@ handleKeyPress(XEvent *event, void *clientData) { WMAlertPanel *panel = (WMAlertPanel*)clientData; KeySym ksym; - + XLookupString(&event->xkey, NULL, 0, &ksym, NULL); - + if (ksym == XK_Return && panel->defBtn) { - WMPerformButtonClick(panel->defBtn); + WMPerformButtonClick(panel->defBtn); } else if (ksym == XK_Escape) { - if (panel->altBtn || panel->othBtn) { - WMPerformButtonClick(panel->othBtn ? panel->othBtn : panel->altBtn); - } else { - panel->result = WAPRDefault; - WMBreakModalLoop(WMWidgetScreen(panel->win)); - } + if (panel->altBtn || panel->othBtn) { + WMPerformButtonClick(panel->othBtn ? panel->othBtn : panel->altBtn); + } else { + panel->result = WAPRDefault; + WMBreakModalLoop(WMWidgetScreen(panel->win)); + } } } -int +int WMRunAlertPanel(WMScreen *scrPtr, WMWindow *owner, - char *title, char *msg, char *defaultButton, - char *alternateButton, char *otherButton) + char *title, char *msg, char *defaultButton, + char *alternateButton, char *otherButton) { WMAlertPanel *panel; int tmp; panel = WMCreateAlertPanel(scrPtr, owner, title, msg, defaultButton, - alternateButton, otherButton); + alternateButton, otherButton); { - int px, py; - WMView *view = WMWidgetView(panel->win); - - if (owner) { - WMView *oview = WMWidgetView(owner); - WMPoint pt = WMGetViewScreenPosition(oview); - - px = (W_VIEW_WIDTH(oview)-W_VIEW_WIDTH(view))/2; - py = (W_VIEW_HEIGHT(oview)-W_VIEW_HEIGHT(view))/2; - - px += pt.x; - py += pt.y; - } else { - px = (W_VIEW_WIDTH(scrPtr->rootView)-W_VIEW_WIDTH(view))/2; - py = (W_VIEW_HEIGHT(scrPtr->rootView)-W_VIEW_HEIGHT(view))/2; - } - WMSetWindowInitialPosition(panel->win, px, py); + int px, py; + WMView *view = WMWidgetView(panel->win); + + if (owner) { + WMView *oview = WMWidgetView(owner); + WMPoint pt = WMGetViewScreenPosition(oview); + + px = (W_VIEW_WIDTH(oview)-W_VIEW_WIDTH(view))/2; + py = (W_VIEW_HEIGHT(oview)-W_VIEW_HEIGHT(view))/2; + + px += pt.x; + py += pt.y; + } else { + px = (W_VIEW_WIDTH(scrPtr->rootView)-W_VIEW_WIDTH(view))/2; + py = (W_VIEW_HEIGHT(scrPtr->rootView)-W_VIEW_HEIGHT(view))/2; + } + WMSetWindowInitialPosition(panel->win, px, py); } WMMapWidget(panel->win); WMRunModalLoop(scrPtr, W_VIEW(panel->win)); - + tmp = panel->result; WMDestroyAlertPanel(panel); - + return tmp; } @@ -95,10 +95,10 @@ WMDestroyAlertPanel(WMAlertPanel *panel) } -WMAlertPanel* -WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner, - char *title, char *msg, char *defaultButton, - char *alternateButton, char *otherButton) +WMAlertPanel* +WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner, + char *title, char *msg, char *defaultButton, + char *alternateButton, char *otherButton) { WMAlertPanel *panel; int dw=0, aw=0, ow=0, w; @@ -110,16 +110,16 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner, memset(panel, 0, sizeof(WMAlertPanel)); if (owner) { - panel->win = WMCreatePanelWithStyleForWindow(owner, "alertPanel", - WMTitledWindowMask); + panel->win = WMCreatePanelWithStyleForWindow(owner, "alertPanel", + WMTitledWindowMask); } else { - panel->win = WMCreateWindowWithStyle(scrPtr, "alertPanel", - WMTitledWindowMask); + panel->win = WMCreateWindowWithStyle(scrPtr, "alertPanel", + WMTitledWindowMask); } WMSetWindowInitialPosition(panel->win, - (scrPtr->rootView->size.width - WMWidgetWidth(panel->win))/2, - (scrPtr->rootView->size.height - WMWidgetHeight(panel->win))/2); + (scrPtr->rootView->size.width - WMWidgetWidth(panel->win))/2, + (scrPtr->rootView->size.height - WMWidgetHeight(panel->win))/2); WMSetWindowTitle(panel->win, ""); @@ -143,112 +143,112 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner, WMSetLabelImage(panel->iLbl, icon); WMReleasePixmap(icon); } else { - WMSetLabelImage(panel->iLbl, scrPtr->applicationIconPixmap); + WMSetLabelImage(panel->iLbl, scrPtr->applicationIconPixmap); } if (title) { - WMFont *largeFont; - - largeFont = WMBoldSystemFontOfSize(scrPtr, 24); - - panel->tLbl = WMCreateLabel(hbox); - WMMapWidget(panel->tLbl); - WMAddBoxSubview(hbox, WMWidgetView(panel->tLbl), True, True, - 64, 0, 0); - WMSetLabelText(panel->tLbl, title); - WMSetLabelTextAlignment(panel->tLbl, WALeft); - WMSetLabelFont(panel->tLbl, largeFont); - - WMReleaseFont(largeFont); + WMFont *largeFont; + + largeFont = WMBoldSystemFontOfSize(scrPtr, 24); + + panel->tLbl = WMCreateLabel(hbox); + WMMapWidget(panel->tLbl); + WMAddBoxSubview(hbox, WMWidgetView(panel->tLbl), True, True, + 64, 0, 0); + WMSetLabelText(panel->tLbl, title); + WMSetLabelTextAlignment(panel->tLbl, WALeft); + WMSetLabelFont(panel->tLbl, largeFont); + + WMReleaseFont(largeFont); } /* create divider line */ - + panel->line = WMCreateFrame(panel->win); WMMapWidget(panel->line); WMAddBoxSubview(panel->vbox, WMWidgetView(panel->line), False, True, - 2, 2, 5); + 2, 2, 5); WMSetFrameRelief(panel->line, WRGroove); if (msg) { - panel->mLbl = WMCreateLabel(panel->vbox); - WMSetLabelWraps(panel->mLbl, True); - WMMapWidget(panel->mLbl); - WMAddBoxSubview(panel->vbox, WMWidgetView(panel->mLbl), True, True, - WMFontHeight(scrPtr->normalFont)*4, 0, 5); - WMSetLabelText(panel->mLbl, msg); - WMSetLabelTextAlignment(panel->mLbl, WACenter); + panel->mLbl = WMCreateLabel(panel->vbox); + WMSetLabelWraps(panel->mLbl, True); + WMMapWidget(panel->mLbl); + WMAddBoxSubview(panel->vbox, WMWidgetView(panel->mLbl), True, True, + WMFontHeight(scrPtr->normalFont)*4, 0, 5); + WMSetLabelText(panel->mLbl, msg); + WMSetLabelTextAlignment(panel->mLbl, WACenter); } - + panel->hbox = WMCreateBox(panel->vbox); WMSetBoxBorderWidth(panel->hbox, 10); WMSetBoxHorizontal(panel->hbox, True); WMMapWidget(panel->hbox); WMAddBoxSubview(panel->vbox, WMWidgetView(panel->hbox), False, True, 44, 0, 0); - + /* create buttons */ - if (otherButton) - ow = WMWidthOfString(scrPtr->normalFont, otherButton, - strlen(otherButton)); + if (otherButton) + ow = WMWidthOfString(scrPtr->normalFont, otherButton, + strlen(otherButton)); if (alternateButton) - aw = WMWidthOfString(scrPtr->normalFont, alternateButton, - strlen(alternateButton)); - + aw = WMWidthOfString(scrPtr->normalFont, alternateButton, + strlen(alternateButton)); + if (defaultButton) - dw = WMWidthOfString(scrPtr->normalFont, defaultButton, - strlen(defaultButton)); - + dw = WMWidthOfString(scrPtr->normalFont, defaultButton, + strlen(defaultButton)); + dw = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0); - + aw += 30; ow += 30; dw += 30; - + w = WMAX(dw, WMAX(aw, ow)); if ((w+10)*3 < 400) { - aw = w; - ow = w; - dw = w; + aw = w; + ow = w; + dw = w; } else { - int t; + int t; - t = 400 - 40 - aw - ow - dw; - aw += t/3; - ow += t/3; - dw += t/3; + t = 400 - 40 - aw - ow - dw; + aw += t/3; + ow += t/3; + dw += t/3; } if (defaultButton) { - panel->defBtn = WMCreateCommandButton(panel->hbox); - WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel); - WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->defBtn), - False, True, dw, 0, 0); - WMSetButtonText(panel->defBtn, defaultButton); - WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow); - WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow); - WMSetButtonImagePosition(panel->defBtn, WIPRight); + panel->defBtn = WMCreateCommandButton(panel->hbox); + WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel); + WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->defBtn), + False, True, dw, 0, 0); + WMSetButtonText(panel->defBtn, defaultButton); + WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow); + WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow); + WMSetButtonImagePosition(panel->defBtn, WIPRight); } if (alternateButton) { - panel->altBtn = WMCreateCommandButton(panel->hbox); - WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->altBtn), - False, True, aw, 0, 5); - WMSetButtonAction(panel->altBtn, alertPanelOnClick, panel); - WMSetButtonText(panel->altBtn, alternateButton); + panel->altBtn = WMCreateCommandButton(panel->hbox); + WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->altBtn), + False, True, aw, 0, 5); + WMSetButtonAction(panel->altBtn, alertPanelOnClick, panel); + WMSetButtonText(panel->altBtn, alternateButton); } if (otherButton) { - panel->othBtn = WMCreateCommandButton(panel->hbox); - WMSetButtonAction(panel->othBtn, alertPanelOnClick, panel); - WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->othBtn), - False, True, ow, 0, 5); - WMSetButtonText(panel->othBtn, otherButton); + panel->othBtn = WMCreateCommandButton(panel->hbox); + WMSetButtonAction(panel->othBtn, alertPanelOnClick, panel); + WMAddBoxSubviewAtEnd(panel->hbox, WMWidgetView(panel->othBtn), + False, True, ow, 0, 5); + WMSetButtonText(panel->othBtn, otherButton); } - + WMMapSubwidgets(panel->hbox); - + WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask, - handleKeyPress, panel); + handleKeyPress, panel); WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win); @@ -267,9 +267,9 @@ inputBoxOnClick(WMWidget *self, void *clientData) WMBreakModalLoop(WMWidgetScreen(self)); if (self == panel->defBtn) { - panel->result = WAPRDefault; + panel->result = WAPRDefault; } else if (self == panel->altBtn) { - panel->result = WAPRAlternate; + panel->result = WAPRAlternate; } } @@ -280,53 +280,53 @@ handleKeyPress2(XEvent *event, void *clientData) { WMInputPanel *panel = (WMInputPanel*)clientData; KeySym ksym; - + XLookupString(&event->xkey, NULL, 0, &ksym, NULL); - + if (ksym == XK_Return && panel->defBtn) { - WMPerformButtonClick(panel->defBtn); + WMPerformButtonClick(panel->defBtn); } else if (ksym == XK_Escape) { - if (panel->altBtn) { + if (panel->altBtn) { WMPerformButtonClick(panel->altBtn); - } else { - /* printf("got esc\n");*/ - WMBreakModalLoop(WMWidgetScreen(panel->win)); - panel->result = WAPRDefault; - } + } else { + /* printf("got esc\n");*/ + WMBreakModalLoop(WMWidgetScreen(panel->win)); + panel->result = WAPRDefault; + } } } char* -WMRunInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title, - char *msg, char *defaultText, - char *okButton, char *cancelButton) +WMRunInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title, + char *msg, char *defaultText, + char *okButton, char *cancelButton) { WMInputPanel *panel; char *tmp; - panel = WMCreateInputPanel(scrPtr, owner, title, msg, defaultText, - okButton, cancelButton); + panel = WMCreateInputPanel(scrPtr, owner, title, msg, defaultText, + okButton, cancelButton); { - int px, py; - WMView *view = WMWidgetView(panel->win); - - if (owner) { - WMView *oview = WMWidgetView(owner); - WMPoint pt = WMGetViewScreenPosition(oview); - - px = (W_VIEW_WIDTH(oview)-W_VIEW_WIDTH(view))/2; - py = (W_VIEW_HEIGHT(oview)-W_VIEW_HEIGHT(view))/2; - - px += pt.x; - py += pt.y; - } else { - px = (W_VIEW_WIDTH(scrPtr->rootView)-W_VIEW_WIDTH(view))/2; - py = (W_VIEW_HEIGHT(scrPtr->rootView)-W_VIEW_HEIGHT(view))/2; - } - WMSetWindowInitialPosition(panel->win, px, py); + int px, py; + WMView *view = WMWidgetView(panel->win); + + if (owner) { + WMView *oview = WMWidgetView(owner); + WMPoint pt = WMGetViewScreenPosition(oview); + + px = (W_VIEW_WIDTH(oview)-W_VIEW_WIDTH(view))/2; + py = (W_VIEW_HEIGHT(oview)-W_VIEW_HEIGHT(view))/2; + + px += pt.x; + py += pt.y; + } else { + px = (W_VIEW_WIDTH(scrPtr->rootView)-W_VIEW_WIDTH(view))/2; + py = (W_VIEW_HEIGHT(scrPtr->rootView)-W_VIEW_HEIGHT(view))/2; + } + WMSetWindowInitialPosition(panel->win, px, py); } WMMapWidget(panel->win); @@ -334,9 +334,9 @@ WMRunInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title, WMRunModalLoop(scrPtr, W_VIEW(panel->win)); if (panel->result == WAPRDefault) - tmp = WMGetTextFieldText(panel->text); + tmp = WMGetTextFieldText(panel->text); else - tmp = NULL; + tmp = NULL; WMDestroyInputPanel(panel); @@ -359,122 +359,122 @@ static void endedEditingObserver(void *observerData, WMNotification *notification) { WMInputPanel *panel = (WMInputPanel*)observerData; - + switch ((int)WMGetNotificationClientData(notification)) { - case WMReturnTextMovement: - if (panel->defBtn) - WMPerformButtonClick(panel->defBtn); - break; - case WMEscapeTextMovement: - if (panel->altBtn) - WMPerformButtonClick(panel->altBtn); - else { - WMBreakModalLoop(WMWidgetScreen(panel->win)); - panel->result = WAPRDefault; - } - break; - default: - break; + case WMReturnTextMovement: + if (panel->defBtn) + WMPerformButtonClick(panel->defBtn); + break; + case WMEscapeTextMovement: + if (panel->altBtn) + WMPerformButtonClick(panel->altBtn); + else { + WMBreakModalLoop(WMWidgetScreen(panel->win)); + panel->result = WAPRDefault; + } + break; + default: + break; } } WMInputPanel* WMCreateInputPanel(WMScreen *scrPtr, WMWindow *owner, char *title, char *msg, - char *defaultText, char *okButton, char *cancelButton) + char *defaultText, char *okButton, char *cancelButton) { WMInputPanel *panel; int x, dw=0, aw=0, w; - - + + panel = wmalloc(sizeof(WMInputPanel)); memset(panel, 0, sizeof(WMInputPanel)); if (owner) - panel->win = WMCreatePanelWithStyleForWindow(owner, "inputPanel", - WMTitledWindowMask); + panel->win = WMCreatePanelWithStyleForWindow(owner, "inputPanel", + WMTitledWindowMask); else - panel->win = WMCreateWindowWithStyle(scrPtr, "inputPanel", - WMTitledWindowMask); + panel->win = WMCreateWindowWithStyle(scrPtr, "inputPanel", + WMTitledWindowMask); WMSetWindowTitle(panel->win, ""); WMResizeWidget(panel->win, 320, 160); - + if (title) { - WMFont *largeFont; - - largeFont = WMBoldSystemFontOfSize(scrPtr, 24); - - panel->tLbl = WMCreateLabel(panel->win); - WMMoveWidget(panel->tLbl, 20, 16); - WMResizeWidget(panel->tLbl, 320 - 40, WMFontHeight(largeFont)+4); - WMSetLabelText(panel->tLbl, title); - WMSetLabelTextAlignment(panel->tLbl, WALeft); - WMSetLabelFont(panel->tLbl, largeFont); - - WMReleaseFont(largeFont); + WMFont *largeFont; + + largeFont = WMBoldSystemFontOfSize(scrPtr, 24); + + panel->tLbl = WMCreateLabel(panel->win); + WMMoveWidget(panel->tLbl, 20, 16); + WMResizeWidget(panel->tLbl, 320 - 40, WMFontHeight(largeFont)+4); + WMSetLabelText(panel->tLbl, title); + WMSetLabelTextAlignment(panel->tLbl, WALeft); + WMSetLabelFont(panel->tLbl, largeFont); + + WMReleaseFont(largeFont); } if (msg) { - panel->mLbl = WMCreateLabel(panel->win); - WMMoveWidget(panel->mLbl, 20, 50); - WMResizeWidget(panel->mLbl, 320 - 40, - WMFontHeight(scrPtr->normalFont)*2); - WMSetLabelText(panel->mLbl, msg); - WMSetLabelTextAlignment(panel->mLbl, WALeft); + panel->mLbl = WMCreateLabel(panel->win); + WMMoveWidget(panel->mLbl, 20, 50); + WMResizeWidget(panel->mLbl, 320 - 40, + WMFontHeight(scrPtr->normalFont)*2); + WMSetLabelText(panel->mLbl, msg); + WMSetLabelTextAlignment(panel->mLbl, WALeft); } - + panel->text = WMCreateTextField(panel->win); WMMoveWidget(panel->text, 20, 85); WMResizeWidget(panel->text, 320 - 40, WMWidgetHeight(panel->text)); WMSetTextFieldText(panel->text, defaultText); - WMAddNotificationObserver(endedEditingObserver, panel, - WMTextDidEndEditingNotification, panel->text); + WMAddNotificationObserver(endedEditingObserver, panel, + WMTextDidEndEditingNotification, panel->text); /* create buttons */ if (cancelButton) - aw = WMWidthOfString(scrPtr->normalFont, cancelButton, - strlen(cancelButton)); - + aw = WMWidthOfString(scrPtr->normalFont, cancelButton, + strlen(cancelButton)); + if (okButton) - dw = WMWidthOfString(scrPtr->normalFont, okButton, - strlen(okButton)); - + dw = WMWidthOfString(scrPtr->normalFont, okButton, + strlen(okButton)); + w = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0); if (aw > w) - w = aw; + w = aw; w += 30; x = 310; if (okButton) { - x -= w + 10; - - panel->defBtn = WMCreateCustomButton(panel->win, WBBPushInMask - |WBBPushChangeMask - |WBBPushLightMask); - WMSetButtonAction(panel->defBtn, inputBoxOnClick, panel); - WMMoveWidget(panel->defBtn, x, 124); - WMResizeWidget(panel->defBtn, w, 24); - WMSetButtonText(panel->defBtn, okButton); - WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow); - WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow); - WMSetButtonImagePosition(panel->defBtn, WIPRight); + x -= w + 10; + + panel->defBtn = WMCreateCustomButton(panel->win, WBBPushInMask + |WBBPushChangeMask + |WBBPushLightMask); + WMSetButtonAction(panel->defBtn, inputBoxOnClick, panel); + WMMoveWidget(panel->defBtn, x, 124); + WMResizeWidget(panel->defBtn, w, 24); + WMSetButtonText(panel->defBtn, okButton); + WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow); + WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow); + WMSetButtonImagePosition(panel->defBtn, WIPRight); } if (cancelButton) { - x -= w + 10; + x -= w + 10; - panel->altBtn = WMCreateCommandButton(panel->win); - WMSetButtonAction(panel->altBtn, inputBoxOnClick, panel); - WMMoveWidget(panel->altBtn, x, 124); - WMResizeWidget(panel->altBtn, w, 24); - WMSetButtonText(panel->altBtn, cancelButton); + panel->altBtn = WMCreateCommandButton(panel->win); + WMSetButtonAction(panel->altBtn, inputBoxOnClick, panel); + WMMoveWidget(panel->altBtn, x, 124); + WMResizeWidget(panel->altBtn, w, 24); + WMSetButtonText(panel->altBtn, cancelButton); } WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask, - handleKeyPress2, panel); + handleKeyPress2, panel); WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win); @@ -492,18 +492,18 @@ handleKeyPress3(XEvent *event, void *clientData) { WMGenericPanel *panel = (WMGenericPanel*)clientData; KeySym ksym; - + XLookupString(&event->xkey, NULL, 0, &ksym, NULL); - + if (ksym == XK_Return && panel->defBtn) { - WMPerformButtonClick(panel->defBtn); + WMPerformButtonClick(panel->defBtn); } else if (ksym == XK_Escape) { - if (panel->altBtn) { - WMPerformButtonClick(panel->altBtn); - } else { - panel->result = WAPRDefault; - WMBreakModalLoop(WMWidgetScreen(panel->win)); - } + if (panel->altBtn) { + WMPerformButtonClick(panel->altBtn); + } else { + panel->result = WAPRDefault; + WMBreakModalLoop(WMWidgetScreen(panel->win)); + } } } @@ -517,10 +517,10 @@ WMDestroyGenericPanel(WMGenericPanel *panel) } -WMGenericPanel* -WMCreateGenericPanel(WMScreen *scrPtr, WMWindow *owner, - char *title, char *defaultButton, - char *alternateButton) +WMGenericPanel* +WMCreateGenericPanel(WMScreen *scrPtr, WMWindow *owner, + char *title, char *defaultButton, + char *alternateButton) { WMGenericPanel *panel; int dw=0, aw=0, w; @@ -532,16 +532,16 @@ WMCreateGenericPanel(WMScreen *scrPtr, WMWindow *owner, memset(panel, 0, sizeof(WMGenericPanel)); if (owner) { - panel->win = WMCreatePanelWithStyleForWindow(owner, "genericPanel", - WMTitledWindowMask); + panel->win = WMCreatePanelWithStyleForWindow(owner, "genericPanel", + WMTitledWindowMask); } else { - panel->win = WMCreateWindowWithStyle(scrPtr, "genericPanel", - WMTitledWindowMask); + panel->win = WMCreateWindowWithStyle(scrPtr, "genericPanel", + WMTitledWindowMask); } WMSetWindowInitialPosition(panel->win, - (scrPtr->rootView->size.width - WMWidgetWidth(panel->win))/2, - (scrPtr->rootView->size.height - WMWidgetHeight(panel->win))/2); + (scrPtr->rootView->size.width - WMWidgetWidth(panel->win))/2, + (scrPtr->rootView->size.height - WMWidgetHeight(panel->win))/2); WMSetWindowTitle(panel->win, ""); @@ -569,84 +569,84 @@ WMCreateGenericPanel(WMScreen *scrPtr, WMWindow *owner, } if (title) { - WMFont *largeFont; - - largeFont = WMBoldSystemFontOfSize(scrPtr, 24); - - panel->tLbl = WMCreateLabel(hbox); - WMMapWidget(panel->tLbl); - WMAddBoxSubview(hbox, WMWidgetView(panel->tLbl), True, True, - 64, 0, 0); - WMSetLabelText(panel->tLbl, title); - WMSetLabelTextAlignment(panel->tLbl, WALeft); - WMSetLabelFont(panel->tLbl, largeFont); - - WMReleaseFont(largeFont); + WMFont *largeFont; + + largeFont = WMBoldSystemFontOfSize(scrPtr, 24); + + panel->tLbl = WMCreateLabel(hbox); + WMMapWidget(panel->tLbl); + WMAddBoxSubview(hbox, WMWidgetView(panel->tLbl), True, True, + 64, 0, 0); + WMSetLabelText(panel->tLbl, title); + WMSetLabelTextAlignment(panel->tLbl, WALeft); + WMSetLabelFont(panel->tLbl, largeFont); + + WMReleaseFont(largeFont); } /* create divider line */ - + panel->line = WMCreateFrame(panel->vbox); WMMapWidget(panel->line); WMAddBoxSubview(panel->vbox, WMWidgetView(panel->line), False, True, - 2, 2, 5); + 2, 2, 5); WMSetFrameRelief(panel->line, WRGroove); - + panel->content = WMCreateFrame(panel->vbox); WMMapWidget(panel->content); WMAddBoxSubview(panel->vbox, WMWidgetView(panel->content), True, True, - 50, 0, 5); + 50, 0, 5); WMSetFrameRelief(panel->content, WRFlat); - + hbox = WMCreateBox(panel->vbox); WMSetBoxBorderWidth(hbox, 10); WMSetBoxHorizontal(hbox, True); WMMapWidget(hbox); WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 44, 0, 0); - + /* create buttons */ - if (defaultButton) - dw = WMWidthOfString(scrPtr->normalFont, defaultButton, - strlen(defaultButton)); + if (defaultButton) + dw = WMWidthOfString(scrPtr->normalFont, defaultButton, + strlen(defaultButton)); if (alternateButton) - aw = WMWidthOfString(scrPtr->normalFont, alternateButton, - strlen(alternateButton)); - - + aw = WMWidthOfString(scrPtr->normalFont, alternateButton, + strlen(alternateButton)); + + dw = dw + (scrPtr->buttonArrow ? scrPtr->buttonArrow->width : 0); - + aw += 30; dw += 30; - + w = WMAX(dw, aw); if ((w+10)*2 < 400) { - aw = w; - dw = w; + aw = w; + dw = w; } else { - int t; + int t; - t = 400 - 40 - aw - dw; - aw += t/2; - dw += t/2; + t = 400 - 40 - aw - dw; + aw += t/2; + dw += t/2; } if (defaultButton) { - panel->defBtn = WMCreateCommandButton(hbox); - WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel); - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->defBtn), - False, True, dw, 0, 0); - WMSetButtonText(panel->defBtn, defaultButton); - WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow); - WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow); - WMSetButtonImagePosition(panel->defBtn, WIPRight); + panel->defBtn = WMCreateCommandButton(hbox); + WMSetButtonAction(panel->defBtn, alertPanelOnClick, panel); + WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->defBtn), + False, True, dw, 0, 0); + WMSetButtonText(panel->defBtn, defaultButton); + WMSetButtonImage(panel->defBtn, scrPtr->buttonArrow); + WMSetButtonAltImage(panel->defBtn, scrPtr->pushedButtonArrow); + WMSetButtonImagePosition(panel->defBtn, WIPRight); } WMMapSubwidgets(hbox); WMCreateEventHandler(W_VIEW(panel->win), KeyPressMask, - handleKeyPress3, panel); + handleKeyPress3, panel); WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win); diff --git a/WINGs/wpixmap.c b/WINGs/wpixmap.c index cecfc82c..d4b90c19 100644 --- a/WINGs/wpixmap.c +++ b/WINGs/wpixmap.c @@ -8,7 +8,7 @@ WMPixmap* WMRetainPixmap(WMPixmap *pixmap) { if (pixmap) - pixmap->refCount++; + pixmap->refCount++; return pixmap; } @@ -22,11 +22,11 @@ WMReleasePixmap(WMPixmap *pixmap) pixmap->refCount--; if (pixmap->refCount<1) { - if (pixmap->pixmap) - XFreePixmap(pixmap->screen->display, pixmap->pixmap); - if (pixmap->mask) - XFreePixmap(pixmap->screen->display, pixmap->mask); - wfree(pixmap); + if (pixmap->pixmap) + XFreePixmap(pixmap->screen->display, pixmap->pixmap); + if (pixmap->mask) + XFreePixmap(pixmap->screen->display, pixmap->mask); + wfree(pixmap); } } @@ -44,21 +44,21 @@ WMCreatePixmap(WMScreen *scrPtr, int width, int height, int depth, Bool masked) pixPtr->refCount = 1; pixPtr->pixmap = XCreatePixmap(scrPtr->display, W_DRAWABLE(scrPtr), - width, height, depth); + width, height, depth); if (masked) { pixPtr->mask = XCreatePixmap(scrPtr->display, W_DRAWABLE(scrPtr), width, height, 1); } else { - pixPtr->mask = None; + pixPtr->mask = None; } - return pixPtr; + return pixPtr; } WMPixmap* WMCreatePixmapFromXPixmaps(WMScreen *scrPtr, Pixmap pixmap, Pixmap mask, - int width, int height, int depth) + int width, int height, int depth) { WMPixmap *pixPtr; @@ -70,7 +70,7 @@ WMCreatePixmapFromXPixmaps(WMScreen *scrPtr, Pixmap pixmap, Pixmap mask, pixPtr->height = height; pixPtr->depth = depth; pixPtr->refCount = 1; - + return pixPtr; } @@ -80,15 +80,15 @@ WMCreatePixmapFromFile(WMScreen *scrPtr, char *fileName) { WMPixmap *pixPtr; RImage *image; - + image = RLoadImage(scrPtr->rcontext, fileName, 0); if (!image) - return NULL; + return NULL; pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127); RReleaseImage(image); - + return pixPtr; } @@ -99,11 +99,11 @@ WMCreatePixmapFromRImage(WMScreen *scrPtr, RImage *image, int threshold) WMPixmap *pixPtr; Pixmap pixmap, mask; - if (!RConvertImageMask(scrPtr->rcontext, image, &pixmap, &mask, - threshold)) { - return NULL; + if (!RConvertImageMask(scrPtr->rcontext, image, &pixmap, &mask, + threshold)) { + return NULL; } - + pixPtr = wmalloc(sizeof(WMPixmap)); pixPtr->screen = scrPtr; pixPtr->pixmap = pixmap; @@ -113,7 +113,7 @@ WMCreatePixmapFromRImage(WMScreen *scrPtr, RImage *image, int threshold) pixPtr->depth = scrPtr->depth; pixPtr->refCount = 1; - return pixPtr; + return pixPtr; } @@ -141,17 +141,17 @@ WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, char *fileName, RColor *color) WMPixmap *pixPtr; RImage *image; - + image = RLoadImage(scrPtr->rcontext, fileName, 0); if (!image) - return NULL; - + return NULL; + RCombineImageWithColor(image, color); pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 0); - + RReleaseImage(image); - + return pixPtr; } @@ -164,12 +164,12 @@ WMCreatePixmapFromXPMData(WMScreen *scrPtr, char **data) image = RGetImageFromXPMData(scrPtr->rcontext, data); if (!image) - return NULL; - + return NULL; + pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127); RReleaseImage(image); - + return pixPtr; } @@ -192,13 +192,13 @@ WMGetPixmapMaskXID(WMPixmap *pixmap) } -WMSize +WMSize WMGetPixmapSize(WMPixmap *pixmap) { WMSize size = {0,0}; wassertrv(pixmap != NULL, size); - + size.width = pixmap->width; size.height = pixmap->height; @@ -210,44 +210,44 @@ WMPixmap* WMGetSystemPixmap(WMScreen *scr, int image) { switch (image) { - case WSIReturnArrow: - return WMRetainPixmap(scr->buttonArrow); - - case WSIHighlightedReturnArrow: - return WMRetainPixmap(scr->pushedButtonArrow); - - case WSIScrollerDimple: - return WMRetainPixmap(scr->scrollerDimple); - - case WSIArrowLeft: - return WMRetainPixmap(scr->leftArrow); - - case WSIHighlightedArrowLeft: - return WMRetainPixmap(scr->hiLeftArrow); - - case WSIArrowRight: - return WMRetainPixmap(scr->rightArrow); - - case WSIHighlightedArrowRight: - return WMRetainPixmap(scr->hiRightArrow); - - case WSIArrowUp: - return WMRetainPixmap(scr->upArrow); - - case WSIHighlightedArrowUp: - return WMRetainPixmap(scr->hiUpArrow); - - case WSIArrowDown: - return WMRetainPixmap(scr->downArrow); - - case WSIHighlightedArrowDown: - return WMRetainPixmap(scr->hiDownArrow); - - case WSICheckMark: - return WMRetainPixmap(scr->checkMark); - - default: - return NULL; + case WSIReturnArrow: + return WMRetainPixmap(scr->buttonArrow); + + case WSIHighlightedReturnArrow: + return WMRetainPixmap(scr->pushedButtonArrow); + + case WSIScrollerDimple: + return WMRetainPixmap(scr->scrollerDimple); + + case WSIArrowLeft: + return WMRetainPixmap(scr->leftArrow); + + case WSIHighlightedArrowLeft: + return WMRetainPixmap(scr->hiLeftArrow); + + case WSIArrowRight: + return WMRetainPixmap(scr->rightArrow); + + case WSIHighlightedArrowRight: + return WMRetainPixmap(scr->hiRightArrow); + + case WSIArrowUp: + return WMRetainPixmap(scr->upArrow); + + case WSIHighlightedArrowUp: + return WMRetainPixmap(scr->hiUpArrow); + + case WSIArrowDown: + return WMRetainPixmap(scr->downArrow); + + case WSIHighlightedArrowDown: + return WMRetainPixmap(scr->hiDownArrow); + + case WSICheckMark: + return WMRetainPixmap(scr->checkMark); + + default: + return NULL; } } @@ -261,6 +261,7 @@ WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y) XSetClipMask(scr->display, scr->clipGC, pixmap->mask); XSetClipOrigin(scr->display, scr->clipGC, x, y); - XCopyArea(scr->display, pixmap->pixmap, d, scr->clipGC, 0, 0, - pixmap->width, pixmap->height, x, y); + XCopyArea(scr->display, pixmap->pixmap, d, scr->clipGC, 0, 0, + pixmap->width, pixmap->height, x, y); } + diff --git a/WINGs/wpopupbutton.c b/WINGs/wpopupbutton.c index 81f51844..d0e3b7dd 100644 --- a/WINGs/wpopupbutton.c +++ b/WINGs/wpopupbutton.c @@ -8,33 +8,33 @@ typedef struct W_PopUpButton { W_Class widgetClass; WMView *view; - + void *clientData; WMAction *action; char *caption; WMArray *items; - + short selectedItemIndex; - + short highlightedItem; - + WMView *menuView; /* override redirect popup menu */ WMHandlerID timer; /* for autoscroll */ /**/ int scrollStartY; /* for autoscroll */ - + struct { - unsigned int pullsDown:1; + unsigned int pullsDown:1; - unsigned int configured:1; - - unsigned int insideMenu:1; - - unsigned int enabled:1; + unsigned int configured:1; + + unsigned int insideMenu:1; + + unsigned int enabled:1; } flags; } PopUpButton; @@ -59,38 +59,38 @@ static void handleActionEvents(XEvent *event, void *data); static void resizeMenu(PopUpButton *bPtr); - + WMPopUpButton* WMCreatePopUpButton(WMWidget *parent) { PopUpButton *bPtr; W_Screen *scr = W_VIEW(parent)->screen; - + bPtr = wmalloc(sizeof(PopUpButton)); memset(bPtr, 0, sizeof(PopUpButton)); bPtr->widgetClass = WC_PopUpButton; - + bPtr->view = W_CreateView(W_VIEW(parent)); if (!bPtr->view) { - wfree(bPtr); - return NULL; + wfree(bPtr); + return NULL; } bPtr->view->self = bPtr; - + WMCreateEventHandler(bPtr->view, ExposureMask|StructureNotifyMask - |ClientMessageMask, handleEvents, bPtr); + |ClientMessageMask, handleEvents, bPtr); W_ResizeView(bPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT); bPtr->caption = wstrdup(DEFAULT_CAPTION); WMCreateEventHandler(bPtr->view, ButtonPressMask|ButtonReleaseMask, - handleActionEvents, bPtr); + handleActionEvents, bPtr); bPtr->flags.enabled = 1; - + bPtr->items = WMCreateArrayWithDestructor(4, (WMFreeDataProc*)WMDestroyMenuItem); @@ -101,8 +101,8 @@ WMCreatePopUpButton(WMWidget *parent) W_ResizeView(bPtr->menuView, bPtr->view->size.width, 1); WMCreateEventHandler(bPtr->menuView, ButtonPressMask|ButtonReleaseMask - |EnterWindowMask|LeaveWindowMask|ButtonMotionMask - |ExposureMask, handleActionEvents, bPtr); + |EnterWindowMask|LeaveWindowMask|ButtonMotionMask + |ExposureMask, handleActionEvents, bPtr); return bPtr; } @@ -112,9 +112,9 @@ void WMSetPopUpButtonAction(WMPopUpButton *bPtr, WMAction *action, void *clientData) { CHECK_CLASS(bPtr, WC_PopUpButton); - + bPtr->action = action; - + bPtr->clientData = clientData; } @@ -123,7 +123,7 @@ WMMenuItem* WMAddPopUpButtonItem(WMPopUpButton *bPtr, char *title) { WMMenuItem *item; - + CHECK_CLASS(bPtr, WC_PopUpButton); item = WMCreateMenuItem(); @@ -132,7 +132,7 @@ WMAddPopUpButtonItem(WMPopUpButton *bPtr, char *title) WMAddToArray(bPtr->items, item); if (bPtr->menuView && bPtr->menuView->flags.realized) - resizeMenu(bPtr); + resizeMenu(bPtr); return item; } @@ -144,20 +144,20 @@ WMInsertPopUpButtonItem(WMPopUpButton *bPtr, int index, char *title) WMMenuItem *item; CHECK_CLASS(bPtr, WC_PopUpButton); - + item = WMCreateMenuItem(); WMSetMenuItemTitle(item, title); WMInsertInArray(bPtr->items, index, item); - - /* if there is an selected item, update it's index to match the new + + /* if there is an selected item, update it's index to match the new * position */ if (index < bPtr->selectedItemIndex) - bPtr->selectedItemIndex++; - + bPtr->selectedItemIndex++; + if (bPtr->menuView && bPtr->menuView->flags.realized) - resizeMenu(bPtr); - + resizeMenu(bPtr); + return item; } @@ -173,19 +173,19 @@ WMRemovePopUpButtonItem(WMPopUpButton *bPtr, int index) WMDeleteFromArray(bPtr->items, index); if (bPtr->selectedItemIndex >= 0 && !bPtr->flags.pullsDown) { - if (index < bPtr->selectedItemIndex) - bPtr->selectedItemIndex--; - else if (index == bPtr->selectedItemIndex) { - /* reselect first item if the removed item is the - * selected one */ - bPtr->selectedItemIndex = 0; - if (bPtr->view->flags.mapped) - paintPopUpButton(bPtr); - } + if (index < bPtr->selectedItemIndex) + bPtr->selectedItemIndex--; + else if (index == bPtr->selectedItemIndex) { + /* reselect first item if the removed item is the + * selected one */ + bPtr->selectedItemIndex = 0; + if (bPtr->view->flags.mapped) + paintPopUpButton(bPtr); + } } - + if (bPtr->menuView && bPtr->menuView->flags.realized) - resizeMenu(bPtr); + resizeMenu(bPtr); } @@ -194,7 +194,7 @@ WMSetPopUpButtonEnabled(WMPopUpButton *bPtr, Bool flag) { bPtr->flags.enabled = ((flag==0) ? 0 : 1); if (bPtr->view->flags.mapped) - paintPopUpButton(bPtr); + paintPopUpButton(bPtr); } @@ -212,12 +212,12 @@ WMSetPopUpButtonSelectedItem(WMPopUpButton *bPtr, int index) wassertr(index < WMGetArrayItemCount(bPtr->items)); /* if (index >= WMGetArrayCount(bPtr->items)) - index = -1;*/ + index = -1;*/ bPtr->selectedItemIndex = index; - + if (bPtr->view->flags.mapped) - paintPopUpButton(bPtr); + paintPopUpButton(bPtr); } @@ -225,9 +225,9 @@ int WMGetPopUpButtonSelectedItem(WMPopUpButton *bPtr) { if (!bPtr->flags.pullsDown && bPtr->selectedItemIndex < 0) - return -1; + return -1; else - return bPtr->selectedItemIndex; + return bPtr->selectedItemIndex; } @@ -235,21 +235,21 @@ void WMSetPopUpButtonText(WMPopUpButton *bPtr, char *text) { if (bPtr->caption) - wfree(bPtr->caption); + wfree(bPtr->caption); if (text) - bPtr->caption = wstrdup(text); + bPtr->caption = wstrdup(text); else - bPtr->caption = NULL; + bPtr->caption = NULL; if (bPtr->view->flags.realized) { - if (bPtr->flags.pullsDown || bPtr->selectedItemIndex < 0) { - paintPopUpButton(bPtr); - } + if (bPtr->flags.pullsDown || bPtr->selectedItemIndex < 0) { + paintPopUpButton(bPtr); + } } } -void +void WMSetPopUpButtonItemEnabled(WMPopUpButton *bPtr, int index, Bool flag) { WMSetMenuItemEnabled(WMGetFromArray(bPtr->items, index), (flag ? 1 : 0)); @@ -268,11 +268,11 @@ WMSetPopUpButtonPullsDown(WMPopUpButton *bPtr, Bool flag) { bPtr->flags.pullsDown = ((flag==0) ? 0 : 1); if (flag) { - bPtr->selectedItemIndex = -1; + bPtr->selectedItemIndex = -1; } if (bPtr->view->flags.mapped) - paintPopUpButton(bPtr); + paintPopUpButton(bPtr); } @@ -287,7 +287,7 @@ char* WMGetPopUpButtonItem(WMPopUpButton *bPtr, int index) { if (index >= WMGetArrayItemCount(bPtr->items) || index < 0) - return NULL; + return NULL; return WMGetMenuItemTitle(WMGetFromArray(bPtr->items, index)); } @@ -308,57 +308,57 @@ paintPopUpButton(PopUpButton *bPtr) char *caption; Pixmap pixmap; - + if (bPtr->flags.pullsDown) { - caption = bPtr->caption; + caption = bPtr->caption; } else { - if (bPtr->selectedItemIndex < 0) { - /* if no item selected, show the caption */ - caption = bPtr->caption; - } else { - caption = WMGetPopUpButtonItem(bPtr, bPtr->selectedItemIndex); - } + if (bPtr->selectedItemIndex < 0) { + /* if no item selected, show the caption */ + caption = bPtr->caption; + } else { + caption = WMGetPopUpButtonItem(bPtr, bPtr->selectedItemIndex); + } } - pixmap = XCreatePixmap(scr->display, bPtr->view->window, - bPtr->view->size.width, bPtr->view->size.height, - scr->depth); + pixmap = XCreatePixmap(scr->display, bPtr->view->window, + bPtr->view->size.width, bPtr->view->size.height, + scr->depth); XFillRectangle(scr->display, pixmap, WMColorGC(scr->gray), 0, 0, - bPtr->view->size.width, bPtr->view->size.height); + bPtr->view->size.width, bPtr->view->size.height); W_DrawRelief(scr, pixmap, 0, 0, bPtr->view->size.width, - bPtr->view->size.height, WRRaised); + bPtr->view->size.height, WRRaised); if (caption) { - W_PaintText(bPtr->view, pixmap, scr->normalFont, 6, - (bPtr->view->size.height-WMFontHeight(scr->normalFont))/2, - bPtr->view->size.width, WALeft, - bPtr->flags.enabled ? scr->black : scr->darkGray, - False, caption, strlen(caption)); + W_PaintText(bPtr->view, pixmap, scr->normalFont, 6, + (bPtr->view->size.height-WMFontHeight(scr->normalFont))/2, + bPtr->view->size.width, WALeft, + bPtr->flags.enabled ? scr->black : scr->darkGray, + False, caption, strlen(caption)); } if (bPtr->flags.pullsDown) { - XCopyArea(scr->display, scr->pullDownIndicator->pixmap, - pixmap, scr->copyGC, 0, 0, scr->pullDownIndicator->width, - scr->pullDownIndicator->height, - bPtr->view->size.width-scr->pullDownIndicator->width-4, - (bPtr->view->size.height-scr->pullDownIndicator->height)/2); + XCopyArea(scr->display, scr->pullDownIndicator->pixmap, + pixmap, scr->copyGC, 0, 0, scr->pullDownIndicator->width, + scr->pullDownIndicator->height, + bPtr->view->size.width-scr->pullDownIndicator->width-4, + (bPtr->view->size.height-scr->pullDownIndicator->height)/2); } else { - int x, y; - - x = bPtr->view->size.width - scr->popUpIndicator->width - 4; - y = (bPtr->view->size.height-scr->popUpIndicator->height)/2; - - XSetClipOrigin(scr->display, scr->clipGC, x, y); - XSetClipMask(scr->display, scr->clipGC, scr->popUpIndicator->mask); - XCopyArea(scr->display, scr->popUpIndicator->pixmap, pixmap, - scr->clipGC, 0, 0, scr->popUpIndicator->width, - scr->popUpIndicator->height, x, y); + int x, y; + + x = bPtr->view->size.width - scr->popUpIndicator->width - 4; + y = (bPtr->view->size.height-scr->popUpIndicator->height)/2; + + XSetClipOrigin(scr->display, scr->clipGC, x, y); + XSetClipMask(scr->display, scr->clipGC, scr->popUpIndicator->mask); + XCopyArea(scr->display, scr->popUpIndicator->pixmap, pixmap, + scr->clipGC, 0, 0, scr->popUpIndicator->width, + scr->popUpIndicator->height, x, y); } XCopyArea(scr->display, pixmap, bPtr->view->window, scr->copyGC, 0, 0, - bPtr->view->size.width, bPtr->view->size.height, 0, 0); - + bPtr->view->size.width, bPtr->view->size.height, 0, 0); + XFreePixmap(scr->display, pixmap); } @@ -373,15 +373,15 @@ handleEvents(XEvent *event, void *data) switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintPopUpButton(bPtr); - break; - - case DestroyNotify: - destroyPopUpButton(bPtr); - break; + case Expose: + if (event->xexpose.count!=0) + break; + paintPopUpButton(bPtr); + break; + + case DestroyNotify: + destroyPopUpButton(bPtr); + break; } } @@ -405,31 +405,31 @@ paintMenuEntry(PopUpButton *bPtr, int index, int highlight) yo = (itemHeight - WMFontHeight(scr->normalFont))/2; if (!highlight) { - XClearArea(scr->display, bPtr->menuView->window, 0, index*itemHeight, - width, itemHeight, False); - return; + XClearArea(scr->display, bPtr->menuView->window, 0, index*itemHeight, + width, itemHeight, False); + return; } else if (index < 0 && bPtr->flags.pullsDown) { - return; + return; } - + XFillRectangle(scr->display, bPtr->menuView->window, WMColorGC(scr->white), - 1, index*itemHeight+1, width-3, itemHeight-3); - + 1, index*itemHeight+1, width-3, itemHeight-3); + title = WMGetPopUpButtonItem(bPtr, index); - W_DrawRelief(scr, bPtr->menuView->window, 0, index*itemHeight, - width, itemHeight, WRRaised); + W_DrawRelief(scr, bPtr->menuView->window, 0, index*itemHeight, + width, itemHeight, WRRaised); - W_PaintText(bPtr->menuView, bPtr->menuView->window, scr->normalFont, 6, - index*itemHeight + yo, width, WALeft, scr->black, - False, title, strlen(title)); + W_PaintText(bPtr->menuView, bPtr->menuView->window, scr->normalFont, 6, + index*itemHeight + yo, width, WALeft, scr->black, + False, title, strlen(title)); if (!bPtr->flags.pullsDown && index == bPtr->selectedItemIndex) { - XCopyArea(scr->display, scr->popUpIndicator->pixmap, - bPtr->menuView->window, scr->copyGC, 0, 0, - scr->popUpIndicator->width, scr->popUpIndicator->height, - width-scr->popUpIndicator->width-4, - index*itemHeight+(itemHeight-scr->popUpIndicator->height)/2); + XCopyArea(scr->display, scr->popUpIndicator->pixmap, + bPtr->menuView->window, scr->copyGC, 0, 0, + scr->popUpIndicator->width, scr->popUpIndicator->height, + width-scr->popUpIndicator->width-4, + index*itemHeight+(itemHeight-scr->popUpIndicator->height)/2); } } @@ -443,48 +443,48 @@ makeMenuPixmap(PopUpButton *bPtr) WMArrayIterator iter; int yo, i; int width, height, itemHeight; - + itemHeight = bPtr->view->size.height; width = bPtr->view->size.width; height = itemHeight * WMGetArrayItemCount(bPtr->items); yo = (itemHeight - WMFontHeight(scr->normalFont))/2; - - pixmap = XCreatePixmap(scr->display, bPtr->view->window, width, height, - scr->depth); - + + pixmap = XCreatePixmap(scr->display, bPtr->view->window, width, height, + scr->depth); + XFillRectangle(scr->display, pixmap, WMColorGC(scr->gray), 0, 0, - width, height); + width, height); i = 0; WM_ITERATE_ARRAY(bPtr->items, item, iter) { - WMColor *color; - char *text; + WMColor *color; + char *text; - text = WMGetMenuItemTitle(item); + text = WMGetMenuItemTitle(item); - W_DrawRelief(scr, pixmap, 0, i*itemHeight, width, itemHeight, - WRRaised); + W_DrawRelief(scr, pixmap, 0, i*itemHeight, width, itemHeight, + WRRaised); if (!WMGetMenuItemEnabled(item)) - color = scr->darkGray; - else - color = scr->black; - - W_PaintText(bPtr->menuView, pixmap, scr->normalFont, 6, - i*itemHeight + yo, width, WALeft, color, False, - text, strlen(text)); - - if (!bPtr->flags.pullsDown && i == bPtr->selectedItemIndex) { - XCopyArea(scr->display, scr->popUpIndicator->pixmap, pixmap, - scr->copyGC, 0, 0, scr->popUpIndicator->width, - scr->popUpIndicator->height, - width-scr->popUpIndicator->width-4, - i*itemHeight+(itemHeight-scr->popUpIndicator->height)/2); - } - - i++; + color = scr->darkGray; + else + color = scr->black; + + W_PaintText(bPtr->menuView, pixmap, scr->normalFont, 6, + i*itemHeight + yo, width, WALeft, color, False, + text, strlen(text)); + + if (!bPtr->flags.pullsDown && i == bPtr->selectedItemIndex) { + XCopyArea(scr->display, scr->popUpIndicator->pixmap, pixmap, + scr->copyGC, 0, 0, scr->popUpIndicator->width, + scr->popUpIndicator->height, + width-scr->popUpIndicator->width-4, + i*itemHeight+(itemHeight-scr->popUpIndicator->height)/2); + } + + i++; } - + return pixmap; } @@ -493,10 +493,10 @@ static void resizeMenu(PopUpButton *bPtr) { int height; - + height = WMGetArrayItemCount(bPtr->items) * bPtr->view->size.height; if (height > 0) - W_ResizeView(bPtr->menuView, bPtr->view->size.width, height); + W_ResizeView(bPtr->menuView, bPtr->view->size.width, height); } @@ -508,38 +508,38 @@ popUpMenu(PopUpButton *bPtr) int x, y; if (!bPtr->flags.enabled) - return; - + return; + if (!bPtr->menuView->flags.realized) { - W_RealizeView(bPtr->menuView); - resizeMenu(bPtr); + W_RealizeView(bPtr->menuView); + resizeMenu(bPtr); } - + if (WMGetArrayItemCount(bPtr->items) < 1) - return; - + return; + XTranslateCoordinates(scr->display, bPtr->view->window, scr->rootWin, - 0, 0, &x, &y, &dummyW); + 0, 0, &x, &y, &dummyW); if (bPtr->flags.pullsDown) { - y += bPtr->view->size.height; + y += bPtr->view->size.height; } else { - y -= bPtr->view->size.height*bPtr->selectedItemIndex; + y -= bPtr->view->size.height*bPtr->selectedItemIndex; } W_MoveView(bPtr->menuView, x, y); - + XSetWindowBackgroundPixmap(scr->display, bPtr->menuView->window, - makeMenuPixmap(bPtr)); + makeMenuPixmap(bPtr)); XClearWindow(scr->display, bPtr->menuView->window); - + if (W_VIEW_WIDTH(bPtr->menuView) != W_VIEW_WIDTH(bPtr->view)) - resizeMenu(bPtr); - + resizeMenu(bPtr); + W_MapView(bPtr->menuView); - + bPtr->highlightedItem = 0; if (!bPtr->flags.pullsDown && bPtr->selectedItemIndex < 0) - paintMenuEntry(bPtr, bPtr->selectedItemIndex, True); + paintMenuEntry(bPtr, bPtr->selectedItemIndex, True); } @@ -560,39 +560,39 @@ autoScroll(void *data) if (bPtr->scrollStartY >= scrHeight-1 - && bPtr->menuView->pos.y+bPtr->menuView->size.height >= scrHeight-1) { - repeat = 1; + && bPtr->menuView->pos.y+bPtr->menuView->size.height >= scrHeight-1) { + repeat = 1; - if (bPtr->menuView->pos.y+bPtr->menuView->size.height-5 - <= scrHeight - 1) { - dy = scrHeight - 1 - - (bPtr->menuView->pos.y+bPtr->menuView->size.height); - } else - dy = -5; + if (bPtr->menuView->pos.y+bPtr->menuView->size.height-5 + <= scrHeight - 1) { + dy = scrHeight - 1 + - (bPtr->menuView->pos.y+bPtr->menuView->size.height); + } else + dy = -5; } else if (bPtr->scrollStartY <= 1 && bPtr->menuView->pos.y < 1) { - repeat = 1; + repeat = 1; - if (bPtr->menuView->pos.y+5 > 1) - dy = 1 - bPtr->menuView->pos.y; - else - dy = 5; + if (bPtr->menuView->pos.y+5 > 1) + dy = 1 - bPtr->menuView->pos.y; + else + dy = 5; } if (repeat) { - int oldItem; + int oldItem; - W_MoveView(bPtr->menuView, bPtr->menuView->pos.x, - bPtr->menuView->pos.y + dy); + W_MoveView(bPtr->menuView, bPtr->menuView->pos.x, + bPtr->menuView->pos.y + dy); - oldItem = bPtr->highlightedItem; - bPtr->highlightedItem = (bPtr->scrollStartY - bPtr->menuView->pos.y) - / bPtr->view->size.height; + oldItem = bPtr->highlightedItem; + bPtr->highlightedItem = (bPtr->scrollStartY - bPtr->menuView->pos.y) + / bPtr->view->size.height; - if (oldItem!=bPtr->highlightedItem) { + if (oldItem!=bPtr->highlightedItem) { WMMenuItem *item; - paintMenuEntry(bPtr, oldItem, False); + paintMenuEntry(bPtr, oldItem, False); if (bPtr->highlightedItem >= 0 && bPtr->highlightedItem < WMGetArrayItemCount(bPtr->items)) { @@ -602,11 +602,11 @@ autoScroll(void *data) } else { bPtr->highlightedItem = -1; } - } + } - bPtr->timer = WMAddTimerHandler(SCROLL_DELAY, autoScroll, bPtr); + bPtr->timer = WMAddTimerHandler(SCROLL_DELAY, autoScroll, bPtr); } else { - bPtr->timer = NULL; + bPtr->timer = NULL; } } @@ -619,7 +619,7 @@ wheelScrollUp(PopUpButton *bPtr) while (testIndex>=0 && !WMGetPopUpButtonItemEnabled(bPtr, testIndex)) testIndex--; if (testIndex != -1) { - WMSetPopUpButtonSelectedItem(bPtr, testIndex); + WMSetPopUpButtonSelectedItem(bPtr, testIndex); if (bPtr->action) (*bPtr->action)(bPtr, bPtr->clientData); } @@ -633,9 +633,9 @@ wheelScrollDown(PopUpButton *bPtr) int testIndex = bPtr->selectedItemIndex + 1; while (testIndexaction) (*bPtr->action)(bPtr, bPtr->clientData); } @@ -652,33 +652,33 @@ handleActionEvents(XEvent *event, void *data) CHECK_CLASS(data, WC_PopUpButton); if (WMGetArrayItemCount(bPtr->items) < 1) - return; - + return; + switch (event->type) { - /* called for menuView */ - case Expose: - paintMenuEntry(bPtr, bPtr->highlightedItem, True); - break; - - case LeaveNotify: - bPtr->flags.insideMenu = 0; - if (bPtr->menuView->flags.mapped) - paintMenuEntry(bPtr, bPtr->highlightedItem, False); - bPtr->highlightedItem = -1; - break; - - case EnterNotify: - bPtr->flags.insideMenu = 1; - break; - - case MotionNotify: - if (bPtr->flags.insideMenu) { - oldItem = bPtr->highlightedItem; - bPtr->highlightedItem = event->xmotion.y / bPtr->view->size.height; - if (oldItem!=bPtr->highlightedItem) { - WMMenuItem *item; - - paintMenuEntry(bPtr, oldItem, False); + /* called for menuView */ + case Expose: + paintMenuEntry(bPtr, bPtr->highlightedItem, True); + break; + + case LeaveNotify: + bPtr->flags.insideMenu = 0; + if (bPtr->menuView->flags.mapped) + paintMenuEntry(bPtr, bPtr->highlightedItem, False); + bPtr->highlightedItem = -1; + break; + + case EnterNotify: + bPtr->flags.insideMenu = 1; + break; + + case MotionNotify: + if (bPtr->flags.insideMenu) { + oldItem = bPtr->highlightedItem; + bPtr->highlightedItem = event->xmotion.y / bPtr->view->size.height; + if (oldItem!=bPtr->highlightedItem) { + WMMenuItem *item; + + paintMenuEntry(bPtr, oldItem, False); if (bPtr->highlightedItem >= 0 && bPtr->highlightedItem < WMGetArrayItemCount(bPtr->items)) { item = WMGetPopUpButtonMenuItem(bPtr, bPtr->highlightedItem); @@ -688,24 +688,24 @@ handleActionEvents(XEvent *event, void *data) bPtr->highlightedItem = -1; } - } - - if (event->xmotion.y_root >= scrHeight-1 - || event->xmotion.y_root <= 1) { - bPtr->scrollStartY = event->xmotion.y_root; - if (!bPtr->timer) - autoScroll(bPtr); - } else if (bPtr->timer) { - WMDeleteTimerHandler(bPtr->timer); - bPtr->timer = NULL; - } - } - break; - - /* called for bPtr->view */ - case ButtonPress: - if (!bPtr->flags.enabled) - break; + } + + if (event->xmotion.y_root >= scrHeight-1 + || event->xmotion.y_root <= 1) { + bPtr->scrollStartY = event->xmotion.y_root; + if (!bPtr->timer) + autoScroll(bPtr); + } else if (bPtr->timer) { + WMDeleteTimerHandler(bPtr->timer); + bPtr->timer = NULL; + } + } + break; + + /* called for bPtr->view */ + case ButtonPress: + if (!bPtr->flags.enabled) + break; if (event->xbutton.button==WINGsConfiguration.mouseWheelUp) { if (!bPtr->menuView->flags.mapped && !bPtr->flags.pullsDown) { @@ -719,62 +719,62 @@ handleActionEvents(XEvent *event, void *data) break; } popUpMenu(bPtr); - if (!bPtr->flags.pullsDown) { - bPtr->highlightedItem = bPtr->selectedItemIndex; - bPtr->flags.insideMenu = 1; - } else { - bPtr->highlightedItem = -1; - bPtr->flags.insideMenu = 0; - } - XGrabPointer(bPtr->view->screen->display, bPtr->menuView->window, - False, ButtonReleaseMask|ButtonMotionMask|EnterWindowMask - |LeaveWindowMask, GrabModeAsync, GrabModeAsync, - None, None, CurrentTime); - break; - - case ButtonRelease: - if (event->xbutton.button==WINGsConfiguration.mouseWheelUp || + if (!bPtr->flags.pullsDown) { + bPtr->highlightedItem = bPtr->selectedItemIndex; + bPtr->flags.insideMenu = 1; + } else { + bPtr->highlightedItem = -1; + bPtr->flags.insideMenu = 0; + } + XGrabPointer(bPtr->view->screen->display, bPtr->menuView->window, + False, ButtonReleaseMask|ButtonMotionMask|EnterWindowMask + |LeaveWindowMask, GrabModeAsync, GrabModeAsync, + None, None, CurrentTime); + break; + + case ButtonRelease: + if (event->xbutton.button==WINGsConfiguration.mouseWheelUp || event->xbutton.button==WINGsConfiguration.mouseWheelDown) { break; } - XUngrabPointer(bPtr->view->screen->display, event->xbutton.time); - if (!bPtr->flags.pullsDown) - popDownMenu(bPtr); + XUngrabPointer(bPtr->view->screen->display, event->xbutton.time); + if (!bPtr->flags.pullsDown) + popDownMenu(bPtr); - if (bPtr->timer) { - WMDeleteTimerHandler(bPtr->timer); - bPtr->timer = NULL; - } + if (bPtr->timer) { + WMDeleteTimerHandler(bPtr->timer); + bPtr->timer = NULL; + } - if (bPtr->flags.insideMenu && bPtr->highlightedItem>=0) { - WMMenuItem *item; + if (bPtr->flags.insideMenu && bPtr->highlightedItem>=0) { + WMMenuItem *item; - item = WMGetPopUpButtonMenuItem(bPtr, bPtr->highlightedItem); + item = WMGetPopUpButtonMenuItem(bPtr, bPtr->highlightedItem); if (WMGetMenuItemEnabled(item)) { - int i; + int i; WMSetPopUpButtonSelectedItem(bPtr, bPtr->highlightedItem); - if (bPtr->flags.pullsDown) { - for (i=0; ihighlightedItem, False); - XSync(bPtr->view->screen->display, 0); - wusleep(MENU_BLINK_DELAY); - paintMenuEntry(bPtr, bPtr->highlightedItem, True); - XSync(bPtr->view->screen->display, 0); - wusleep(MENU_BLINK_DELAY); - } - } - paintMenuEntry(bPtr, bPtr->highlightedItem, False); - popDownMenu(bPtr); + if (bPtr->flags.pullsDown) { + for (i=0; ihighlightedItem, False); + XSync(bPtr->view->screen->display, 0); + wusleep(MENU_BLINK_DELAY); + paintMenuEntry(bPtr, bPtr->highlightedItem, True); + XSync(bPtr->view->screen->display, 0); + wusleep(MENU_BLINK_DELAY); + } + } + paintMenuEntry(bPtr, bPtr->highlightedItem, False); + popDownMenu(bPtr); if (bPtr->action) (*bPtr->action)(bPtr, bPtr->clientData); } - } - if (bPtr->menuView->flags.mapped) - popDownMenu(bPtr); - break; - } + } + if (bPtr->menuView->flags.mapped) + popDownMenu(bPtr); + break; + } } @@ -783,16 +783,18 @@ static void destroyPopUpButton(PopUpButton *bPtr) { if (bPtr->timer) { - WMDeleteTimerHandler(bPtr->timer); + WMDeleteTimerHandler(bPtr->timer); } WMFreeArray(bPtr->items); if (bPtr->caption) - wfree(bPtr->caption); + wfree(bPtr->caption); /* have to destroy explicitly because the popup is a toplevel */ W_DestroyView(bPtr->menuView); wfree(bPtr); } + + diff --git a/WINGs/wprogressindicator.c b/WINGs/wprogressindicator.c index 36d5de5c..f9c90d0c 100644 --- a/WINGs/wprogressindicator.c +++ b/WINGs/wprogressindicator.c @@ -10,11 +10,11 @@ typedef struct W_ProgressIndicator { W_Class widgetClass; W_View *view; - + int value; int minValue; int maxValue; - + void *clientData; } ProgressIndicator; @@ -48,34 +48,34 @@ WMProgressIndicator* WMCreateProgressIndicator(WMWidget *parent) { ProgressIndicator *pPtr; - + pPtr = wmalloc(sizeof(ProgressIndicator)); memset(pPtr, 0, sizeof(ProgressIndicator)); - + pPtr->widgetClass = WC_ProgressIndicator; - + pPtr->view = W_CreateView(W_VIEW(parent)); if (!pPtr->view) { - wfree(pPtr); - return NULL; + wfree(pPtr); + return NULL; } - + pPtr->view->self = pPtr; - + pPtr->view->delegate = &_ProgressIndicatorDelegate; - + WMCreateEventHandler(pPtr->view, ExposureMask|StructureNotifyMask, - handleEvents, pPtr); - - + handleEvents, pPtr); + + W_ResizeView(pPtr->view, DEFAULT_PROGRESS_INDICATOR_WIDTH, - DEFAULT_PROGRESS_INDICATOR_HEIGHT); - + DEFAULT_PROGRESS_INDICATOR_HEIGHT); + /* Initialize ProgressIndicator Values */ pPtr->value = 0; pPtr->minValue = 0; pPtr->maxValue = 100; - + return pPtr; } @@ -84,13 +84,13 @@ void WMSetProgressIndicatorMinValue(WMProgressIndicator *progressindicator, int value) { CHECK_CLASS(progressindicator, WC_ProgressIndicator); - + progressindicator->minValue = value; if (progressindicator->value < value) { - progressindicator->value = value; - if (progressindicator->view->flags.mapped) { - paintProgressIndicator(progressindicator); - } + progressindicator->value = value; + if (progressindicator->view->flags.mapped) { + paintProgressIndicator(progressindicator); + } } } @@ -99,13 +99,13 @@ void WMSetProgressIndicatorMaxValue(WMProgressIndicator *progressindicator, int value) { CHECK_CLASS(progressindicator, WC_ProgressIndicator); - + progressindicator->maxValue = value; if (progressindicator->value > value) { - progressindicator->value = value; - if (progressindicator->view->flags.mapped) { - paintProgressIndicator(progressindicator); - } + progressindicator->value = value; + if (progressindicator->view->flags.mapped) { + paintProgressIndicator(progressindicator); + } } } @@ -114,19 +114,19 @@ void WMSetProgressIndicatorValue(WMProgressIndicator *progressindicator, int value) { CHECK_CLASS(progressindicator, WC_ProgressIndicator); - + progressindicator->value = value; - + /* Check if value is within min/max-range */ if (progressindicator->minValue > value) - progressindicator->value = progressindicator->minValue; - + progressindicator->value = progressindicator->minValue; + if (progressindicator->maxValue < value) - progressindicator->value = progressindicator->maxValue; - - + progressindicator->value = progressindicator->maxValue; + + if (progressindicator->view->flags.mapped) { - paintProgressIndicator(progressindicator); + paintProgressIndicator(progressindicator); } } @@ -135,7 +135,7 @@ int WMGetProgressIndicatorMinValue(WMProgressIndicator *progressindicator) { CHECK_CLASS(progressindicator, WC_ProgressIndicator); - + return progressindicator->minValue; } @@ -144,7 +144,7 @@ int WMGetProgressIndicatorMaxValue(WMProgressIndicator *progressindicator) { CHECK_CLASS(progressindicator, WC_ProgressIndicator); - + return progressindicator->maxValue; } @@ -153,7 +153,7 @@ int WMGetProgressIndicatorValue(WMProgressIndicator *progressindicator) { CHECK_CLASS(progressindicator, WC_ProgressIndicator); - + return progressindicator->value; } @@ -164,7 +164,7 @@ didResizeProgressIndicator(W_ViewDelegate *self, WMView *view) WMProgressIndicator *pPtr = (WMProgressIndicator*)view->self; int width = pPtr->view->size.width; int height = pPtr->view->size.height; - + assert(width > 0); assert(height > 0); } @@ -182,73 +182,73 @@ paintProgressIndicator(ProgressIndicator *pPtr) int perc, w, h; double unit, i; Pixmap buffer; - + bgc = WMColorGC(scr->black); wgc = WMColorGC(scr->white); lgc = WMColorGC(scr->gray); dgc = WMColorGC(scr->darkGray); - + unit = (double)(size.width - 3.0) / 100; - - buffer = XCreatePixmap(scr->display, pPtr->view->window, - size.width, size.height, scr->depth); - + + buffer = XCreatePixmap(scr->display, pPtr->view->window, + size.width, size.height, scr->depth); + XFillRectangle(scr->display, buffer, lgc, 0, 0, size.width, size.height); - + /* Calculate size of Progress to draw and paint ticks*/ perc = (pPtr->value - pPtr->minValue) * 100 / (pPtr->maxValue - pPtr->minValue); - + w = (int)((double)(perc * unit)); h = size.height - 2; - + if (w > (size.width - 3)) - w = size.width - 3; - + w = size.width - 3; + if (w > 0) { - XFillRectangle(scr->display, buffer, lgc, 2, 1, w, h); - XFillRectangle(scr->display, buffer, scr->stippleGC, 2, 1, w, h); - W_DrawRelief(scr, buffer, 2, 1, w, h, WRFlat); - - /* Draw Progress Marks */ - i=(5.0*unit); - + XFillRectangle(scr->display, buffer, lgc, 2, 1, w, h); + XFillRectangle(scr->display, buffer, scr->stippleGC, 2, 1, w, h); + W_DrawRelief(scr, buffer, 2, 1, w, h, WRFlat); + + /* Draw Progress Marks */ + i=(5.0*unit); + #ifdef SHOW_PROGRESS_TICKS_ONLY - while((int)idisplay, buffer, dgc, (int)i+2, h-1, i+2, h-3); - - i+=(5.0*unit); - + XDrawLine(scr->display, buffer, dgc, (int)i+2, h-1, i+2, h-3); + + i+=(5.0*unit); + #ifdef SHOW_PROGRESS_TICKS_ONLY - if((int)i>=w) - break; + if((int)i>=w) + break; #endif - - XDrawLine(scr->display, buffer, dgc, (int)i+2, h-1, i+2, h-6); - - i+=(5.0*unit); - } + + XDrawLine(scr->display, buffer, dgc, (int)i+2, h-1, i+2, h-6); + + i+=(5.0*unit); + } } - + XDrawLine(scr->display, buffer, bgc, w+2, 1, w+2, h+1); XDrawLine(scr->display, buffer, lgc, 2, h, w+2, h); - - + + XDrawLine(scr->display, buffer, dgc, 0, 0, 0, size.height-1); XDrawLine(scr->display, buffer, dgc, 0, 0, size.width, 0); XDrawLine(scr->display, buffer, bgc, 1, 1, 1, size.height-1); XDrawLine(scr->display, buffer, bgc, 1, 1, size.width-1, 1); - + XDrawLine(scr->display, buffer, wgc, size.width-1, 0, - size.width-1, size.height-1); + size.width-1, size.height-1); XDrawLine(scr->display, buffer, wgc, 0, size.height-1, - size.width-1, size.height-1); - + size.width-1, size.height-1); + XCopyArea(scr->display, buffer, pPtr->view->window, scr->copyGC, 0, 0, - size.width, size.height, 0, 0); - + size.width, size.height, 0, 0); + XFreePixmap(scr->display, buffer); } @@ -257,18 +257,18 @@ static void handleEvents(XEvent *event, void *data) { ProgressIndicator *pPtr = (ProgressIndicator*)data; - + CHECK_CLASS(data, WC_ProgressIndicator); - + switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintProgressIndicator(pPtr); - break; - case DestroyNotify: - destroyProgressIndicator(pPtr); - break; + case Expose: + if (event->xexpose.count!=0) + break; + paintProgressIndicator(pPtr); + break; + case DestroyNotify: + destroyProgressIndicator(pPtr); + break; } } @@ -277,7 +277,7 @@ static void destroyProgressIndicator(ProgressIndicator *pPtr) { WMRemoveNotificationObserver(pPtr); - + wfree(pPtr); } diff --git a/WINGs/wruler.c b/WINGs/wruler.c index 2bd633ad..e98caac5 100644 --- a/WINGs/wruler.c +++ b/WINGs/wruler.c @@ -1,5 +1,5 @@ /* - * WINGs WMRuler: nifty ruler widget for WINGs :-) + * WINGs WMRuler: nifty ruler widget for WINGs :-) * * Copyright (c) 1999-2000 Nwanua Elumeze * @@ -38,8 +38,8 @@ typedef struct W_Ruler { WMFont *font; WMRulerMargins margins; int offset; - int motion; /* the position of the _moving_ marker(s) */ - int end; /* the last tick on the baseline (restrict markers to it) */ + int motion; /* the position of the _moving_ marker(s) */ + int end; /* the last tick on the baseline (restrict markers to it) */ Pixmap drawBuffer; @@ -65,7 +65,7 @@ typedef struct W_Ruler { | */ -static void +static void drawLeftMarker(Ruler * rPtr) { XPoint points[4]; @@ -183,7 +183,7 @@ drawRulerOnPixmap(Ruler * rPtr) if (!rPtr->drawBuffer || !rPtr->view->flags.realized) return; - + XFillRectangle(rPtr->view->screen->display, rPtr->drawBuffer, rPtr->bgGC, 0, 0, rPtr->view->size.width, 40); @@ -346,7 +346,7 @@ handleEvents(XEvent * event, void *data) switch (event->type) { case Expose: - rulerDidResize(rPtr->view->delegate, rPtr->view); + rulerDidResize(rPtr->view->delegate, rPtr->view); break; case MotionNotify: @@ -500,7 +500,7 @@ WMGetRulerMargins(WMRuler * rPtr) { WMRulerMargins *margins = wmalloc(sizeof(WMRulerMargins)); - if (!rPtr) { + if (!rPtr) { margins->first = margins->body = margins->left = 0; margins->right = 100; return margins; @@ -598,3 +598,4 @@ WMGetGrabbedRulerMargin(WMRuler * rPtr) return 0; return rPtr->flags.whichMarker; } + diff --git a/WINGs/wscroller.c b/WINGs/wscroller.c index 263848aa..803eed86 100644 --- a/WINGs/wscroller.c +++ b/WINGs/wscroller.c @@ -7,7 +7,7 @@ #include /* undefine will disable the autoadjusting of the knob dimple to be - * directly below the cursor + * directly below the cursor * DOES NOT WORK */ #undef STRICT_NEXT_BEHAVIOUR @@ -33,32 +33,32 @@ typedef struct W_Scroller { WMHandlerID timerID; /* for continuous scrolling mode */ #ifndef STRICT_NEXT_BEHAVIOUR - int dragPoint; /* point where the knob is being - * dragged */ + int dragPoint; /* point where the knob is being + * dragged */ #endif struct { - WMScrollArrowPosition arrowsPosition:4; + WMScrollArrowPosition arrowsPosition:4; - unsigned int horizontal:1; + unsigned int horizontal:1; - WMScrollerPart hitPart:4; + WMScrollerPart hitPart:4; - /* */ - unsigned int documentFullyVisible:1; /* document is fully visible */ - - unsigned int prevSelected:1; - - unsigned int pushed:1; - - unsigned int incrDown:1; /* whether increment button is down */ + /* */ + unsigned int documentFullyVisible:1; /* document is fully visible */ - unsigned int decrDown:1; - - unsigned int draggingKnob:1; + unsigned int prevSelected:1; - unsigned int configured:1; + unsigned int pushed:1; - unsigned int redrawPending:1; + unsigned int incrDown:1; /* whether increment button is down */ + + unsigned int decrDown:1; + + unsigned int draggingKnob:1; + + unsigned int configured:1; + + unsigned int redrawPending:1; } flags; } Scroller; @@ -84,48 +84,48 @@ static void handleMotion(Scroller *sPtr, int mouseX, int mouseY); W_ViewDelegate _ScrollerViewDelegate = { NULL, - NULL, - NULL, - NULL, - willResizeScroller + NULL, + NULL, + NULL, + willResizeScroller }; - + WMScroller* WMCreateScroller(WMWidget *parent) { Scroller *sPtr; - + sPtr = wmalloc(sizeof(Scroller)); memset(sPtr, 0, sizeof(Scroller)); - + sPtr->widgetClass = WC_Scroller; sPtr->view = W_CreateView(W_VIEW(parent)); if (!sPtr->view) { - wfree(sPtr); - return NULL; + wfree(sPtr); + return NULL; } sPtr->view->self = sPtr; sPtr->view->delegate = &_ScrollerViewDelegate; - + sPtr->flags.documentFullyVisible = 1; - + WMCreateEventHandler(sPtr->view, ExposureMask|StructureNotifyMask - |ClientMessageMask, handleEvents, sPtr); + |ClientMessageMask, handleEvents, sPtr); W_ResizeView(sPtr->view, DEFAULT_WIDTH, DEFAULT_WIDTH); sPtr->flags.arrowsPosition = DEFAULT_ARROWS_POSITION; WMCreateEventHandler(sPtr->view, ButtonPressMask|ButtonReleaseMask - |EnterWindowMask|LeaveWindowMask|ButtonMotionMask, - handleActionEvents, sPtr); - + |EnterWindowMask|LeaveWindowMask|ButtonMotionMask, + handleActionEvents, sPtr); + sPtr->flags.hitPart = WSNoPart; - + sPtr->floatValue = 0.0; sPtr->knobProportion = 1.0; @@ -139,23 +139,23 @@ WMSetScrollerArrowsPosition(WMScroller *sPtr, WMScrollArrowPosition position) { sPtr->flags.arrowsPosition = position; if (sPtr->view->flags.realized) { - paintScroller(sPtr); + paintScroller(sPtr); } } static void -willResizeScroller(W_ViewDelegate *self, WMView *view, - unsigned int *width, unsigned int *height) +willResizeScroller(W_ViewDelegate *self, WMView *view, + unsigned int *width, unsigned int *height) { WMScroller *sPtr = (WMScroller*)view->self; - + if (*width > *height) { - sPtr->flags.horizontal = 1; - *height = SCROLLER_WIDTH; + sPtr->flags.horizontal = 1; + *height = SCROLLER_WIDTH; } else { - sPtr->flags.horizontal = 0; - *width = SCROLLER_WIDTH; + sPtr->flags.horizontal = 0; + *width = SCROLLER_WIDTH; } } @@ -164,47 +164,47 @@ void WMSetScrollerAction(WMScroller *sPtr, WMAction *action, void *clientData) { CHECK_CLASS(sPtr, WC_Scroller); - + sPtr->action = action; - + sPtr->clientData = clientData; } void WMSetScrollerParameters(WMScroller *sPtr, float floatValue, - float knobProportion) + float knobProportion) { CHECK_CLASS(sPtr, WC_Scroller); assert(!isnan(floatValue)); - + if (floatValue < 0.0) - sPtr->floatValue = 0.0; + sPtr->floatValue = 0.0; else if (floatValue > 1.0) - sPtr->floatValue = 1.0; + sPtr->floatValue = 1.0; else - sPtr->floatValue = floatValue; + sPtr->floatValue = floatValue; if (knobProportion <= 0.0) { - - sPtr->knobProportion = 0.0; - sPtr->flags.documentFullyVisible = 0; - + + sPtr->knobProportion = 0.0; + sPtr->flags.documentFullyVisible = 0; + } else if (knobProportion >= 1.0) { - - sPtr->knobProportion = 1.0; - sPtr->flags.documentFullyVisible = 1; - + + sPtr->knobProportion = 1.0; + sPtr->flags.documentFullyVisible = 1; + } else { - sPtr->knobProportion = knobProportion; - sPtr->flags.documentFullyVisible = 0; + sPtr->knobProportion = knobProportion; + sPtr->flags.documentFullyVisible = 0; } if (sPtr->view->flags.realized) - paintScroller(sPtr); - - /* WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);*/ + paintScroller(sPtr); + + /* WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);*/ } @@ -212,7 +212,7 @@ float WMGetScrollerKnobProportion(WMScroller *sPtr) { CHECK_CLASS(sPtr, WC_Scroller); - + return sPtr->knobProportion; } @@ -221,7 +221,7 @@ float WMGetScrollerValue(WMScroller *sPtr) { CHECK_CLASS(sPtr, WC_Scroller); - + return sPtr->floatValue; } @@ -230,7 +230,7 @@ WMScrollerPart WMGetScrollerHitPart(WMScroller *sPtr) { CHECK_CLASS(sPtr, WC_Scroller); - + return sPtr->flags.hitPart; } @@ -251,111 +251,111 @@ paintArrow(WMScroller *sPtr, Drawable d, int part) #endif if (part == 0) { /* decrement button */ - if (sPtr->flags.horizontal) { - if (sPtr->flags.arrowsPosition == WSAMaxEnd) { - ofs = view->size.width - 2*(BUTTON_SIZE+1) - 1; - } else { - ofs = 2; - } - if (sPtr->flags.decrDown) - arrow = scr->hiLeftArrow; - else - arrow = scr->leftArrow; - - } else { - if (sPtr->flags.arrowsPosition == WSAMaxEnd) { - ofs = view->size.height - 2*(BUTTON_SIZE+1) - 1; - } else { - ofs = 2; - } - if (sPtr->flags.decrDown) - arrow = scr->hiUpArrow; - else - arrow = scr->upArrow; - } - + if (sPtr->flags.horizontal) { + if (sPtr->flags.arrowsPosition == WSAMaxEnd) { + ofs = view->size.width - 2*(BUTTON_SIZE+1) - 1; + } else { + ofs = 2; + } + if (sPtr->flags.decrDown) + arrow = scr->hiLeftArrow; + else + arrow = scr->leftArrow; + + } else { + if (sPtr->flags.arrowsPosition == WSAMaxEnd) { + ofs = view->size.height - 2*(BUTTON_SIZE+1) - 1; + } else { + ofs = 2; + } + if (sPtr->flags.decrDown) + arrow = scr->hiUpArrow; + else + arrow = scr->upArrow; + } + #ifndef DOUBLE_BUFFER - if (sPtr->flags.decrDown) - gc = WMColorGC(scr->white); + if (sPtr->flags.decrDown) + gc = WMColorGC(scr->white); #endif } else { /* increment button */ - if (sPtr->flags.horizontal) { - if (sPtr->flags.arrowsPosition == WSAMaxEnd) { - ofs = view->size.width - BUTTON_SIZE+1 - 3; - } else { - ofs = 2 + BUTTON_SIZE+1; - } - if (sPtr->flags.incrDown) - arrow = scr->hiRightArrow; - else - arrow = scr->rightArrow; - } else { - if (sPtr->flags.arrowsPosition == WSAMaxEnd) { - ofs = view->size.height - BUTTON_SIZE+1 - 3; - } else { - ofs = 2 + BUTTON_SIZE+1; - } - if (sPtr->flags.incrDown) - arrow = scr->hiDownArrow; - else - arrow = scr->downArrow; - } - + if (sPtr->flags.horizontal) { + if (sPtr->flags.arrowsPosition == WSAMaxEnd) { + ofs = view->size.width - BUTTON_SIZE+1 - 3; + } else { + ofs = 2 + BUTTON_SIZE+1; + } + if (sPtr->flags.incrDown) + arrow = scr->hiRightArrow; + else + arrow = scr->rightArrow; + } else { + if (sPtr->flags.arrowsPosition == WSAMaxEnd) { + ofs = view->size.height - BUTTON_SIZE+1 - 3; + } else { + ofs = 2 + BUTTON_SIZE+1; + } + if (sPtr->flags.incrDown) + arrow = scr->hiDownArrow; + else + arrow = scr->downArrow; + } + #ifndef DOUBLE_BUFFER - if (sPtr->flags.incrDown) - gc = scr->whiteGC; + if (sPtr->flags.incrDown) + gc = scr->whiteGC; #endif } if (sPtr->flags.horizontal) { - /* paint button */ + /* paint button */ #ifndef DOUBLE_BUFFER - XFillRectangle(scr->display, d, gc, - ofs+1, 2+1, BUTTON_SIZE+1-3, BUTTON_SIZE-3); + XFillRectangle(scr->display, d, gc, + ofs+1, 2+1, BUTTON_SIZE+1-3, BUTTON_SIZE-3); #else - if ((!part&&sPtr->flags.decrDown) || (part&&sPtr->flags.incrDown)) - XFillRectangle(scr->display, d, WMColorGC(scr->white), - ofs+1, 2+1, BUTTON_SIZE+1-3, BUTTON_SIZE-3); + if ((!part&&sPtr->flags.decrDown) || (part&&sPtr->flags.incrDown)) + XFillRectangle(scr->display, d, WMColorGC(scr->white), + ofs+1, 2+1, BUTTON_SIZE+1-3, BUTTON_SIZE-3); #endif /* DOUBLE_BUFFER */ - W_DrawRelief(scr, d, ofs, 2, BUTTON_SIZE, BUTTON_SIZE, WRRaised); - - /* paint arrow */ - XSetClipMask(scr->display, scr->clipGC, arrow->mask); - XSetClipOrigin(scr->display, scr->clipGC, - ofs + (BUTTON_SIZE - arrow->width) / 2, - 2 + (BUTTON_SIZE - arrow->height) / 2); - - XCopyArea(scr->display, arrow->pixmap, d, scr->clipGC, - 0, 0, arrow->width, arrow->height, - ofs + (BUTTON_SIZE - arrow->width) / 2, - 2 + (BUTTON_SIZE - arrow->height) / 2); - + W_DrawRelief(scr, d, ofs, 2, BUTTON_SIZE, BUTTON_SIZE, WRRaised); + + /* paint arrow */ + XSetClipMask(scr->display, scr->clipGC, arrow->mask); + XSetClipOrigin(scr->display, scr->clipGC, + ofs + (BUTTON_SIZE - arrow->width) / 2, + 2 + (BUTTON_SIZE - arrow->height) / 2); + + XCopyArea(scr->display, arrow->pixmap, d, scr->clipGC, + 0, 0, arrow->width, arrow->height, + ofs + (BUTTON_SIZE - arrow->width) / 2, + 2 + (BUTTON_SIZE - arrow->height) / 2); + } else { /* vertical */ - - /* paint button */ + + /* paint button */ #ifndef DOUBLE_BUFFER - XFillRectangle(scr->display, d, gc, - 2+1, ofs+1, BUTTON_SIZE-3, BUTTON_SIZE+1-3); + XFillRectangle(scr->display, d, gc, + 2+1, ofs+1, BUTTON_SIZE-3, BUTTON_SIZE+1-3); #else - if ((!part&&sPtr->flags.decrDown) || (part&&sPtr->flags.incrDown)) - XFillRectangle(scr->display, d, WMColorGC(scr->white), - 2+1, ofs+1, BUTTON_SIZE-3, BUTTON_SIZE+1-3); + if ((!part&&sPtr->flags.decrDown) || (part&&sPtr->flags.incrDown)) + XFillRectangle(scr->display, d, WMColorGC(scr->white), + 2+1, ofs+1, BUTTON_SIZE-3, BUTTON_SIZE+1-3); #endif /* DOUBLE_BUFFER */ - W_DrawRelief(scr, d, 2, ofs, BUTTON_SIZE, BUTTON_SIZE, WRRaised); - - /* paint arrow */ - - XSetClipMask(scr->display, scr->clipGC, arrow->mask); - XSetClipOrigin(scr->display, scr->clipGC, - 2 + (BUTTON_SIZE - arrow->width) / 2, - ofs + (BUTTON_SIZE - arrow->height) / 2); - XCopyArea(scr->display, arrow->pixmap, d, scr->clipGC, - 0, 0, arrow->width, arrow->height, - 2 + (BUTTON_SIZE - arrow->width) / 2, - ofs + (BUTTON_SIZE - arrow->height) / 2); + W_DrawRelief(scr, d, 2, ofs, BUTTON_SIZE, BUTTON_SIZE, WRRaised); + + /* paint arrow */ + + XSetClipMask(scr->display, scr->clipGC, arrow->mask); + XSetClipOrigin(scr->display, scr->clipGC, + 2 + (BUTTON_SIZE - arrow->width) / 2, + ofs + (BUTTON_SIZE - arrow->height) / 2); + XCopyArea(scr->display, arrow->pixmap, d, scr->clipGC, + 0, 0, arrow->width, arrow->height, + 2 + (BUTTON_SIZE - arrow->width) / 2, + ofs + (BUTTON_SIZE - arrow->height) / 2); } -} +} static int @@ -363,21 +363,21 @@ knobLength(Scroller *sPtr) { int tmp, length; - + if (sPtr->flags.horizontal) - length = sPtr->view->size.width - 4; + length = sPtr->view->size.width - 4; else - length = sPtr->view->size.height - 4; + length = sPtr->view->size.height - 4; if (sPtr->flags.arrowsPosition != WSANone) { - length -= 2*(BUTTON_SIZE+1); + length -= 2*(BUTTON_SIZE+1); } - + tmp = (int)((float)length * sPtr->knobProportion + 0.5); /* keep minimum size */ if (tmp < BUTTON_SIZE) - tmp = BUTTON_SIZE; - + tmp = BUTTON_SIZE; + return tmp; } @@ -394,107 +394,107 @@ paintScroller(Scroller *sPtr) #endif int length, ofs; float knobP, knobL; - - + + #ifdef DOUBLE_BUFFER - d = XCreatePixmap(scr->display, view->window, view->size.width, - view->size.height, scr->depth); - XFillRectangle(scr->display, d, WMColorGC(scr->gray), 0, 0, - view->size.width, view->size.height); + d = XCreatePixmap(scr->display, view->window, view->size.width, + view->size.height, scr->depth); + XFillRectangle(scr->display, d, WMColorGC(scr->gray), 0, 0, + view->size.width, view->size.height); #endif - + XDrawRectangle(scr->display, d, WMColorGC(scr->black), 0, 0, - view->size.width-1, view->size.height-1); + view->size.width-1, view->size.height-1); #ifndef DOUBLE_BUFFER XDrawRectangle(scr->display, d, WMColorGC(scr->gray), 1, 1, - view->size.width-3, view->size.height-3); + view->size.width-3, view->size.height-3); #endif if (sPtr->flags.horizontal) - length = view->size.width - 4; + length = view->size.width - 4; else - length = view->size.height - 4; - + length = view->size.height - 4; + if (sPtr->flags.documentFullyVisible) { - XFillRectangle(scr->display, d, scr->stippleGC, 2, 2, - view->size.width-4, view->size.height-4); + XFillRectangle(scr->display, d, scr->stippleGC, 2, 2, + view->size.width-4, view->size.height-4); } else { ofs = 2; - if (sPtr->flags.arrowsPosition==WSAMaxEnd) { - length -= (BUTTON_SIZE+1)*2; - } else if (sPtr->flags.arrowsPosition==WSAMinEnd) { - ofs += (BUTTON_SIZE+1)*2; - length -= (BUTTON_SIZE+1)*2; - } - - knobL = (float)knobLength(sPtr); - - knobP = sPtr->floatValue * ((float)length - knobL); - - if (sPtr->flags.horizontal) { - /* before */ - XFillRectangle(scr->display, d, scr->stippleGC, - ofs, 2, (int)knobP, view->size.height-4); - - /* knob */ + if (sPtr->flags.arrowsPosition==WSAMaxEnd) { + length -= (BUTTON_SIZE+1)*2; + } else if (sPtr->flags.arrowsPosition==WSAMinEnd) { + ofs += (BUTTON_SIZE+1)*2; + length -= (BUTTON_SIZE+1)*2; + } + + knobL = (float)knobLength(sPtr); + + knobP = sPtr->floatValue * ((float)length - knobL); + + if (sPtr->flags.horizontal) { + /* before */ + XFillRectangle(scr->display, d, scr->stippleGC, + ofs, 2, (int)knobP, view->size.height-4); + + /* knob */ #ifndef DOUBLE_BUFFER - XFillRectangle(scr->display, d, scr->lightGC, - ofs+(int)knobP+2, 2+2, (int)knobL-4, - view->size.height-4-4); + XFillRectangle(scr->display, d, scr->lightGC, + ofs+(int)knobP+2, 2+2, (int)knobL-4, + view->size.height-4-4); #endif - W_DrawRelief(scr, d, ofs+(int)knobP, 2, (int)knobL, - view->size.height-4, WRRaised); - - XCopyArea(scr->display, scr->scrollerDimple->pixmap, d, - scr->copyGC, 0, 0, - scr->scrollerDimple->width, scr->scrollerDimple->height, - ofs+(int)knobP+((int)knobL-scr->scrollerDimple->width-1)/2, - (view->size.height-scr->scrollerDimple->height-1)/2); - - /* after */ - if ((int)(knobP+knobL) < length) - XFillRectangle(scr->display, d, scr->stippleGC, - ofs+(int)(knobP+knobL), 2, - length-(int)(knobP+knobL), - view->size.height-4); - } else { - /* before */ - if (knobP>0.0) - XFillRectangle(scr->display, d, scr->stippleGC, - 2, ofs, view->size.width-4, (int)knobP); - - /* knob */ + W_DrawRelief(scr, d, ofs+(int)knobP, 2, (int)knobL, + view->size.height-4, WRRaised); + + XCopyArea(scr->display, scr->scrollerDimple->pixmap, d, + scr->copyGC, 0, 0, + scr->scrollerDimple->width, scr->scrollerDimple->height, + ofs+(int)knobP+((int)knobL-scr->scrollerDimple->width-1)/2, + (view->size.height-scr->scrollerDimple->height-1)/2); + + /* after */ + if ((int)(knobP+knobL) < length) + XFillRectangle(scr->display, d, scr->stippleGC, + ofs+(int)(knobP+knobL), 2, + length-(int)(knobP+knobL), + view->size.height-4); + } else { + /* before */ + if (knobP>0.0) + XFillRectangle(scr->display, d, scr->stippleGC, + 2, ofs, view->size.width-4, (int)knobP); + + /* knob */ #ifndef DOUBLE_BUFFER - XFillRectangle(scr->display, d, scr->lightGC, - 2+2, ofs+(int)knobP+2, - view->size.width-4-4, (int)knobL-4); + XFillRectangle(scr->display, d, scr->lightGC, + 2+2, ofs+(int)knobP+2, + view->size.width-4-4, (int)knobL-4); #endif - XCopyArea(scr->display, scr->scrollerDimple->pixmap, d, - scr->copyGC, 0, 0, - scr->scrollerDimple->width, scr->scrollerDimple->height, - (view->size.width-scr->scrollerDimple->width-1)/2, - ofs+(int)knobP+((int)knobL-scr->scrollerDimple->height-1)/2); - - W_DrawRelief(scr, d, 2, ofs+(int)knobP, - view->size.width-4, (int)knobL, WRRaised); - - /* after */ - if ((int)(knobP+knobL) < length) - XFillRectangle(scr->display, d, scr->stippleGC, - 2, ofs+(int)(knobP+knobL), - view->size.width-4, - length-(int)(knobP+knobL)); - } - - if (sPtr->flags.arrowsPosition != WSANone) { - paintArrow(sPtr, d, 0); - paintArrow(sPtr, d, 1); - } + XCopyArea(scr->display, scr->scrollerDimple->pixmap, d, + scr->copyGC, 0, 0, + scr->scrollerDimple->width, scr->scrollerDimple->height, + (view->size.width-scr->scrollerDimple->width-1)/2, + ofs+(int)knobP+((int)knobL-scr->scrollerDimple->height-1)/2); + + W_DrawRelief(scr, d, 2, ofs+(int)knobP, + view->size.width-4, (int)knobL, WRRaised); + + /* after */ + if ((int)(knobP+knobL) < length) + XFillRectangle(scr->display, d, scr->stippleGC, + 2, ofs+(int)(knobP+knobL), + view->size.width-4, + length-(int)(knobP+knobL)); + } + + if (sPtr->flags.arrowsPosition != WSANone) { + paintArrow(sPtr, d, 0); + paintArrow(sPtr, d, 1); + } } #ifdef DOUBLE_BUFFER - XCopyArea(scr->display, d, view->window, scr->copyGC, 0, 0, - view->size.width, view->size.height, 0, 0); + XCopyArea(scr->display, d, view->window, scr->copyGC, 0, 0, + view->size.width, view->size.height, 0, 0); XFreePixmap(scr->display, d); #endif } @@ -510,14 +510,14 @@ handleEvents(XEvent *event, void *data) switch (event->type) { - case Expose: - if (event->xexpose.count==0) - paintScroller(sPtr); - break; - - case DestroyNotify: - destroyScroller(sPtr); - break; + case Expose: + if (event->xexpose.count==0) + paintScroller(sPtr); + break; + + case DestroyNotify: + destroyScroller(sPtr); + break; } } @@ -538,72 +538,72 @@ locatePointInScroller(Scroller *sPtr, int x, int y, int alternate) /* if there is no knob... */ if (sPtr->flags.documentFullyVisible) - return WSKnobSlot; - + return WSKnobSlot; + if (sPtr->flags.horizontal) - c = x; + c = x; else - c = y; + c = y; /* p1 p2 p3 p4 p5 p6 - * | | |###########| |#####| | | + * | | |###########| |#####| | | * | < | > |###########| O |#####| < | > | * | | |###########| |#####| | | */ - + if (sPtr->flags.arrowsPosition == WSAMinEnd) { - p1 = 18; - p2 = 36; - - if (sPtr->flags.horizontal) { - slotL = width - 36; - p5 = width; - } else { - slotL = height - 36; - p5 = height; - } - p6 = p5; + p1 = 18; + p2 = 36; + + if (sPtr->flags.horizontal) { + slotL = width - 36; + p5 = width; + } else { + slotL = height - 36; + p5 = height; + } + p6 = p5; } else if (sPtr->flags.arrowsPosition == WSAMaxEnd) { - if (sPtr->flags.horizontal) { - slotL = width - 36; - p6 = width - 18; - } else { - slotL = height - 36; - p6 = height - 18; - } - p5 = p6 - 18; - - p1 = p2 = 0; + if (sPtr->flags.horizontal) { + slotL = width - 36; + p6 = width - 18; + } else { + slotL = height - 36; + p6 = height - 18; + } + p5 = p6 - 18; + + p1 = p2 = 0; } else { - /* no arrows */ - p1 = p2 = 0; - - if (sPtr->flags.horizontal) { - slotL = p5 = p6 = width; - } else { - slotL = p5 = p6 = height; - } + /* no arrows */ + p1 = p2 = 0; + + if (sPtr->flags.horizontal) { + slotL = p5 = p6 = width; + } else { + slotL = p5 = p6 = height; + } } - + knobL = knobLength(sPtr); p3 = p2 + (int)((float)(slotL-knobL) * sPtr->floatValue); p4 = p3 + knobL; /* uses a mix of the NS and Win ways of doing scroll page */ if (c <= p1) - return alternate ? WSDecrementPage : WSDecrementLine; + return alternate ? WSDecrementPage : WSDecrementLine; else if (c <= p2) - return alternate ? WSIncrementPage : WSIncrementLine; + return alternate ? WSIncrementPage : WSIncrementLine; else if (c <= p3) - return WSDecrementPage; + return WSDecrementPage; else if (c <= p4) - return WSKnob; + return WSKnob; else if (c <= p5) - return WSIncrementPage; + return WSIncrementPage; else if (c <= p6) - return alternate ? WSDecrementPage : WSDecrementLine; + return alternate ? WSDecrementPage : WSDecrementLine; else - return alternate ? WSIncrementPage : WSIncrementLine; + return alternate ? WSIncrementPage : WSIncrementLine; } @@ -613,40 +613,40 @@ handlePush(Scroller *sPtr, int pushX, int pushY, int alternate) { WMScrollerPart part; int doAction = 0; - + part = locatePointInScroller(sPtr, pushX, pushY, alternate); - + sPtr->flags.hitPart = part; - + switch (part) { - case WSIncrementLine: - sPtr->flags.incrDown = 1; - doAction = 1; - break; - - case WSIncrementPage: - doAction = 1; - break; - - case WSDecrementLine: - sPtr->flags.decrDown = 1; - doAction = 1; - break; - - case WSDecrementPage: - doAction = 1; - break; - - case WSKnob: - sPtr->flags.draggingKnob = 1; + case WSIncrementLine: + sPtr->flags.incrDown = 1; + doAction = 1; + break; + + case WSIncrementPage: + doAction = 1; + break; + + case WSDecrementLine: + sPtr->flags.decrDown = 1; + doAction = 1; + break; + + case WSDecrementPage: + doAction = 1; + break; + + case WSKnob: + sPtr->flags.draggingKnob = 1; #ifndef STRICT_NEXT_BEHAVIOUR - if (sPtr->flags.horizontal) - sPtr->dragPoint = pushX; - else - sPtr->dragPoint = pushY; + if (sPtr->flags.horizontal) + sPtr->dragPoint = pushX; + else + sPtr->dragPoint = pushY; - { - int length, knobP; + { + int length, knobP; int buttonsLen; if (sPtr->flags.arrowsPosition != WSANone) @@ -654,34 +654,34 @@ handlePush(Scroller *sPtr, int pushX, int pushY, int alternate) else buttonsLen = 0; - if (sPtr->flags.horizontal) - length = sPtr->view->size.width - 4 - buttonsLen; - else - length = sPtr->view->size.height - 4 - buttonsLen; + if (sPtr->flags.horizontal) + length = sPtr->view->size.width - 4 - buttonsLen; + else + length = sPtr->view->size.height - 4 - buttonsLen; - knobP = (int)(sPtr->floatValue * (float)(length-knobLength(sPtr))); + knobP = (int)(sPtr->floatValue * (float)(length-knobLength(sPtr))); - if (sPtr->flags.arrowsPosition == WSAMinEnd) - sPtr->dragPoint -= 2 + buttonsLen + knobP; - else - sPtr->dragPoint -= 2 + knobP; - } + if (sPtr->flags.arrowsPosition == WSAMinEnd) + sPtr->dragPoint -= 2 + buttonsLen + knobP; + else + sPtr->dragPoint -= 2 + knobP; + } #endif /* STRICT_NEXT_BEHAVIOUR */ /* This does not seem necesary here since we don't know yet if the * knob will be dragged later. -Dan - handleMotion(sPtr, pushX, pushY); */ - break; + handleMotion(sPtr, pushX, pushY); */ + break; - case WSKnobSlot: - case WSNoPart: - /* dummy */ - break; + case WSKnobSlot: + case WSNoPart: + /* dummy */ + break; } - + if (doAction && sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - - WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL); + (*sPtr->action)(sPtr, sPtr->clientData); + + WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL); } } @@ -709,22 +709,22 @@ floatValueForPoint(Scroller *sPtr, int point) knobL = (float)knobLength(sPtr); #ifdef STRICT_NEXT_BEHAVIOUR if (point < slotOfs + knobL/2) - position = (float)(slotOfs + knobL/2); + position = (float)(slotOfs + knobL/2); else if (point > slotOfs + slotLength - knobL/2) - position = (float)(slotOfs + slotLength - knobL/2); + position = (float)(slotOfs + slotLength - knobL/2); else - position = (float)point; - + position = (float)point; + floatValue = (position-(float)(slotOfs+slotLength/2)) - /(float)(slotLength-knobL); + /(float)(slotLength-knobL); #else - /* Adjust the last point to lie inside the knob slot */ + /* Adjust the last point to lie inside the knob slot */ if (point < slotOfs) - position = (float)slotOfs; + position = (float)slotOfs; else if (point > slotOfs + slotLength) - position = (float)(slotOfs + slotLength); + position = (float)(slotOfs + slotLength); else - position = (float)point; + position = (float)point; /* Compute the float value */ floatValue = (position-(float)slotOfs) / (float)(slotLength-knobL); @@ -742,11 +742,11 @@ handleMotion(Scroller *sPtr, int mouseX, int mouseY) float newFloatValue; int point; - if (sPtr->flags.horizontal) { + if (sPtr->flags.horizontal) { point = mouseX; - } else { + } else { point = mouseY; - } + } #ifndef STRICT_NEXT_BEHAVIOUR point -= sPtr->dragPoint; @@ -754,29 +754,29 @@ handleMotion(Scroller *sPtr, int mouseX, int mouseY) newFloatValue = floatValueForPoint(sPtr, point); WMSetScrollerParameters(sPtr, newFloatValue, sPtr->knobProportion); - if (sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, - NULL); - } + if (sPtr->action) { + (*sPtr->action)(sPtr, sPtr->clientData); + WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, + NULL); + } } else { - int part; - - part = locatePointInScroller(sPtr, mouseX, mouseY, False); - - sPtr->flags.hitPart = part; - - if (part == WSIncrementLine && sPtr->flags.decrDown) { - sPtr->flags.decrDown = 0; - sPtr->flags.incrDown = 1; - } else if (part == WSDecrementLine && sPtr->flags.incrDown) { - sPtr->flags.incrDown = 0; - sPtr->flags.decrDown = 1; - } else if (part != WSIncrementLine && part != WSDecrementLine) { - sPtr->flags.incrDown = 0; - sPtr->flags.decrDown = 0; - } - } + int part; + + part = locatePointInScroller(sPtr, mouseX, mouseY, False); + + sPtr->flags.hitPart = part; + + if (part == WSIncrementLine && sPtr->flags.decrDown) { + sPtr->flags.decrDown = 0; + sPtr->flags.incrDown = 1; + } else if (part == WSDecrementLine && sPtr->flags.incrDown) { + sPtr->flags.incrDown = 0; + sPtr->flags.decrDown = 1; + } else if (part != WSIncrementLine && part != WSDecrementLine) { + sPtr->flags.incrDown = 0; + sPtr->flags.decrDown = 0; + } + } } @@ -784,10 +784,10 @@ static void autoScroll(void *clientData) { Scroller *sPtr = (Scroller*)clientData; - + if (sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL); + (*sPtr->action)(sPtr, sPtr->clientData); + WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL); } sPtr->timerID= WMAddTimerHandler(AUTOSCROLL_DELAY, autoScroll, clientData); } @@ -813,13 +813,13 @@ handleActionEvents(XEvent *event, void *data) break; case LeaveNotify: - if (sPtr->timerID) { - WMDeleteTimerHandler(sPtr->timerID); - sPtr->timerID = NULL; - } - sPtr->flags.incrDown = 0; - sPtr->flags.decrDown = 0; - break; + if (sPtr->timerID) { + WMDeleteTimerHandler(sPtr->timerID); + sPtr->timerID = NULL; + } + sPtr->flags.incrDown = 0; + sPtr->flags.decrDown = 0; + break; case ButtonPress: /* FIXME: change Mod1Mask with something else */ @@ -834,7 +834,7 @@ handleActionEvents(XEvent *event, void *data) wheelIncrement = WINGsConfiguration.mouseWheelDown; } - if (event->xbutton.button == wheelDecrement) { + if (event->xbutton.button == wheelDecrement) { if (event->xbutton.state & ControlMask) { sPtr->flags.hitPart = WSDecrementPage; } else if (event->xbutton.state & ShiftMask) { @@ -842,12 +842,12 @@ handleActionEvents(XEvent *event, void *data) } else { sPtr->flags.hitPart = WSDecrementWheel; } - if (sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, - NULL); - } - } else if (event->xbutton.button == wheelIncrement) { + if (sPtr->action) { + (*sPtr->action)(sPtr, sPtr->clientData); + WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, + NULL); + } + } else if (event->xbutton.button == wheelIncrement) { if (event->xbutton.state & ControlMask) { sPtr->flags.hitPart = WSIncrementPage; } else if (event->xbutton.state & ShiftMask) { @@ -855,52 +855,52 @@ handleActionEvents(XEvent *event, void *data) } else { sPtr->flags.hitPart = WSIncrementWheel; } - if (sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, - NULL); - } - } else { - handlePush(sPtr, event->xbutton.x, event->xbutton.y, - (event->xbutton.state & Mod1Mask) - ||event->xbutton.button==Button2); - /* continue scrolling if pushed on the buttons */ - if (sPtr->flags.hitPart == WSIncrementLine - || sPtr->flags.hitPart == WSDecrementLine) { - sPtr->timerID = WMAddTimerHandler(AUTOSCROLL_INITIAL_DELAY, - autoScroll, sPtr); - } - } - break; + if (sPtr->action) { + (*sPtr->action)(sPtr, sPtr->clientData); + WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, + NULL); + } + } else { + handlePush(sPtr, event->xbutton.x, event->xbutton.y, + (event->xbutton.state & Mod1Mask) + ||event->xbutton.button==Button2); + /* continue scrolling if pushed on the buttons */ + if (sPtr->flags.hitPart == WSIncrementLine + || sPtr->flags.hitPart == WSDecrementLine) { + sPtr->timerID = WMAddTimerHandler(AUTOSCROLL_INITIAL_DELAY, + autoScroll, sPtr); + } + } + break; case ButtonRelease: - if (sPtr->flags.draggingKnob) { - if (sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, - NULL); - } - } - if (sPtr->timerID) { - WMDeleteTimerHandler(sPtr->timerID); - sPtr->timerID = NULL; - } - sPtr->flags.incrDown = 0; - sPtr->flags.decrDown = 0; - sPtr->flags.draggingKnob = 0; - break; + if (sPtr->flags.draggingKnob) { + if (sPtr->action) { + (*sPtr->action)(sPtr, sPtr->clientData); + WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, + NULL); + } + } + if (sPtr->timerID) { + WMDeleteTimerHandler(sPtr->timerID); + sPtr->timerID = NULL; + } + sPtr->flags.incrDown = 0; + sPtr->flags.decrDown = 0; + sPtr->flags.draggingKnob = 0; + break; case MotionNotify: - handleMotion(sPtr, event->xbutton.x, event->xbutton.y); - if (sPtr->timerID && sPtr->flags.hitPart != WSIncrementLine - && sPtr->flags.hitPart != WSDecrementLine) { - WMDeleteTimerHandler(sPtr->timerID); - sPtr->timerID = NULL; - } - break; + handleMotion(sPtr, event->xbutton.x, event->xbutton.y); + if (sPtr->timerID && sPtr->flags.hitPart != WSIncrementLine + && sPtr->flags.hitPart != WSDecrementLine) { + WMDeleteTimerHandler(sPtr->timerID); + sPtr->timerID = NULL; + } + break; } if (id != sPtr->flags.incrDown || dd != sPtr->flags.decrDown) - paintScroller(sPtr); + paintScroller(sPtr); } @@ -910,7 +910,7 @@ destroyScroller(Scroller *sPtr) { /* we don't want autoscroll try to scroll a freed widget */ if (sPtr->timerID) { - WMDeleteTimerHandler(sPtr->timerID); + WMDeleteTimerHandler(sPtr->timerID); } wfree(sPtr); diff --git a/WINGs/wscrollview.c b/WINGs/wscrollview.c index 3fde2512..0285a237 100644 --- a/WINGs/wscrollview.c +++ b/WINGs/wscrollview.c @@ -11,20 +11,20 @@ typedef struct W_ScrollView { WMView *contentView; WMView *viewport; - + WMScroller *vScroller; WMScroller *hScroller; - + short lineScroll; short pageScroll; - + struct { - WMReliefType relief:3; - unsigned int hasVScroller:1; - unsigned int hasHScroller:1; - + WMReliefType relief:3; + unsigned int hasVScroller:1; + unsigned int hasHScroller:1; + } flags; - + } ScrollView; @@ -40,14 +40,14 @@ static void updateScrollerProportion(); W_ViewDelegate _ScrollViewViewDelegate = { NULL, - NULL, - resizeScrollView, - NULL, - NULL + NULL, + resizeScrollView, + NULL, + NULL }; - + WMScrollView* WMCreateScrollView(WMWidget *parent) { @@ -57,29 +57,29 @@ WMCreateScrollView(WMWidget *parent) memset(sPtr, 0, sizeof(ScrollView)); sPtr->widgetClass = WC_ScrollView; - + sPtr->view = W_CreateView(W_VIEW(parent)); if (!sPtr->view) { - wfree(sPtr); - return NULL; + wfree(sPtr); + return NULL; } sPtr->viewport = W_CreateView(sPtr->view); if (!sPtr->viewport) { - W_DestroyView(sPtr->view); - wfree(sPtr); - return NULL; + W_DestroyView(sPtr->view); + wfree(sPtr); + return NULL; } sPtr->view->self = sPtr; sPtr->viewport->self = sPtr; - + sPtr->view->delegate = &_ScrollViewViewDelegate; sPtr->viewport->flags.mapWhenRealized = 1; WMCreateEventHandler(sPtr->view, StructureNotifyMask|ExposureMask, - handleEvents, sPtr); - WMCreateEventHandler(sPtr->viewport, SubstructureNotifyMask, - handleViewportEvents, sPtr); + handleEvents, sPtr); + WMCreateEventHandler(sPtr->viewport, SubstructureNotifyMask, + handleViewportEvents, sPtr); sPtr->lineScroll = 4; @@ -95,38 +95,38 @@ applyScrollerValues(WMScrollView *sPtr) int x, y; if (sPtr->contentView == NULL) - return; - + return; + if (sPtr->flags.hasHScroller) { - float v = WMGetScrollerValue(sPtr->hScroller); - int size; + float v = WMGetScrollerValue(sPtr->hScroller); + int size; - size = sPtr->contentView->size.width-sPtr->viewport->size.width; - - x = v * size; + size = sPtr->contentView->size.width-sPtr->viewport->size.width; + + x = v * size; } else { - x = 0; + x = 0; } - + if (sPtr->flags.hasVScroller) { - float v = WMGetScrollerValue(sPtr->vScroller); + float v = WMGetScrollerValue(sPtr->vScroller); - int size; + int size; - size = sPtr->contentView->size.height-sPtr->viewport->size.height; - - y = v * size; + size = sPtr->contentView->size.height-sPtr->viewport->size.height; + + y = v * size; } else { - y = 0; + y = 0; } - - - + + + x = WMAX(0, x); y = WMAX(0, y); - + W_MoveView(sPtr->contentView, -x, -y); - + W_RaiseView(sPtr->viewport); } @@ -137,84 +137,84 @@ reorganizeInterior(WMScrollView *sPtr) int hx, hy, hw; int vx, vy, vh; int cx, cy, cw, ch; - - + + cw = hw = sPtr->view->size.width; vh = ch = sPtr->view->size.height; if (sPtr->flags.relief == WRSimple) { - cw -= 2; - ch -= 2; - cx = 1; - cy = 1; + cw -= 2; + ch -= 2; + cx = 1; + cy = 1; } else if (sPtr->flags.relief != WRFlat) { - cw -= 3; - ch -= 3; - cx = 2; - cy = 2; + cw -= 3; + ch -= 3; + cx = 2; + cy = 2; } else { - cx = 0; - cy = 0; + cx = 0; + cy = 0; } - + if (sPtr->flags.hasHScroller) { - int h = 20; - - ch -= h; - - if (sPtr->flags.relief == WRSimple) { - hx = 0; - hy = sPtr->view->size.height - h; - } else if (sPtr->flags.relief != WRFlat) { - hx = 1; - hy = sPtr->view->size.height - h - 1; - hw -= 2; - } else { - hx = 0; - hy = sPtr->view->size.height - h; - } + int h = 20; + + ch -= h; + + if (sPtr->flags.relief == WRSimple) { + hx = 0; + hy = sPtr->view->size.height - h; + } else if (sPtr->flags.relief != WRFlat) { + hx = 1; + hy = sPtr->view->size.height - h - 1; + hw -= 2; + } else { + hx = 0; + hy = sPtr->view->size.height - h; + } } else { - /* make compiler shutup */ - hx = 0; - hy = 0; + /* make compiler shutup */ + hx = 0; + hy = 0; } - + if (sPtr->flags.hasVScroller) { - int w = 20; - cw -= w; - cx += w; - hx += w - 1; - hw -= w - 1; - - if (sPtr->flags.relief == WRSimple) { - vx = 0; - vy = 0; - } else if (sPtr->flags.relief != WRFlat) { - vx = 1; - vy = 1; - vh -= 2; - } else { - vx = 0; - vy = 0; - } + int w = 20; + cw -= w; + cx += w; + hx += w - 1; + hw -= w - 1; + + if (sPtr->flags.relief == WRSimple) { + vx = 0; + vy = 0; + } else if (sPtr->flags.relief != WRFlat) { + vx = 1; + vy = 1; + vh -= 2; + } else { + vx = 0; + vy = 0; + } } else { - /* make compiler shutup */ - vx = 0; - vy = 0; + /* make compiler shutup */ + vx = 0; + vy = 0; } W_ResizeView(sPtr->viewport, cw, ch); W_MoveView(sPtr->viewport, cx, cy); if (sPtr->flags.hasHScroller) { - WMResizeWidget(sPtr->hScroller, hw, 20); - WMMoveWidget(sPtr->hScroller, hx, hy); + WMResizeWidget(sPtr->hScroller, hw, 20); + WMMoveWidget(sPtr->hScroller, hx, hy); } if (sPtr->flags.hasVScroller) { - WMResizeWidget(sPtr->vScroller, 20, vh); - WMMoveWidget(sPtr->vScroller, vx, vy); + WMResizeWidget(sPtr->vScroller, 20, vh); + WMMoveWidget(sPtr->vScroller, vx, vy); } - + applyScrollerValues(sPtr); } @@ -229,8 +229,8 @@ resizeScrollView(W_ViewDelegate *self, WMView *view) void -WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width, - unsigned int height) +WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width, + unsigned int height) { int w, h, x; @@ -239,23 +239,23 @@ WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width, x = 0; if (sPtr->flags.relief == WRSimple) { - w += 2; - h += 2; + w += 2; + h += 2; } else if (sPtr->flags.relief != WRFlat) { - w += 4; - h += 4; - x = 1; + w += 4; + h += 4; + x = 1; } if (sPtr->flags.hasVScroller) { - WMResizeWidget(sPtr->vScroller, 20, h); - width -= W_VIEW(sPtr->vScroller)->size.width; + WMResizeWidget(sPtr->vScroller, 20, h); + width -= W_VIEW(sPtr->vScroller)->size.width; } if (sPtr->flags.hasHScroller) { - WMResizeWidget(sPtr->hScroller, w, 20); - WMMoveWidget(sPtr->hScroller, x, h); - height -= W_VIEW(sPtr->hScroller)->size.height; + WMResizeWidget(sPtr->hScroller, w, 20); + WMMoveWidget(sPtr->hScroller, x, h); + height -= W_VIEW(sPtr->hScroller)->size.height; } W_ResizeView(sPtr->view, w, h); @@ -268,7 +268,7 @@ void WMSetScrollViewLineScroll(WMScrollView *sPtr, int amount) { assert(amount > 0); - + sPtr->lineScroll = amount; } @@ -282,7 +282,7 @@ WMSetScrollViewPageScroll(WMScrollView *sPtr, int amount) } -WMRect +WMRect WMGetScrollViewVisibleRect(WMScrollView *sPtr) { WMRect rect; @@ -300,20 +300,20 @@ WMScrollViewScrollPoint(WMScrollView *sPtr, WMPoint point) { float xsize, ysize; float xpos, ypos; - + xsize = sPtr->contentView->size.width-sPtr->viewport->size.width; ysize = sPtr->contentView->size.height-sPtr->viewport->size.height; - + xpos = point.x / xsize; ypos = point.y / ysize; if (sPtr->hScroller) - WMSetScrollerParameters(sPtr->hScroller, xpos, - WMGetScrollerKnobProportion(sPtr->hScroller)); + WMSetScrollerParameters(sPtr->hScroller, xpos, + WMGetScrollerKnobProportion(sPtr->hScroller)); if (sPtr->vScroller) - WMSetScrollerParameters(sPtr->vScroller, ypos, - WMGetScrollerKnobProportion(sPtr->vScroller)); - + WMSetScrollerParameters(sPtr->vScroller, ypos, + WMGetScrollerKnobProportion(sPtr->vScroller)); + W_MoveView(sPtr->contentView, -point.x, -point.y); } @@ -326,99 +326,99 @@ doScrolling(WMWidget *self, void *data) int pos; int vpsize; float size; - + if (sPtr->hScroller == (WMScroller *)self) { - pos = -sPtr->contentView->pos.x; - size = sPtr->contentView->size.width-sPtr->viewport->size.width; - vpsize = sPtr->viewport->size.width - sPtr->pageScroll; + pos = -sPtr->contentView->pos.x; + size = sPtr->contentView->size.width-sPtr->viewport->size.width; + vpsize = sPtr->viewport->size.width - sPtr->pageScroll; } else { - pos = -sPtr->contentView->pos.y; - size = sPtr->contentView->size.height-sPtr->viewport->size.height; - vpsize = sPtr->viewport->size.height - sPtr->pageScroll; + pos = -sPtr->contentView->pos.y; + size = sPtr->contentView->size.height-sPtr->viewport->size.height; + vpsize = sPtr->viewport->size.height - sPtr->pageScroll; } if (vpsize <= 0) - vpsize = 1; + vpsize = 1; switch (WMGetScrollerHitPart(self)) { case WSDecrementLine: - if (pos > 0) { - pos-=sPtr->lineScroll; - if (pos < 0) - pos = 0; - value = (float)pos / size; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - } - break; + if (pos > 0) { + pos-=sPtr->lineScroll; + if (pos < 0) + pos = 0; + value = (float)pos / size; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + } + break; case WSIncrementLine: - if (pos < size) { - pos+=sPtr->lineScroll; - if (pos > size) - pos = size; - value = (float)pos / size; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - } - break; + if (pos < size) { + pos+=sPtr->lineScroll; + if (pos > size) + pos = size; + value = (float)pos / size; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + } + break; case WSKnob: - value = WMGetScrollerValue(self); - pos = value*size; - break; + value = WMGetScrollerValue(self); + pos = value*size; + break; case WSDecrementPage: - if (pos > 0) { - pos -= vpsize; - if (pos < 0) - pos = 0; - value = (float)pos / size; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - } + if (pos > 0) { + pos -= vpsize; + if (pos < 0) + pos = 0; + value = (float)pos / size; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + } break; case WSDecrementWheel: - if (pos > 0) { - pos -= vpsize/3; - if (pos < 0) - pos = 0; - value = (float)pos / size; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - } - break; + if (pos > 0) { + pos -= vpsize/3; + if (pos < 0) + pos = 0; + value = (float)pos / size; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + } + break; case WSIncrementPage: - if (pos < size) { - pos += vpsize; - if (pos > size) - pos = size; - value = (float)pos / size; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - } - break; + if (pos < size) { + pos += vpsize; + if (pos > size) + pos = size; + value = (float)pos / size; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + } + break; case WSIncrementWheel: - if (pos < size) { - pos += vpsize/3; - if (pos > size) - pos = size; - value = (float)pos / size; - WMSetScrollerParameters(self, value, - WMGetScrollerKnobProportion(self)); - } - break; - - case WSNoPart: - case WSKnobSlot: - break; + if (pos < size) { + pos += vpsize/3; + if (pos > size) + pos = size; + value = (float)pos / size; + WMSetScrollerParameters(self, value, + WMGetScrollerKnobProportion(self)); + } + break; + + case WSNoPart: + case WSKnobSlot: + break; } - + if (sPtr->hScroller == (WMScroller *)self) { - W_MoveView(sPtr->contentView, -pos, sPtr->contentView->pos.y); + W_MoveView(sPtr->contentView, -pos, sPtr->contentView->pos.y); } else { - W_MoveView(sPtr->contentView, sPtr->contentView->pos.x, -pos); + W_MoveView(sPtr->contentView, sPtr->contentView->pos.x, -pos); } } @@ -442,32 +442,32 @@ void WMSetScrollViewHasHorizontalScroller(WMScrollView *sPtr, Bool flag) { if (flag) { - if (sPtr->flags.hasHScroller) - return; - sPtr->flags.hasHScroller = 1; - - sPtr->hScroller = WMCreateScroller(sPtr); - WMSetScrollerAction(sPtr->hScroller, doScrolling, sPtr); - /* make it a horiz. scroller */ - WMResizeWidget(sPtr->hScroller, 2, 1); - - if (W_VIEW_REALIZED(sPtr->view)) { - WMRealizeWidget(sPtr->hScroller); - } - - reorganizeInterior(sPtr); - - WMMapWidget(sPtr->hScroller); + if (sPtr->flags.hasHScroller) + return; + sPtr->flags.hasHScroller = 1; + + sPtr->hScroller = WMCreateScroller(sPtr); + WMSetScrollerAction(sPtr->hScroller, doScrolling, sPtr); + /* make it a horiz. scroller */ + WMResizeWidget(sPtr->hScroller, 2, 1); + + if (W_VIEW_REALIZED(sPtr->view)) { + WMRealizeWidget(sPtr->hScroller); + } + + reorganizeInterior(sPtr); + + WMMapWidget(sPtr->hScroller); } else { - if (!sPtr->flags.hasHScroller) - return; - - WMUnmapWidget(sPtr->hScroller); - WMDestroyWidget(sPtr->hScroller); - sPtr->hScroller = NULL; - sPtr->flags.hasHScroller = 0; - - reorganizeInterior(sPtr); + if (!sPtr->flags.hasHScroller) + return; + + WMUnmapWidget(sPtr->hScroller); + WMDestroyWidget(sPtr->hScroller); + sPtr->hScroller = NULL; + sPtr->flags.hasHScroller = 0; + + reorganizeInterior(sPtr); } } @@ -476,33 +476,33 @@ void WMSetScrollViewHasVerticalScroller(WMScrollView *sPtr, Bool flag) { if (flag) { - if (sPtr->flags.hasVScroller) - return; - sPtr->flags.hasVScroller = 1; - - sPtr->vScroller = WMCreateScroller(sPtr); - WMSetScrollerAction(sPtr->vScroller, doScrolling, sPtr); - WMSetScrollerArrowsPosition(sPtr->vScroller, WSAMaxEnd); - /* make it a vert. scroller */ - WMResizeWidget(sPtr->vScroller, 1, 2); - - if (W_VIEW_REALIZED(sPtr->view)) { - WMRealizeWidget(sPtr->vScroller); - } - - reorganizeInterior(sPtr); - - WMMapWidget(sPtr->vScroller); + if (sPtr->flags.hasVScroller) + return; + sPtr->flags.hasVScroller = 1; + + sPtr->vScroller = WMCreateScroller(sPtr); + WMSetScrollerAction(sPtr->vScroller, doScrolling, sPtr); + WMSetScrollerArrowsPosition(sPtr->vScroller, WSAMaxEnd); + /* make it a vert. scroller */ + WMResizeWidget(sPtr->vScroller, 1, 2); + + if (W_VIEW_REALIZED(sPtr->view)) { + WMRealizeWidget(sPtr->vScroller); + } + + reorganizeInterior(sPtr); + + WMMapWidget(sPtr->vScroller); } else { - if (!sPtr->flags.hasVScroller) - return; - sPtr->flags.hasVScroller = 0; - - WMUnmapWidget(sPtr->vScroller); - WMDestroyWidget(sPtr->vScroller); - sPtr->vScroller = NULL; - - reorganizeInterior(sPtr); + if (!sPtr->flags.hasVScroller) + return; + sPtr->flags.hasVScroller = 0; + + WMUnmapWidget(sPtr->vScroller); + WMDestroyWidget(sPtr->vScroller); + sPtr->vScroller = NULL; + + reorganizeInterior(sPtr); } } @@ -511,23 +511,23 @@ void WMSetScrollViewContentView(WMScrollView *sPtr, WMView *view) { assert(sPtr->contentView == NULL); - + sPtr->contentView = view; W_ReparentView(sPtr->contentView, sPtr->viewport, 0, 0); if (sPtr->flags.hasHScroller) { - float prop; - - prop = (float)sPtr->viewport->size.width/sPtr->contentView->size.width; - WMSetScrollerParameters(sPtr->hScroller, 0, prop); + float prop; + + prop = (float)sPtr->viewport->size.width/sPtr->contentView->size.width; + WMSetScrollerParameters(sPtr->hScroller, 0, prop); } if (sPtr->flags.hasVScroller) { - float prop; - - prop = (float)sPtr->viewport->size.height/sPtr->contentView->size.height; - - WMSetScrollerParameters(sPtr->vScroller, 0, prop); + float prop; + + prop = (float)sPtr->viewport->size.height/sPtr->contentView->size.height; + + WMSetScrollerParameters(sPtr->vScroller, 0, prop); } } @@ -536,13 +536,13 @@ void WMSetScrollViewRelief(WMScrollView *sPtr, WMReliefType type) { sPtr->flags.relief = type; - + reorganizeInterior(sPtr); - + if (sPtr->view->flags.mapped) - paintScrollView(sPtr); - - + paintScrollView(sPtr); + + } @@ -551,8 +551,8 @@ static void paintScrollView(ScrollView *sPtr) { W_DrawRelief(sPtr->view->screen, sPtr->view->window, 0, 0, - sPtr->view->size.width, sPtr->view->size.height, - sPtr->flags.relief); + sPtr->view->size.width, sPtr->view->size.height, + sPtr->flags.relief); } @@ -562,29 +562,29 @@ updateScrollerProportion(ScrollView *sPtr) float prop, value; float oldV, oldP; - if (sPtr->flags.hasHScroller) { - oldV = WMGetScrollerValue(sPtr->hScroller); - oldP = WMGetScrollerKnobProportion(sPtr->hScroller); - - prop = (float)sPtr->viewport->size.width/(float)sPtr->contentView->size.width; - - if (oldP == 1.0) - value = 0; - else - value = (prop * oldV) / oldP; - WMSetScrollerParameters(sPtr->hScroller, value, prop); + if (sPtr->flags.hasHScroller) { + oldV = WMGetScrollerValue(sPtr->hScroller); + oldP = WMGetScrollerKnobProportion(sPtr->hScroller); + + prop = (float)sPtr->viewport->size.width/(float)sPtr->contentView->size.width; + + if (oldP == 1.0) + value = 0; + else + value = (prop * oldV) / oldP; + WMSetScrollerParameters(sPtr->hScroller, value, prop); } if (sPtr->flags.hasVScroller) { - oldV = WMGetScrollerValue(sPtr->vScroller); - oldP = WMGetScrollerKnobProportion(sPtr->vScroller); - - prop = (float)sPtr->viewport->size.height/(float)sPtr->contentView->size.height; - - if (oldP == 1.0) - value = 0; - else - value = (prop * oldV) / oldP; - WMSetScrollerParameters(sPtr->vScroller, value, prop); + oldV = WMGetScrollerValue(sPtr->vScroller); + oldP = WMGetScrollerKnobProportion(sPtr->vScroller); + + prop = (float)sPtr->viewport->size.height/(float)sPtr->contentView->size.height; + + if (oldP == 1.0) + value = 0; + else + value = (prop * oldV) / oldP; + WMSetScrollerParameters(sPtr->vScroller, value, prop); } applyScrollerValues(sPtr); } @@ -595,9 +595,9 @@ handleViewportEvents(XEvent *event, void *data) { ScrollView *sPtr = (ScrollView*)data; - if (sPtr->contentView - && event->xconfigure.window == sPtr->contentView->window) - updateScrollerProportion(sPtr); + if (sPtr->contentView + && event->xconfigure.window == sPtr->contentView->window) + updateScrollerProportion(sPtr); } @@ -608,27 +608,27 @@ handleEvents(XEvent *event, void *data) CHECK_CLASS(data, WC_ScrollView); - switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - if (event->xexpose.serial == 0) /* means it's artificial */ - W_RedisplayView(sPtr->contentView); - else - paintScrollView(sPtr); - break; - - case DestroyNotify: - destroyScrollView(sPtr); - break; - + switch (event->type) { + case Expose: + if (event->xexpose.count!=0) + break; + if (event->xexpose.serial == 0) /* means it's artificial */ + W_RedisplayView(sPtr->contentView); + else + paintScrollView(sPtr); + break; + + case DestroyNotify: + destroyScrollView(sPtr); + break; + } } static void destroyScrollView(ScrollView *sPtr) -{ +{ wfree(sPtr); } diff --git a/WINGs/wslider.c b/WINGs/wslider.c index aa978734..7815bc79 100644 --- a/WINGs/wslider.c +++ b/WINGs/wslider.c @@ -14,7 +14,7 @@ typedef struct W_Slider { int minValue; int maxValue; - + int value; Pixmap knobPixmap; @@ -26,12 +26,12 @@ typedef struct W_Slider { int knobThickness; struct { - unsigned int continuous:1; - - unsigned int vertical:1; - unsigned int dragging:1; + unsigned int continuous:1; + + unsigned int vertical:1; + unsigned int dragging:1; } flags; - + } Slider; @@ -42,10 +42,10 @@ static void didResizeSlider(); W_ViewDelegate _SliderViewDelegate = { NULL, - NULL, - didResizeSlider, - NULL, - NULL + NULL, + didResizeSlider, + NULL, + NULL }; @@ -75,23 +75,23 @@ WMCreateSlider(WMWidget *parent) memset(sPtr, 0, sizeof(Slider)); sPtr->widgetClass = WC_Slider; - + sPtr->view = W_CreateView(W_VIEW(parent)); if (!sPtr->view) { - wfree(sPtr); - return NULL; + wfree(sPtr); + return NULL; } sPtr->view->self = sPtr; sPtr->view->delegate = &_SliderViewDelegate; WMCreateEventHandler(sPtr->view, ExposureMask|StructureNotifyMask, - handleEvents, sPtr); + handleEvents, sPtr); WMCreateEventHandler(sPtr->view, ButtonPressMask|ButtonReleaseMask - |EnterWindowMask|LeaveWindowMask|ButtonMotionMask, - handleActionEvents, sPtr); + |EnterWindowMask|LeaveWindowMask|ButtonMotionMask, + handleActionEvents, sPtr); W_ResizeView(sPtr->view, 100, 16); sPtr->flags.vertical = 0; @@ -104,7 +104,7 @@ WMCreateSlider(WMWidget *parent) sPtr->flags.continuous = 1; WMAddNotificationObserver(realizeObserver, sPtr, - WMViewRealizedNotification, sPtr->view); + WMViewRealizedNotification, sPtr->view); return sPtr; } @@ -114,12 +114,12 @@ void WMSetSliderImage(WMSlider *sPtr, WMPixmap *pixmap) { if (sPtr->backPixmap) - WMReleasePixmap(sPtr->backPixmap); + WMReleasePixmap(sPtr->backPixmap); sPtr->backPixmap = WMRetainPixmap(pixmap); - + if (sPtr->view->flags.mapped) { - paintSlider(sPtr); + paintSlider(sPtr); } } @@ -132,11 +132,11 @@ WMSetSliderKnobThickness(WMSlider *sPtr, int thickness) sPtr->knobThickness = thickness; if (sPtr->knobPixmap) { - makeKnobPixmap(sPtr); + makeKnobPixmap(sPtr); } if (sPtr->view->flags.mapped) { - paintSlider(sPtr); + paintSlider(sPtr); } } @@ -145,7 +145,7 @@ int WMGetSliderMinValue(WMSlider *slider) { CHECK_CLASS(slider, WC_Slider); - + return slider->minValue; } @@ -154,7 +154,7 @@ int WMGetSliderMaxValue(WMSlider *slider) { CHECK_CLASS(slider, WC_Slider); - + return slider->maxValue; } @@ -172,12 +172,12 @@ void WMSetSliderMinValue(WMSlider *slider, int value) { CHECK_CLASS(slider, WC_Slider); - + slider->minValue = value; if (slider->value < value) { - slider->value = value; - if (slider->view->flags.mapped) - paintSlider(slider); + slider->value = value; + if (slider->view->flags.mapped) + paintSlider(slider); } } @@ -186,12 +186,12 @@ void WMSetSliderMaxValue(WMSlider *slider, int value) { CHECK_CLASS(slider, WC_Slider); - + slider->maxValue = value; if (slider->value > value) { - slider->value = value; - if (slider->view->flags.mapped) - paintSlider(slider); + slider->value = value; + if (slider->view->flags.mapped) + paintSlider(slider); } } @@ -200,16 +200,16 @@ void WMSetSliderValue(WMSlider *slider, int value) { CHECK_CLASS(slider, WC_Slider); - + if (value < slider->minValue) - slider->value = slider->minValue; + slider->value = slider->minValue; else if (value > slider->maxValue) - slider->value = slider->maxValue; + slider->value = slider->maxValue; else - slider->value = value; - + slider->value = value; + if (slider->view->flags.mapped) - paintSlider(slider); + paintSlider(slider); } @@ -217,7 +217,7 @@ void WMSetSliderContinuous(WMSlider *slider, Bool flag) { CHECK_CLASS(slider, WC_Slider); - + slider->flags.continuous = ((flag==0) ? 0 : 1); } @@ -226,7 +226,7 @@ void WMSetSliderAction(WMSlider *slider, WMAction *action, void *data) { CHECK_CLASS(slider, WC_Slider); - + slider->action = action; slider->clientData = data; } @@ -238,57 +238,57 @@ makeKnobPixmap(Slider *sPtr) Pixmap pix; WMScreen *scr = sPtr->view->screen; int w, h; - + if (sPtr->flags.vertical) { - w = sPtr->view->size.width-2; - h = sPtr->knobThickness; + w = sPtr->view->size.width-2; + h = sPtr->knobThickness; } else { - w = sPtr->knobThickness; - h = sPtr->view->size.height-2; + w = sPtr->knobThickness; + h = sPtr->view->size.height-2; } - + pix = XCreatePixmap(scr->display, sPtr->view->window, w, h, scr->depth); XFillRectangle(scr->display, pix, WMColorGC(scr->gray), 0, 0, w, h); if (sPtr->knobThickness < 10) { - W_DrawRelief(scr, pix, 0, 0, w, h, WRRaised); + W_DrawRelief(scr, pix, 0, 0, w, h, WRRaised); } else if (sPtr->flags.vertical) { - XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, 0, h-3); - XDrawLine(scr->display, pix, WMColorGC(scr->white), 1, 0, 1, h-3); - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-2, 1, w-2, h/2-2); - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-2, h/2, w-2, h-2); - - XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, w-2, 0); - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 1, h/2-2, w-3, h/2-2); - XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, h/2-1, w-3, h/2-1); - - XDrawLine(scr->display, pix, WMColorGC(scr->black), w-1, 0, w-1, h-2); - - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 0, h-3, w-2, h-3); - XDrawLine(scr->display, pix, WMColorGC(scr->black), 0, h-2, w-1, h-2); - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 0, h-1, w-1,h-1); + XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, 0, h-3); + XDrawLine(scr->display, pix, WMColorGC(scr->white), 1, 0, 1, h-3); + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-2, 1, w-2, h/2-2); + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-2, h/2, w-2, h-2); + + XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, w-2, 0); + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 1, h/2-2, w-3, h/2-2); + XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, h/2-1, w-3, h/2-1); + + XDrawLine(scr->display, pix, WMColorGC(scr->black), w-1, 0, w-1, h-2); + + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 0, h-3, w-2, h-3); + XDrawLine(scr->display, pix, WMColorGC(scr->black), 0, h-2, w-1, h-2); + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 0, h-1, w-1,h-1); } else { - XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, w-3, 0); - - XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, 0, h-2); + XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, w-3, 0); + + XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, 0, h-2); - XDrawLine(scr->display, pix, WMColorGC(scr->white), 1, 0, 1, h-3); - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w/2-2, 1, w/2-2, h-3); - XDrawLine(scr->display, pix, WMColorGC(scr->white), w/2-1, 0, w/2-1, h-3); + XDrawLine(scr->display, pix, WMColorGC(scr->white), 1, 0, 1, h-3); + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w/2-2, 1, w/2-2, h-3); + XDrawLine(scr->display, pix, WMColorGC(scr->white), w/2-1, 0, w/2-1, h-3); - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-3, 0, w-3, h-2); - XDrawLine(scr->display, pix, WMColorGC(scr->black), w-2, 0, w-2, h-2); - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-1, 0, w-1, h-1); + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-3, 0, w-3, h-2); + XDrawLine(scr->display, pix, WMColorGC(scr->black), w-2, 0, w-2, h-2); + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-1, 0, w-1, h-1); - XDrawLine(scr->display, pix, WMColorGC(scr->black), 1, h-1, w/2+1, h-1); - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 1, h-2, w/2-2, h-2); - XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w/2, h-2, w-3,h-2); + XDrawLine(scr->display, pix, WMColorGC(scr->black), 1, h-1, w/2+1, h-1); + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 1, h-2, w/2-2, h-2); + XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w/2, h-2, w-3,h-2); - XDrawLine(scr->display, pix, WMColorGC(scr->black), 0, h-1, w-2, h-1); + XDrawLine(scr->display, pix, WMColorGC(scr->black), 0, h-1, w-2, h-1); } - + if (sPtr->knobPixmap) - XFreePixmap(scr->display, sPtr->knobPixmap); + XFreePixmap(scr->display, sPtr->knobPixmap); sPtr->knobPixmap = pix; } @@ -302,19 +302,19 @@ didResizeSlider(W_ViewDelegate *self, WMView *view) assert(width > 0); assert(height > 0); - + if (width > height) { - if (sPtr->flags.vertical) { - sPtr->flags.vertical = 0; - if (sPtr->view->flags.realized) - makeKnobPixmap(sPtr); - } + if (sPtr->flags.vertical) { + sPtr->flags.vertical = 0; + if (sPtr->view->flags.realized) + makeKnobPixmap(sPtr); + } } else { - if (!sPtr->flags.vertical) { - sPtr->flags.vertical = 1; - if (sPtr->view->flags.realized) - makeKnobPixmap(sPtr); - } + if (!sPtr->flags.vertical) { + sPtr->flags.vertical = 1; + if (sPtr->view->flags.realized) + makeKnobPixmap(sPtr); + } } } @@ -330,53 +330,53 @@ paintSlider(Slider *sPtr) WMSize size = sPtr->view->size; int pos; Pixmap buffer; - + #define MINV sPtr->minValue #define MAXV sPtr->maxValue #define POSV sPtr->value - + bgc = WMColorGC(scr->black); wgc = WMColorGC(scr->white); lgc = WMColorGC(scr->gray); - buffer = XCreatePixmap(scr->display, sPtr->view->window, - size.width, size.height, scr->depth); + buffer = XCreatePixmap(scr->display, sPtr->view->window, + size.width, size.height, scr->depth); if (sPtr->backPixmap) { - WMSize size = WMGetPixmapSize(sPtr->backPixmap); + WMSize size = WMGetPixmapSize(sPtr->backPixmap); - XCopyArea(scr->display, WMGetPixmapXID(sPtr->backPixmap), - buffer, scr->copyGC, 0, 0, size.width, size.height, 1, 1); + XCopyArea(scr->display, WMGetPixmapXID(sPtr->backPixmap), + buffer, scr->copyGC, 0, 0, size.width, size.height, 1, 1); } else { - XFillRectangle(scr->display, buffer, lgc, 0, 0, size.width, - size.height); - XFillRectangle(scr->display, buffer, scr->stippleGC, 0, 0, size.width, - size.height); + XFillRectangle(scr->display, buffer, lgc, 0, 0, size.width, + size.height); + XFillRectangle(scr->display, buffer, scr->stippleGC, 0, 0, size.width, + size.height); } - + if (sPtr->flags.vertical) { - pos = (size.height-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV)+1; - /* draw knob */ - XCopyArea(scr->display, sPtr->knobPixmap, buffer, - scr->copyGC, 0, 0, size.width-2, sPtr->knobThickness, - 1, pos); + pos = (size.height-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV)+1; + /* draw knob */ + XCopyArea(scr->display, sPtr->knobPixmap, buffer, + scr->copyGC, 0, 0, size.width-2, sPtr->knobThickness, + 1, pos); } else { - pos = (size.width-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV)+1; - /* draw knob */ - XCopyArea(scr->display, sPtr->knobPixmap, buffer, - scr->copyGC, 0, 0, sPtr->knobThickness, size.height, pos, 1); + pos = (size.width-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV)+1; + /* draw knob */ + XCopyArea(scr->display, sPtr->knobPixmap, buffer, + scr->copyGC, 0, 0, sPtr->knobThickness, size.height, pos, 1); } XDrawLine(scr->display, buffer, bgc, 0, 0, 0, size.height-1); XDrawLine(scr->display, buffer, bgc, 0, 0, size.width, 0); - - XDrawLine(scr->display, buffer, wgc, size.width-1, 0, - size.width-1, size.height-1); - XDrawLine(scr->display, buffer, wgc, 0, size.height-1, - size.width-1, size.height-1); + + XDrawLine(scr->display, buffer, wgc, size.width-1, 0, + size.width-1, size.height-1); + XDrawLine(scr->display, buffer, wgc, 0, size.height-1, + size.width-1, size.height-1); XCopyArea(scr->display, buffer, sPtr->view->window, scr->copyGC, 0, 0, - size.width, size.height, 0, 0); + size.width, size.height, 0, 0); XFreePixmap(scr->display, buffer); } @@ -391,16 +391,16 @@ handleEvents(XEvent *event, void *data) switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintSlider(sPtr); - break; - - case DestroyNotify: - destroySlider(sPtr); - break; - + case Expose: + if (event->xexpose.count!=0) + break; + paintSlider(sPtr); + break; + + case DestroyNotify: + destroySlider(sPtr); + break; + } } @@ -415,24 +415,24 @@ getSliderPart(Slider *sPtr, int x, int y) int p; int pos; WMSize size = sPtr->view->size; - + if (sPtr->flags.vertical) { - p = y; - pos = (size.height-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV); - if (p < pos) - return INCR_PART; - if (p > pos + sPtr->knobThickness) - return DECR_PART; - return KNOB_PART; + p = y; + pos = (size.height-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV); + if (p < pos) + return INCR_PART; + if (p > pos + sPtr->knobThickness) + return DECR_PART; + return KNOB_PART; } else { - p = x; - pos = (size.width-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV); - if (p < pos) - return DECR_PART; - if (p > pos + sPtr->knobThickness) - return INCR_PART; - return KNOB_PART; + p = x; + pos = (size.width-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV); + if (p < pos) + return DECR_PART; + if (p > pos + sPtr->knobThickness) + return INCR_PART; + return KNOB_PART; } } @@ -444,18 +444,18 @@ valueForMousePoint(Slider *sPtr, int x, int y) int f; if (sPtr->flags.vertical) { - f = (y-sPtr->knobThickness/2)*(MAXV-MINV) - / ((int)size.height-2-sPtr->knobThickness); + f = (y-sPtr->knobThickness/2)*(MAXV-MINV) + / ((int)size.height-2-sPtr->knobThickness); } else { - f = (x-sPtr->knobThickness/2)*(MAXV-MINV) - / ((int)size.width-2-sPtr->knobThickness); + f = (x-sPtr->knobThickness/2)*(MAXV-MINV) + / ((int)size.width-2-sPtr->knobThickness); } f += sPtr->minValue; if (f < sPtr->minValue) - f = sPtr->minValue; + f = sPtr->minValue; else if (f > sPtr->maxValue) - f = sPtr->maxValue; + f = sPtr->maxValue; return f; } @@ -470,81 +470,81 @@ handleActionEvents(XEvent *event, void *data) switch (event->type) { - case ButtonPress: - if (event->xbutton.button==WINGsConfiguration.mouseWheelUp - &&!sPtr->flags.dragging) { - /* Wheel up */ - if (sPtr->value+1<=sPtr->maxValue) { - WMSetSliderValue(sPtr, sPtr->value+1); - if (sPtr->flags.continuous && sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - } - } - } else if (event->xbutton.button==WINGsConfiguration.mouseWheelDown - &&!sPtr->flags.dragging) { - /* Wheel down */ - if (sPtr->value-1>=sPtr->minValue) - { - WMSetSliderValue(sPtr, sPtr->value-1); - if (sPtr->flags.continuous && sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - } - } - } - else if (getSliderPart(sPtr, event->xbutton.x, event->xbutton.y) - ==KNOB_PART) - sPtr->flags.dragging = 1; - else { + case ButtonPress: + if (event->xbutton.button==WINGsConfiguration.mouseWheelUp + &&!sPtr->flags.dragging) { + /* Wheel up */ + if (sPtr->value+1<=sPtr->maxValue) { + WMSetSliderValue(sPtr, sPtr->value+1); + if (sPtr->flags.continuous && sPtr->action) { + (*sPtr->action)(sPtr, sPtr->clientData); + } + } + } else if (event->xbutton.button==WINGsConfiguration.mouseWheelDown + &&!sPtr->flags.dragging) { + /* Wheel down */ + if (sPtr->value-1>=sPtr->minValue) + { + WMSetSliderValue(sPtr, sPtr->value-1); + if (sPtr->flags.continuous && sPtr->action) { + (*sPtr->action)(sPtr, sPtr->clientData); + } + } + } + else if (getSliderPart(sPtr, event->xbutton.x, event->xbutton.y) + ==KNOB_PART) + sPtr->flags.dragging = 1; + else { #ifdef STRICT_NEXT_BEHAVIOUR - sPtr->flags.dragging = 1; + sPtr->flags.dragging = 1; - sPtr->value = valueForMousePoint(sPtr, event->xmotion.x, - event->xmotion.y); - paintSlider(sPtr); + sPtr->value = valueForMousePoint(sPtr, event->xmotion.x, + event->xmotion.y); + paintSlider(sPtr); #else - int tmp; - - if (event->xbutton.button == Button2) { - sPtr->flags.dragging = 1; - - sPtr->value = valueForMousePoint(sPtr, event->xmotion.x, - event->xmotion.y); - paintSlider(sPtr); - } else { - tmp = valueForMousePoint(sPtr, event->xmotion.x, - event->xmotion.y); - if (tmp < sPtr->value) - tmp = sPtr->value-1; - else - tmp = sPtr->value+1; - WMSetSliderValue(sPtr, tmp); - } + int tmp; + + if (event->xbutton.button == Button2) { + sPtr->flags.dragging = 1; + + sPtr->value = valueForMousePoint(sPtr, event->xmotion.x, + event->xmotion.y); + paintSlider(sPtr); + } else { + tmp = valueForMousePoint(sPtr, event->xmotion.x, + event->xmotion.y); + if (tmp < sPtr->value) + tmp = sPtr->value-1; + else + tmp = sPtr->value+1; + WMSetSliderValue(sPtr, tmp); + } #endif - if (sPtr->flags.continuous && sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - } - } - break; - - case ButtonRelease: - if (!sPtr->flags.continuous && sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - } - sPtr->flags.dragging = 0; - break; - - case MotionNotify: - if (sPtr->flags.dragging) { - sPtr->value = valueForMousePoint(sPtr, event->xmotion.x, - event->xmotion.y); - paintSlider(sPtr); - - if (sPtr->flags.continuous && sPtr->action) { - (*sPtr->action)(sPtr, sPtr->clientData); - } - } - break; + if (sPtr->flags.continuous && sPtr->action) { + (*sPtr->action)(sPtr, sPtr->clientData); + } + } + break; + + case ButtonRelease: + if (!sPtr->flags.continuous && sPtr->action) { + (*sPtr->action)(sPtr, sPtr->clientData); + } + sPtr->flags.dragging = 0; + break; + + case MotionNotify: + if (sPtr->flags.dragging) { + sPtr->value = valueForMousePoint(sPtr, event->xmotion.x, + event->xmotion.y); + paintSlider(sPtr); + + if (sPtr->flags.continuous && sPtr->action) { + (*sPtr->action)(sPtr, sPtr->clientData); + } + } + break; } } @@ -554,10 +554,10 @@ static void destroySlider(Slider *sPtr) { if (sPtr->knobPixmap) - XFreePixmap(sPtr->view->screen->display, sPtr->knobPixmap); + XFreePixmap(sPtr->view->screen->display, sPtr->knobPixmap); if (sPtr->backPixmap) - WMReleasePixmap(sPtr->backPixmap); + WMReleasePixmap(sPtr->backPixmap); WMRemoveNotificationObserver(sPtr); diff --git a/WINGs/wsplitview.c b/WINGs/wsplitview.c index 78e287bd..de9d0f50 100644 --- a/WINGs/wsplitview.c +++ b/WINGs/wsplitview.c @@ -5,11 +5,11 @@ #include "WINGsP.h" /* -char *WMSplitViewDidResizeSubviewsNotification - = "WMSplitViewDidResizeSubviewsNotification"; -char *WMSplitViewWillResizeSubviewsNotification - = "WMSplitViewWillResizeSubviewsNotification"; -*/ + char *WMSplitViewDidResizeSubviewsNotification + = "WMSplitViewDidResizeSubviewsNotification"; + char *WMSplitViewWillResizeSubviewsNotification + = "WMSplitViewWillResizeSubviewsNotification"; + */ typedef struct W_SplitViewSubview { WMView *view; @@ -23,15 +23,15 @@ typedef struct W_SplitViewSubview { typedef struct W_SplitView { W_Class widgetClass; W_View *view; - + WMArray *subviews; - + WMSplitViewConstrainProc *constrainProc; - + struct { - unsigned int vertical:1; - unsigned int adjustOnPaint:1; - unsigned int subviewsWereManuallyMoved:1; + unsigned int vertical:1; + unsigned int adjustOnPaint:1; + unsigned int subviewsWereManuallyMoved:1; } flags; /* WMSplitViewResizeSubviewsProc *resizeSubviewsProc; */ @@ -48,28 +48,28 @@ typedef struct W_SplitView { #define _GetSubviewsCount() WMGetArrayItemCount(sPtr->subviews) #define _AddPSubviewStruct(P) \ -(WMAddToArray(sPtr->subviews,((void*)P))) + (WMAddToArray(sPtr->subviews,((void*)P))) #define _GetPSubviewStructAt(i) \ -((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i))) + ((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i))) #define _GetSubviewAt(i) \ -(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->view) + (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->view) #define _GetMinSizeAt(i) \ -(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->minSize) + (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->minSize) #define _GetMaxSizeAt(i) \ -(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->maxSize) + (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->maxSize) #define _GetSizeAt(i) \ -(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->size) + (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->size) #define _GetPosAt(i) \ -(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->pos) + (((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->pos) #define _GetSplitViewSize() \ -((sPtr->flags.vertical) ? sPtr->view->size.width : sPtr->view->size.height) + ((sPtr->flags.vertical) ? sPtr->view->size.width : sPtr->view->size.height) static void destroySplitView(WMSplitView *sPtr); static void paintSplitView(WMSplitView *sPtr); @@ -85,15 +85,15 @@ getConstraints(WMSplitView *sPtr, int index, int *minSize, int *maxSize) *maxSize = MAX_SUBVIEW_SIZE; if (sPtr->constrainProc) - (*sPtr->constrainProc)(sPtr, index, minSize, maxSize); + (*sPtr->constrainProc)(sPtr, index, minSize, maxSize); if (*minSize < MIN_SUBVIEW_SIZE) - *minSize = MIN_SUBVIEW_SIZE; + *minSize = MIN_SUBVIEW_SIZE; if (*maxSize < MIN_SUBVIEW_SIZE) - *maxSize = MAX_SUBVIEW_SIZE; + *maxSize = MAX_SUBVIEW_SIZE; else if (*maxSize < *minSize) - *maxSize = *minSize; + *maxSize = *minSize; } @@ -105,8 +105,8 @@ updateConstraints(WMSplitView *sPtr) count = _GetSubviewsCount(); for (i = 0; i < count; i++) { - p = _GetPSubviewStructAt(i); - getConstraints(sPtr, i, &(p->minSize), &(p->maxSize)); + p = _GetPSubviewStructAt(i); + getConstraints(sPtr, i, &(p->minSize), &(p->maxSize)); } } @@ -117,17 +117,17 @@ resizeView(WMSplitView *sPtr, WMView *view, int size) int width, height; if (sPtr->flags.vertical) { - width = size; - height = sPtr->view->size.height; + width = size; + height = sPtr->view->size.height; } else { - width = sPtr->view->size.width; - height = size; + width = sPtr->view->size.width; + height = size; } if (view->self) - WMResizeWidget(view->self, width, height); + WMResizeWidget(view->self, width, height); else - W_ResizeView(view, width, height); + W_ResizeView(view, width, height); } @@ -137,11 +137,11 @@ reparentView(WMSplitView *sPtr, WMView *view, int pos) int x, y; if (sPtr->flags.vertical) { - x = pos; - y = 0; + x = pos; + y = 0; } else { - x = 0; - y = pos; + x = 0; + y = pos; } W_ReparentView(view, sPtr->view, x, y); @@ -154,17 +154,17 @@ moveView(WMSplitView *sPtr, WMView *view, int pos) int x, y; if (sPtr->flags.vertical) { - x = pos; - y = 0; + x = pos; + y = 0; } else { - x = 0; - y = pos; + x = 0; + y = pos; } if (view->self) - WMMoveWidget(view->self, x, y); + WMMoveWidget(view->self, x, y); else - W_MoveView(view, x, y); + W_MoveView(view, x, y); } @@ -177,16 +177,16 @@ checkSizes(WMSplitView *sPtr) count = _GetSubviewsCount(); offset = 0; for (i = 0; i < count; i++) { - p = _GetPSubviewStructAt(i); - if (p->size < p->minSize) { - offset += p->minSize - p->size; - p->size = p->minSize; - } else if (p->maxSize != MAX_SUBVIEW_SIZE && p->size > p->maxSize) { - offset += p->maxSize - p->size; - p->size = p->maxSize; - } + p = _GetPSubviewStructAt(i); + if (p->size < p->minSize) { + offset += p->minSize - p->size; + p->size = p->minSize; + } else if (p->maxSize != MAX_SUBVIEW_SIZE && p->size > p->maxSize) { + offset += p->maxSize - p->size; + p->size = p->maxSize; + } } - + return (offset); } @@ -200,9 +200,9 @@ checkPositions(WMSplitView *sPtr) count = _GetSubviewsCount(); pos = 0; for (i = 0; i < count; i++) { - p = _GetPSubviewStructAt(i); - p->pos = pos; - pos += p->size + DIVIDER_THICKNESS; + p = _GetPSubviewStructAt(i); + p->pos = pos; + pos += p->size + DIVIDER_THICKNESS; } } @@ -215,9 +215,9 @@ updateSubviewsGeom(WMSplitView *sPtr) count = _GetSubviewsCount(); for (i = 0; i < count; i++) { - p = _GetPSubviewStructAt(i); - resizeView(sPtr, p->view, p->size); - moveView(sPtr, p->view, p->pos); + p = _GetPSubviewStructAt(i); + resizeView(sPtr, p->view, p->size); + moveView(sPtr, p->view, p->pos); } } @@ -229,12 +229,12 @@ getTotalSize(WMSplitView *sPtr) count = _GetSubviewsCount(); if (!count) - return (0); + return (0); totSize = 0; for (i = 0; i < count; i++) - totSize += _GetSizeAt(i) + DIVIDER_THICKNESS; - + totSize += _GetSizeAt(i) + DIVIDER_THICKNESS; + return (totSize - DIVIDER_THICKNESS); } @@ -246,36 +246,36 @@ distributeOffsetEqually(WMSplitView *sPtr, int offset) int i, count, sizeChanged, forced; if ((count = _GetSubviewsCount()) < 1) - return (True); + return (True); forced = False; while (offset != 0) { - sizeChanged = 0; - for (i = 0; i < count && offset != 0; i++) { - p = _GetPSubviewStructAt(i); - if (offset < 0) { - if (p->size > p->minSize) { - offset++; - p->size--; - sizeChanged = 1; - } - } else if (p->maxSize == MAX_SUBVIEW_SIZE || p->size < p->maxSize) { - offset--; - p->size++; - sizeChanged = 1; - } - } - if (offset != 0 && !sizeChanged) { - p = _GetPSubviewStructAt(count-1); - if (offset > 0) { - p->size += offset; - p->maxSize = MAX_SUBVIEW_SIZE; - } - offset = 0; - forced = True; - } + sizeChanged = 0; + for (i = 0; i < count && offset != 0; i++) { + p = _GetPSubviewStructAt(i); + if (offset < 0) { + if (p->size > p->minSize) { + offset++; + p->size--; + sizeChanged = 1; + } + } else if (p->maxSize == MAX_SUBVIEW_SIZE || p->size < p->maxSize) { + offset--; + p->size++; + sizeChanged = 1; + } + } + if (offset != 0 && !sizeChanged) { + p = _GetPSubviewStructAt(count-1); + if (offset > 0) { + p->size += offset; + p->maxSize = MAX_SUBVIEW_SIZE; + } + offset = 0; + forced = True; + } } - + return (forced); } @@ -287,23 +287,23 @@ distributeOffsetFormEnd(WMSplitView *sPtr, int offset) int i, count, sizeTmp; if ((count = _GetSubviewsCount()) < 1) - return (True); + return (True); for (i = count-1; i >= 0 && offset != 0; i--) { - p = _GetPSubviewStructAt(i); - sizeTmp = p->size; - if (offset > 0) { - if (p->maxSize == MAX_SUBVIEW_SIZE || p->size + offset < p->maxSize) - p->size += offset; - else - p->size = p->maxSize; - } else { - if (p->size + offset >= p->minSize) - p->size += offset; - else - p->size = p->minSize; - } - offset -= p->size - sizeTmp; + p = _GetPSubviewStructAt(i); + sizeTmp = p->size; + if (offset > 0) { + if (p->maxSize == MAX_SUBVIEW_SIZE || p->size + offset < p->maxSize) + p->size += offset; + else + p->size = p->maxSize; + } else { + if (p->size + offset >= p->minSize) + p->size += offset; + else + p->size = p->minSize; + } + offset -= p->size - sizeTmp; } return (offset == 0); @@ -324,23 +324,23 @@ adjustSplitViewSubviews(WMSplitView *sPtr) #endif if ((count = _GetSubviewsCount()) < 1) - return; + return; adjSize = (_GetSplitViewSize() - ((count-1) * DIVIDER_THICKNESS)) / count; adjPad = (_GetSplitViewSize() - ((count-1) * DIVIDER_THICKNESS)) % count; for (i = 0; i < count; i++) { - p = _GetPSubviewStructAt(i); - p->size = adjSize; + p = _GetPSubviewStructAt(i); + p->size = adjSize; } - + distributeOffsetEqually(sPtr, adjPad - checkSizes(sPtr)); - + checkPositions(sPtr); updateSubviewsGeom(sPtr); - + sPtr->flags.subviewsWereManuallyMoved = 0; -#if 0 +#if 0 printf("---- (adjustSplitViewSubviews - 2) ----\n"); dumpSubviews(sPtr); #endif @@ -355,25 +355,25 @@ handleSubviewResized(void *self, WMNotification *notif) CHECK_CLASS(sPtr, WC_SplitView); if (WMGetNotificationName(notif) == WMViewSizeDidChangeNotification) { - W_SplitViewSubview *p; - int i, count, done; - WMView *view = WMGetNotificationObject(notif); - - count = _GetSubviewsCount(); - done = 0; - for (i = 0; i < count; i++) { - p = _GetPSubviewStructAt(i); - if (p->view == view) { - done = 1; - break; - } - } - - if (done) { - /* TODO !!! */ - resizeView(sPtr, p->view, p->size); - moveView(sPtr, p->view, p->pos); - } + W_SplitViewSubview *p; + int i, count, done; + WMView *view = WMGetNotificationObject(notif); + + count = _GetSubviewsCount(); + done = 0; + for (i = 0; i < count; i++) { + p = _GetPSubviewStructAt(i); + if (p->view == view) { + done = 1; + break; + } + } + + if (done) { + /* TODO !!! */ + resizeView(sPtr, p->view, p->size); + moveView(sPtr, p->view, p->pos); + } } } #endif @@ -390,13 +390,13 @@ handleViewResized(void *self, WMNotification *notification) updateConstraints(sPtr); checkSizes(sPtr); - + if (sPtr->constrainProc || sPtr->flags.subviewsWereManuallyMoved) { - distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr)); - checkPositions(sPtr); - updateSubviewsGeom(sPtr); + distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr)); + checkPositions(sPtr); + updateSubviewsGeom(sPtr); } else - adjustSplitViewSubviews(sPtr); + adjustSplitViewSubviews(sPtr); assert(checkSizes(sPtr) == 0); @@ -419,47 +419,47 @@ paintSplitView(WMSplitView *sPtr) printf("---- (paintSplitView - 1) ----\n"); dumpSubviews(sPtr); #endif - + if (!sPtr->view->flags.mapped || !sPtr->view->flags.realized) - return; + return; XClearWindow(scr->display, sPtr->view->window); count = _GetSubviewsCount(); if (count == 0) - return; + return; if (sPtr->flags.adjustOnPaint) { - handleViewResized(sPtr, NULL); - sPtr->flags.adjustOnPaint = 0; + handleViewResized(sPtr, NULL); + sPtr->flags.adjustOnPaint = 0; } XSetClipMask(scr->display, scr->clipGC, dimple->mask); if (sPtr->flags.vertical) { - x = ((DIVIDER_THICKNESS - dimple->width) / 2); - y = (sPtr->view->size.height - dimple->height)/2; + x = ((DIVIDER_THICKNESS - dimple->width) / 2); + y = (sPtr->view->size.height - dimple->height)/2; } else { - x = (sPtr->view->size.width - dimple->width)/2; - y = ((DIVIDER_THICKNESS - dimple->height) / 2); + x = (sPtr->view->size.width - dimple->width)/2; + y = ((DIVIDER_THICKNESS - dimple->height) / 2); } for (i = 0; i < count-1; i++) { - p = _GetPSubviewStructAt(i); - - if (sPtr->flags.vertical) - x += p->size; - else - y += p->size; - - XSetClipOrigin(scr->display, scr->clipGC, x, y); - XCopyArea(scr->display, dimple->pixmap, sPtr->view->window, - scr->clipGC, 0, 0, dimple->width, dimple->height, x, y); - - if (sPtr->flags.vertical) - x += DIVIDER_THICKNESS; - else - y += DIVIDER_THICKNESS; + p = _GetPSubviewStructAt(i); + + if (sPtr->flags.vertical) + x += p->size; + else + y += p->size; + + XSetClipOrigin(scr->display, scr->clipGC, x, y); + XCopyArea(scr->display, dimple->pixmap, sPtr->view->window, + scr->clipGC, 0, 0, dimple->width, dimple->height, x, y); + + if (sPtr->flags.vertical) + x += DIVIDER_THICKNESS; + else + y += DIVIDER_THICKNESS; } #if 0 @@ -473,21 +473,21 @@ static void drawDragingRectangle(WMSplitView *sPtr, int pos) { int x, y, w, h; - + if (sPtr->flags.vertical) { - x = pos; - y = 0; - w = DIVIDER_THICKNESS; - h = sPtr->view->size.height; + x = pos; + y = 0; + w = DIVIDER_THICKNESS; + h = sPtr->view->size.height; } else { - x = 0; - y = pos; - w = sPtr->view->size.width; - h = DIVIDER_THICKNESS; + x = 0; + y = pos; + w = sPtr->view->size.width; + h = DIVIDER_THICKNESS; } - + XFillRectangle(sPtr->view->screen->display, sPtr->view->window, - sPtr->view->screen->ixorGC, x, y, w, h); + sPtr->view->screen->ixorGC, x, y, w, h); } @@ -499,14 +499,14 @@ getMinMaxDividerCoord(WMSplitView *sPtr, int divider, int *minC, int *maxC) relMinC = _GetMinSizeAt(divider); if (_GetMaxSizeAt(divider+1) != MAX_SUBVIEW_SIZE - && relMinC < totSize - _GetMaxSizeAt(divider+1)) - relMinC = totSize - _GetMaxSizeAt(divider+1); + && relMinC < totSize - _GetMaxSizeAt(divider+1)) + relMinC = totSize - _GetMaxSizeAt(divider+1); relMaxC = totSize - _GetMinSizeAt(divider+1); if (_GetMaxSizeAt(divider) != MAX_SUBVIEW_SIZE - && relMaxC > _GetMaxSizeAt(divider)) - relMaxC = _GetMaxSizeAt(divider); - + && relMaxC > _GetMaxSizeAt(divider)) + relMaxC = _GetMaxSizeAt(divider); + *minC = _GetPosAt(divider) + relMinC; *maxC = _GetPosAt(divider) + relMaxC; } @@ -522,11 +522,11 @@ dragDivider(WMSplitView *sPtr, int clickX, int clickY) int minCoord, maxCoord, coord; if (sPtr->constrainProc) { - updateConstraints(sPtr); - checkSizes(sPtr); - distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr)); - checkPositions(sPtr); - updateSubviewsGeom(sPtr); + updateConstraints(sPtr); + checkSizes(sPtr); + distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr)); + checkPositions(sPtr); + updateSubviewsGeom(sPtr); } scr = sPtr->view->screen; @@ -534,74 +534,74 @@ dragDivider(WMSplitView *sPtr, int clickX, int clickY) coord = (sPtr->flags.vertical) ? clickX : clickY; count = _GetSubviewsCount(); if (count < 2) - return; + return; for (i = 0; i < count-1; i++) { - pos += _GetSizeAt(i) + DIVIDER_THICKNESS; - if (coord < pos) { - ofs = coord - pos + DIVIDER_THICKNESS; - done = 1; - break; - } - divider++; + pos += _GetSizeAt(i) + DIVIDER_THICKNESS; + if (coord < pos) { + ofs = coord - pos + DIVIDER_THICKNESS; + done = 1; + break; + } + divider++; } if (!done) - return; + return; getMinMaxDividerCoord(sPtr, divider, &minCoord, &maxCoord); done = 0; dragging = 0; while (!done) { - WMMaskEvent(scr->display, ButtonMotionMask|ButtonReleaseMask - |ExposureMask, &ev); - - coord = (sPtr->flags.vertical) ? ev.xmotion.x : ev.xmotion.y; - - switch (ev.type) { - case ButtonRelease: - done = 1; - if (dragging) - drawDragingRectangle(sPtr, pos); - break; - - case MotionNotify: - if (dragging) - drawDragingRectangle(sPtr, pos); - if (coord - ofs < minCoord) - pos = minCoord; - else if (coord - ofs > maxCoord) - pos = maxCoord; - else - pos = coord - ofs; - drawDragingRectangle(sPtr, pos); - dragging = 1; - break; - - default: - WMHandleEvent(&ev); - break; - } + WMMaskEvent(scr->display, ButtonMotionMask|ButtonReleaseMask + |ExposureMask, &ev); + + coord = (sPtr->flags.vertical) ? ev.xmotion.x : ev.xmotion.y; + + switch (ev.type) { + case ButtonRelease: + done = 1; + if (dragging) + drawDragingRectangle(sPtr, pos); + break; + + case MotionNotify: + if (dragging) + drawDragingRectangle(sPtr, pos); + if (coord - ofs < minCoord) + pos = minCoord; + else if (coord - ofs > maxCoord) + pos = maxCoord; + else + pos = coord - ofs; + drawDragingRectangle(sPtr, pos); + dragging = 1; + break; + + default: + WMHandleEvent(&ev); + break; + } } - + if (dragging) { - W_SplitViewSubview *p1, *p2; - int totSize; - - p1 = _GetPSubviewStructAt(divider); - p2 = _GetPSubviewStructAt(divider+1); - - totSize = p1->size + DIVIDER_THICKNESS + p2->size; - - p1->size = pos - p1->pos; - p2->size = totSize - p1->size - DIVIDER_THICKNESS; - p2->pos = p1->pos + p1->size + DIVIDER_THICKNESS; - - resizeView(sPtr, p1->view, p1->size); - moveView(sPtr, p2->view, p2->pos); - resizeView(sPtr, p2->view, p2->size); - sPtr->flags.subviewsWereManuallyMoved = 1; + W_SplitViewSubview *p1, *p2; + int totSize; + + p1 = _GetPSubviewStructAt(divider); + p2 = _GetPSubviewStructAt(divider+1); + + totSize = p1->size + DIVIDER_THICKNESS + p2->size; + + p1->size = pos - p1->pos; + p2->size = totSize - p1->size - DIVIDER_THICKNESS; + p2->pos = p1->pos + p1->size + DIVIDER_THICKNESS; + + resizeView(sPtr, p1->view, p1->size); + moveView(sPtr, p2->view, p2->pos); + resizeView(sPtr, p2->view, p2->size); + sPtr->flags.subviewsWereManuallyMoved = 1; } } @@ -614,16 +614,16 @@ handleEvents(XEvent *event, void *data) CHECK_CLASS(data, WC_SplitView); - switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintSplitView(sPtr); - break; - - case DestroyNotify: - destroySplitView(sPtr); - break; + switch (event->type) { + case Expose: + if (event->xexpose.count!=0) + break; + paintSplitView(sPtr); + break; + + case DestroyNotify: + destroySplitView(sPtr); + break; } } @@ -631,14 +631,14 @@ handleEvents(XEvent *event, void *data) static void handleActionEvents(XEvent *event, void *data) { - + CHECK_CLASS(data, WC_SplitView); switch (event->type) { - case ButtonPress: - if (event->xbutton.button == Button1) - dragDivider(data, event->xbutton.x, event->xbutton.y); - break; + case ButtonPress: + if (event->xbutton.button == Button1) + dragDivider(data, event->xbutton.x, event->xbutton.y); + break; } } @@ -663,27 +663,27 @@ WMCreateSplitView(WMWidget *parent) memset(sPtr, 0, sizeof(WMSplitView)); sPtr->widgetClass = WC_SplitView; - + sPtr->view = W_CreateView(W_VIEW(parent)); if (!sPtr->view) { - wfree(sPtr); - return NULL; + wfree(sPtr); + return NULL; } sPtr->view->self = sPtr; WMSetViewNotifySizeChanges(sPtr->view, True); WMCreateEventHandler(sPtr->view, ExposureMask|StructureNotifyMask - |ClientMessageMask, handleEvents, sPtr); + |ClientMessageMask, handleEvents, sPtr); WMCreateEventHandler(sPtr->view, ButtonPressMask|ButtonReleaseMask - |EnterWindowMask|LeaveWindowMask, - handleActionEvents, sPtr); + |EnterWindowMask|LeaveWindowMask, + handleActionEvents, sPtr); - WMAddNotificationObserver(handleViewResized, sPtr, - WMViewSizeDidChangeNotification, sPtr->view); + WMAddNotificationObserver(handleViewResized, sPtr, + WMViewSizeDidChangeNotification, sPtr->view); sPtr->subviews = WMCreateArrayWithDestructor(8, wfree); @@ -695,7 +695,7 @@ void WMAdjustSplitViewSubviews(WMSplitView *sPtr) { CHECK_CLASS(sPtr, WC_SplitView); - + checkSizes(sPtr); adjustSplitViewSubviews(sPtr); @@ -713,42 +713,42 @@ WMAddSplitViewSubview(WMSplitView *sPtr, WMView *subview) CHECK_CLASS(sPtr, WC_SplitView); if (!(p = (W_SplitViewSubview*)wmalloc(sizeof(W_SplitViewSubview)))) - return; + return; wasMapped = subview->flags.mapped; if (wasMapped) - W_UnmapView(subview); + W_UnmapView(subview); count = _GetSubviewsCount(); p->view = subview; getConstraints(sPtr, count, &(p->minSize), &(p->maxSize)); if (sPtr->flags.vertical) - p->size = subview->size.width; + p->size = subview->size.width; else - p->size = subview->size.height; + p->size = subview->size.height; WMAddToArray(sPtr->subviews, p); reparentView(sPtr, subview, 0); -/* - We should have something like that... - - WMSetViewNotifySizeChanges(subview, True); - WMAddNotificationObserver(handleSubviewResized, sPtr, - WMViewSizeDidChangeNotification, - subview); - WMSetViewNotifyMoveChanges(subview, True); - WMAddNotificationObserver(handleSubviewResized, sPtr, - WMViewMoveDidChangeNotification, - subview); -*/ + /* + We should have something like that... + + WMSetViewNotifySizeChanges(subview, True); + WMAddNotificationObserver(handleSubviewResized, sPtr, + WMViewSizeDidChangeNotification, + subview); + WMSetViewNotifyMoveChanges(subview, True); + WMAddNotificationObserver(handleSubviewResized, sPtr, + WMViewMoveDidChangeNotification, + subview); + */ if (wasMapped) { - W_MapView(subview); + W_MapView(subview); - sPtr->flags.adjustOnPaint = 1; - paintSplitView(sPtr); + sPtr->flags.adjustOnPaint = 1; + paintSplitView(sPtr); } else { - handleViewResized(sPtr, NULL); + handleViewResized(sPtr, NULL); } } @@ -759,9 +759,9 @@ WMGetSplitViewSubviewAt(WMSplitView *sPtr, int index) CHECK_CLASS(sPtr, WC_SplitView); if (index >= 0 && index < _GetSubviewsCount()) - return (_GetSubviewAt(index)); + return (_GetSubviewAt(index)); else - return (NULL); + return (NULL); } @@ -776,13 +776,13 @@ WMRemoveSplitViewSubview(WMSplitView *sPtr, WMView *view) /* TODO: rewrite this. This code with macros is getting more complex than it worths */ count = _GetSubviewsCount(); for (i = 0; i < count; i++) { - p = _GetPSubviewStructAt(i); - if (p->view == view) { - WMDeleteFromArray(sPtr->subviews, i); - sPtr->flags.adjustOnPaint = 1; - paintSplitView(sPtr); - break; - } + p = _GetPSubviewStructAt(i); + if (p->view == view) { + WMDeleteFromArray(sPtr->subviews, i); + sPtr->flags.adjustOnPaint = 1; + paintSplitView(sPtr); + break; + } } } @@ -796,15 +796,15 @@ WMRemoveSplitViewSubviewAt(WMSplitView *sPtr, int index) /* TODO: same about rewrite */ if (index >= 0 && index < _GetSubviewsCount()) { - p = _GetPSubviewStructAt(index); - WMDeleteFromArray(sPtr->subviews, index); - sPtr->flags.adjustOnPaint = 1; - paintSplitView(sPtr); + p = _GetPSubviewStructAt(index); + WMDeleteFromArray(sPtr->subviews, index); + sPtr->flags.adjustOnPaint = 1; + paintSplitView(sPtr); } } -void +void WMSetSplitViewConstrainProc(WMSplitView *sPtr, WMSplitViewConstrainProc *proc) { CHECK_CLASS(sPtr, WC_SplitView); @@ -834,20 +834,20 @@ void WMSetSplitViewVertical(WMSplitView *sPtr, Bool flag) { int vertical; - + CHECK_CLASS(sPtr, WC_SplitView); vertical = ((flag==0) ? 0 : 1); if (sPtr->flags.vertical == vertical) - return; - + return; + sPtr->flags.vertical = vertical; - -/* if (sPtr->view->flags.mapped && sPtr->view->flags.realized)*/ - handleViewResized(sPtr, NULL); -/* else - sPtr->flags.adjustOnPaint = 1; - */ + + /* if (sPtr->view->flags.mapped && sPtr->view->flags.realized)*/ + handleViewResized(sPtr, NULL); + /* else + sPtr->flags.adjustOnPaint = 1; + */ } @@ -861,11 +861,12 @@ WMGetSplitViewDividerThickness(WMSplitView *sPtr) #if 0 void -WMSetSplitViewResizeSubviewsProc(WMSplitView *sPtr, - WMSplitViewResizeSubviewsProc *proc) +WMSetSplitViewResizeSubviewsProc(WMSplitView *sPtr, + WMSplitViewResizeSubviewsProc *proc) { CHECK_CLASS(sPtr, WC_SplitView); sPtr->resizeSubviewsProc = proc; } #endif + diff --git a/WINGs/wtabview.c b/WINGs/wtabview.c index 74f9983e..00e2727f 100644 --- a/WINGs/wtabview.c +++ b/WINGs/wtabview.c @@ -12,7 +12,7 @@ typedef struct W_TabView { int selectedItem; int firstVisible; - + int visibleTabs; WMFont *font; @@ -25,15 +25,15 @@ typedef struct W_TabView { short tabHeight; struct { - WMReliefType relief:4; - WMTitlePosition titlePosition:4; - WMTabViewType type:2; - - unsigned enabled:1; - unsigned tabbed:1; - unsigned dontFitAll:1; - unsigned bordered:1; - unsigned uniformTabs:1; + WMReliefType relief:4; + WMTitlePosition titlePosition:4; + WMTabViewType type:2; + + unsigned enabled:1; + unsigned tabbed:1; + unsigned dontFitAll:1; + unsigned bordered:1; + unsigned uniformTabs:1; } flags; } TabView; @@ -66,14 +66,14 @@ typedef struct W_TabViewItem { #define BUTTONED_SIDE_OFFSET 15 -static void destroyTabView(TabView *tPtr); +static void destroyTabView(TabView *tPtr); static void paintTabView(TabView *tPtr); static void W_SetTabViewItemParent(WMTabViewItem *item, WMTabView *parent); static void W_DrawLabel(WMTabViewItem *item, Drawable d, WMRect rect, - Bool enabled); + Bool enabled); static void W_UnmapTabViewItem(WMTabViewItem *item); @@ -93,10 +93,10 @@ static void didResize(struct W_ViewDelegate*, WMView*); static W_ViewDelegate delegate = { NULL, - NULL, - didResize, - NULL, - NULL + NULL, + didResize, + NULL, + NULL }; @@ -105,21 +105,21 @@ positionOfTab(WMTabView *tabView, int tab) { int i; int offs; - + if (tab < tabView->firstVisible) - return -1; - + return -1; + if (tab > tabView->firstVisible + tabView->visibleTabs) - return -1; + return -1; if (tabView->flags.dontFitAll) - offs = BUTTONED_SIDE_OFFSET; + offs = BUTTONED_SIDE_OFFSET; else - offs = NORMAL_SIDE_OFFSET; - + offs = NORMAL_SIDE_OFFSET; + for (i = tabView->firstVisible; i < tab; i++) - offs += W_TabViewItemTabWidth(tabView->items[i]) - 10; - + offs += W_TabViewItemTabWidth(tabView->items[i]) - 10; + return offs; } @@ -131,17 +131,17 @@ countVisibleTabs(TabView *tPtr, int first) int width; if (first < 0) { - width = W_VIEW_WIDTH(tPtr->view) - 2 * NORMAL_SIDE_OFFSET; - first = 0; + width = W_VIEW_WIDTH(tPtr->view) - 2 * NORMAL_SIDE_OFFSET; + first = 0; } else { - width = W_VIEW_WIDTH(tPtr->view) - 2 * BUTTONED_SIDE_OFFSET; + width = W_VIEW_WIDTH(tPtr->view) - 2 * BUTTONED_SIDE_OFFSET; } for (i = first; i < tPtr->itemCount; i++) { - width -= W_TabViewItemTabWidth(tPtr->items[i]) - 10; - if (width <= 0) { - return i - first; - } + width -= W_TabViewItemTabWidth(tPtr->items[i]) - 10; + if (width <= 0) { + return i - first; + } } return i - first; } @@ -156,49 +156,49 @@ handleEvents(XEvent *event, void *data) CHECK_CLASS(data, WC_TabView); switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintTabView(tPtr); - break; - - case ButtonPress: - if (tPtr->flags.enabled) { - WMTabViewItem *item = WMTabViewItemAtPoint(tPtr, - event->xbutton.x, - event->xbutton.y); + case Expose: + if (event->xexpose.count!=0) + break; + paintTabView(tPtr); + break; + + case ButtonPress: + if (tPtr->flags.enabled) { + WMTabViewItem *item = WMTabViewItemAtPoint(tPtr, + event->xbutton.x, + event->xbutton.y); /*if (item && !item->flags.enabled) - break;*/ + break;*/ if (item && item->flags.enabled) { - WMSelectTabViewItem(tPtr, item); - } else if (tPtr->flags.dontFitAll) { - int redraw = 0; - int lastVisible = tPtr->firstVisible+tPtr->visibleTabs-1; - - if (event->xbutton.x < BUTTONED_SIDE_OFFSET) { - if (tPtr->firstVisible > 0) { - redraw = 1; - tPtr->firstVisible--; - } - } else if (event->xbutton.x > positionOfTab(tPtr,lastVisible)){ - - if (lastVisible < tPtr->itemCount-1) { - redraw = 1; - tPtr->firstVisible++; - } - } - tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible); - if (redraw) { - paintTabView(tPtr); - } - } - } - break; - - case DestroyNotify: - destroyTabView(tPtr); - break; + WMSelectTabViewItem(tPtr, item); + } else if (tPtr->flags.dontFitAll) { + int redraw = 0; + int lastVisible = tPtr->firstVisible+tPtr->visibleTabs-1; + + if (event->xbutton.x < BUTTONED_SIDE_OFFSET) { + if (tPtr->firstVisible > 0) { + redraw = 1; + tPtr->firstVisible--; + } + } else if (event->xbutton.x > positionOfTab(tPtr,lastVisible)){ + + if (lastVisible < tPtr->itemCount-1) { + redraw = 1; + tPtr->firstVisible++; + } + } + tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible); + if (redraw) { + paintTabView(tPtr); + } + } + } + break; + + case DestroyNotify: + destroyTabView(tPtr); + break; } } @@ -217,8 +217,8 @@ WMCreateTabView(WMWidget *parent) tPtr->view = W_CreateView(W_VIEW(parent)); if (!tPtr->view) { - wfree(tPtr); - return NULL; + wfree(tPtr); + return NULL; } tPtr->view->self = tPtr; tPtr->view->delegate = &delegate; @@ -227,14 +227,14 @@ WMCreateTabView(WMWidget *parent) tPtr->tabColor = WMCreateRGBColor(scr, 0x8420, 0x8420, 0x8420, False); tPtr->font = WMRetainFont(scr->normalFont); - + tPtr->flags.type = WTTopTabsBevelBorder; tPtr->flags.bordered = 1; tPtr->flags.uniformTabs = 0; tPtr->flags.enabled = 1; WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask - |ButtonPressMask, handleEvents, tPtr); + |ButtonPressMask, handleEvents, tPtr); WMResizeWidget(tPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT); @@ -253,10 +253,10 @@ WMSetTabViewDelegate(WMTabView *tPtr, WMTabViewDelegate *delegate) WMTabViewItem* WMAddTabViewItemWithView(WMTabView *tPtr, WMView *view, int identifier, - char *label) + char *label) { WMTabViewItem *item; - + item = WMCreateTabViewItemWithIdentifier(identifier); WMSetTabViewItemView(item, view); WMAddItemInTabView(tPtr, item); @@ -278,7 +278,7 @@ WMSetTabViewEnabled(WMTabView *tPtr, Bool flag) { tPtr->flags.enabled = ((flag==0) ? 0 : 1); if (W_VIEW_REALIZED(tPtr->view)) - paintTabView(tPtr); + paintTabView(tPtr); } @@ -288,25 +288,25 @@ WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item) wassertr(W_TabViewItemView(item) != NULL); if (tPtr->maxItems == tPtr->itemCount) { - WMTabViewItem **items; + WMTabViewItem **items; - items = wrealloc(tPtr->items, - sizeof(WMTabViewItem*) * (tPtr->maxItems + 10)); - memset(&items[tPtr->maxItems], 0, sizeof(WMTabViewItem*) * 10); - tPtr->items = items; - tPtr->maxItems += 10; + items = wrealloc(tPtr->items, + sizeof(WMTabViewItem*) * (tPtr->maxItems + 10)); + memset(&items[tPtr->maxItems], 0, sizeof(WMTabViewItem*) * 10); + tPtr->items = items; + tPtr->maxItems += 10; } if (index > tPtr->itemCount) - index = tPtr->itemCount; + index = tPtr->itemCount; if (index == 0 && tPtr->items[0]) { - W_UnmapTabViewItem(tPtr->items[0]); + W_UnmapTabViewItem(tPtr->items[0]); } if (index < tPtr->itemCount) { - memmove(tPtr->items + index + 1, tPtr->items + index, - (tPtr->itemCount - index) * sizeof(WMTabViewItem*)); + memmove(tPtr->items + index + 1, tPtr->items + index, + (tPtr->itemCount - index) * sizeof(WMTabViewItem*)); } tPtr->items[index] = item; @@ -320,27 +320,27 @@ WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item) W_UnmapTabViewItem(item); if (tPtr->flags.bordered) { - W_ReparentView(W_TabViewItemView(item), tPtr->view, 1, - tPtr->tabHeight + 1); + W_ReparentView(W_TabViewItemView(item), tPtr->view, 1, + tPtr->tabHeight + 1); - W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width - 3, - tPtr->view->size.height - tPtr->tabHeight - 3); + W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width - 3, + tPtr->view->size.height - tPtr->tabHeight - 3); } else { - W_ReparentView(W_TabViewItemView(item), tPtr->view, 0, - tPtr->tabHeight); + W_ReparentView(W_TabViewItemView(item), tPtr->view, 0, + tPtr->tabHeight); - W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width, - tPtr->view->size.height - tPtr->tabHeight); + W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width, + tPtr->view->size.height - tPtr->tabHeight); } if (index == 0) { - W_MapTabViewItem(item); + W_MapTabViewItem(item); } if (tPtr->delegate && tPtr->delegate->didChangeNumberOfItems) - (*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr); - + (*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr); + if (W_VIEW_REALIZED(tPtr->view)) - paintTabView(tPtr); + paintTabView(tPtr); } @@ -350,21 +350,21 @@ WMRemoveTabViewItem(WMTabView *tPtr, WMTabViewItem *item) int i; for (i = 0; i < tPtr->itemCount; i++) { - if (tPtr->items[i] == item) { - if (i < tPtr->itemCount - 1) - memmove(&tPtr->items[i], &tPtr->items[i + 1], - tPtr->itemCount - i - 1); - else - tPtr->items[i] = NULL; - - W_SetTabViewItemParent(item, NULL); - - tPtr->itemCount--; - break; - } + if (tPtr->items[i] == item) { + if (i < tPtr->itemCount - 1) + memmove(&tPtr->items[i], &tPtr->items[i + 1], + tPtr->itemCount - i - 1); + else + tPtr->items[i] = NULL; + + W_SetTabViewItemParent(item, NULL); + + tPtr->itemCount--; + break; + } } if (tPtr->delegate && tPtr->delegate->didChangeNumberOfItems) - (*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr); + (*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr); } @@ -373,22 +373,22 @@ static Bool isInside(int x, int y, int width, int height, int px, int py) { if (py >= y + height - 3 && py <= y + height - && px >= x + py - (y + height - 3) - && px <= x + width - (py - (y + height - 3))) { + && px >= x + py - (y + height - 3) + && px <= x + width - (py - (y + height - 3))) { - return True; + return True; } if (py >= y + 3 && py < y + height - 3 - && px >= x + 3 + ((y + 3) - py)*3/7 - && px <= x + width - 3 - ((y + 3) - py)*3/7) { + && px >= x + 3 + ((y + 3) - py)*3/7 + && px <= x + width - 3 - ((y + 3) - py)*3/7) { - return True; + return True; } if (py >= y && py < y + 3 - && px >= x + 7 + py - y - && px <= x + width - 7 - (py - y)) { + && px >= x + 7 + py - y + && px <= x + width - 7 - (py - y)) { - return True; + return True; } return False; } @@ -400,32 +400,32 @@ WMTabViewItemAtPoint(WMTabView *tPtr, int x, int y) int i; int count = tPtr->visibleTabs; int first = tPtr->firstVisible; - + if (tPtr->flags.dontFitAll) { - i = tPtr->selectedItem - tPtr->firstVisible; - if (i >= 0 && i < tPtr->visibleTabs - && isInside(positionOfTab(tPtr, tPtr->selectedItem), 0, - W_TabViewItemTabWidth(tPtr->items[tPtr->selectedItem]), - tPtr->tabHeight, x, y)) { - return tPtr->items[tPtr->selectedItem]; - } + i = tPtr->selectedItem - tPtr->firstVisible; + if (i >= 0 && i < tPtr->visibleTabs + && isInside(positionOfTab(tPtr, tPtr->selectedItem), 0, + W_TabViewItemTabWidth(tPtr->items[tPtr->selectedItem]), + tPtr->tabHeight, x, y)) { + return tPtr->items[tPtr->selectedItem]; + } } else { - i = tPtr->selectedItem; - if (isInside(positionOfTab(tPtr, i), 0, - W_TabViewItemTabWidth(tPtr->items[i]), - tPtr->tabHeight, x, y)) { - return tPtr->items[i]; - } + i = tPtr->selectedItem; + if (isInside(positionOfTab(tPtr, i), 0, + W_TabViewItemTabWidth(tPtr->items[i]), + tPtr->tabHeight, x, y)) { + return tPtr->items[i]; + } } for (i = first; i < first + count; i++) { - int pos; + int pos; - pos = positionOfTab(tPtr, i); - if (isInside(pos, 0, W_TabViewItemTabWidth(tPtr->items[i]), - tPtr->tabHeight, x, y)) { - return tPtr->items[i]; - } + pos = positionOfTab(tPtr, i); + if (isInside(pos, 0, W_TabViewItemTabWidth(tPtr->items[i]), + tPtr->tabHeight, x, y)) { + return tPtr->items[i]; + } } return NULL; } @@ -435,17 +435,17 @@ void WMSetTabViewType(WMTabView *tPtr, WMTabViewType type) { tPtr->flags.type = type; - + if (type != WTTopTabsBevelBorder) - tPtr->tabHeight = 0; + tPtr->tabHeight = 0; else - tPtr->tabHeight = WMFontHeight(tPtr->font) + 3; - + tPtr->tabHeight = WMFontHeight(tPtr->font) + 3; + if (type == WTNoTabsNoBorder) - tPtr->flags.bordered = 0; + tPtr->flags.bordered = 0; else - tPtr->flags.bordered = 1; - + tPtr->flags.bordered = 1; + rearrange(tPtr); } @@ -490,10 +490,10 @@ WMSelectTabViewItem(WMTabView *tPtr, WMTabViewItem *item) int i; for (i = 0; i < tPtr->itemCount; i++) { - if (tPtr->items[i] == item) { - WMSelectTabViewItemAtIndex(tPtr, i); - break; - } + if (tPtr->items[i] == item) { + WMSelectTabViewItemAtIndex(tPtr, i); + break; + } } } @@ -504,24 +504,24 @@ WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index) WMTabViewItem *item; if (index == tPtr->selectedItem) { - return; + return; } if (index < 0) - index = 0; + index = 0; else if (index >= tPtr->itemCount) - index = tPtr->itemCount - 1; + index = tPtr->itemCount - 1; item = tPtr->items[tPtr->selectedItem]; if (tPtr->delegate && tPtr->delegate->shouldSelectItem) - if (!(*tPtr->delegate->shouldSelectItem)(tPtr->delegate, tPtr, - tPtr->items[index])) - return; + if (!(*tPtr->delegate->shouldSelectItem)(tPtr->delegate, tPtr, + tPtr->items[index])) + return; if (tPtr->delegate && tPtr->delegate->willSelectItem) - (*tPtr->delegate->willSelectItem)(tPtr->delegate, tPtr, - tPtr->items[index]); + (*tPtr->delegate->willSelectItem)(tPtr->delegate, tPtr, + tPtr->items[index]); W_UnmapTabViewItem(item); @@ -533,9 +533,9 @@ WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index) tPtr->selectedItem = index; if (tPtr->delegate && tPtr->delegate->didSelectItem) - (*tPtr->delegate->didSelectItem)(tPtr->delegate, tPtr, - tPtr->items[index]); - + (*tPtr->delegate->didSelectItem)(tPtr->delegate, tPtr, + tPtr->items[index]); + paintTabView(tPtr); } @@ -549,58 +549,58 @@ recalcTabWidth(TabView *tPtr) int width; if (tPtr->flags.uniformTabs) { - int tabWidth; - - tabWidth = 0; - - for (i = 0; i < tPtr->itemCount; i++) { - char *str = WMGetTabViewItemLabel(tPtr->items[i]); - - if (str) { - width = WMWidthOfString(tPtr->font, str, strlen(str)); - if (width > tabWidth) - tabWidth = width; - } - } - - tabWidth = tabWidth + 30; - - for (i = 0; i < tPtr->itemCount; i++) - W_SetTabViewItemTabWidth(tPtr->items[i], tabWidth); - - tPtr->firstVisible = 0; - tPtr->visibleTabs = countVisibleTabs(tPtr, -1); - if (tPtr->visibleTabs < tPtr->itemCount) - tPtr->flags.dontFitAll = 1; - else - tPtr->flags.dontFitAll = 0; + int tabWidth; + + tabWidth = 0; + + for (i = 0; i < tPtr->itemCount; i++) { + char *str = WMGetTabViewItemLabel(tPtr->items[i]); + + if (str) { + width = WMWidthOfString(tPtr->font, str, strlen(str)); + if (width > tabWidth) + tabWidth = width; + } + } + + tabWidth = tabWidth + 30; + + for (i = 0; i < tPtr->itemCount; i++) + W_SetTabViewItemTabWidth(tPtr->items[i], tabWidth); + + tPtr->firstVisible = 0; + tPtr->visibleTabs = countVisibleTabs(tPtr, -1); + if (tPtr->visibleTabs < tPtr->itemCount) + tPtr->flags.dontFitAll = 1; + else + tPtr->flags.dontFitAll = 0; } else { - for (i = 0; i < tPtr->itemCount; i++) { - char *str = WMGetTabViewItemLabel(tPtr->items[i]); - if (!str) - continue; - - width = WMWidthOfString(tPtr->font, str, strlen(str)) + 30; - - W_SetTabViewItemTabWidth(tPtr->items[i], width); - } - - if (countVisibleTabs(tPtr, -1) < tPtr->itemCount) { - tPtr->flags.dontFitAll = 1; - tPtr->firstVisible = 0; - tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible); - } else { - tPtr->flags.dontFitAll = 0; - tPtr->firstVisible = 0; - tPtr->visibleTabs = tPtr->itemCount; - } + for (i = 0; i < tPtr->itemCount; i++) { + char *str = WMGetTabViewItemLabel(tPtr->items[i]); + if (!str) + continue; + + width = WMWidthOfString(tPtr->font, str, strlen(str)) + 30; + + W_SetTabViewItemTabWidth(tPtr->items[i], width); + } + + if (countVisibleTabs(tPtr, -1) < tPtr->itemCount) { + tPtr->flags.dontFitAll = 1; + tPtr->firstVisible = 0; + tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible); + } else { + tPtr->flags.dontFitAll = 0; + tPtr->firstVisible = 0; + tPtr->visibleTabs = tPtr->itemCount; + } } } static void drawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width, - unsigned int height) + unsigned int height) { Display *dpy = scr->display; GC bgc = WMColorGC(scr->black); @@ -618,8 +618,8 @@ drawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width, static void -drawTab(TabView *tPtr, Drawable d, int x, int y, - unsigned width, unsigned height, Bool selected) +drawTab(TabView *tPtr, Drawable d, int x, int y, + unsigned width, unsigned height, Bool selected) { WMScreen *scr = W_VIEW(tPtr)->screen; Display *dpy = scr->display; @@ -654,7 +654,7 @@ drawTab(TabView *tPtr, Drawable d, int x, int y, trap[7].y = y + height - (selected ? 0 : 1); XFillPolygon(dpy, d, selected ? light : WMColorGC(tPtr->tabColor), trap, 8, - Convex, CoordModeOrigin); + Convex, CoordModeOrigin); XDrawLine(dpy, d, white, trap[0].x, trap[0].y, trap[1].x, trap[1].y); XDrawLine(dpy, d, white, trap[1].x, trap[1].y, trap[2].x, trap[2].y); @@ -664,8 +664,8 @@ drawTab(TabView *tPtr, Drawable d, int x, int y, XDrawLine(dpy, d, black, trap[5].x, trap[5].y, trap[6].x, trap[6].y); XDrawLine(dpy, d, black, trap[6].x, trap[6].y, trap[7].x, trap[7].y); - XDrawLine(dpy, d, selected ? light : WMColorGC(scr->white), - trap[0].x, trap[0].y, trap[7].x, trap[7].y); + XDrawLine(dpy, d, selected ? light : WMColorGC(scr->white), + trap[0].x, trap[0].y, trap[7].x, trap[7].y); } @@ -693,126 +693,126 @@ paintTabView(TabView *tPtr) int i; if (tPtr->flags.type == WTTopTabsBevelBorder) { - int count = tPtr->visibleTabs; - int first = tPtr->firstVisible; - int moreAtLeft; - int moreAtRight; - int selectedIsVisible; - int ty; - int twidth, theight; - - ty = 2; - theight = tPtr->tabHeight; - - buffer = XCreatePixmap(dpy, W_VIEW(tPtr)->window, - W_VIEW(tPtr)->size.width, theight, - W_VIEW(tPtr)->screen->depth); - - XFillRectangle(dpy, buffer, WMColorGC(W_VIEW(tPtr)->backColor), - 0, 0, W_VIEW(tPtr)->size.width, tPtr->tabHeight); - - if (tPtr->flags.dontFitAll) { - moreAtLeft = first > 0; - moreAtRight = (first + count) < tPtr->itemCount; - if (tPtr->selectedItem >= first - && tPtr->selectedItem < first + count) - selectedIsVisible = 1; - else - selectedIsVisible = 0; - } else { - moreAtLeft = 0; - moreAtRight = 0; - selectedIsVisible = 1; - } - - if (moreAtRight) { - drawTab(tPtr, buffer, positionOfTab(tPtr, first+count), 0, - W_VIEW_WIDTH(tPtr->view), theight, False); - } - for (i = first + count-1; i >= first; i--) { - if (!selectedIsVisible || i != tPtr->selectedItem) { - twidth = W_TabViewItemTabWidth(tPtr->items[i]); - - drawTab(tPtr, buffer, positionOfTab(tPtr, i), 0, - twidth, theight, False); - } - } - if (moreAtLeft) { - drawTab(tPtr, buffer, positionOfTab(tPtr, 0)-2*BUTTONED_SIDE_OFFSET, - 0, BUTTONED_SIDE_OFFSET*4, theight, False); - } - - if (selectedIsVisible) { - int idx = tPtr->selectedItem; - - drawTab(tPtr, buffer, positionOfTab(tPtr, idx), - 0, W_TabViewItemTabWidth(tPtr->items[idx]), - theight, True); - - XDrawLine(dpy, buffer, white, 0, theight - 1, - positionOfTab(tPtr, idx), theight - 1); - - XDrawLine(dpy, buffer, white, - positionOfTab(tPtr, idx) + W_TabViewItemTabWidth(tPtr->items[idx]), - tPtr->tabHeight - 1, W_VIEW_WIDTH(tPtr->view) - 1, - tPtr->tabHeight - 1); - } else { - XDrawLine(dpy, buffer, white, 0, theight - 1, - W_VIEW_WIDTH(tPtr->view), theight - 1); - } - - for (i = 0; i < count; i++) { - WMRect rect; - - rect.pos.x = 15 + positionOfTab(tPtr, first+i); - rect.pos.y = ty; - rect.size.width = W_TabViewItemTabWidth(tPtr->items[first+i]); - rect.size.height = theight; - W_DrawLabel(tPtr->items[first+i], buffer, rect, + int count = tPtr->visibleTabs; + int first = tPtr->firstVisible; + int moreAtLeft; + int moreAtRight; + int selectedIsVisible; + int ty; + int twidth, theight; + + ty = 2; + theight = tPtr->tabHeight; + + buffer = XCreatePixmap(dpy, W_VIEW(tPtr)->window, + W_VIEW(tPtr)->size.width, theight, + W_VIEW(tPtr)->screen->depth); + + XFillRectangle(dpy, buffer, WMColorGC(W_VIEW(tPtr)->backColor), + 0, 0, W_VIEW(tPtr)->size.width, tPtr->tabHeight); + + if (tPtr->flags.dontFitAll) { + moreAtLeft = first > 0; + moreAtRight = (first + count) < tPtr->itemCount; + if (tPtr->selectedItem >= first + && tPtr->selectedItem < first + count) + selectedIsVisible = 1; + else + selectedIsVisible = 0; + } else { + moreAtLeft = 0; + moreAtRight = 0; + selectedIsVisible = 1; + } + + if (moreAtRight) { + drawTab(tPtr, buffer, positionOfTab(tPtr, first+count), 0, + W_VIEW_WIDTH(tPtr->view), theight, False); + } + for (i = first + count-1; i >= first; i--) { + if (!selectedIsVisible || i != tPtr->selectedItem) { + twidth = W_TabViewItemTabWidth(tPtr->items[i]); + + drawTab(tPtr, buffer, positionOfTab(tPtr, i), 0, + twidth, theight, False); + } + } + if (moreAtLeft) { + drawTab(tPtr, buffer, positionOfTab(tPtr, 0)-2*BUTTONED_SIDE_OFFSET, + 0, BUTTONED_SIDE_OFFSET*4, theight, False); + } + + if (selectedIsVisible) { + int idx = tPtr->selectedItem; + + drawTab(tPtr, buffer, positionOfTab(tPtr, idx), + 0, W_TabViewItemTabWidth(tPtr->items[idx]), + theight, True); + + XDrawLine(dpy, buffer, white, 0, theight - 1, + positionOfTab(tPtr, idx), theight - 1); + + XDrawLine(dpy, buffer, white, + positionOfTab(tPtr, idx) + W_TabViewItemTabWidth(tPtr->items[idx]), + tPtr->tabHeight - 1, W_VIEW_WIDTH(tPtr->view) - 1, + tPtr->tabHeight - 1); + } else { + XDrawLine(dpy, buffer, white, 0, theight - 1, + W_VIEW_WIDTH(tPtr->view), theight - 1); + } + + for (i = 0; i < count; i++) { + WMRect rect; + + rect.pos.x = 15 + positionOfTab(tPtr, first+i); + rect.pos.y = ty; + rect.size.width = W_TabViewItemTabWidth(tPtr->items[first+i]); + rect.size.height = theight; + W_DrawLabel(tPtr->items[first+i], buffer, rect, tPtr->flags.enabled && tPtr->items[first+i]->flags.enabled); - } - - if (moreAtLeft) { - paintDot(tPtr, buffer, 4, 10); - paintDot(tPtr, buffer, 7, 10); - paintDot(tPtr, buffer, 10, 10); - } - if (moreAtRight) { - int x; - - x = positionOfTab(tPtr, tPtr->firstVisible + tPtr->visibleTabs); - - x = x + (W_VIEW_WIDTH(tPtr->view) - x)/2; - paintDot(tPtr, buffer, x + 5, 10); - paintDot(tPtr, buffer, x + 8, 10); - paintDot(tPtr, buffer, x + 11, 10); - } - - XCopyArea(dpy, buffer, W_VIEW(tPtr)->window, scr->copyGC, 0, 0, - W_VIEW_WIDTH(tPtr->view), theight, 0, 0); - - XFreePixmap(dpy, buffer); + } + + if (moreAtLeft) { + paintDot(tPtr, buffer, 4, 10); + paintDot(tPtr, buffer, 7, 10); + paintDot(tPtr, buffer, 10, 10); + } + if (moreAtRight) { + int x; + + x = positionOfTab(tPtr, tPtr->firstVisible + tPtr->visibleTabs); + + x = x + (W_VIEW_WIDTH(tPtr->view) - x)/2; + paintDot(tPtr, buffer, x + 5, 10); + paintDot(tPtr, buffer, x + 8, 10); + paintDot(tPtr, buffer, x + 11, 10); + } + + XCopyArea(dpy, buffer, W_VIEW(tPtr)->window, scr->copyGC, 0, 0, + W_VIEW_WIDTH(tPtr->view), theight, 0, 0); + + XFreePixmap(dpy, buffer); } switch (tPtr->flags.type) { - case WTTopTabsBevelBorder: - drawRelief(scr, W_VIEW(tPtr)->window, 0, tPtr->tabHeight - 1, - W_VIEW(tPtr)->size.width, - W_VIEW(tPtr)->size.height - tPtr->tabHeight + 1); - break; - - case WTNoTabsBevelBorder: - W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width, - W_VIEW(tPtr)->size.height, WRRaised); - break; - - case WTNoTabsLineBorder: - W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width, - W_VIEW(tPtr)->size.height, WRSimple); - break; - - case WTNoTabsNoBorder: - break; + case WTTopTabsBevelBorder: + drawRelief(scr, W_VIEW(tPtr)->window, 0, tPtr->tabHeight - 1, + W_VIEW(tPtr)->size.width, + W_VIEW(tPtr)->size.height - tPtr->tabHeight + 1); + break; + + case WTNoTabsBevelBorder: + W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width, + W_VIEW(tPtr)->size.height, WRRaised); + break; + + case WTNoTabsLineBorder: + W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width, + W_VIEW(tPtr)->size.height, WRSimple); + break; + + case WTNoTabsNoBorder: + break; } } @@ -823,19 +823,19 @@ rearrange(TabView *tPtr) int i; int width, height; int bordered = tPtr->flags.bordered; - + recalcTabWidth(tPtr); width = tPtr->view->size.width - (bordered ? 3 : 0); height = tPtr->view->size.height - tPtr->tabHeight - (bordered ? 3 : 0); - + for (i = 0; i < tPtr->itemCount; i++) { - W_MoveView(W_TabViewItemView(tPtr->items[i]), - 1*bordered, tPtr->tabHeight + 1*bordered); - W_ResizeView(W_TabViewItemView(tPtr->items[i]), width, height); + W_MoveView(W_TabViewItemView(tPtr->items[i]), + 1*bordered, tPtr->tabHeight + 1*bordered); + W_ResizeView(W_TabViewItemView(tPtr->items[i]), width, height); } if (W_VIEW_MAPPED(tPtr->view) && W_VIEW_REALIZED(tPtr->view)) - paintTabView(tPtr); + paintTabView(tPtr); } @@ -852,8 +852,8 @@ destroyTabView(TabView *tPtr) int i; for (i = 0; i < tPtr->itemCount; i++) { - WMSetTabViewItemView(tPtr->items[i], NULL); - WMDestroyTabViewItem(tPtr->items[i]); + WMSetTabViewItemView(tPtr->items[i], NULL); + WMDestroyTabViewItem(tPtr->items[i]); } wfree(tPtr->items); @@ -880,11 +880,11 @@ W_DrawLabel(WMTabViewItem *item, Drawable d, WMRect rect, Bool enabled) WMScreen *scr = W_VIEW(item->tabView)->screen; if (!item->label) - return; + return; WMDrawString(scr, d, enabled ? scr->black : scr->darkGray, - item->tabView->font, rect.pos.x, rect.pos.y, - item->label, strlen(item->label)); + item->tabView->font, rect.pos.x, rect.pos.y, + item->label, strlen(item->label)); } @@ -971,7 +971,7 @@ WMSetTabViewItemEnabled(WMTabViewItem *tPtr, Bool flag) { tPtr->flags.enabled = ((flag==0) ? 0 : 1); if (tPtr->tabView && W_VIEW_REALIZED(tPtr->tabView->view)) - paintTabView(tPtr->tabView); + paintTabView(tPtr->tabView); } @@ -986,7 +986,7 @@ void WMSetTabViewFont(WMTabView *tPtr, WMFont *font) { if (tPtr->font) - WMReleaseFont(tPtr->font); + WMReleaseFont(tPtr->font); tPtr->font = WMRetainFont(font); tPtr->tabHeight = WMFontHeight(tPtr->font) + 3; @@ -998,15 +998,15 @@ void WMSetTabViewItemLabel(WMTabViewItem *item, char *label) { if (item->label) - wfree(item->label); + wfree(item->label); if (label) - item->label = wstrdup(label); + item->label = wstrdup(label); else - item->label = NULL; + item->label = NULL; if (item->tabView) - recalcTabWidth(item->tabView); + recalcTabWidth(item->tabView); } @@ -1035,10 +1035,11 @@ void WMDestroyTabViewItem(WMTabViewItem *item) { if (item->label) - wfree(item->label); + wfree(item->label); if (item->view) - W_DestroyView(item->view); + W_DestroyView(item->view); wfree(item); } + diff --git a/WINGs/wtext.c b/WINGs/wtext.c index 342fae70..fe9cbd27 100644 --- a/WINGs/wtext.c +++ b/WINGs/wtext.c @@ -167,8 +167,8 @@ typedef struct W_Text { /* unsigned int RESERVED:1; */ } flags; - WMArray *xdndSourceTypes; - WMArray *xdndDestinationTypes; + WMArray *xdndSourceTypes; + WMArray *xdndDestinationTypes; } Text; @@ -208,15 +208,17 @@ output(char *ptr, int len) #define STIPPLE_WIDTH 8 #define STIPPLE_HEIGHT 8 static unsigned char STIPPLE_BITS[] = { - 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa + 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }; static char *default_bullet[] = { "6 6 4 1", - " c None s None", ". c black", - "X c white", "o c #808080", + " c None s None", + ". c black", + "X c white", + "o c #808080", " ... ", ".XX.. ", ".XX..o", @@ -261,12 +263,12 @@ newMargin(Text *tPtr, WMRulerMargins *margins) if (n == -1) { if(tPtr->nMargins >= 127) { - n = tPtr->nMargins-1; - return n; + n = tPtr->nMargins-1; + return n; } tPtr->margins = wrealloc(tPtr->margins, - (++tPtr->nMargins)*sizeof(WMRulerMargins)); + (++tPtr->nMargins)*sizeof(WMRulerMargins)); n = tPtr->nMargins-1; tPtr->margins[n].left = margins->left; @@ -297,22 +299,22 @@ sectionWasSelected(Text *tPtr, TextBlock *tb, XRectangle *rect, int s) sel.w = tPtr->visible.w; selected = extend = True; - /* or if it starts on a line and then goes further down */ + /* or if it starts on a line and then goes further down */ } else if ((tb->sections[s]._y <= tPtr->visible.y + tPtr->sel.y) - && (tb->sections[s]._y + tb->sections[s].h - <= tPtr->visible.y + tPtr->sel.y + tPtr->sel.h) - && (tb->sections[s]._y + tb->sections[s].h - >= tPtr->visible.y + tPtr->sel.y) ) { + && (tb->sections[s]._y + tb->sections[s].h + <= tPtr->visible.y + tPtr->sel.y + tPtr->sel.h) + && (tb->sections[s]._y + tb->sections[s].h + >= tPtr->visible.y + tPtr->sel.y) ) { sel.x = WMAX(tPtr->sel.x, tPtr->clicked.x); sel.w = tPtr->visible.w; selected = extend = True; - /* or if it begins before a line, but ends on it */ + /* or if it begins before a line, but ends on it */ } else if ((tb->sections[s]._y >= tPtr->visible.y + tPtr->sel.y) - && (tb->sections[s]._y + tb->sections[s].h - >= tPtr->visible.y + tPtr->sel.y + tPtr->sel.h) - && (tb->sections[s]._y - <= tPtr->visible.y + tPtr->sel.y + tPtr->sel.h) ) { + && (tb->sections[s]._y + tb->sections[s].h + >= tPtr->visible.y + tPtr->sel.y + tPtr->sel.h) + && (tb->sections[s]._y + <= tPtr->visible.y + tPtr->sel.y + tPtr->sel.h) ) { if (1||tPtr->sel.x + tPtr->sel.w > tPtr->clicked.x) sel.w = tPtr->sel.x + tPtr->sel.w; @@ -322,11 +324,11 @@ sectionWasSelected(Text *tPtr, TextBlock *tb, XRectangle *rect, int s) sel.x = 0; selected = True; - /* or if the selection rectangle lies entirely within a line */ + /* or if the selection rectangle lies entirely within a line */ } else if ((tb->sections[s]._y <= tPtr->visible.y + tPtr->sel.y) - && (tPtr->sel.w >= 2) - && (tb->sections[s]._y + tb->sections[s].h - >= tPtr->visible.y + tPtr->sel.y + tPtr->sel.h) ) { + && (tPtr->sel.w >= 2) + && (tb->sections[s]._y + tb->sections[s].h + >= tPtr->visible.y + tPtr->sel.y + tPtr->sel.h) ) { sel.x = tPtr->sel.x; sel.w = tPtr->sel.w; selected = True; @@ -376,40 +378,40 @@ sectionWasSelected(Text *tPtr, TextBlock *tb, XRectangle *rect, int s) return False; } -_selEnd: rect->x = tb->sections[s].x + lw; - lw = 0; - while(++i <= tb->sections[s].end) { + _selEnd: rect->x = tb->sections[s].x + lw; + lw = 0; + while(++i <= tb->sections[s].end) { - w = WMWidthOfString(tb->d.font, &(tb->text[i-1]), 1); - lw += w; + w = WMWidthOfString(tb->d.font, &(tb->text[i-1]), 1); + lw += w; - if (lw + rect->x >= sel.x + sel.w - || i == tb->sections[s].end ) { + if (lw + rect->x >= sel.x + sel.w + || i == tb->sections[s].end ) { - if (i != tb->sections[s].end) { - lw -= w; - i--; - } + if (i != tb->sections[s].end) { + lw -= w; + i--; + } - rect->width = lw; - if (tb->sections[s].last && sel.x + sel.w - >= tb->sections[s].x + tb->sections[s].w - && extend ) { - rect->width += (tPtr->visible.w - rect->x - lw); - } + rect->width = lw; + if (tb->sections[s].last && sel.x + sel.w + >= tb->sections[s].x + tb->sections[s].w + && extend ) { + rect->width += (tPtr->visible.w - rect->x - lw); + } - tb->s_end = (tb->selected? WMAX(tb->s_end, i) : i); - selected = True; - break; - } + tb->s_end = (tb->selected? WMAX(tb->s_end, i) : i); + selected = True; + break; } } + } } if (selected) { rect->y = tb->sections[s]._y - tPtr->vpos; rect->height = tb->sections[s].h; -if(tb->graphic) { printf("DEBUG: graphic s%d h%d\n", s,tb->sections[s].h);} + if(tb->graphic) { printf("DEBUG: graphic s%d h%d\n", s,tb->sections[s].h);} } return selected; @@ -452,14 +454,14 @@ setSelectionProperty(WMText *tPtr, WMFont *font, WMColor *color, int underlined) if(underlined != -1) { midtb = (TextBlock *) WMCreateTextBlockWithText(tPtr, - &(tb->text[tb->s_begin]), tb->d.font, tb->color, - False, (tb->s_end - tb->s_begin)); + &(tb->text[tb->s_begin]), tb->d.font, tb->color, + False, (tb->s_end - tb->s_begin)); } else { midtb = (TextBlock *) WMCreateTextBlockWithText(tPtr, - &(tb->text[tb->s_begin]), - (isFont?font:tb->d.font), - (isFont?tb->color:color), - False, (tb->s_end - tb->s_begin)); + &(tb->text[tb->s_begin]), + (isFont?font:tb->d.font), + (isFont?tb->color:color), + False, (tb->s_end - tb->s_begin)); } @@ -482,8 +484,8 @@ setSelectionProperty(WMText *tPtr, WMFont *font, WMColor *color, int underlined) TextBlock *ntb; ntb = (TextBlock *) WMCreateTextBlockWithText(tPtr, - &(otb->text[otb->s_end]), otb->d.font, otb->color, - False, otb->used - otb->s_end); + &(otb->text[otb->s_end]), otb->d.font, otb->color, + False, otb->used - otb->s_end); if (ntb) { ntb->underlined = otb->underlined; @@ -512,14 +514,14 @@ setSelectionProperty(WMText *tPtr, WMFont *font, WMColor *color, int underlined) if(isFont && tPtr->currentTextBlock) { TextBlock *tb = tPtr->currentTextBlock; -printf("%d %d %d\n", tPtr->sel.y, tPtr->sel.h, tPtr->sel.w); + printf("%d %d %d\n", tPtr->sel.y, tPtr->sel.h, tPtr->sel.w); tPtr->sel.y = 3 + tb->sections[0]._y; tPtr->sel.h = tb->sections[tb->nsections-1]._y - tb->sections[0]._y; tPtr->sel.w = tb->sections[tb->nsections-1].w; if(tb->sections[tb->nsections-1]._y != tb->sections[0]._y) { tPtr->sel.x = 0; } -printf("%d %d %d\n\n\n", tPtr->sel.y, tPtr->sel.h, tPtr->sel.w); + printf("%d %d %d\n\n\n", tPtr->sel.y, tPtr->sel.h, tPtr->sel.w); } } @@ -545,12 +547,12 @@ removeSelection(Text *tPtr) if ( (tb->s_end - tb->s_begin == tb->used) || tb->graphic) { tPtr->currentTextBlock = tb; if(tb->next) { - tPtr->tpos = 0; + tPtr->tpos = 0; } else if(tb->prior) { - if(tb->prior->graphic) - tPtr->tpos = 1; - else - tPtr->tpos = tb->prior->used; + if(tb->prior->graphic) + tPtr->tpos = 1; + else + tPtr->tpos = tb->prior->used; } else tPtr->tpos = 0; WMDestroyTextBlock(tPtr, WMRemoveTextBlock(tPtr)); @@ -559,7 +561,7 @@ removeSelection(Text *tPtr) } else if (tb->s_end <= tb->used) { memmove(&(tb->text[tb->s_begin]), - &(tb->text[tb->s_end]), tb->used - tb->s_end); + &(tb->text[tb->s_end]), tb->used - tb->s_end); tb->used -= (tb->s_end - tb->s_begin); tb->selected = False; tPtr->tpos = tb->s_begin; @@ -597,7 +599,7 @@ getFirstNonGraphicBlockFor(TextBlock *tb, short dir) } if(!tb) - return NULL; + return NULL; return tb; } @@ -605,7 +607,7 @@ getFirstNonGraphicBlockFor(TextBlock *tb, short dir) static Bool updateStartForCurrentTextBlock(Text *tPtr, int x, int y, int *dir, -TextBlock *tb) + TextBlock *tb) { if (tPtr->flags.monoFont && tb->graphic) { tb = getFirstNonGraphicBlockFor(tb, *dir); @@ -622,8 +624,8 @@ TextBlock *tb) if(!tb->sections) { - layOutDocument(tPtr); - return 0; + layOutDocument(tPtr); + return 0; } *dir = !(y <= tb->sections[0].y); @@ -632,15 +634,15 @@ TextBlock *tb) && (y >= tb->sections[0]._y ) ) { /* if it's on the same line */ if(x < tb->sections[0].x) - *dir = 0; + *dir = 0; } } else { if ( ( y <= tb->sections[tb->nsections-1]._y - + tb->sections[tb->nsections-1].h ) + + tb->sections[tb->nsections-1].h ) && (y >= tb->sections[tb->nsections-1]._y ) ) { /* if it's on the same line */ if(x > tb->sections[tb->nsections-1].x) - *dir = 1; + *dir = 1; } } @@ -669,8 +671,8 @@ paintText(Text *tPtr) if (tPtr->bgPixmap) { WMDrawPixmap(tPtr->bgPixmap, tPtr->db, - (tPtr->visible.w-tPtr->visible.x-tPtr->bgPixmap->width)/2, - (tPtr->visible.h-tPtr->visible.y-tPtr->bgPixmap->height)/2); + (tPtr->visible.w-tPtr->visible.x-tPtr->bgPixmap->width)/2, + (tPtr->visible.h-tPtr->visible.y-tPtr->bgPixmap->height)/2); } if (! (tb = tPtr->currentTextBlock)) { @@ -684,37 +686,37 @@ paintText(Text *tPtr) /* first, which direction? Don't waste time looking all over, - since the parts to be drawn will most likely be near what - was previously drawn */ + since the parts to be drawn will most likely be near what + was previously drawn */ if(!updateStartForCurrentTextBlock(tPtr, 0, tPtr->vpos, &dir, tb)) goto _copy_area; while(tb) { - if (tb->graphic && tPtr->flags.monoFont) - goto _getSibling; + if (tb->graphic && tPtr->flags.monoFont) + goto _getSibling; - if(dir) { + if(dir) { if(tPtr->vpos <= tb->sections[tb->nsections-1]._y - + tb->sections[tb->nsections-1].h) - break; - } else { + + tb->sections[tb->nsections-1].h) + break; + } else { if(tPtr->vpos >= tb->sections[tb->nsections-1]._y - + tb->sections[tb->nsections-1].h) - break; - } - -_getSibling: - if(dir) { - if(tb->next) - tb = tb->next; - else break; - } else { - if(tb->prior) - tb = tb->prior; - else break; - } - } + + tb->sections[tb->nsections-1].h) + break; + } + + _getSibling: + if(dir) { + if(tb->next) + tb = tb->next; + else break; + } else { + if(tb->prior) + tb = tb->prior; + else break; + } + } /* first, place all text that can be viewed */ @@ -750,7 +752,7 @@ _getSibling: if (sectionWasSelected(tPtr, tb, &rect, s)) { tb->selected = True; XFillRectangle(dpy, tPtr->db, WMColorGC(scr->gray), - rect.x, rect.y, rect.width, rect.height); + rect.x, rect.y, rect.width, rect.height); } } @@ -791,9 +793,9 @@ _getSibling: } } } else { - /* if it's viewable, and not mapped, map it */ + /* if it's viewable, and not mapped, map it */ if(tb->object) { - W_View *view = W_VIEW(tb->d.widget); + W_View *view = W_VIEW(tb->d.widget); if (!view->flags.realized) WMRealizeWidget(tb->d.widget); @@ -806,14 +808,14 @@ _getSibling: if(tb->object) { WMMoveWidget(tb->d.widget, - tb->sections[0].x + tPtr->visible.x - tPtr->hpos, - tb->sections[0].y + tPtr->visible.y - tPtr->vpos); + tb->sections[0].x + tPtr->visible.x - tPtr->hpos, + tb->sections[0].y + tPtr->visible.y - tPtr->vpos); h = WMWidgetHeight(tb->d.widget) + 1; } else { WMDrawPixmap(tb->d.pixmap, tPtr->db, - tb->sections[0].x - tPtr->hpos, - tb->sections[0].y - tPtr->vpos); + tb->sections[0].x - tPtr->hpos, + tb->sections[0].y - tPtr->vpos); h = tb->d.pixmap->height + 1; } @@ -823,21 +825,21 @@ _getSibling: if ( sectionWasSelected(tPtr, tb, &rect, 0)) { Drawable d = (0&&tb->object? - (WMWidgetView(tb->d.widget))->window : tPtr->db); + (WMWidgetView(tb->d.widget))->window : tPtr->db); tb->selected = True; XFillRectangle(dpy, d, tPtr->stippledGC, - /*XFillRectangle(dpy, tPtr->db, tPtr->stippledGC,*/ - rect.x, rect.y, rect.width, rect.height); + /*XFillRectangle(dpy, tPtr->db, tPtr->stippledGC,*/ + rect.x, rect.y, rect.width, rect.height); } } if (!tPtr->flags.monoFont && tb->underlined) { XDrawLine(dpy, tPtr->db, WMColorGC(tb->color), - tb->sections[0].x - tPtr->hpos, - tb->sections[0].y + h - tPtr->vpos, - tb->sections[0].x + tb->sections[0].w - tPtr->hpos, - tb->sections[0].y + h - tPtr->vpos); + tb->sections[0].x - tPtr->hpos, + tb->sections[0].y + h - tPtr->vpos, + tb->sections[0].x + tb->sections[0].w - tPtr->hpos, + tb->sections[0].y + h - tPtr->vpos); } } } @@ -858,8 +860,8 @@ _copy_area: tPtr->visible.x, tPtr->visible.y); W_DrawRelief(scr, win, 0, 0, - tPtr->view->size.width, tPtr->view->size.height, - tPtr->flags.relief); + tPtr->view->size.width, tPtr->view->size.height, + tPtr->flags.relief); if (tPtr->ruler && tPtr->flags.rulerShown) XDrawLine(dpy, win, WMColorGC(tPtr->fgColor), @@ -880,12 +882,12 @@ mouseOverObject(Text *tPtr, int x, int y) if(tPtr->flags.ownsSelection) { if(tPtr->sel.x <= x - && tPtr->sel.y <= y - && tPtr->sel.x + tPtr->sel.w >= x - && tPtr->sel.y + tPtr->sel.h >= y) { + && tPtr->sel.y <= y + && tPtr->sel.x + tPtr->sel.w >= x + && tPtr->sel.y + tPtr->sel.h >= y) { tPtr->flags.isOverGraphic = 1; result = True; - } + } } @@ -893,7 +895,7 @@ mouseOverObject(Text *tPtr, int x, int y) int j, c = WMGetArrayItemCount(tPtr->gfxItems); if (c<1) - tPtr->flags.isOverGraphic = 0; + tPtr->flags.isOverGraphic = 0; for(j=0; jobject) { if(tb->sections[0].x <= x - && tb->sections[0].y <= y - && tb->sections[0].x + tb->sections[0].w >= x - && tb->sections[0].y + tb->d.pixmap->height >= y ) { + && tb->sections[0].y <= y + && tb->sections[0].x + tb->sections[0].w >= x + && tb->sections[0].y + tb->d.pixmap->height >= y ) { tPtr->flags.isOverGraphic = 3; - result = True; - break; - } + result = True; + break; + } } } @@ -924,15 +926,15 @@ mouseOverObject(Text *tPtr, int x, int y) tPtr->view->attribs.cursor = (result? - tPtr->view->screen->defaultCursor - : tPtr->view->screen->textCursor); + tPtr->view->screen->defaultCursor + : tPtr->view->screen->textCursor); { XSetWindowAttributes attribs; attribs.cursor = tPtr->view->attribs.cursor; XChangeWindowAttributes(tPtr->view->screen->display, - tPtr->view->window, CWCursor, - &attribs); - } + tPtr->view->window, CWCursor, + &attribs); + } } #if DO_BLINK @@ -944,10 +946,10 @@ blinkCursor(void *data) if (tPtr->flags.cursorShown) { tPtr->timerID = WMAddTimerHandler(CURSOR_BLINK_OFF_DELAY, - blinkCursor, data); + blinkCursor, data); } else { tPtr->timerID = WMAddTimerHandler(CURSOR_BLINK_ON_DELAY, - blinkCursor, data); + blinkCursor, data); } paintText(tPtr); tPtr->flags.cursorShown = !tPtr->flags.cursorShown; @@ -976,11 +978,11 @@ updateCursorPosition(Text *tPtr) } - if(tb->blank) { - tPtr->tpos = 0; - y = tb->sections[0].y; - h = tb->sections[0].h; - x = tb->sections[0].x; + if(tb->blank) { + tPtr->tpos = 0; + y = tb->sections[0].y; + h = tb->sections[0].h; + x = tb->sections[0].x; } else if(tb->graphic) { y = tb->sections[0].y; @@ -996,16 +998,16 @@ updateCursorPosition(Text *tPtr) for(s=0; snsections-1; s++) { if(tPtr->tpos >= tb->sections[s].begin - && tPtr->tpos <= tb->sections[s].end) + && tPtr->tpos <= tb->sections[s].end) break; } - y = tb->sections[s]._y; - h = tb->sections[s].h; - x = tb->sections[s].x + WMWidthOfString( - (tPtr->flags.monoFont?tPtr->dFont:tb->d.font), - &tb->text[tb->sections[s].begin], - tPtr->tpos - tb->sections[s].begin); + y = tb->sections[s]._y; + h = tb->sections[s].h; + x = tb->sections[s].x + WMWidthOfString( + (tPtr->flags.monoFont?tPtr->dFont:tb->d.font), + &tb->text[tb->sections[s].begin], + tPtr->tpos - tb->sections[s].begin); } tPtr->cursor.y = y; @@ -1013,13 +1015,13 @@ updateCursorPosition(Text *tPtr) tPtr->cursor.x = x; -/* scroll the bars if the cursor is not visible */ + /* scroll the bars if the cursor is not visible */ if(tPtr->flags.editable && tPtr->cursor.x != -23) { if(tPtr->cursor.y+tPtr->cursor.h - > tPtr->vpos+tPtr->visible.y+tPtr->visible.h) { + > tPtr->vpos+tPtr->visible.y+tPtr->visible.h) { tPtr->vpos += (tPtr->cursor.y+tPtr->cursor.h+10 - - (tPtr->vpos+tPtr->visible.y+tPtr->visible.h)); + - (tPtr->vpos+tPtr->visible.y+tPtr->visible.h)); } else if(tPtr->cursor.y < tPtr->vpos+tPtr->visible.y) { tPtr->vpos -= (tPtr->vpos+tPtr->visible.y-tPtr->cursor.y); } @@ -1064,7 +1066,7 @@ cursorToTextPosition(Text *tPtr, int x, int y) } /* first, which direction? Most likely, newly clicked - position will be close to previous */ + position will be close to previous */ if(!updateStartForCurrentTextBlock(tPtr, x, y, &dir, tb)) return; @@ -1076,7 +1078,7 @@ cursorToTextPosition(Text *tPtr, int x, int y) } /* get the first (or last) section of the TextBlock that - lies about the vertical click point */ + lies about the vertical click point */ done = False; while (!done && tb) { @@ -1090,11 +1092,11 @@ cursorToTextPosition(Text *tPtr, int x, int y) while (!done && (dir? (snsections) : (s>=0) )) { if ( (dir? (y <= tb->sections[s]._y + tb->sections[s].h) : - ( y >= tb->sections[s]._y ) ) ) { - done = True; - } else { - dir? s++ : s--; - } + ( y >= tb->sections[s]._y ) ) ) { + done = True; + } else { + dir? s++ : s--; + } } if (!done) { @@ -1185,9 +1187,9 @@ _doneV: tPtr->cursor.x += tb->d.pixmap->width; } else if (pos > tb->sections[s].begin) { tPtr->cursor.x += - WMWidthOfString(tb->d.font, - &(tb->text[tb->sections[s].begin]), - pos - tb->sections[s].begin); + WMWidthOfString(tb->d.font, + &(tb->text[tb->sections[s].begin]), + pos - tb->sections[s].begin); } } goto _doneH; @@ -1208,51 +1210,51 @@ _doneV: /* we have said TextBlock, now where within it? */ if (tb) { if(tb->graphic) { - int gw = (tb->object ? - WMWidgetWidth(tb->d.widget) : tb->d.pixmap->width); + int gw = (tb->object ? + WMWidgetWidth(tb->d.widget) : tb->d.pixmap->width); - tPtr->cursor.x = tb->sections[0].x; + tPtr->cursor.x = tb->sections[0].x; - if(x > tPtr->cursor.x + gw/2) { - pos = 1; - tPtr->cursor.x += gw; - } else { -printf("first %d\n", tb->first); - if(tb->prior) { - if(tb->prior->graphic) pos = 1; - else pos = tb->prior->used; - tb = tb->prior; - } else pos = 0; + if(x > tPtr->cursor.x + gw/2) { + pos = 1; + tPtr->cursor.x += gw; + } else { + printf("first %d\n", tb->first); + if(tb->prior) { + if(tb->prior->graphic) pos = 1; + else pos = tb->prior->used; + tb = tb->prior; + } else pos = 0; - } + } - s = 0; - goto _doneH; + s = 0; + goto _doneH; } else { - WMFont *f = tb->d.font; - len = tb->sections[s].end - tb->sections[s].begin; - text = &(tb->text[tb->sections[s].begin]); + WMFont *f = tb->d.font; + len = tb->sections[s].end - tb->sections[s].begin; + text = &(tb->text[tb->sections[s].begin]); - _w = x - tb->sections[s].x; - pos = 0; + _w = x - tb->sections[s].x; + pos = 0; - while (poscursor.x = tb->sections[s].x + - (pos? WMWidthOfString(f, text, pos) : 0); + tPtr->cursor.x = tb->sections[s].x + + (pos? WMWidthOfString(f, text, pos) : 0); - pos += tb->sections[s].begin; + pos += tb->sections[s].begin; } - } + } _doneH: - if(tb->graphic) { - tPtr->tpos = (pos<=1)? pos : 0; - } else { - tPtr->tpos = (posused)? pos : tb->used; - } + if(tb->graphic) { + tPtr->tpos = (pos<=1)? pos : 0; + } else { + tPtr->tpos = (posused)? pos : tb->used; + } _doNothing: if (!tb) printf("...for this app will surely crash :-)\n"); @@ -1264,10 +1266,10 @@ _doNothing: /* scroll the bars if the cursor is not visible */ if(tPtr->flags.editable && tPtr->cursor.x != -23) { if(tPtr->cursor.y+tPtr->cursor.h - > tPtr->vpos+tPtr->visible.y+tPtr->visible.h) { + > tPtr->vpos+tPtr->visible.y+tPtr->visible.h) { tPtr->vpos += (tPtr->cursor.y+tPtr->cursor.h+10 - - (tPtr->vpos+tPtr->visible.y+tPtr->visible.h)); + - (tPtr->vpos+tPtr->visible.y+tPtr->visible.h)); updateScrollers(tPtr); } else if(tPtr->cursor.y < tPtr->vpos+tPtr->visible.y) { tPtr->vpos -= (tPtr->vpos+tPtr->visible.y-tPtr->cursor.y); @@ -1293,8 +1295,8 @@ updateScrollers(Text *tPtr) } else { float hmax = (float)(tPtr->docHeight); WMSetScrollerParameters(tPtr->vS, - ((float)tPtr->vpos)/(hmax - (float)tPtr->visible.h), - (float)tPtr->visible.h/hmax); + ((float)tPtr->vpos)/(hmax - (float)tPtr->visible.h), + (float)tPtr->visible.h/hmax); } } else tPtr->vpos = 0; @@ -1305,8 +1307,8 @@ updateScrollers(Text *tPtr) } else { float wmax = (float)(tPtr->docWidth); WMSetScrollerParameters(tPtr->hS, - ((float)tPtr->hpos)/(wmax - (float)tPtr->visible.w), - (float)tPtr->visible.w/wmax); + ((float)tPtr->hpos)/(wmax - (float)tPtr->visible.w), + (float)tPtr->visible.w/wmax); } } else tPtr->hpos = 0; } @@ -1328,49 +1330,49 @@ scrollersCallBack(WMWidget *w, void *self) which = WMGetScrollerHitPart(tPtr->vS); switch(which) { - case WSDecrementLine: - if (tPtr->vpos > 0) { - if (tPtr->vpos>16) tPtr->vpos-=16; - else tPtr->vpos=0; - scroll=True; - } - break; - - case WSIncrementLine: { - int limit = tPtr->docHeight - height; - if (tPtr->vpos < limit) { - if (tPtr->vposvpos+=16; - else tPtr->vpos=limit; - scroll = True; - } + case WSDecrementLine: + if (tPtr->vpos > 0) { + if (tPtr->vpos>16) tPtr->vpos-=16; + else tPtr->vpos=0; + scroll=True; } break; - case WSDecrementPage: - if(((int)tPtr->vpos - (int)height) >= 0) - tPtr->vpos -= height; - else - tPtr->vpos = 0; - + case WSIncrementLine: { + int limit = tPtr->docHeight - height; + if (tPtr->vpos < limit) { + if (tPtr->vposvpos+=16; + else tPtr->vpos=limit; scroll = True; - break; + } + } + break; - case WSIncrementPage: - tPtr->vpos += height; - if (tPtr->vpos > (tPtr->docHeight - height)) - tPtr->vpos = tPtr->docHeight - height; - scroll = True; - break; + case WSDecrementPage: + if(((int)tPtr->vpos - (int)height) >= 0) + tPtr->vpos -= height; + else + tPtr->vpos = 0; + scroll = True; + break; + + case WSIncrementPage: + tPtr->vpos += height; + if (tPtr->vpos > (tPtr->docHeight - height)) + tPtr->vpos = tPtr->docHeight - height; + scroll = True; + break; - case WSKnob: - tPtr->vpos = WMGetScrollerValue(tPtr->vS) - * (float)(tPtr->docHeight - height); - scroll = True; + + case WSKnob: + tPtr->vpos = WMGetScrollerValue(tPtr->vS) + * (float)(tPtr->docHeight - height); + scroll = True; break; - case WSKnobSlot: - case WSNoPart: + case WSKnobSlot: + case WSNoPart: break; } scroll = (tPtr->vpos != tPtr->prevVpos); @@ -1384,47 +1386,47 @@ scrollersCallBack(WMWidget *w, void *self) which = WMGetScrollerHitPart(tPtr->hS); switch(which) { - case WSDecrementLine: - if (tPtr->hpos > 0) { - if (tPtr->hpos>16) tPtr->hpos-=16; - else tPtr->hpos=0; - scroll=True; + case WSDecrementLine: + if (tPtr->hpos > 0) { + if (tPtr->hpos>16) tPtr->hpos-=16; + else tPtr->hpos=0; + scroll=True; }break; - case WSIncrementLine: { - int limit = tPtr->docWidth - width; - if (tPtr->hpos < limit) { - if (tPtr->hposhpos+=16; - else tPtr->hpos=limit; - scroll = True; - } - }break; + case WSIncrementLine: { + int limit = tPtr->docWidth - width; + if (tPtr->hpos < limit) { + if (tPtr->hposhpos+=16; + else tPtr->hpos=limit; + scroll = True; + } + }break; - case WSDecrementPage: - if(((int)tPtr->hpos - (int)width) >= 0) - tPtr->hpos -= width; - else - tPtr->hpos = 0; + case WSDecrementPage: + if(((int)tPtr->hpos - (int)width) >= 0) + tPtr->hpos -= width; + else + tPtr->hpos = 0; - scroll = True; - break; + scroll = True; + break; - case WSIncrementPage: - tPtr->hpos += width; - if (tPtr->hpos > (tPtr->docWidth - width)) - tPtr->hpos = tPtr->docWidth - width; - scroll = True; + case WSIncrementPage: + tPtr->hpos += width; + if (tPtr->hpos > (tPtr->docWidth - width)) + tPtr->hpos = tPtr->docWidth - width; + scroll = True; break; - case WSKnob: - tPtr->hpos = WMGetScrollerValue(tPtr->hS) - * (float)(tPtr->docWidth - width); - scroll = True; + case WSKnob: + tPtr->hpos = WMGetScrollerValue(tPtr->hS) + * (float)(tPtr->docWidth - width); + scroll = True; break; - case WSKnobSlot: - case WSNoPart: + case WSKnobSlot: + case WSNoPart: break; } scroll = (tPtr->hpos != tPtr->prevHpos); @@ -1468,7 +1470,7 @@ layOutLine(Text *tPtr, myLineItems *items, int nitems, int x, int y) lw += WMWidgetWidth(wdt); } else { line_height = WMAX(line_height, - tb->d.pixmap->height + max_d); + tb->d.pixmap->height + max_d); if (tPtr->flags.alignment != WALeft) lw += tb->d.pixmap->width; } @@ -1500,7 +1502,7 @@ layOutLine(Text *tPtr, myLineItems *items, int nitems, int x, int y) n = tb->nsections-1; } else { tb->sections = wrealloc(tb->sections, - (++tb->nsections)*sizeof(Section)); + (++tb->nsections)*sizeof(Section)); n = tb->nsections-1; tb->sections[n]._y = y + max_d; tb->sections[n].max_d = max_d; @@ -1534,8 +1536,8 @@ layOutLine(Text *tPtr, myLineItems *items, int nitems, int x, int y) tb->sections[n].y = y+line_height-font->y; tb->sections[n].w = WMWidthOfString(font, - &(tb->text[tb->sections[n].begin]), - tb->sections[n].end - tb->sections[n].begin); + &(tb->text[tb->sections[n].begin]), + tb->sections[n].end - tb->sections[n].begin); x += WMWidthOfString(font, text, len); } @@ -1649,7 +1651,7 @@ _layOut: if(nitems + 1> itemsSize) { items = wrealloc(items, - (++itemsSize)*sizeof(myLineItems)); + (++itemsSize)*sizeof(myLineItems)); } items[nitems].tb = tb; @@ -1678,7 +1680,7 @@ _layOut: if (end-begin > 0) { width = WMWidthOfString(font, - &tb->text[begin], end-begin); + &tb->text[begin], end-begin); /* if it won't fit, char wrap it */ if (width >= tPtr->visible.w) { @@ -1704,7 +1706,7 @@ _layOut: if(nitems + 1 > itemsSize) { items = wrealloc(items, - (++itemsSize)*sizeof(myLineItems)); + (++itemsSize)*sizeof(myLineItems)); } items[nitems].tb = tb; @@ -1717,37 +1719,37 @@ _layOut: } -/* not yet fully ready. but is already VERY FAST for a 3Mbyte file ;-) */ + /* not yet fully ready. but is already VERY FAST for a 3Mbyte file ;-) */ if(0&&tPtr->flags.laidOut - && tb->next && tb->next->sections && tb->next->nsections>0 - && (tPtr->vpos + tPtr->visible.h - < tb->next->sections[0]._y)) { + && tb->next && tb->next->sections && tb->next->nsections>0 + && (tPtr->vpos + tPtr->visible.h + < tb->next->sections[0]._y)) { if(tPtr->lastTextBlock->sections - && tPtr->lastTextBlock->nsections > 0 ) { - TextBlock *ltb = tPtr->lastTextBlock; - int ly = ltb->sections[ltb->nsections-1]._y; - int lh = ltb->sections[ltb->nsections-1].h; - int ss, sd; - -lh += 1 + tPtr->visible.y + ltb->sections[ltb->nsections-1].max_d; -printf("it's %d\n", tPtr->visible.y + ltb->sections[ltb->nsections-1].max_d); + && tPtr->lastTextBlock->nsections > 0 ) { + TextBlock *ltb = tPtr->lastTextBlock; + int ly = ltb->sections[ltb->nsections-1]._y; + int lh = ltb->sections[ltb->nsections-1].h; + int ss, sd; + + lh += 1 + tPtr->visible.y + ltb->sections[ltb->nsections-1].max_d; + printf("it's %d\n", tPtr->visible.y + ltb->sections[ltb->nsections-1].max_d); + + y += layOutLine(tPtr, items, nitems, x, y); + ss= ly+lh-y; + sd = tPtr->docHeight-y; + + printf("dif %d-%d: %d\n", ss, sd, ss-sd); + y += tb->next->sections[0]._y-y; + nitems = 0; + printf("nitems%d\n", nitems); + if(ss-sd!=0) + y = tPtr->docHeight+ss-sd; - y += layOutLine(tPtr, items, nitems, x, y); -ss= ly+lh-y; -sd = tPtr->docHeight-y; - -printf("dif %d-%d: %d\n", ss, sd, ss-sd); -y += tb->next->sections[0]._y-y; - nitems = 0; -printf("nitems%d\n", nitems); -if(ss-sd!=0) -y = tPtr->docHeight+ss-sd; - - break; + break; } else { tPtr->flags.laidOut = False; - } - } + } + } tb = tb->next; } @@ -1770,7 +1772,7 @@ y = tPtr->docHeight+ss-sd; handleEvents(&event, (void *)tPtr); } else if(tPtr->docWidth <= tPtr->visible.w - && tPtr->hS && tPtr->flags.horizOnDemand ) { + && tPtr->hS && tPtr->flags.horizOnDemand ) { tPtr->flags.horizOnDemand = False; WMSetTextHasHorizontalScroller((WMText*)tPtr, False); } @@ -1837,8 +1839,8 @@ textDidResize(W_ViewDelegate *self, WMView *view) if(!tPtr->db) { tPtr->db = XCreatePixmap(tPtr->view->screen->display, - tPtr->view->window, tPtr->visible.w, - tPtr->visible.h, tPtr->view->screen->depth); + tPtr->view->window, tPtr->visible.w, + tPtr->visible.h, tPtr->view->screen->depth); } } @@ -1876,8 +1878,8 @@ clearText(Text *tPtr) } /* possibly remove a single character from the currentTextBlock, - or if there's a selection, remove it... - note that Delete and Backspace are treated differently */ + or if there's a selection, remove it... + note that Delete and Backspace are treated differently */ static void deleteTextInteractively(Text *tPtr, KeySym ksym) { @@ -1914,7 +1916,7 @@ deleteTextInteractively(Text *tPtr, KeySym ksym) WMRemoveTextBlock(tPtr); tb = prior; } else { - tb = tb->prior; + tb = tb->prior; } if(tb->graphic) @@ -1939,13 +1941,13 @@ deleteTextInteractively(Text *tPtr, KeySym ksym) if (back) tPtr->tpos--; memmove(&(tb->text[tPtr->tpos]), - &(tb->text[tPtr->tpos + 1]), tb->used - tPtr->tpos); + &(tb->text[tPtr->tpos + 1]), tb->used - tPtr->tpos); tb->used--; done = 0; } /* if there are no characters left to back over in the textblock, - but it still has characters to the right of the cursor: */ + but it still has characters to the right of the cursor: */ if ( (back? (tPtr->tpos == 0 && !done) : ( tPtr->tpos >= tb->used)) || tb->graphic) { @@ -1963,19 +1965,19 @@ deleteTextInteractively(Text *tPtr, KeySym ksym) else tPtr->tpos = (back? sibling->used : 0); } - /* no more chars, so mark it as blank */ + /* no more chars, so mark it as blank */ } else if(tb->used == 0) { tb->blank = 1; } else if(tb->graphic) { - Bool hasNext = (Bool)(tb->next); + Bool hasNext = (Bool)(tb->next); - WMDestroyTextBlock(tPtr, WMRemoveTextBlock(tPtr)); - if(hasNext) { - tPtr->tpos = 0; - } else if(tPtr->currentTextBlock) { - tPtr->tpos = (tPtr->currentTextBlock->graphic? - 1 : tPtr->currentTextBlock->used); - } + WMDestroyTextBlock(tPtr, WMRemoveTextBlock(tPtr)); + if(hasNext) { + tPtr->tpos = 0; + } else if(tPtr->currentTextBlock) { + tPtr->tpos = (tPtr->currentTextBlock->graphic? + 1 : tPtr->currentTextBlock->used); + } } else printf("DEBUG: unaccounted for... catch this!\n"); } @@ -2046,12 +2048,12 @@ insertTextInteractively(Text *tPtr, char *text, int len) unsigned short savePos = tPtr->tpos; void *ntb = WMCreateTextBlockWithText( - tPtr, &tb->text[tPtr->tpos], - tb->d.font, tb->color, True, tb->used - tPtr->tpos); + tPtr, &tb->text[tPtr->tpos], + tb->d.font, tb->color, True, tb->used - tPtr->tpos); if(tb->sections[0].end == tPtr->tpos) WMAppendTextBlock(tPtr, WMCreateTextBlockWithText(tPtr, - NULL, tb->d.font, tb->color, True, 0)); + NULL, tb->d.font, tb->color, True, 0)); tb->used = savePos; WMAppendTextBlock(tPtr, ntb); @@ -2060,20 +2062,20 @@ insertTextInteractively(Text *tPtr, char *text, int len) } else if (tPtr->tpos == tb->used) { if(tPtr->flags.indentNewLine) { WMAppendTextBlock(tPtr, WMCreateTextBlockWithText(tPtr, - " ", tb->d.font, tb->color, True, 4)); + " ", tb->d.font, tb->color, True, 4)); tPtr->tpos = 4; } else { WMAppendTextBlock(tPtr, WMCreateTextBlockWithText(tPtr, - NULL, tb->d.font, tb->color, True, 0)); + NULL, tb->d.font, tb->color, True, 0)); tPtr->tpos = 0; } - } else if (tPtr->tpos == 0) { + } else if (tPtr->tpos == 0) { if(tPtr->flags.indentNewLine) { WMPrependTextBlock(tPtr, WMCreateTextBlockWithText(tPtr, - " ", tb->d.font, tb->color, True, 4)); + " ", tb->d.font, tb->color, True, 4)); } else { WMPrependTextBlock(tPtr, WMCreateTextBlockWithText(tPtr, - NULL, tb->d.font, tb->color, True, 0)); + NULL, tb->d.font, tb->color, True, 0)); } tPtr->tpos = 0; if(tPtr->currentTextBlock->next) @@ -2095,7 +2097,7 @@ insertTextInteractively(Text *tPtr, char *text, int len) } else { memmove(&(tb->text[tPtr->tpos+len]), &tb->text[tPtr->tpos], - tb->used-tPtr->tpos+1); + tb->used-tPtr->tpos+1); memmove(&tb->text[tPtr->tpos], text, len); tb->used += len; tPtr->tpos += len; @@ -2118,7 +2120,7 @@ selectRegion(Text *tPtr, int x, int y) y += (tPtr->flags.rulerShown? 40: 0); y += tPtr->vpos; if (y>10) - y -= 10; /* the original offset */ + y -= 10; /* the original offset */ x -= tPtr->visible.x-2; if (x<0) @@ -2145,7 +2147,7 @@ releaseSelection(Text *tPtr) } tPtr->flags.ownsSelection = False; WMDeleteSelectionHandler(tPtr->view, XA_PRIMARY, - CurrentTime); + CurrentTime); paintText(tPtr); } @@ -2153,7 +2155,7 @@ releaseSelection(Text *tPtr) WMData* requestHandler(WMView *view, Atom selection, Atom target, void *cdata, - Atom *type) + Atom *type) { Text *tPtr = view->self; Display *dpy = tPtr->view->screen->display; @@ -2168,7 +2170,7 @@ requestHandler(WMView *view, Atom selection, Atom target, void *cdata, if (text) { data = WMCreateDataWithBytes(text, strlen(text)); - WMSetDataFormat(data, TYPETEXT); + WMSetDataFormat(data, TYPETEXT); } *type = target; return data; @@ -2225,17 +2227,17 @@ autoSelectText(Text *tPtr, int clicks) if(!(tb = tPtr->currentTextBlock)) return; - if(clicks == 2) { + if(clicks == 2) { switch(tb->text[tPtr->tpos]) { - case ' ': return; -/* - case '<': case '>': behind = '<'; ahead = '>'; break; - case '{': case '}': behind = '{'; ahead = '}'; break; - case '[': case ']': behind = '['; ahead = ']'; break; -*/ - default: behind = ahead = ' '; + case ' ': return; + /* + case '<': case '>': behind = '<'; ahead = '>'; break; + case '{': case '}': behind = '{'; ahead = '}'; break; + case '[': case ']': behind = '['; ahead = ']'; break; + */ + default: behind = ahead = ' '; } tPtr->sel.y = tPtr->cursor.y+5; @@ -2254,43 +2256,43 @@ autoSelectText(Text *tPtr, int clicks) x = tPtr->cursor.x; if(tPtr->tpos > start){ x -= WMWidthOfString(font, &tb->text[start], - tPtr->tpos - start); + tPtr->tpos - start); } tPtr->sel.x = (x<0?0:x)+1; if((mark = strchr(&tb->text[start], ahead))) { tPtr->sel.w = WMWidthOfString(font, &tb->text[start], - (int)(mark - &tb->text[start])); + (int)(mark - &tb->text[start])); } else if(tb->used > start) { tPtr->sel.w = WMWidthOfString(font, &tb->text[start], - tb->used - start); + tb->used - start); } } } else if(clicks == 3) { - TextBlock *cur = tb; - - while(tb && !tb->first) { - tb = tb->prior; - } - tPtr->sel.y = tb->sections[0]._y; - - tb = cur; - while(tb->next && !tb->next->first) { - tb = tb->next; - } - tPtr->sel.h = tb->sections[tb->nsections-1]._y - + 5 - tPtr->sel.y; - - tPtr->sel.x = 0; - tPtr->sel.w = tPtr->docWidth; - tPtr->clicked.x = 0; /* only for now, fix sel. code */ + TextBlock *cur = tb; + + while(tb && !tb->first) { + tb = tb->prior; + } + tPtr->sel.y = tb->sections[0]._y; + + tb = cur; + while(tb->next && !tb->next->first) { + tb = tb->next; + } + tPtr->sel.h = tb->sections[tb->nsections-1]._y + + 5 - tPtr->sel.y; + + tPtr->sel.x = 0; + tPtr->sel.w = tPtr->docWidth; + tPtr->clicked.x = 0; /* only for now, fix sel. code */ } if (!tPtr->flags.ownsSelection) { - WMCreateSelectionHandler(tPtr->view, - XA_PRIMARY, tPtr->lastClickTime, &selectionHandler, NULL); - tPtr->flags.ownsSelection = True; + WMCreateSelectionHandler(tPtr->view, + XA_PRIMARY, tPtr->lastClickTime, &selectionHandler, NULL); + tPtr->flags.ownsSelection = True; } paintText(tPtr); @@ -2302,7 +2304,7 @@ fontChanged(void *observerData, WMNotification *notification) { WMText *tPtr = (WMText *) observerData; WMFont *font = (WMFont *)WMGetNotificationClientData(notification); -printf("fontChanged\n"); + printf("fontChanged\n"); if(!tPtr || !font) return; @@ -2326,14 +2328,14 @@ handleTextKeyPress(Text *tPtr, XEvent *event) switch(ksym) { - case XK_Home: + case XK_Home: if((tPtr->currentTextBlock = tPtr->firstTextBlock)) tPtr->tpos = 0; updateCursorPosition(tPtr); paintText(tPtr); break; - case XK_End: + case XK_End: if((tPtr->currentTextBlock = tPtr->lastTextBlock)) { if(tPtr->currentTextBlock->graphic) tPtr->tpos = 1; @@ -2344,88 +2346,88 @@ handleTextKeyPress(Text *tPtr, XEvent *event) paintText(tPtr); break; - case XK_Left: + case XK_Left: if(!(tb = tPtr->currentTextBlock)) break; - if(tb->graphic) - goto L_imaGFX; + if(tb->graphic) + goto L_imaGFX; - if(tPtr->tpos==0) { - L_imaGFX: - if(tb->prior) { - tPtr->currentTextBlock = tb->prior; - if(tPtr->currentTextBlock->graphic) - tPtr->tpos = 1; - else - tPtr->tpos = tPtr->currentTextBlock->used; + if(tPtr->tpos==0) { + L_imaGFX: + if(tb->prior) { + tPtr->currentTextBlock = tb->prior; + if(tPtr->currentTextBlock->graphic) + tPtr->tpos = 1; + else + tPtr->tpos = tPtr->currentTextBlock->used; - if(!tb->first && tPtr->tpos > 0) - tPtr->tpos--; - } else tPtr->tpos = 0; - } else tPtr->tpos--; - updateCursorPosition(tPtr); - paintText(tPtr); - break; + if(!tb->first && tPtr->tpos > 0) + tPtr->tpos--; + } else tPtr->tpos = 0; + } else tPtr->tpos--; + updateCursorPosition(tPtr); + paintText(tPtr); + break; - case XK_Right: + case XK_Right: if(!(tb = tPtr->currentTextBlock)) break; - if(tb->graphic) - goto R_imaGFX; - if(tPtr->tpos == tb->used) { - R_imaGFX: - if(tb->next) { - tPtr->currentTextBlock = tb->next; - tPtr->tpos = 0; - if(!tb->next->first && tb->next->used>0) - tPtr->tpos++; - } else { - if(tb->graphic) - tPtr->tpos = 1; - else - tPtr->tpos = tb->used; - } - } else tPtr->tpos++; - updateCursorPosition(tPtr); - paintText(tPtr); + if(tb->graphic) + goto R_imaGFX; + if(tPtr->tpos == tb->used) { + R_imaGFX: + if(tb->next) { + tPtr->currentTextBlock = tb->next; + tPtr->tpos = 0; + if(!tb->next->first && tb->next->used>0) + tPtr->tpos++; + } else { + if(tb->graphic) + tPtr->tpos = 1; + else + tPtr->tpos = tb->used; + } + } else tPtr->tpos++; + updateCursorPosition(tPtr); + paintText(tPtr); break; - case XK_Down: - cursorToTextPosition(tPtr, tPtr->cursor.x + tPtr->visible.x, - tPtr->clicked.y + tPtr->cursor.h - tPtr->vpos); - paintText(tPtr); - break; + case XK_Down: + cursorToTextPosition(tPtr, tPtr->cursor.x + tPtr->visible.x, + tPtr->clicked.y + tPtr->cursor.h - tPtr->vpos); + paintText(tPtr); + break; - case XK_Up: - cursorToTextPosition(tPtr, tPtr->cursor.x + tPtr->visible.x, - tPtr->visible.y + tPtr->cursor.y - tPtr->vpos - 3); - paintText(tPtr); + case XK_Up: + cursorToTextPosition(tPtr, tPtr->cursor.x + tPtr->visible.x, + tPtr->visible.y + tPtr->cursor.y - tPtr->vpos - 3); + paintText(tPtr); break; - case XK_BackSpace: - case XK_Delete: + case XK_BackSpace: + case XK_Delete: #ifdef XK_KP_Delete - case XK_KP_Delete: + case XK_KP_Delete: #endif - deleteTextInteractively(tPtr, ksym); - updateCursorPosition(tPtr); - paintText(tPtr); + deleteTextInteractively(tPtr, ksym); + updateCursorPosition(tPtr); + paintText(tPtr); break; - case XK_Control_R : - case XK_Control_L : - control_pressed = True; + case XK_Control_R : + case XK_Control_L : + control_pressed = True; break; - case XK_Tab: - insertTextInteractively(tPtr, " ", 4); - updateCursorPosition(tPtr); - paintText(tPtr); + case XK_Tab: + insertTextInteractively(tPtr, " ", 4); + updateCursorPosition(tPtr); + paintText(tPtr); break; - case XK_Return: - *buffer = '\n'; - default: + case XK_Return: + *buffer = '\n'; + default: if (*buffer != 0 && !control_pressed) { insertTextInteractively(tPtr, buffer, strlen(buffer)); updateCursorPosition(tPtr); @@ -2450,7 +2452,7 @@ handleTextKeyPress(Text *tPtr, XEvent *event) static void pasteText(WMView *view, Atom selection, Atom target, Time timestamp, - void *cdata, WMData *data) + void *cdata, WMData *data) { Text *tPtr = (Text *)view->self; char *text; @@ -2498,192 +2500,192 @@ handleActionEvents(XEvent *event, void *data) switch (event->type) { - case KeyPress: - ksym = XLookupKeysym((XKeyEvent*)event, 0); - if (ksym == XK_Shift_R || ksym == XK_Shift_L) { - tPtr->flags.extendSelection = True; - return; - } + case KeyPress: + ksym = XLookupKeysym((XKeyEvent*)event, 0); + if (ksym == XK_Shift_R || ksym == XK_Shift_L) { + tPtr->flags.extendSelection = True; + return; + } - if (tPtr->flags.focused) { - XGrabPointer(dpy, W_VIEW(tPtr)->window, False, - PointerMotionMask|ButtonPressMask|ButtonReleaseMask, - GrabModeAsync, GrabModeAsync, None, - tPtr->view->screen->invisibleCursor, CurrentTime); - tPtr->flags.pointerGrabbed = True; - handleTextKeyPress(tPtr, event); + if (tPtr->flags.focused) { + XGrabPointer(dpy, W_VIEW(tPtr)->window, False, + PointerMotionMask|ButtonPressMask|ButtonReleaseMask, + GrabModeAsync, GrabModeAsync, None, + tPtr->view->screen->invisibleCursor, CurrentTime); + tPtr->flags.pointerGrabbed = True; + handleTextKeyPress(tPtr, event); - } break; + } break; - case KeyRelease: - ksym = XLookupKeysym((XKeyEvent*)event, 0); - if (ksym == XK_Shift_R || ksym == XK_Shift_L) { - tPtr->flags.extendSelection = False; - return; + case KeyRelease: + ksym = XLookupKeysym((XKeyEvent*)event, 0); + if (ksym == XK_Shift_R || ksym == XK_Shift_L) { + tPtr->flags.extendSelection = False; + return; /* end modify flag so selection can be extended */ - } + } break; - case MotionNotify: + case MotionNotify: - if (tPtr->flags.pointerGrabbed) { - tPtr->flags.pointerGrabbed = False; - XUngrabPointer(dpy, CurrentTime); - } + if (tPtr->flags.pointerGrabbed) { + tPtr->flags.pointerGrabbed = False; + XUngrabPointer(dpy, CurrentTime); + } - if(tPtr->flags.waitingForSelection) - break; + if(tPtr->flags.waitingForSelection) + break; - if ((event->xmotion.state & Button1Mask)) { + if ((event->xmotion.state & Button1Mask)) { - if (WMIsDraggingFromView(tPtr->view)) { - WMDragImageFromView(tPtr->view, event); - break; - } - - if (!tPtr->flags.ownsSelection) { - WMCreateSelectionHandler(tPtr->view, - XA_PRIMARY, event->xbutton.time, - &selectionHandler, NULL); - tPtr->flags.ownsSelection = True; - } - selectRegion(tPtr, event->xmotion.x, event->xmotion.y); + if (WMIsDraggingFromView(tPtr->view)) { + WMDragImageFromView(tPtr->view, event); break; } - mouseOverObject(tPtr, event->xmotion.x, event->xmotion.y); + if (!tPtr->flags.ownsSelection) { + WMCreateSelectionHandler(tPtr->view, + XA_PRIMARY, event->xbutton.time, + &selectionHandler, NULL); + tPtr->flags.ownsSelection = True; + } + selectRegion(tPtr, event->xmotion.x, event->xmotion.y); break; + } + mouseOverObject(tPtr, event->xmotion.x, event->xmotion.y); + break; - case ButtonPress: - if (tPtr->flags.pointerGrabbed) { - tPtr->flags.pointerGrabbed = False; - XUngrabPointer(dpy, CurrentTime); - break; - } + case ButtonPress: - if (tPtr->flags.waitingForSelection) - break; + if (tPtr->flags.pointerGrabbed) { + tPtr->flags.pointerGrabbed = False; + XUngrabPointer(dpy, CurrentTime); + break; + } - if (tPtr->flags.extendSelection && tPtr->flags.ownsSelection) { - selectRegion(tPtr, event->xmotion.x, event->xmotion.y); - return; - } + if (tPtr->flags.waitingForSelection) + break; - if (tPtr->flags.ownsSelection) - releaseSelection(tPtr); + if (tPtr->flags.extendSelection && tPtr->flags.ownsSelection) { + selectRegion(tPtr, event->xmotion.x, event->xmotion.y); + return; + } + if (tPtr->flags.ownsSelection) + releaseSelection(tPtr); - if (event->xbutton.button == Button1) { - TextBlock *tb = tPtr->currentTextBlock; - if(WMIsDoubleClick(event)) { + if (event->xbutton.button == Button1) { + TextBlock *tb = tPtr->currentTextBlock; - tPtr->lastClickTime = event->xbutton.time; - if(tb && tb->graphic && !tb->object) { - if(tPtr->delegate && tPtr->delegate->didDoubleClickOnPicture) { - char *desc; + if(WMIsDoubleClick(event)) { - desc = wmalloc(tb->used+1); - memcpy(desc, tb->text, tb->used); - desc[tb->used] = 0; - (*tPtr->delegate->didDoubleClickOnPicture)(tPtr->delegate, desc); - wfree(desc); - } - } else { - autoSelectText(tPtr, 2); + tPtr->lastClickTime = event->xbutton.time; + if(tb && tb->graphic && !tb->object) { + if(tPtr->delegate && tPtr->delegate->didDoubleClickOnPicture) { + char *desc; + + desc = wmalloc(tb->used+1); + memcpy(desc, tb->text, tb->used); + desc[tb->used] = 0; + (*tPtr->delegate->didDoubleClickOnPicture)(tPtr->delegate, desc); + wfree(desc); } - break; - } else if (event->xbutton.time - tPtr->lastClickTime - < WINGsConfiguration.doubleClickDelay) { - tPtr->lastClickTime = event->xbutton.time; - autoSelectText(tPtr, 3); - break; - } - - if (!tPtr->flags.focused) { - WMSetFocusToWidget(tPtr); - tPtr->flags.focused = True; - } else if (tb && tPtr->flags.isOverGraphic && - tb->graphic && !tb->object && tb->d.pixmap) { - - WMSetViewDragImage(tPtr->view, tb->d.pixmap); - WMDragImageFromView(tPtr->view, event); - break; + } else { + autoSelectText(tPtr, 2); } - + break; + } else if (event->xbutton.time - tPtr->lastClickTime + < WINGsConfiguration.doubleClickDelay) { tPtr->lastClickTime = event->xbutton.time; - cursorToTextPosition(tPtr, event->xmotion.x, event->xmotion.y); - paintText(tPtr); - } - - if (event->xbutton.button - == WINGsConfiguration.mouseWheelDown) { - WMScrollText(tPtr, 16); + autoSelectText(tPtr, 3); break; } - if (event->xbutton.button - == WINGsConfiguration.mouseWheelUp) { - WMScrollText(tPtr, -16); + if (!tPtr->flags.focused) { + WMSetFocusToWidget(tPtr); + tPtr->flags.focused = True; + } else if (tb && tPtr->flags.isOverGraphic && + tb->graphic && !tb->object && tb->d.pixmap) { + + WMSetViewDragImage(tPtr->view, tb->d.pixmap); + WMDragImageFromView(tPtr->view, event); break; } - if (event->xbutton.button == Button2) { - char *text = NULL; - int n; + tPtr->lastClickTime = event->xbutton.time; + cursorToTextPosition(tPtr, event->xmotion.x, event->xmotion.y); + paintText(tPtr); + } - if (!tPtr->flags.editable) { - XBell(dpy, 0); - break; - } + if (event->xbutton.button + == WINGsConfiguration.mouseWheelDown) { + WMScrollText(tPtr, 16); + break; + } - if (!WMRequestSelection(tPtr->view, XA_PRIMARY, XA_STRING, - event->xbutton.time, pasteText, NULL)) { + if (event->xbutton.button + == WINGsConfiguration.mouseWheelUp) { + WMScrollText(tPtr, -16); + break; + } - text = XFetchBuffer(tPtr->view->screen->display, &n, 0); - tPtr->flags.waitingForSelection = 0; + if (event->xbutton.button == Button2) { + char *text = NULL; + int n; - if (text) { - text[n] = 0; + if (!tPtr->flags.editable) { + XBell(dpy, 0); + break; + } - if (tPtr->parser) { - (tPtr->parser) (tPtr, (void *) text); - layOutDocument(tPtr); - } - else - insertTextInteractively(tPtr, text, n); + if (!WMRequestSelection(tPtr->view, XA_PRIMARY, XA_STRING, + event->xbutton.time, pasteText, NULL)) { - XFree(text); + text = XFetchBuffer(tPtr->view->screen->display, &n, 0); + tPtr->flags.waitingForSelection = 0; + + if (text) { + text[n] = 0; + + if (tPtr->parser) { + (tPtr->parser) (tPtr, (void *) text); + layOutDocument(tPtr); + } + else + insertTextInteractively(tPtr, text, n); + + XFree(text); #if 0 - NOTIFY(tPtr, didChange, WMTextDidChangeNotification, - (void*)WMInsertTextEvent); + NOTIFY(tPtr, didChange, WMTextDidChangeNotification, + (void*)WMInsertTextEvent); #endif - updateCursorPosition(tPtr); - paintText(tPtr); + updateCursorPosition(tPtr); + paintText(tPtr); - } else { - tPtr->flags.waitingForSelection = True; - } + } else { + tPtr->flags.waitingForSelection = True; } - break; } + break; + } - case ButtonRelease: - if (tPtr->flags.pointerGrabbed) { - tPtr->flags.pointerGrabbed = False; - XUngrabPointer(dpy, CurrentTime); - break; - } + case ButtonRelease: + if (tPtr->flags.pointerGrabbed) { + tPtr->flags.pointerGrabbed = False; + XUngrabPointer(dpy, CurrentTime); + break; + } - if (tPtr->flags.waitingForSelection) - break; + if (tPtr->flags.waitingForSelection) + break; - if (WMIsDraggingFromView(tPtr->view)) - WMDragImageFromView(tPtr->view, event); + if (WMIsDraggingFromView(tPtr->view)) + WMDragImageFromView(tPtr->view, event); } } @@ -2695,78 +2697,78 @@ handleEvents(XEvent *event, void *data) Text *tPtr = (Text *)data; switch(event->type) { - case Expose: + case Expose: - if (event->xexpose.count!=0) - break; + if (event->xexpose.count!=0) + break; - if(tPtr->hS) { - if (!(W_VIEW(tPtr->hS))->flags.realized) - WMRealizeWidget(tPtr->hS); - } + if(tPtr->hS) { + if (!(W_VIEW(tPtr->hS))->flags.realized) + WMRealizeWidget(tPtr->hS); + } - if(tPtr->vS) { - if (!(W_VIEW(tPtr->vS))->flags.realized) - WMRealizeWidget(tPtr->vS); - } + if(tPtr->vS) { + if (!(W_VIEW(tPtr->vS))->flags.realized) + WMRealizeWidget(tPtr->vS); + } - if(tPtr->ruler) { - if (!(W_VIEW(tPtr->ruler))->flags.realized) - WMRealizeWidget(tPtr->ruler); + if(tPtr->ruler) { + if (!(W_VIEW(tPtr->ruler))->flags.realized) + WMRealizeWidget(tPtr->ruler); - } + } - if(!tPtr->db) - textDidResize(tPtr->view->delegate, tPtr->view); + if(!tPtr->db) + textDidResize(tPtr->view->delegate, tPtr->view); - paintText(tPtr); + paintText(tPtr); break; - case FocusIn: - if (W_FocusedViewOfToplevel(W_TopLevelOfView(tPtr->view)) - != tPtr->view) - return; - tPtr->flags.focused = True; + case FocusIn: + if (W_FocusedViewOfToplevel(W_TopLevelOfView(tPtr->view)) + != tPtr->view) + return; + tPtr->flags.focused = True; #if DO_BLINK - if (tPtr->flags.editable && !tPtr->timerID) { - tPtr->timerID = WMAddTimerHandler(12+0*CURSOR_BLINK_ON_DELAY, - blinkCursor, tPtr); - } + if (tPtr->flags.editable && !tPtr->timerID) { + tPtr->timerID = WMAddTimerHandler(12+0*CURSOR_BLINK_ON_DELAY, + blinkCursor, tPtr); + } #endif break; - case FocusOut: - tPtr->flags.focused = False; - paintText(tPtr); + case FocusOut: + tPtr->flags.focused = False; + paintText(tPtr); #if DO_BLINK - if (tPtr->timerID) { - WMDeleteTimerHandler(tPtr->timerID); - tPtr->timerID = NULL; - } + if (tPtr->timerID) { + WMDeleteTimerHandler(tPtr->timerID); + tPtr->timerID = NULL; + } #endif break; - case DestroyNotify: - clearText(tPtr); - if(tPtr->db) - XFreePixmap(tPtr->view->screen->display, tPtr->db); - if(tPtr->gfxItems) - WMEmptyArray(tPtr->gfxItems); + case DestroyNotify: + clearText(tPtr); + if(tPtr->db) + XFreePixmap(tPtr->view->screen->display, tPtr->db); + if(tPtr->gfxItems) + WMEmptyArray(tPtr->gfxItems); #if DO_BLINK - if (tPtr->timerID) - WMDeleteTimerHandler(tPtr->timerID); + if (tPtr->timerID) + WMDeleteTimerHandler(tPtr->timerID); #endif - WMReleaseFont(tPtr->dFont); - WMReleaseColor(tPtr->dColor); - WMDeleteSelectionHandler(tPtr->view, XA_PRIMARY, CurrentTime); - WMRemoveNotificationObserver(tPtr); + WMReleaseFont(tPtr->dFont); + WMReleaseColor(tPtr->dColor); + WMDeleteSelectionHandler(tPtr->view, XA_PRIMARY, CurrentTime); + WMRemoveNotificationObserver(tPtr); - WMFreeArray(tPtr->xdndSourceTypes); - WMFreeArray(tPtr->xdndDestinationTypes); + WMFreeArray(tPtr->xdndSourceTypes); + WMFreeArray(tPtr->xdndDestinationTypes); - wfree(tPtr); + wfree(tPtr); break; @@ -2785,14 +2787,14 @@ insertPlainText(Text *tPtr, char *text) mark = strchr(start, '\n'); if (mark) { tb = WMCreateTextBlockWithText(tPtr, - start, tPtr->dFont, - tPtr->dColor, tPtr->flags.first, (int)(mark-start)); + start, tPtr->dFont, + tPtr->dColor, tPtr->flags.first, (int)(mark-start)); start = mark+1; tPtr->flags.first = True; } else { if (start && strlen(start)) { tb = WMCreateTextBlockWithText(tPtr, start, tPtr->dFont, - tPtr->dColor, tPtr->flags.first, strlen(start)); + tPtr->dColor, tPtr->flags.first, strlen(start)); } else tb = NULL; tPtr->flags.first = False; start = mark; @@ -2972,7 +2974,7 @@ getStream(WMText *tPtr, int sel, int array) && tb != tPtr->firstTextBlock) { text = wrealloc(text, where+1); text[where++] = '\n'; - } + } if(tb->blank) goto _gSnext; @@ -2992,8 +2994,8 @@ getStream(WMText *tPtr, int sel, int array) } else if (sel && tb->selected) { if (!tPtr->flags.ignoreNewLine && tb->blank) { - text = wrealloc(text, where+1); - text[where++] = '\n'; + text = wrealloc(text, where+1); + text[where++] = '\n'; } if(tb->blank) @@ -3001,13 +3003,13 @@ getStream(WMText *tPtr, int sel, int array) text = wrealloc(text, where+(tb->s_end - tb->s_begin)); memcpy(&text[where], &tb->text[tb->s_begin], - tb->s_end - tb->s_begin); + tb->s_end - tb->s_begin); where += tb->s_end - tb->s_begin; } } -_gSnext:tb = tb->next; + _gSnext:tb = tb->next; } /* +1 for the end of string, let's be nice */ @@ -3043,11 +3045,11 @@ getStreamObjects(WMText *tPtr, int sel) fa = strchr(start, 0xFA); if (fa) { if((int)(fa - start)>0) { - desc = start; - desc[(int)(fa - start)] = 0; - data = WMCreateDataWithBytes((void *)desc, (int)(fa - start)); - WMSetDataFormat(data, TYPETEXT); - WMAddToArray(array, (void *) data); + desc = start; + desc[(int)(fa - start)] = 0; + data = WMCreateDataWithBytes((void *)desc, (int)(fa - start)); + WMSetDataFormat(data, TYPETEXT); + WMAddToArray(array, (void *) data); } len = *(fa+1)*0xff + *(fa+2); @@ -3056,14 +3058,14 @@ getStreamObjects(WMText *tPtr, int sel) WMAddToArray(array, (void *) data); start = fa + len + 4; - } else { - if (start && strlen(start)) { - data = WMCreateDataWithBytes((void *)start, strlen(start)); - WMSetDataFormat(data, TYPETEXT); - WMAddToArray(array, (void *) data); - } - start = fa; - } + } else { + if (start && strlen(start)) { + data = WMCreateDataWithBytes((void *)start, strlen(start)); + WMSetDataFormat(data, TYPETEXT); + WMAddToArray(array, (void *) data); + } + start = fa; + } } wfree(stream); @@ -3148,12 +3150,12 @@ WMCreateTextForDocumentType(WMWidget *parent, WMAction *parser, WMAction *writer #endif WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask - |EnterWindowMask|LeaveWindowMask|FocusChangeMask, - handleEvents, tPtr); + |EnterWindowMask|LeaveWindowMask|FocusChangeMask, + handleEvents, tPtr); WMCreateEventHandler(tPtr->view, ButtonReleaseMask|ButtonPressMask - |KeyReleaseMask|KeyPressMask|Button1MotionMask, - handleActionEvents, tPtr); + |KeyReleaseMask|KeyPressMask|Button1MotionMask, + handleActionEvents, tPtr); WMAddNotificationObserver(ownershipObserver, tPtr, WMSelectionOwnerDidChangeNotification, @@ -3171,7 +3173,7 @@ WMCreateTextForDocumentType(WMWidget *parent, WMAction *parser, WMAction *writer } /*WMAddNotificationObserver(fontChanged, tPtr, - WMFontPanelDidChangeNotification, tPtr);*/ + WMFontPanelDidChangeNotification, tPtr);*/ tPtr->firstTextBlock = NULL; tPtr->lastTextBlock = NULL; @@ -3197,7 +3199,7 @@ WMCreateTextForDocumentType(WMWidget *parent, WMAction *parser, WMAction *writer tPtr->docWidth = 0; tPtr->docHeight = 0; tPtr->dBulletPix = WMCreatePixmapFromXPMData(tPtr->view->screen, - default_bullet); + default_bullet); tPtr->db = (Pixmap) NULL; tPtr->bgPixmap = NULL; @@ -3454,8 +3456,8 @@ WMCreateTextBlockWithText(WMText *tPtr, char *text, WMFont *font, WMColor *color void WMSetTextBlockProperties(WMText *tPtr, void *vtb, unsigned int first, - unsigned int kanji, unsigned int underlined, int script, - WMRulerMargins *margins) + unsigned int kanji, unsigned int underlined, int script, + WMRulerMargins *margins) { TextBlock *tb = (TextBlock *) vtb; if (!tb) @@ -3471,8 +3473,8 @@ WMSetTextBlockProperties(WMText *tPtr, void *vtb, unsigned int first, void WMGetTextBlockProperties(WMText *tPtr, void *vtb, unsigned int *first, - unsigned int *kanji, unsigned int *underlined, int *script, - WMRulerMargins *margins) + unsigned int *kanji, unsigned int *underlined, int *script, + WMRulerMargins *margins) { TextBlock *tb = (TextBlock *) vtb; if (!tb) @@ -3629,8 +3631,8 @@ WMRemoveTextBlock(WMText *tPtr) static void destroyWidget(WMWidget *widget) { - WMDestroyWidget(widget); - // -- never do this -- wfree(widget); + WMDestroyWidget(widget); + // -- never do this -- wfree(widget); } #endif @@ -4066,7 +4068,7 @@ WMThawText(WMText *tPtr) WMUnmapWidget(tb->d.widget); } } - } + } tPtr->flags.laidOut = False; @@ -4080,7 +4082,7 @@ WMThawText(WMText *tPtr) /* find first occurence of a string */ static char * mystrstr(char *haystack, char *needle, unsigned short len, char *end, - Bool caseSensitive) + Bool caseSensitive) { char *ptr; @@ -4105,7 +4107,7 @@ mystrstr(char *haystack, char *needle, unsigned short len, char *end, /* find last occurence of a string */ static char * mystrrstr(char *haystack, char *needle, unsigned short len, char *end, - Bool caseSensitive) + Bool caseSensitive) { char *ptr; @@ -4139,12 +4141,12 @@ WMFindInTextStream(WMText *tPtr, char *needle, Bool direction, #if 0 if (! (tb = tPtr->currentTextBlock)) { if (! (tb = ( (direction > 0) ? - tPtr->firstTextBlock : tPtr->lastTextBlock) ) ){ + tPtr->firstTextBlock : tPtr->lastTextBlock) ) ){ return False; - } + } } else { - /* if(tb != ((direction>0) ?tPtr->firstTextBlock : tPtr->lastTextBlock)) - tb = (direction>0) ? tb->next : tb->prior; */ + /* if(tb != ((direction>0) ?tPtr->firstTextBlock : tPtr->lastTextBlock)) + tb = (direction>0) ? tb->next : tb->prior; */ if(tb != tPtr->lastTextBlock) tb = tb->prior; } @@ -4161,8 +4163,8 @@ WMFindInTextStream(WMText *tPtr, char *needle, Bool direction, pos++; if(tb->used - pos> 0 && pos > 0) { - mark = mystrstr(&tb->text[pos], needle, - strlen(needle), &tb->text[tb->used], caseSensitive); + mark = mystrstr(&tb->text[pos], needle, + strlen(needle), &tb->text[tb->used], caseSensitive); } else { tb = tb->next; @@ -4175,15 +4177,15 @@ WMFindInTextStream(WMText *tPtr, char *needle, Bool direction, pos--; if(pos > 0) { - mark = mystrrstr(&tb->text[pos], needle, - strlen(needle), tb->text, caseSensitive); + mark = mystrrstr(&tb->text[pos], needle, + strlen(needle), tb->text, caseSensitive); } else { tb = tb->prior; if(!tb) return False; pos = tb->used; continue; - } + } } @@ -4197,8 +4199,8 @@ WMFindInTextStream(WMText *tPtr, char *needle, Bool direction, tPtr->sel.h = tPtr->cursor.h-10; tPtr->sel.x = tPtr->cursor.x +1; tPtr->sel.w = WMIN(WMWidthOfString(font, - &tb->text[tPtr->tpos], strlen(needle)), - tPtr->docWidth - tPtr->sel.x); + &tb->text[tPtr->tpos], strlen(needle)), + tPtr->docWidth - tPtr->sel.x); tPtr->flags.ownsSelection = True; paintText(tPtr); diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index cd279959..bc49a222 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -50,38 +50,38 @@ typedef struct W_TextField { WMHandlerID timerID; /* for cursor blinking */ #endif struct { - WMAlignment alignment:2; + WMAlignment alignment:2; - unsigned int bordered:1; + unsigned int bordered:1; - unsigned int beveled:1; + unsigned int beveled:1; - unsigned int enabled:1; + unsigned int enabled:1; - unsigned int focused:1; + unsigned int focused:1; - unsigned int cursorOn:1; + unsigned int cursorOn:1; - unsigned int secure:1; /* password entry style */ + unsigned int secure:1; /* password entry style */ - unsigned int pointerGrabbed:1; + unsigned int pointerGrabbed:1; - unsigned int ownsSelection:1; + unsigned int ownsSelection:1; - unsigned int waitingSelection:1; /* requested selection, but - * didnt get yet */ + unsigned int waitingSelection:1; /* requested selection, but + * didnt get yet */ - /**/ - unsigned int notIllegalMovement:1; + /**/ + unsigned int notIllegalMovement:1; } flags; } TextField; #define NOTIFY(T,C,N,A) { WMNotification *notif = WMCreateNotification(N,T,A);\ - if ((T)->delegate && (T)->delegate->C)\ - (*(T)->delegate->C)((T)->delegate,notif);\ - WMPostNotification(notif);\ - WMReleaseNotification(notif);} + if ((T)->delegate && (T)->delegate->C)\ + (*(T)->delegate->C)((T)->delegate,notif);\ + WMPostNotification(notif);\ + WMReleaseNotification(notif);} #define MIN_TEXT_BUFFER 2 @@ -137,59 +137,59 @@ static WMSelectionProcs selectionHandler = { #define TEXT_WIDTH(tPtr, start) (WMWidthOfString((tPtr)->font, \ - &((tPtr)->text[(start)]), (tPtr)->textLen - (start) + 1)) + &((tPtr)->text[(start)]), (tPtr)->textLen - (start) + 1)) #define TEXT_WIDTH2(tPtr, start, end) (WMWidthOfString((tPtr)->font, \ - &((tPtr)->text[(start)]), (end) - (start) + 1)) + &((tPtr)->text[(start)]), (end) - (start) + 1)) static void normalizeRange(TextField *tPtr, WMRange *range) { if (range->position < 0 && range->count < 0) - range->count = 0; + range->count = 0; if (range->count == 0) { - /*range->position = 0; why is this?*/ - return; + /*range->position = 0; why is this?*/ + return; } - + /* (1,-2) ~> (0,1) ; (1,-1) ~> (0,1) ; (2,-1) ~> (1,1) */ if (range->count < 0) { /* && range->position >= 0 */ - if (range->position + range->count < 0) { - range->count = range->position; - range->position = 0; - } else { - range->count = -range->count; - range->position -= range->count; - } - /* (-2,1) ~> (0,0) ; (-1,1) ~> (0,0) ; (-1,2) ~> (0,1) */ + if (range->position + range->count < 0) { + range->count = range->position; + range->position = 0; + } else { + range->count = -range->count; + range->position -= range->count; + } + /* (-2,1) ~> (0,0) ; (-1,1) ~> (0,0) ; (-1,2) ~> (0,1) */ } else if (range->position < 0) { /* && range->count > 0 */ - if (range->position + range->count < 0) { - range->position = range->count = 0; - } else { - range->count += range->position; - range->position = 0; - } + if (range->position + range->count < 0) { + range->position = range->count = 0; + } else { + range->count += range->position; + range->position = 0; + } } - + if (range->position + range->count > tPtr->textLen) - range->count = tPtr->textLen - range->position; + range->count = tPtr->textLen - range->position; } static void memmv(char *dest, char *src, int size) { int i; - + if (dest > src) { - for (i=size-1; i>=0; i--) { - dest[i] = src[i]; - } + for (i=size-1; i>=0; i--) { + dest[i] = src[i]; + } } else if (dest < src) { - for (i=0; iviewPosition; while (TEXT_WIDTH(tPtr, tPtr->viewPosition) > tPtr->usableWidth) { - tPtr->viewPosition++; + tPtr->viewPosition++; } return vp!=tPtr->viewPosition; } @@ -210,11 +210,11 @@ static int incrToFit2(TextField *tPtr) { int vp = tPtr->viewPosition; - while (TEXT_WIDTH2(tPtr, tPtr->viewPosition, tPtr->cursorPosition) - >= tPtr->usableWidth) - tPtr->viewPosition++; + while (TEXT_WIDTH2(tPtr, tPtr->viewPosition, tPtr->cursorPosition) + >= tPtr->usableWidth) + tPtr->viewPosition++; + - return vp!=tPtr->viewPosition; } @@ -223,8 +223,8 @@ static void decrToFit(TextField *tPtr) { while (TEXT_WIDTH(tPtr, tPtr->viewPosition-1) < tPtr->usableWidth - && tPtr->viewPosition>0) - tPtr->viewPosition--; + && tPtr->viewPosition>0) + tPtr->viewPosition--; } #undef TEXT_WIDTH @@ -233,7 +233,7 @@ decrToFit(TextField *tPtr) static WMData* -requestHandler(WMView *view, Atom selection, Atom target, void *cdata, +requestHandler(WMView *view, Atom selection, Atom target, void *cdata, Atom *type) { TextField *tPtr = view->self; @@ -249,15 +249,15 @@ requestHandler(WMView *view, Atom selection, Atom target, void *cdata, : tPtr->selection.position; if (target == XA_STRING || target == TEXT || target == COMPOUND_TEXT) { - - data = WMCreateDataWithBytes(&(tPtr->text[count]), - abs(tPtr->selection.count)); - WMSetDataFormat(data, 8); + + data = WMCreateDataWithBytes(&(tPtr->text[count]), + abs(tPtr->selection.count)); + WMSetDataFormat(data, 8); *type = target; - + return data; } - + _TARGETS = XInternAtom(dpy, "TARGETS", False); if (target == _TARGETS) { Atom *ptr; @@ -267,10 +267,10 @@ requestHandler(WMView *view, Atom selection, Atom target, void *cdata, ptr[1] = XA_STRING; ptr[2] = TEXT; ptr[3] = COMPOUND_TEXT; - - data = WMCreateDataWithBytes(ptr, 4*4); - WMSetDataFormat(data, 32); - + + data = WMCreateDataWithBytes(ptr, 4*4); + WMSetDataFormat(data, 32); + *type = target; return data; } @@ -304,9 +304,9 @@ selectionNotification(void *observerData, WMNotification *notification) if (observerView != newOwnerView) { /* - //if (tPtr->flags.ownsSelection) - // WMDeleteSelectionHandler(observerView, XA_PRIMARY, CurrentTime); - */ + //if (tPtr->flags.ownsSelection) + // WMDeleteSelectionHandler(observerView, XA_PRIMARY, CurrentTime); + */ lostSelection(observerView, XA_PRIMARY, NULL); } } @@ -321,11 +321,11 @@ WMCreateTextField(WMWidget *parent) memset(tPtr, 0, sizeof(TextField)); tPtr->widgetClass = WC_TextField; - + tPtr->view = W_CreateView(W_VIEW(parent)); if (!tPtr->view) { - wfree(tPtr); - return NULL; + wfree(tPtr); + return NULL; } tPtr->view->self = tPtr; @@ -333,32 +333,32 @@ WMCreateTextField(WMWidget *parent) tPtr->view->attribFlags |= CWCursor; tPtr->view->attribs.cursor = tPtr->view->screen->textCursor; - + W_SetViewBackgroundColor(tPtr->view, tPtr->view->screen->white); - + tPtr->text = wmalloc(MIN_TEXT_BUFFER); tPtr->text[0] = 0; tPtr->textLen = 0; tPtr->bufferSize = MIN_TEXT_BUFFER; tPtr->flags.enabled = 1; - + WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask - |FocusChangeMask, handleEvents, tPtr); + |FocusChangeMask, handleEvents, tPtr); tPtr->font = WMRetainFont(tPtr->view->screen->normalFont); tPtr->flags.bordered = DEFAULT_BORDERED; tPtr->flags.beveled = True; tPtr->flags.alignment = DEFAULT_ALIGNMENT; - tPtr->offsetWidth = - WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1); + tPtr->offsetWidth = + WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1); W_ResizeView(tPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT); WMCreateEventHandler(tPtr->view, EnterWindowMask|LeaveWindowMask - |ButtonReleaseMask|ButtonPressMask|KeyPressMask|Button1MotionMask, - handleTextFieldActionEvents, tPtr); + |ButtonReleaseMask|ButtonPressMask|KeyPressMask|Button1MotionMask, + handleTextFieldActionEvents, tPtr); WMAddNotificationObserver(selectionNotification, tPtr->view, WMSelectionOwnerDidChangeNotification, @@ -375,7 +375,7 @@ void WMSetTextFieldDelegate(WMTextField *tPtr, WMTextFieldDelegate *delegate) { CHECK_CLASS(tPtr, WC_TextField); - + tPtr->delegate = delegate; } @@ -393,42 +393,42 @@ void WMInsertTextFieldText(WMTextField *tPtr, char *text, int position) { int len; - + CHECK_CLASS(tPtr, WC_TextField); - + if (!text) - return; - + return; + len = strlen(text); /* check if buffer will hold the text */ if (len + tPtr->textLen >= tPtr->bufferSize) { - tPtr->bufferSize = tPtr->textLen + len + TEXT_BUFFER_INCR; - tPtr->text = wrealloc(tPtr->text, tPtr->bufferSize); + tPtr->bufferSize = tPtr->textLen + len + TEXT_BUFFER_INCR; + tPtr->text = wrealloc(tPtr->text, tPtr->bufferSize); } - + if (position < 0 || position >= tPtr->textLen) { - /* append the text at the end */ - strcat(tPtr->text, text); - - incrToFit(tPtr); + /* append the text at the end */ + strcat(tPtr->text, text); + + incrToFit(tPtr); - tPtr->textLen += len; - tPtr->cursorPosition += len; + tPtr->textLen += len; + tPtr->cursorPosition += len; } else { - /* insert text at position */ - memmv(&(tPtr->text[position+len]), &(tPtr->text[position]), - tPtr->textLen-position+1); - - memcpy(&(tPtr->text[position]), text, len); - - tPtr->textLen += len; - if (position >= tPtr->cursorPosition) { - tPtr->cursorPosition += len; - incrToFit2(tPtr); - } else { - incrToFit(tPtr); - } + /* insert text at position */ + memmv(&(tPtr->text[position+len]), &(tPtr->text[position]), + tPtr->textLen-position+1); + + memcpy(&(tPtr->text[position]), text, len); + + tPtr->textLen += len; + if (position >= tPtr->cursorPosition) { + tPtr->cursorPosition += len; + incrToFit2(tPtr); + } else { + incrToFit(tPtr); + } } paintTextField(tPtr); @@ -442,19 +442,19 @@ WMDeleteTextFieldRange(WMTextField *tPtr, WMRange range) normalizeRange(tPtr, &range); if (!range.count) - return; - + return; + memmv(&(tPtr->text[range.position]), &(tPtr->text[range.position+range.count]), - tPtr->textLen - (range.position+range.count) + 1); + tPtr->textLen - (range.position+range.count) + 1); tPtr->textLen -= range.count; /* try to keep cursorPosition at the same place */ tPtr->viewPosition -= range.count; if (tPtr->viewPosition < 0) - tPtr->viewPosition = 0; + tPtr->viewPosition = 0; tPtr->cursorPosition = range.position; - + decrToFit(tPtr); paintTextField(tPtr); @@ -466,7 +466,7 @@ char* WMGetTextFieldText(WMTextField *tPtr) { CHECK_CLASS(tPtr, WC_TextField); - + return wstrdup(tPtr->text); } @@ -475,30 +475,30 @@ void WMSetTextFieldText(WMTextField *tPtr, char *text) { CHECK_CLASS(tPtr, WC_TextField); - + if ((text && strcmp(tPtr->text, text) == 0) || (!text && tPtr->textLen == 0)) return; if (text==NULL) { - tPtr->text[0] = 0; - tPtr->textLen = 0; + tPtr->text[0] = 0; + tPtr->textLen = 0; } else { - tPtr->textLen = strlen(text); - - if (tPtr->textLen >= tPtr->bufferSize) { - tPtr->bufferSize = tPtr->textLen + TEXT_BUFFER_INCR; - tPtr->text = wrealloc(tPtr->text, tPtr->bufferSize); - } - strcpy(tPtr->text, text); + tPtr->textLen = strlen(text); + + if (tPtr->textLen >= tPtr->bufferSize) { + tPtr->bufferSize = tPtr->textLen + TEXT_BUFFER_INCR; + tPtr->text = wrealloc(tPtr->text, tPtr->bufferSize); + } + strcpy(tPtr->text, text); } tPtr->cursorPosition = tPtr->selection.position = tPtr->textLen; tPtr->viewPosition = 0; tPtr->selection.count = 0; - + if (tPtr->view->flags.realized) - paintTextField(tPtr); + paintTextField(tPtr); } @@ -506,16 +506,16 @@ void WMSetTextFieldAlignment(WMTextField *tPtr, WMAlignment alignment) { CHECK_CLASS(tPtr, WC_TextField); - + tPtr->flags.alignment = alignment; - + if (alignment!=WALeft) { - wwarning("only left alignment is supported in textfields"); - return; + wwarning("only left alignment is supported in textfields"); + return; } - + if (tPtr->view->flags.realized) { - paintTextField(tPtr); + paintTextField(tPtr); } } @@ -524,11 +524,11 @@ void WMSetTextFieldBordered(WMTextField *tPtr, Bool bordered) { CHECK_CLASS(tPtr, WC_TextField); - + tPtr->flags.bordered = bordered; if (tPtr->view->flags.realized) { - paintTextField(tPtr); + paintTextField(tPtr); } } @@ -537,11 +537,11 @@ void WMSetTextFieldBeveled(WMTextField *tPtr, Bool flag) { CHECK_CLASS(tPtr, WC_TextField); - + tPtr->flags.beveled = ((flag==0) ? 0 : 1); if (tPtr->view->flags.realized) { - paintTextField(tPtr); + paintTextField(tPtr); } } @@ -551,12 +551,12 @@ void WMSetTextFieldSecure(WMTextField *tPtr, Bool flag) { CHECK_CLASS(tPtr, WC_TextField); - + tPtr->flags.secure = ((flag==0) ? 0 : 1); - + if (tPtr->view->flags.realized) { - paintTextField(tPtr); - } + paintTextField(tPtr); + } } @@ -564,7 +564,7 @@ Bool WMGetTextFieldEditable(WMTextField *tPtr) { CHECK_CLASS(tPtr, WC_TextField); - + return tPtr->flags.enabled; } @@ -573,11 +573,11 @@ void WMSetTextFieldEditable(WMTextField *tPtr, Bool flag) { CHECK_CLASS(tPtr, WC_TextField); - + tPtr->flags.enabled = ((flag==0) ? 0 : 1); - + if (tPtr->view->flags.realized) { - paintTextField(tPtr); + paintTextField(tPtr); } } @@ -586,9 +586,9 @@ void WMSelectTextFieldRange(WMTextField *tPtr, WMRange range) { CHECK_CLASS(tPtr, WC_TextField); - + if (tPtr->flags.enabled) { - normalizeRange(tPtr, &range); + normalizeRange(tPtr, &range); tPtr->selection = range; @@ -605,7 +605,7 @@ void WMSetTextFieldCursorPosition(WMTextField *tPtr, unsigned int position) { CHECK_CLASS(tPtr, WC_TextField); - + if (tPtr->flags.enabled) { if (position > tPtr->textLen) position = tPtr->textLen; @@ -664,20 +664,20 @@ WMSetTextFieldPrevTextField(WMTextField *tPtr, WMTextField *prev) } -void +void WMSetTextFieldFont(WMTextField *tPtr, WMFont *font) { CHECK_CLASS(tPtr, WC_TextField); - + if (tPtr->font) - WMReleaseFont(tPtr->font); + WMReleaseFont(tPtr->font); tPtr->font = WMRetainFont(font); - - tPtr->offsetWidth = - WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1); + + tPtr->offsetWidth = + WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1); if (tPtr->view->flags.realized) { - paintTextField(tPtr); + paintTextField(tPtr); } } @@ -690,13 +690,13 @@ WMGetTextFieldFont(WMTextField *tPtr) } -static void +static void didResizeTextField(W_ViewDelegate *self, WMView *view) { WMTextField *tPtr = (WMTextField*)view->self; - tPtr->offsetWidth = - WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1); + tPtr->offsetWidth = + WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1); tPtr->usableWidth = tPtr->view->size.width - 2*tPtr->offsetWidth /*+ 2*/; } @@ -728,39 +728,39 @@ paintCursor(TextField *tPtr) text = tPtr->text; cx = WMWidthOfString(tPtr->font, &(text[tPtr->viewPosition]), - tPtr->cursorPosition-tPtr->viewPosition); + tPtr->cursorPosition-tPtr->viewPosition); switch (tPtr->flags.alignment) { - case WARight: - textWidth = WMWidthOfString(tPtr->font, text, tPtr->textLen); - if (textWidth < tPtr->usableWidth) - cx += tPtr->offsetWidth + tPtr->usableWidth - textWidth + 1; - else - cx += tPtr->offsetWidth + 1; - break; - case WALeft: - cx += tPtr->offsetWidth + 1; - break; - case WAJustified: - /* not supported */ - case WACenter: - textWidth = WMWidthOfString(tPtr->font, text, tPtr->textLen); - if (textWidth < tPtr->usableWidth) - cx += tPtr->offsetWidth + (tPtr->usableWidth-textWidth)/2; - else - cx += tPtr->offsetWidth; - break; + case WARight: + textWidth = WMWidthOfString(tPtr->font, text, tPtr->textLen); + if (textWidth < tPtr->usableWidth) + cx += tPtr->offsetWidth + tPtr->usableWidth - textWidth + 1; + else + cx += tPtr->offsetWidth + 1; + break; + case WALeft: + cx += tPtr->offsetWidth + 1; + break; + case WAJustified: + /* not supported */ + case WACenter: + textWidth = WMWidthOfString(tPtr->font, text, tPtr->textLen); + if (textWidth < tPtr->usableWidth) + cx += tPtr->offsetWidth + (tPtr->usableWidth-textWidth)/2; + else + cx += tPtr->offsetWidth; + break; } /* - XDrawRectangle(screen->display, tPtr->view->window, screen->xorGC, - cx, tPtr->offsetWidth, 1, - tPtr->view->size.height - 2*tPtr->offsetWidth - 1); - printf("%d %d\n",cx,tPtr->cursorPosition); + XDrawRectangle(screen->display, tPtr->view->window, screen->xorGC, + cx, tPtr->offsetWidth, 1, + tPtr->view->size.height - 2*tPtr->offsetWidth - 1); + printf("%d %d\n",cx,tPtr->cursorPosition); */ XDrawLine(screen->display, tPtr->view->window, screen->xorGC, - cx, tPtr->offsetWidth, cx, - tPtr->view->size.height - tPtr->offsetWidth - 1); + cx, tPtr->offsetWidth, cx, + tPtr->view->size.height - tPtr->offsetWidth - 1); if (tPtr->flags.secure) wfree(text); @@ -778,13 +778,13 @@ drawRelief(WMView *view, Bool beveled) GC dgc; int width = view->size.width; int height = view->size.height; - + dgc = WMColorGC(scr->darkGray); if (!beveled) { - XDrawRectangle(dpy, view->window, dgc, 0, 0, width-1, height-1); + XDrawRectangle(dpy, view->window, dgc, 0, 0, width-1, height-1); - return; + return; } wgc = WMColorGC(scr->white); lgc = WMColorGC(scr->gray); @@ -792,10 +792,10 @@ drawRelief(WMView *view, Bool beveled) /* top left */ XDrawLine(dpy, view->window, dgc, 0, 0, width-1, 0); XDrawLine(dpy, view->window, dgc, 0, 1, width-2, 1); - + XDrawLine(dpy, view->window, dgc, 0, 0, 0, height-2); XDrawLine(dpy, view->window, dgc, 1, 0, 1, height-3); - + /* bottom right */ XDrawLine(dpy, view->window, wgc, 0, height-1, width-1, height-1); XDrawLine(dpy, view->window, lgc, 1, height-2, width-2, height-2); @@ -821,12 +821,12 @@ paintTextField(TextField *tPtr) if (!view->flags.realized || !view->flags.mapped) - return; + return; if (!tPtr->flags.bordered) { - bd = 0; + bd = 0; } else { - bd = 2; + bd = 2; } if (tPtr->flags.secure) { @@ -838,9 +838,9 @@ paintTextField(TextField *tPtr) totalWidth = tPtr->view->size.width - 2*bd; drawbuffer = XCreatePixmap(screen->display, view->window, - view->size.width, view->size.height, screen->depth); + view->size.width, view->size.height, screen->depth); XFillRectangle(screen->display, drawbuffer, WMColorGC(screen->white), - 0,0, view->size.width,view->size.height); + 0,0, view->size.width,view->size.height); /* this is quite dirty */ viewbuffer.screen = view->screen; viewbuffer.size = view->size; @@ -848,36 +848,36 @@ paintTextField(TextField *tPtr) if (tPtr->textLen > 0) { - tw = WMWidthOfString(tPtr->font, &(text[tPtr->viewPosition]), - tPtr->textLen - tPtr->viewPosition); - - th = WMFontHeight(tPtr->font); - - ty = tPtr->offsetWidth; - switch (tPtr->flags.alignment) { - case WALeft: - tx = tPtr->offsetWidth + 1; - if (tw < tPtr->usableWidth) - XFillRectangle(screen->display, drawbuffer, - WMColorGC(screen->white), - bd+tw,bd, totalWidth-tw,view->size.height-2*bd); - break; - - case WACenter: - tx = tPtr->offsetWidth + (tPtr->usableWidth - tw) / 2; - if (tw < tPtr->usableWidth) - XClearArea(screen->display, view->window, bd, bd, - totalWidth, view->size.height-2*bd, False); - break; - - default: - case WARight: - tx = tPtr->offsetWidth + tPtr->usableWidth - tw - 1; - if (tw < tPtr->usableWidth) - XClearArea(screen->display, view->window, bd, bd, - totalWidth-tw, view->size.height-2*bd, False); - break; - } + tw = WMWidthOfString(tPtr->font, &(text[tPtr->viewPosition]), + tPtr->textLen - tPtr->viewPosition); + + th = WMFontHeight(tPtr->font); + + ty = tPtr->offsetWidth; + switch (tPtr->flags.alignment) { + case WALeft: + tx = tPtr->offsetWidth + 1; + if (tw < tPtr->usableWidth) + XFillRectangle(screen->display, drawbuffer, + WMColorGC(screen->white), + bd+tw,bd, totalWidth-tw,view->size.height-2*bd); + break; + + case WACenter: + tx = tPtr->offsetWidth + (tPtr->usableWidth - tw) / 2; + if (tw < tPtr->usableWidth) + XClearArea(screen->display, view->window, bd, bd, + totalWidth, view->size.height-2*bd, False); + break; + + default: + case WARight: + tx = tPtr->offsetWidth + tPtr->usableWidth - tw - 1; + if (tw < tPtr->usableWidth) + XClearArea(screen->display, view->window, bd, bd, + totalWidth-tw, view->size.height-2*bd, False); + break; + } color = tPtr->flags.enabled ? screen->black : screen->darkGray; @@ -916,8 +916,8 @@ paintTextField(TextField *tPtr) if (tPtr->flags.secure) wfree(text); XCopyArea(screen->display, drawbuffer, view->window, - screen->copyGC, 0,0, view->size.width, - view->size.height,0,0); + screen->copyGC, 0,0, view->size.width, + view->size.height,0,0); XFreePixmap(screen->display, drawbuffer); /* draw cursor */ @@ -932,13 +932,13 @@ static void blinkCursor(void *data) { TextField *tPtr = (TextField*)data; - + if (tPtr->flags.cursorOn) { - tPtr->timerID = WMAddTimerHandler(CURSOR_BLINK_OFF_DELAY, blinkCursor, - data); + tPtr->timerID = WMAddTimerHandler(CURSOR_BLINK_OFF_DELAY, blinkCursor, + data); } else { - tPtr->timerID = WMAddTimerHandler(CURSOR_BLINK_ON_DELAY, blinkCursor, - data); + tPtr->timerID = WMAddTimerHandler(CURSOR_BLINK_ON_DELAY, blinkCursor, + data); } paintCursor(tPtr); tPtr->flags.cursorOn = !tPtr->flags.cursorOn; @@ -955,47 +955,47 @@ handleEvents(XEvent *event, void *data) switch (event->type) { - case FocusIn: - if (W_FocusedViewOfToplevel(W_TopLevelOfView(tPtr->view))!=tPtr->view) - return; - tPtr->flags.focused = 1; + case FocusIn: + if (W_FocusedViewOfToplevel(W_TopLevelOfView(tPtr->view))!=tPtr->view) + return; + tPtr->flags.focused = 1; #if 0 - if (!tPtr->timerID) { - tPtr->timerID = WMAddTimerHandler(CURSOR_BLINK_ON_DELAY, - blinkCursor, tPtr); - } + if (!tPtr->timerID) { + tPtr->timerID = WMAddTimerHandler(CURSOR_BLINK_ON_DELAY, + blinkCursor, tPtr); + } #endif - paintTextField(tPtr); + paintTextField(tPtr); - NOTIFY(tPtr, didBeginEditing, WMTextDidBeginEditingNotification, NULL); + NOTIFY(tPtr, didBeginEditing, WMTextDidBeginEditingNotification, NULL); - tPtr->flags.notIllegalMovement = 0; - break; + tPtr->flags.notIllegalMovement = 0; + break; - case FocusOut: - tPtr->flags.focused = 0; + case FocusOut: + tPtr->flags.focused = 0; #if 0 - if (tPtr->timerID) - WMDeleteTimerHandler(tPtr->timerID); - tPtr->timerID = NULL; + if (tPtr->timerID) + WMDeleteTimerHandler(tPtr->timerID); + tPtr->timerID = NULL; #endif - paintTextField(tPtr); - if (!tPtr->flags.notIllegalMovement) { - NOTIFY(tPtr, didEndEditing, WMTextDidEndEditingNotification, - (void*)WMIllegalTextMovement); - } - break; - - case Expose: - if (event->xexpose.count!=0) - break; - paintTextField(tPtr); - break; - - case DestroyNotify: - destroyTextField(tPtr); - break; + paintTextField(tPtr); + if (!tPtr->flags.notIllegalMovement) { + NOTIFY(tPtr, didEndEditing, WMTextDidEndEditingNotification, + (void*)WMIllegalTextMovement); + } + break; + + case Expose: + if (event->xexpose.count!=0) + break; + paintTextField(tPtr); + break; + + case DestroyNotify: + destroyTextField(tPtr); + break; } } @@ -1015,7 +1015,7 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event) /*printf("(%d,%d) -> ", tPtr->selection.position, tPtr->selection.count);*/ if (((XKeyEvent *) event)->state & WM_EMACSKEYMASK) - control_pressed = 1; + control_pressed = 1; shifted = (event->xkey.state & ShiftMask ? True : False); controled = (event->xkey.state & ControlMask ? True : False); @@ -1025,62 +1025,62 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event) buffer[count] = '\0'; switch (ksym) { - case XK_Tab: + case XK_Tab: #ifdef XK_ISO_Left_Tab - case XK_ISO_Left_Tab: + case XK_ISO_Left_Tab: #endif - if (!controled) { - if (shifted) { - if (tPtr->view->prevFocusChain) { - W_SetFocusOfTopLevel(W_TopLevelOfView(tPtr->view), - tPtr->view->prevFocusChain); + if (!controled) { + if (shifted) { + if (tPtr->view->prevFocusChain) { + W_SetFocusOfTopLevel(W_TopLevelOfView(tPtr->view), + tPtr->view->prevFocusChain); tPtr->flags.notIllegalMovement = 1; - } - data = (void*)WMBacktabTextMovement; - } else { - if (tPtr->view->nextFocusChain) { - W_SetFocusOfTopLevel(W_TopLevelOfView(tPtr->view), - tPtr->view->nextFocusChain); + } + data = (void*)WMBacktabTextMovement; + } else { + if (tPtr->view->nextFocusChain) { + W_SetFocusOfTopLevel(W_TopLevelOfView(tPtr->view), + tPtr->view->nextFocusChain); tPtr->flags.notIllegalMovement = 1; - } - data = (void*)WMTabTextMovement; - } - textEvent = WMTextDidEndEditingNotification; + } + data = (void*)WMTabTextMovement; + } + textEvent = WMTextDidEndEditingNotification; cancelSelection = 0; - relay = False; - } - break; - - case XK_Escape: - if (!modified) { - data = (void*)WMEscapeTextMovement; - textEvent = WMTextDidEndEditingNotification; - - relay = False; - } - break; - - case XK_Return: - if (!modified) { - data = (void*)WMReturnTextMovement; - textEvent = WMTextDidEndEditingNotification; - - relay = False; - } - break; - - case WM_EMACSKEY_LEFT: - if (!control_pressed) - goto normal_key; - else + relay = False; + } + break; + + case XK_Escape: + if (!modified) { + data = (void*)WMEscapeTextMovement; + textEvent = WMTextDidEndEditingNotification; + + relay = False; + } + break; + + case XK_Return: + if (!modified) { + data = (void*)WMReturnTextMovement; + textEvent = WMTextDidEndEditingNotification; + + relay = False; + } + break; + + case WM_EMACSKEY_LEFT: + if (!control_pressed) + goto normal_key; + else controled = False; #ifdef XK_KP_Left - case XK_KP_Left: + case XK_KP_Left: #endif - case XK_Left: + case XK_Left: if (tPtr->cursorPosition > 0) { paintCursor(tPtr); if (controled) { @@ -1104,13 +1104,13 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event) relay = False; - break; + break; case WM_EMACSKEY_RIGHT: if (!control_pressed) goto normal_key; else - controled = False; + controled = False; #ifdef XK_KP_Right case XK_KP_Right: @@ -1143,8 +1143,8 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event) relay = False; - break; - + break; + case WM_EMACSKEY_HOME: if (!control_pressed) goto normal_key; @@ -1155,23 +1155,23 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event) case XK_KP_Home: #endif case XK_Home: - if (!controled) { - if (tPtr->cursorPosition > 0) { - paintCursor(tPtr); - tPtr->cursorPosition = 0; - if (tPtr->viewPosition > 0) { - tPtr->viewPosition = 0; - refresh = 1; - } else - paintCursor(tPtr); - } - if (shifted) - cancelSelection = 0; - - relay = False; - } - break; - + if (!controled) { + if (tPtr->cursorPosition > 0) { + paintCursor(tPtr); + tPtr->cursorPosition = 0; + if (tPtr->viewPosition > 0) { + tPtr->viewPosition = 0; + refresh = 1; + } else + paintCursor(tPtr); + } + if (shifted) + cancelSelection = 0; + + relay = False; + } + break; + case WM_EMACSKEY_END: if (!control_pressed) goto normal_key; @@ -1182,100 +1182,100 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event) case XK_KP_End: #endif case XK_End: - if (!controled) { - if (tPtr->cursorPosition < tPtr->textLen) { - paintCursor(tPtr); - tPtr->cursorPosition = tPtr->textLen; - tPtr->viewPosition = 0; - while (WMWidthOfString(tPtr->font, - &(tPtr->text[tPtr->viewPosition]), - tPtr->textLen-tPtr->viewPosition) - > tPtr->usableWidth) { - tPtr->viewPosition++; - refresh = 1; - } - if (!refresh) - paintCursor(tPtr); - } - if (shifted) - cancelSelection = 0; - - relay = False; - } - break; - - case WM_EMACSKEY_BS: - if (!control_pressed) - goto normal_key; - else - modified = False; - - case XK_BackSpace: - if (!modified) { - if (tPtr->selection.count) { - WMDeleteTextFieldRange(tPtr, tPtr->selection); - data = (void*)WMDeleteTextEvent; - textEvent = WMTextDidChangeNotification; - } else if (tPtr->cursorPosition > 0) { - WMRange range; - range.position = tPtr->cursorPosition - 1; - range.count = 1; - WMDeleteTextFieldRange(tPtr, range); - data = (void*)WMDeleteTextEvent; - textEvent = WMTextDidChangeNotification; - } - - relay = False; - } - break; - + if (!controled) { + if (tPtr->cursorPosition < tPtr->textLen) { + paintCursor(tPtr); + tPtr->cursorPosition = tPtr->textLen; + tPtr->viewPosition = 0; + while (WMWidthOfString(tPtr->font, + &(tPtr->text[tPtr->viewPosition]), + tPtr->textLen-tPtr->viewPosition) + > tPtr->usableWidth) { + tPtr->viewPosition++; + refresh = 1; + } + if (!refresh) + paintCursor(tPtr); + } + if (shifted) + cancelSelection = 0; + + relay = False; + } + break; + + case WM_EMACSKEY_BS: + if (!control_pressed) + goto normal_key; + else + modified = False; + + case XK_BackSpace: + if (!modified) { + if (tPtr->selection.count) { + WMDeleteTextFieldRange(tPtr, tPtr->selection); + data = (void*)WMDeleteTextEvent; + textEvent = WMTextDidChangeNotification; + } else if (tPtr->cursorPosition > 0) { + WMRange range; + range.position = tPtr->cursorPosition - 1; + range.count = 1; + WMDeleteTextFieldRange(tPtr, range); + data = (void*)WMDeleteTextEvent; + textEvent = WMTextDidChangeNotification; + } + + relay = False; + } + break; + case WM_EMACSKEY_DEL: if (!control_pressed) goto normal_key; - else + else modified = False; #ifdef XK_KP_Delete case XK_KP_Delete: #endif case XK_Delete: - if (!modified) { - if (tPtr->selection.count) { - WMDeleteTextFieldRange(tPtr, tPtr->selection); - data = (void*)WMDeleteTextEvent; - textEvent = WMTextDidChangeNotification; - } else if (tPtr->cursorPosition < tPtr->textLen) { - WMRange range; - range.position = tPtr->cursorPosition; - range.count = 1; - WMDeleteTextFieldRange(tPtr, range); - data = (void*)WMDeleteTextEvent; - textEvent = WMTextDidChangeNotification; - } - - relay = False; + if (!modified) { + if (tPtr->selection.count) { + WMDeleteTextFieldRange(tPtr, tPtr->selection); + data = (void*)WMDeleteTextEvent; + textEvent = WMTextDidChangeNotification; + } else if (tPtr->cursorPosition < tPtr->textLen) { + WMRange range; + range.position = tPtr->cursorPosition; + range.count = 1; + WMDeleteTextFieldRange(tPtr, range); + data = (void*)WMDeleteTextEvent; + textEvent = WMTextDidChangeNotification; + } + + relay = False; } - break; + break; normal_key: - default: - if (!controled) { - if (count > 0 && !iscntrl(buffer[0])) { - if (tPtr->selection.count) - WMDeleteTextFieldRange(tPtr, tPtr->selection); - WMInsertTextFieldText(tPtr, buffer, tPtr->cursorPosition); - data = (void*)WMInsertTextEvent; - textEvent = WMTextDidChangeNotification; - - relay = False; - } + default: + if (!controled) { + if (count > 0 && !iscntrl(buffer[0])) { + if (tPtr->selection.count) + WMDeleteTextFieldRange(tPtr, tPtr->selection); + WMInsertTextFieldText(tPtr, buffer, tPtr->cursorPosition); + data = (void*)WMInsertTextEvent; + textEvent = WMTextDidChangeNotification; + + relay = False; + } } - break; + break; } if (relay) { - WMRelayToNextResponder(W_VIEW(tPtr), event); - return; + WMRelayToNextResponder(W_VIEW(tPtr), event); + return; } /* Do not allow text selection in secure text fields */ @@ -1320,7 +1320,7 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event) } if (refresh) - paintTextField(tPtr); + paintTextField(tPtr); /*printf("(%d,%d)\n", tPtr->selection.position, tPtr->selection.count);*/ } @@ -1333,25 +1333,25 @@ pointToCursorPosition(TextField *tPtr, int x) int tw; if (tPtr->flags.bordered) - x -= 2; + x -= 2; - if (WMWidthOfString(tPtr->font, &(tPtr->text[tPtr->viewPosition]), - tPtr->textLen - tPtr->viewPosition) < x) - return tPtr->textLen; + if (WMWidthOfString(tPtr->font, &(tPtr->text[tPtr->viewPosition]), + tPtr->textLen - tPtr->viewPosition) < x) + return tPtr->textLen; a = tPtr->viewPosition; b = tPtr->textLen; while (a < b && b-a>1) { - mid = (a+b)/2; - tw = WMWidthOfString(tPtr->font, &(tPtr->text[tPtr->viewPosition]), - mid - tPtr->viewPosition); - if (tw > x) - b = mid; - else if (tw < x) - a = mid; - else - return mid; + mid = (a+b)/2; + tw = WMWidthOfString(tPtr->font, &(tPtr->text[tPtr->viewPosition]), + mid - tPtr->viewPosition); + if (tw > x) + b = mid; + else if (tw < x) + a = mid; + else + return mid; } return (a+b)/2; @@ -1359,33 +1359,33 @@ pointToCursorPosition(TextField *tPtr, int x) -static void -pasteText(WMView *view, Atom selection, Atom target, Time timestamp, - void *cdata, WMData *data) +static void +pasteText(WMView *view, Atom selection, Atom target, Time timestamp, + void *cdata, WMData *data) { TextField *tPtr = (TextField*)view->self; char *str; - + tPtr->flags.waitingSelection = 0; if (data != NULL) { - str = (char*)WMDataBytes(data); + str = (char*)WMDataBytes(data); - WMInsertTextFieldText(tPtr, str, tPtr->cursorPosition); - NOTIFY(tPtr, didChange, WMTextDidChangeNotification, - (void*)WMInsertTextEvent); + WMInsertTextFieldText(tPtr, str, tPtr->cursorPosition); + NOTIFY(tPtr, didChange, WMTextDidChangeNotification, + (void*)WMInsertTextEvent); } else { - int n; - - str = XFetchBuffer(tPtr->view->screen->display, &n, 0); - - if (str != NULL) { - str[n] = 0; - WMInsertTextFieldText(tPtr, str, tPtr->cursorPosition); - XFree(str); - NOTIFY(tPtr, didChange, WMTextDidChangeNotification, - (void*)WMInsertTextEvent); - } + int n; + + str = XFetchBuffer(tPtr->view->screen->display, &n, 0); + + if (str != NULL) { + str[n] = 0; + WMInsertTextFieldText(tPtr, str, tPtr->cursorPosition); + XFree(str); + NOTIFY(tPtr, didChange, WMTextDidChangeNotification, + (void*)WMInsertTextEvent); + } } } @@ -1396,52 +1396,52 @@ handleTextFieldActionEvents(XEvent *event, void *data) TextField *tPtr = (TextField*)data; static int move = 0; static Time lastButtonReleasedEvent = 0; - static Time lastButtonReleasedEvent2 = 0; + static Time lastButtonReleasedEvent2 = 0; Display *dpy = event->xany.display; - + CHECK_CLASS(data, WC_TextField); switch (event->type) { - case KeyPress: - if (tPtr->flags.waitingSelection) { - return; - } + case KeyPress: + if (tPtr->flags.waitingSelection) { + return; + } if (tPtr->flags.enabled && tPtr->flags.focused) { handleTextFieldKeyPress(tPtr, event); - XDefineCursor(dpy, W_VIEW(tPtr)->window, - W_VIEW(tPtr)->screen->invisibleCursor); - tPtr->flags.pointerGrabbed = 1; - } + XDefineCursor(dpy, W_VIEW(tPtr)->window, + W_VIEW(tPtr)->screen->invisibleCursor); + tPtr->flags.pointerGrabbed = 1; + } break; - case MotionNotify: - - if (tPtr->flags.pointerGrabbed) { - tPtr->flags.pointerGrabbed = 0; - XDefineCursor(dpy, W_VIEW(tPtr)->window, - W_VIEW(tPtr)->screen->textCursor); - } - if (tPtr->flags.waitingSelection) { - return; - } + case MotionNotify: + + if (tPtr->flags.pointerGrabbed) { + tPtr->flags.pointerGrabbed = 0; + XDefineCursor(dpy, W_VIEW(tPtr)->window, + W_VIEW(tPtr)->screen->textCursor); + } + if (tPtr->flags.waitingSelection) { + return; + } if (tPtr->flags.enabled && (event->xmotion.state & Button1Mask)) { - if (tPtr->viewPosition < tPtr->textLen && event->xmotion.x > + if (tPtr->viewPosition < tPtr->textLen && event->xmotion.x > tPtr->usableWidth) { - if (WMWidthOfString(tPtr->font, - &(tPtr->text[tPtr->viewPosition]), - tPtr->cursorPosition-tPtr->viewPosition) + if (WMWidthOfString(tPtr->font, + &(tPtr->text[tPtr->viewPosition]), + tPtr->cursorPosition-tPtr->viewPosition) > tPtr->usableWidth) { - tPtr->viewPosition++; - } - } else if (tPtr->viewPosition > 0 && event->xmotion.x < 0) { - paintCursor(tPtr); - tPtr->viewPosition--; - } + tPtr->viewPosition++; + } + } else if (tPtr->viewPosition > 0 && event->xmotion.x < 0) { + paintCursor(tPtr); + tPtr->viewPosition--; + } - tPtr->cursorPosition = - pointToCursorPosition(tPtr, event->xmotion.x); + tPtr->cursorPosition = + pointToCursorPosition(tPtr, event->xmotion.x); /* Do not allow text selection in secure textfields */ if (tPtr->flags.secure) { @@ -1450,145 +1450,145 @@ handleTextFieldActionEvents(XEvent *event, void *data) tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position; - paintCursor(tPtr); - paintTextField(tPtr); + paintCursor(tPtr); + paintTextField(tPtr); - } - break; + } + break; - case ButtonPress: - if (tPtr->flags.pointerGrabbed) { - tPtr->flags.pointerGrabbed = 0; - XDefineCursor(dpy, W_VIEW(tPtr)->window, - W_VIEW(tPtr)->screen->textCursor); - break; - } - - if (tPtr->flags.waitingSelection) { - break; - } + case ButtonPress: + if (tPtr->flags.pointerGrabbed) { + tPtr->flags.pointerGrabbed = 0; + XDefineCursor(dpy, W_VIEW(tPtr)->window, + W_VIEW(tPtr)->screen->textCursor); + break; + } + + if (tPtr->flags.waitingSelection) { + break; + } move = 1; switch (tPtr->flags.alignment) { int textWidth; - case WARight: + case WARight: textWidth = WMWidthOfString(tPtr->font, tPtr->text, tPtr->textLen); if (tPtr->flags.enabled && !tPtr->flags.focused) { WMSetFocusToWidget(tPtr); } if (tPtr->flags.focused) { - tPtr->selection.position = tPtr->cursorPosition; + tPtr->selection.position = tPtr->cursorPosition; tPtr->selection.count = 0; } if (textWidth < tPtr->usableWidth) { - tPtr->cursorPosition = pointToCursorPosition(tPtr, - event->xbutton.x - tPtr->usableWidth - + textWidth); + tPtr->cursorPosition = pointToCursorPosition(tPtr, + event->xbutton.x - tPtr->usableWidth + + textWidth); } else tPtr->cursorPosition = pointToCursorPosition(tPtr, - event->xbutton.x); + event->xbutton.x); paintTextField(tPtr); break; - - case WALeft: + + case WALeft: if (tPtr->flags.enabled && !tPtr->flags.focused) { WMSetFocusToWidget(tPtr); } if (tPtr->flags.focused && event->xbutton.button == Button1) { - tPtr->cursorPosition = pointToCursorPosition(tPtr, - event->xbutton.x); - tPtr->selection.position = tPtr->cursorPosition; + tPtr->cursorPosition = pointToCursorPosition(tPtr, + event->xbutton.x); + tPtr->selection.position = tPtr->cursorPosition; tPtr->selection.count = 0; paintTextField(tPtr); } if (event->xbutton.button == Button2 && tPtr->flags.enabled) { char *text; - int n; - - if (!WMRequestSelection(tPtr->view, XA_PRIMARY, XA_STRING, - event->xbutton.time, - pasteText, NULL)) { - text = XFetchBuffer(tPtr->view->screen->display, &n, 0); - - if (text) { - text[n] = 0; - WMInsertTextFieldText(tPtr, text, tPtr->cursorPosition); - XFree(text); - NOTIFY(tPtr, didChange, WMTextDidChangeNotification, - (void*)WMInsertTextEvent); - } - } else { - tPtr->flags.waitingSelection = 1; - } + int n; + + if (!WMRequestSelection(tPtr->view, XA_PRIMARY, XA_STRING, + event->xbutton.time, + pasteText, NULL)) { + text = XFetchBuffer(tPtr->view->screen->display, &n, 0); + + if (text) { + text[n] = 0; + WMInsertTextFieldText(tPtr, text, tPtr->cursorPosition); + XFree(text); + NOTIFY(tPtr, didChange, WMTextDidChangeNotification, + (void*)WMInsertTextEvent); + } + } else { + tPtr->flags.waitingSelection = 1; + } } break; - default: - break; + default: + break; + } + break; + + case ButtonRelease: + if (tPtr->flags.pointerGrabbed) { + tPtr->flags.pointerGrabbed = 0; + XDefineCursor(dpy, W_VIEW(tPtr)->window, + W_VIEW(tPtr)->screen->textCursor); + } + if (tPtr->flags.waitingSelection) { + break; + } + + if (!tPtr->flags.secure && tPtr->selection.count!=0) { + int start, count; + XRotateBuffers(dpy, 1); + + count = abs(tPtr->selection.count); + if (tPtr->selection.count < 0) + start = tPtr->selection.position - count; + else + start = tPtr->selection.position; + + XStoreBuffer(dpy, &tPtr->text[start], count, 0); } - break; - - case ButtonRelease: - if (tPtr->flags.pointerGrabbed) { - tPtr->flags.pointerGrabbed = 0; - XDefineCursor(dpy, W_VIEW(tPtr)->window, - W_VIEW(tPtr)->screen->textCursor); - } - if (tPtr->flags.waitingSelection) { - break; - } - - if (!tPtr->flags.secure && tPtr->selection.count!=0) { - int start, count; - XRotateBuffers(dpy, 1); - - count = abs(tPtr->selection.count); - if (tPtr->selection.count < 0) - start = tPtr->selection.position - count; - else - start = tPtr->selection.position; - - XStoreBuffer(dpy, &tPtr->text[start], count, 0); - } - - move = 0; - + + move = 0; + if (!tPtr->flags.secure && event->xbutton.time - lastButtonReleasedEvent <= WINGsConfiguration.doubleClickDelay) { - if (event->xbutton.time - lastButtonReleasedEvent2 <= 2*WINGsConfiguration.doubleClickDelay) { - tPtr->selection.position = 0; - tPtr->selection.count = tPtr->textLen; - } else { - int pos, cnt; - char *txt; - pos = tPtr->selection.position; - cnt = tPtr->selection.count; - txt = tPtr->text; - while(pos >= 0) { - if (txt[pos] == ' ' || txt[pos] == '\t') break; - pos--; - } - pos++; - - while(pos + cnt < tPtr->textLen) { - if (txt[pos + cnt] == ' ' || txt[pos + cnt] == '\t') - break; - cnt++; - } - tPtr->selection.position = pos; - tPtr->selection.count = cnt; - } + if (event->xbutton.time - lastButtonReleasedEvent2 <= 2*WINGsConfiguration.doubleClickDelay) { + tPtr->selection.position = 0; + tPtr->selection.count = tPtr->textLen; + } else { + int pos, cnt; + char *txt; + pos = tPtr->selection.position; + cnt = tPtr->selection.count; + txt = tPtr->text; + while(pos >= 0) { + if (txt[pos] == ' ' || txt[pos] == '\t') break; + pos--; + } + pos++; + + while(pos + cnt < tPtr->textLen) { + if (txt[pos + cnt] == ' ' || txt[pos + cnt] == '\t') + break; + cnt++; + } + tPtr->selection.position = pos; + tPtr->selection.count = cnt; + } paintTextField(tPtr); - - if (!tPtr->flags.ownsSelection) { + + if (!tPtr->flags.ownsSelection) { tPtr->flags.ownsSelection = WMCreateSelectionHandler(tPtr->view, XA_PRIMARY, event->xbutton.time, &selectionHandler, NULL); } - } else if (!tPtr->flags.secure && tPtr->selection.count!=0 && + } else if (!tPtr->flags.secure && tPtr->selection.count!=0 && !tPtr->flags.ownsSelection) { tPtr->flags.ownsSelection = WMCreateSelectionHandler(tPtr->view, @@ -1597,9 +1597,9 @@ handleTextFieldActionEvents(XEvent *event, void *data) &selectionHandler, NULL); } - lastButtonReleasedEvent2 = lastButtonReleasedEvent; - lastButtonReleasedEvent = event->xbutton.time; - + lastButtonReleasedEvent2 = lastButtonReleasedEvent; + lastButtonReleasedEvent = event->xbutton.time; + break; } } @@ -1610,7 +1610,7 @@ destroyTextField(TextField *tPtr) { #if 0 if (tPtr->timerID) - WMDeleteTimerHandler(tPtr->timerID); + WMDeleteTimerHandler(tPtr->timerID); #endif WMReleaseFont(tPtr->font); @@ -1619,7 +1619,7 @@ destroyTextField(TextField *tPtr) WMRemoveNotificationObserver(tPtr); if (tPtr->text) - wfree(tPtr->text); + wfree(tPtr->text); wfree(tPtr); } diff --git a/WINGs/wwindow.c b/WINGs/wwindow.c index fcfb56a9..01a78562 100644 --- a/WINGs/wwindow.c +++ b/WINGs/wwindow.c @@ -9,11 +9,11 @@ typedef struct W_Window { W_Class widgetClass; W_View *view; - + struct W_Window *nextPtr; /* next in the window list */ struct W_Window *owner; - + char *title; WMPixmap *miniImage; /* miniwindow */ @@ -33,17 +33,17 @@ typedef struct W_Window { WMAction *closeAction; void *closeData; - + int level; struct { - unsigned style:4; - unsigned configured:1; - unsigned documentEdited:1; + unsigned style:4; + unsigned configured:1; + unsigned documentEdited:1; unsigned setUPos:1; unsigned setPPos:1; - unsigned setAspect:1; + unsigned setAspect:1; } flags; } _Window; @@ -82,10 +82,10 @@ static void willResizeWindow(W_ViewDelegate *, WMView *, unsigned*, unsigned*); struct W_ViewDelegate _WindowViewDelegate = { NULL, - NULL, - NULL, - NULL, - willResizeWindow + NULL, + NULL, + NULL, + willResizeWindow }; @@ -100,7 +100,7 @@ static void handleEvents(); static void realizeWindow(); -static void +static void realizeObserver(void *self, WMNotification *not) { realizeWindow(self); @@ -111,7 +111,7 @@ WMWindow* WMCreatePanelWithStyleForWindow(WMWindow *owner, char *name, int style) { WMWindow *win; - + win = WMCreateWindowWithStyle(owner->view->screen, name, style); win->owner = owner; @@ -122,11 +122,11 @@ WMCreatePanelWithStyleForWindow(WMWindow *owner, char *name, int style) WMWindow* WMCreatePanelForWindow(WMWindow *owner, char *name) -{ - return WMCreatePanelWithStyleForWindow(owner, name, - WMTitledWindowMask - |WMClosableWindowMask - |WMResizableWindowMask); +{ + return WMCreatePanelWithStyleForWindow(owner, name, + WMTitledWindowMask + |WMClosableWindowMask + |WMResizableWindowMask); } @@ -134,10 +134,10 @@ void WMChangePanelOwner(WMWindow *win, WMWindow *newOwner) { win->owner = newOwner; - + if (win->view->flags.realized && newOwner) { - XSetTransientForHint(win->view->screen->display, win->view->window, - newOwner->view->window); + XSetTransientForHint(win->view->screen->display, win->view->window, + newOwner->view->window); } } @@ -147,9 +147,9 @@ WMWindow* WMCreateWindow(WMScreen *screen, char *name) { return WMCreateWindowWithStyle(screen, name, WMTitledWindowMask - |WMClosableWindowMask - |WMMiniaturizableWindowMask - |WMResizableWindowMask); + |WMClosableWindowMask + |WMMiniaturizableWindowMask + |WMResizableWindowMask); } @@ -166,8 +166,8 @@ WMCreateWindowWithStyle(WMScreen *screen, char *name, int style) win->view = W_CreateTopView(screen); if (!win->view) { - wfree(win); - return NULL; + wfree(win); + return NULL; } win->view->self = win; @@ -180,13 +180,13 @@ WMCreateWindowWithStyle(WMScreen *screen, char *name, int style) screen->windowList = win; WMCreateEventHandler(win->view, ExposureMask|StructureNotifyMask - |ClientMessageMask|FocusChangeMask, - handleEvents, win); + |ClientMessageMask|FocusChangeMask, + handleEvents, win); W_ResizeView(win->view, DEFAULT_WIDTH, DEFAULT_HEIGHT); WMAddNotificationObserver(realizeObserver, win, - WMViewRealizedNotification, win->view); + WMViewRealizedNotification, win->view); win->flags.style = style; @@ -206,24 +206,24 @@ WMSetWindowTitle(WMWindow *win, char *title) int result; if (win->title!=NULL) - wfree(win->title); + wfree(win->title); if (title!=NULL) - win->title = wstrdup(title); + win->title = wstrdup(title); else - win->title = NULL; + win->title = NULL; if (win->view->flags.realized) { - result = XmbTextListToTextProperty (win->view->screen->display, - &title, 1, XStdICCTextStyle, - &property); - if (result == XNoMemory || result == XLocaleNotSupported) { - wwarning("window title conversion error... using STRING encoding"); - XStoreName(win->view->screen->display, win->view->window, title); - } else { - XSetWMName(win->view->screen->display, win->view->window, &property); - if (property.value) - XFree(property.value); - } + result = XmbTextListToTextProperty (win->view->screen->display, + &title, 1, XStdICCTextStyle, + &property); + if (result == XNoMemory || result == XLocaleNotSupported) { + wwarning("window title conversion error... using STRING encoding"); + XStoreName(win->view->screen->display, win->view->window, title); + } else { + XSetWMName(win->view->screen->display, win->view->window, &property); + if (property.value) + XFree(property.value); + } } } @@ -239,64 +239,64 @@ WMSetWindowCloseAction(WMWindow *win, WMAction *action, void *clientData) WMScreen *scr = win->view->screen; if (win->view->flags.realized) { - if (action && !win->closeAction) { - if (!XGetWMProtocols(scr->display, win->view->window, &atoms, - &count)) { - count = 0; - } - newAtoms = wmalloc((count+1)*sizeof(Atom)); - if (count > 0) - memcpy(newAtoms, atoms, count*sizeof(Atom)); - newAtoms[count++] = scr->deleteWindowAtom; - XSetWMProtocols(scr->display, win->view->window, newAtoms, count); - if (atoms) - XFree(atoms); - wfree(newAtoms); - } else if (!action && win->closeAction) { - int i, ncount; - - if (XGetWMProtocols(scr->display, win->view->window, &atoms, - &count) && count>0) { - newAtoms = wmalloc((count-1)*sizeof(Atom)); - ncount = 0; - for (i=0; i < count; i++) { - if (atoms[i]!=scr->deleteWindowAtom) { - newAtoms[i] = atoms[i]; - ncount++; - } - } - XSetWMProtocols(scr->display, win->view->window, newAtoms, - ncount); - if (atoms) - XFree(atoms); - wfree(newAtoms); - } - } + if (action && !win->closeAction) { + if (!XGetWMProtocols(scr->display, win->view->window, &atoms, + &count)) { + count = 0; + } + newAtoms = wmalloc((count+1)*sizeof(Atom)); + if (count > 0) + memcpy(newAtoms, atoms, count*sizeof(Atom)); + newAtoms[count++] = scr->deleteWindowAtom; + XSetWMProtocols(scr->display, win->view->window, newAtoms, count); + if (atoms) + XFree(atoms); + wfree(newAtoms); + } else if (!action && win->closeAction) { + int i, ncount; + + if (XGetWMProtocols(scr->display, win->view->window, &atoms, + &count) && count>0) { + newAtoms = wmalloc((count-1)*sizeof(Atom)); + ncount = 0; + for (i=0; i < count; i++) { + if (atoms[i]!=scr->deleteWindowAtom) { + newAtoms[i] = atoms[i]; + ncount++; + } + } + XSetWMProtocols(scr->display, win->view->window, newAtoms, + ncount); + if (atoms) + XFree(atoms); + wfree(newAtoms); + } + } } win->closeAction = action; - win->closeData = clientData; + win->closeData = clientData; } static void willResizeWindow(W_ViewDelegate *self, WMView *view, - unsigned *width, unsigned *height) + unsigned *width, unsigned *height) { WMWindow *win = (WMWindow*)view->self; if (win->minSize.width > 0 && win->minSize.height > 0) { - if (*width < win->minSize.width) - *width = win->minSize.width; - if (*height < win->minSize.height) - *height = win->minSize.height; + if (*width < win->minSize.width) + *width = win->minSize.width; + if (*height < win->minSize.height) + *height = win->minSize.height; } - + if (win->maxSize.width > 0 && win->maxSize.height > 0) { - if (*width > win->maxSize.width) - *width = win->maxSize.width; - if (*height > win->maxSize.height) - *height = win->maxSize.height; + if (*width > win->maxSize.width) + *width = win->maxSize.width; + if (*height > win->maxSize.height) + *height = win->maxSize.height; } } @@ -308,53 +308,53 @@ setSizeHints(WMWindow *win) hints = XAllocSizeHints(); if (!hints) { - wwarning("could not allocate memory for window size hints"); - return; + wwarning("could not allocate memory for window size hints"); + return; } hints->flags = 0; if (win->flags.setPPos) { - hints->flags |= PPosition; - hints->x = win->ppos.x; - hints->y = win->ppos.y; + hints->flags |= PPosition; + hints->x = win->ppos.x; + hints->y = win->ppos.y; } if (win->flags.setUPos) { - hints->flags |= USPosition; - hints->x = win->upos.x; - hints->y = win->upos.y; + hints->flags |= USPosition; + hints->x = win->upos.x; + hints->y = win->upos.y; } if (win->minSize.width>0 && win->minSize.height>0) { - hints->flags |= PMinSize; - hints->min_width = win->minSize.width; - hints->min_height = win->minSize.height; + hints->flags |= PMinSize; + hints->min_width = win->minSize.width; + hints->min_height = win->minSize.height; } if (win->maxSize.width>0 && win->maxSize.height>0) { - hints->flags |= PMaxSize; - hints->max_width = win->maxSize.width; - hints->max_height = win->maxSize.height; + hints->flags |= PMaxSize; + hints->max_width = win->maxSize.width; + hints->max_height = win->maxSize.height; } if (win->baseSize.width>0 && win->baseSize.height>0) { - hints->flags |= PBaseSize; - hints->base_width = win->baseSize.width; - hints->base_height = win->baseSize.height; + hints->flags |= PBaseSize; + hints->base_width = win->baseSize.width; + hints->base_height = win->baseSize.height; } if (win->resizeIncrement.width>0 && win->resizeIncrement.height>0) { - hints->flags |= PResizeInc; - hints->width_inc = win->resizeIncrement.width; - hints->height_inc = win->resizeIncrement.height; + hints->flags |= PResizeInc; + hints->width_inc = win->resizeIncrement.width; + hints->height_inc = win->resizeIncrement.height; } if (win->flags.setAspect) { - hints->flags |= PAspect; - hints->min_aspect.x = win->minAspect.x; - hints->min_aspect.y = win->minAspect.y; - hints->max_aspect.x = win->maxAspect.x; - hints->max_aspect.y = win->maxAspect.y; + hints->flags |= PAspect; + hints->min_aspect.x = win->minAspect.x; + hints->min_aspect.y = win->minAspect.y; + hints->max_aspect.x = win->maxAspect.x; + hints->max_aspect.y = win->maxAspect.y; } if (hints->flags) { - XSetWMNormalHints(win->view->screen->display, win->view->window, hints); + XSetWMNormalHints(win->view->screen->display, win->view->window, hints); } XFree(hints); } @@ -378,7 +378,7 @@ writeGNUstepWMAttr(WMScreen *scr, Window window, GNUstepWMAttributes *attr) data[7] = attr->close_mask; data[8] = attr->extra_flags; XChangeProperty(scr->display, window, scr->attribsAtom, scr->attribsAtom, - 32, PropModeReplace, (unsigned char *)data, 9); + 32, PropModeReplace, (unsigned char *)data, 9); } @@ -387,21 +387,21 @@ setWindowMakerHints(WMWindow *win) { GNUstepWMAttributes attribs; WMScreen *scr = WMWidgetScreen(win); - + memset(&attribs, 0, sizeof(GNUstepWMAttributes)); attribs.flags = GSWindowStyleAttr|GSWindowLevelAttr|GSExtraFlagsAttr; attribs.window_style = win->flags.style; attribs.window_level = win->level; if (win->flags.documentEdited) - attribs.extra_flags = GSDocumentEditedFlag; + attribs.extra_flags = GSDocumentEditedFlag; else - attribs.extra_flags = 0; + attribs.extra_flags = 0; writeGNUstepWMAttr(scr, win->view->window, &attribs); } -static void +static void realizeWindow(WMWindow *win) { XWMHints *hints; @@ -419,40 +419,40 @@ realizeWindow(WMWindow *win) hints = XAllocWMHints(); hints->flags = 0; if (!scr->aflags.simpleApplication) { - hints->flags |= WindowGroupHint; - hints->window_group = scr->groupLeader; + hints->flags |= WindowGroupHint; + hints->window_group = scr->groupLeader; } if (win->miniImage) { - hints->flags |= IconPixmapHint; - hints->icon_pixmap = WMGetPixmapXID(win->miniImage); - hints->icon_mask = WMGetPixmapMaskXID(win->miniImage); - if (hints->icon_mask != None) { - hints->flags |= IconMaskHint; - } + hints->flags |= IconPixmapHint; + hints->icon_pixmap = WMGetPixmapXID(win->miniImage); + hints->icon_mask = WMGetPixmapMaskXID(win->miniImage); + if (hints->icon_mask != None) { + hints->flags |= IconMaskHint; + } } if (hints->flags != 0) - XSetWMHints(scr->display, win->view->window, hints); + XSetWMHints(scr->display, win->view->window, hints); XFree(hints); count = 0; if (win->closeAction) { - atoms[count++] = scr->deleteWindowAtom; + atoms[count++] = scr->deleteWindowAtom; } if (count>0) - XSetWMProtocols(scr->display, win->view->window, atoms, count); + XSetWMProtocols(scr->display, win->view->window, atoms, count); if (win->title || win->miniTitle) - XmbSetWMProperties(scr->display, win->view->window, win->title, - win->miniTitle, NULL, 0, NULL, NULL, NULL); + XmbSetWMProperties(scr->display, win->view->window, win->title, + win->miniTitle, NULL, 0, NULL, NULL, NULL); setWindowMakerHints(win); setSizeHints(win); if (win->owner) { - XSetTransientForHint(scr->display, win->view->window, - win->owner->view->window); + XSetTransientForHint(scr->display, win->view->window, + win->owner->view->window); } } @@ -460,7 +460,7 @@ realizeWindow(WMWindow *win) void WMSetWindowAspectRatio(WMWindow *win, int minX, int minY, - int maxX, int maxY) + int maxX, int maxY) { win->flags.setAspect = 1; win->minAspect.x = minX; @@ -480,7 +480,7 @@ WMSetWindowInitialPosition(WMWindow *win, int x, int y) win->ppos.x = x; win->ppos.y = y; if (win->view->flags.realized) - setSizeHints(win); + setSizeHints(win); WMMoveWidget(win, x, y); } @@ -493,7 +493,7 @@ WMSetWindowUserPosition(WMWindow *win, int x, int y) win->upos.x = x; win->upos.y = y; if (win->view->flags.realized) - setSizeHints(win); + setSizeHints(win); WMMoveWidget(win, x, y); } @@ -506,7 +506,7 @@ WMSetWindowMinSize(WMWindow *win, unsigned width, unsigned height) win->minSize.width = width; win->minSize.height = height; if (win->view->flags.realized) - setSizeHints(win); + setSizeHints(win); } @@ -517,7 +517,7 @@ WMSetWindowMaxSize(WMWindow *win, unsigned width, unsigned height) win->maxSize.width = width; win->maxSize.height = height; if (win->view->flags.realized) - setSizeHints(win); + setSizeHints(win); } @@ -528,7 +528,7 @@ WMSetWindowBaseSize(WMWindow *win, unsigned width, unsigned height) win->baseSize.width = width; win->baseSize.height = height; if (win->view->flags.realized) - setSizeHints(win); + setSizeHints(win); } @@ -538,7 +538,7 @@ WMSetWindowResizeIncrements(WMWindow *win, unsigned wIncr, unsigned hIncr) win->resizeIncrement.width = wIncr; win->resizeIncrement.height = hIncr; if (win->view->flags.realized) - setSizeHints(win); + setSizeHints(win); } @@ -547,7 +547,7 @@ WMSetWindowLevel(WMWindow *win, int level) { win->level = level; if (win->view->flags.realized) - setWindowMakerHints(win); + setWindowMakerHints(win); } @@ -556,9 +556,9 @@ WMSetWindowDocumentEdited(WMWindow *win, Bool flag) { flag = ((flag==0) ? 0 : 1); if (win->flags.documentEdited != flag) { - win->flags.documentEdited = flag; - if (win->view->flags.realized) - setWindowMakerHints(win); + win->flags.documentEdited = flag; + if (win->view->flags.realized) + setWindowMakerHints(win); } } @@ -567,37 +567,37 @@ void WMSetWindowMiniwindowPixmap(WMWindow *win, WMPixmap *pixmap) { if ((win->miniImage && !pixmap) || (!win->miniImage && pixmap)) { - if (win->miniImage) - WMReleasePixmap(win->miniImage); - - if (pixmap) - win->miniImage = WMRetainPixmap(pixmap); - else - win->miniImage = NULL; - - if (win->view->flags.realized) { - XWMHints *hints; - - hints = XGetWMHints(win->view->screen->display, win->view->window); - if (!hints) { - hints = XAllocWMHints(); - if (!hints) { - wwarning("could not allocate memory for WM hints"); - return; - } - hints->flags = 0; - } - if (pixmap) { - hints->flags |= IconPixmapHint; - hints->icon_pixmap = WMGetPixmapXID(pixmap); - hints->icon_mask = WMGetPixmapMaskXID(pixmap); - if (hints->icon_mask != None) { - hints->flags |= IconMaskHint; - } - } - XSetWMHints(win->view->screen->display, win->view->window, hints); - XFree(hints); - } + if (win->miniImage) + WMReleasePixmap(win->miniImage); + + if (pixmap) + win->miniImage = WMRetainPixmap(pixmap); + else + win->miniImage = NULL; + + if (win->view->flags.realized) { + XWMHints *hints; + + hints = XGetWMHints(win->view->screen->display, win->view->window); + if (!hints) { + hints = XAllocWMHints(); + if (!hints) { + wwarning("could not allocate memory for WM hints"); + return; + } + hints->flags = 0; + } + if (pixmap) { + hints->flags |= IconPixmapHint; + hints->icon_pixmap = WMGetPixmapXID(pixmap); + hints->icon_mask = WMGetPixmapMaskXID(pixmap); + if (hints->icon_mask != None) { + hints->flags |= IconMaskHint; + } + } + XSetWMHints(win->view->screen->display, win->view->window, hints); + XFree(hints); + } } } @@ -609,30 +609,30 @@ WMSetWindowMiniwindowTitle(WMWindow *win, char *title) int result; if ((win->miniTitle && !title) || (!win->miniTitle && title) - || (title && win->miniTitle && strcoll(title, win->miniTitle)!=0)) { - if (win->miniTitle) - wfree(win->miniTitle); - - if (title) - win->miniTitle = wstrdup(title); - else - win->miniTitle = NULL; - - if (win->view->flags.realized) { - result = XmbTextListToTextProperty (win->view->screen->display, - &title, 1, XStdICCTextStyle, - &property); - if (result == XNoMemory || result == XLocaleNotSupported) { - wwarning("icon title conversion error..using STRING encoding"); - XSetIconName(win->view->screen->display, win->view->window, - title); - } else { - XSetWMIconName(win->view->screen->display, win->view->window, - &property); - if (property.value) - XFree(property.value); - } - } + || (title && win->miniTitle && strcoll(title, win->miniTitle)!=0)) { + if (win->miniTitle) + wfree(win->miniTitle); + + if (title) + win->miniTitle = wstrdup(title); + else + win->miniTitle = NULL; + + if (win->view->flags.realized) { + result = XmbTextListToTextProperty (win->view->screen->display, + &title, 1, XStdICCTextStyle, + &property); + if (result == XNoMemory || result == XLocaleNotSupported) { + wwarning("icon title conversion error..using STRING encoding"); + XSetIconName(win->view->screen->display, win->view->window, + title); + } else { + XSetWMIconName(win->view->screen->display, win->view->window, + &property); + if (property.value) + XFree(property.value); + } + } } } @@ -643,8 +643,8 @@ WMCloseWindow(WMWindow *win) WMUnmapWidget(win); /* withdraw the window */ if (win->view->flags.realized) - XWithdrawWindow(win->view->screen->display, win->view->window, - win->view->screen->screen); + XWithdrawWindow(win->view->screen->display, win->view->window, + win->view->screen->screen); } @@ -653,65 +653,65 @@ handleEvents(XEvent *event, void *clientData) { _Window *win = (_Window*)clientData; W_View *view = win->view; - - + + switch (event->type) { - case ClientMessage: - if (event->xclient.message_type == win->view->screen->protocolsAtom - && event->xclient.format == 32 - && event->xclient.data.l[0]==win->view->screen->deleteWindowAtom) { - - if (win->closeAction) { - (*win->closeAction)(win, win->closeData); - } - } - break; -/* - * was causing windows to ignore commands like closeWindow - * after the windows is iconized/restored or a workspace change - * if this is really needed, put the MapNotify portion too and - * fix the restack bug in wmaker - case UnmapNotify: - WMUnmapWidget(win); - break; - * - case MapNotify: - WMMapWidget(win); - break; - -*/ - case DestroyNotify: - destroyWindow(win); - break; - - case ConfigureNotify: - if (event->xconfigure.width != view->size.width - || event->xconfigure.height != view->size.height) { - - view->size.width = event->xconfigure.width; - view->size.height = event->xconfigure.height; - - if (view->flags.notifySizeChanged) { - WMPostNotificationName(WMViewSizeDidChangeNotification, - view, NULL); - } - } - if (event->xconfigure.x != view->pos.x - || event->xconfigure.y != view->pos.y) { - - if (event->xconfigure.send_event) { - view->pos.x = event->xconfigure.x; - view->pos.y = event->xconfigure.y; - } else { - Window foo; - - XTranslateCoordinates(view->screen->display, - view->window, view->screen->rootWin, - event->xconfigure.x, event->xconfigure.y, - &view->pos.x, &view->pos.y, &foo); - } - } - break; + case ClientMessage: + if (event->xclient.message_type == win->view->screen->protocolsAtom + && event->xclient.format == 32 + && event->xclient.data.l[0]==win->view->screen->deleteWindowAtom) { + + if (win->closeAction) { + (*win->closeAction)(win, win->closeData); + } + } + break; + /* + * was causing windows to ignore commands like closeWindow + * after the windows is iconized/restored or a workspace change + * if this is really needed, put the MapNotify portion too and + * fix the restack bug in wmaker + case UnmapNotify: + WMUnmapWidget(win); + break; + * + case MapNotify: + WMMapWidget(win); + break; + + */ + case DestroyNotify: + destroyWindow(win); + break; + + case ConfigureNotify: + if (event->xconfigure.width != view->size.width + || event->xconfigure.height != view->size.height) { + + view->size.width = event->xconfigure.width; + view->size.height = event->xconfigure.height; + + if (view->flags.notifySizeChanged) { + WMPostNotificationName(WMViewSizeDidChangeNotification, + view, NULL); + } + } + if (event->xconfigure.x != view->pos.x + || event->xconfigure.y != view->pos.y) { + + if (event->xconfigure.send_event) { + view->pos.x = event->xconfigure.x; + view->pos.y = event->xconfigure.y; + } else { + Window foo; + + XTranslateCoordinates(view->screen->display, + view->window, view->screen->rootWin, + event->xconfigure.x, event->xconfigure.y, + &view->pos.x, &view->pos.y, &foo); + } + } + break; } } @@ -724,38 +724,38 @@ destroyWindow(_Window *win) WMScreen *scr = win->view->screen; WMRemoveNotificationObserver(win); - + if (scr->windowList == win) { - scr->windowList = scr->windowList->nextPtr; + scr->windowList = scr->windowList->nextPtr; } else { - WMWindow *ptr; - ptr = scr->windowList; - - if (ptr) { - while (ptr->nextPtr) { - if (ptr->nextPtr==win) { - ptr->nextPtr = ptr->nextPtr->nextPtr; - break; - } - ptr = ptr->nextPtr; - } - } + WMWindow *ptr; + ptr = scr->windowList; + + if (ptr) { + while (ptr->nextPtr) { + if (ptr->nextPtr==win) { + ptr->nextPtr = ptr->nextPtr->nextPtr; + break; + } + ptr = ptr->nextPtr; + } + } } if (win->title) { - wfree(win->title); + wfree(win->title); } - + if (win->miniTitle) { - wfree(win->miniTitle); + wfree(win->miniTitle); } - + if (win->miniImage) { - WMReleasePixmap(win->miniImage); + WMReleasePixmap(win->miniImage); } - + if (win->wname) - wfree(win->wname); + wfree(win->wname); wfree(win); } diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c index 6bf11c6a..4ff6eea8 100644 --- a/WPrefs.app/Appearance.c +++ b/WPrefs.app/Appearance.c @@ -1,9 +1,9 @@ /* Apperance.c- color/texture for titlebar etc. - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1999-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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,12 +84,12 @@ typedef struct _Panel { /* root bg */ WMFrame *bgF; - + WMLabel *bgprevL; WMButton *selbgB; WMPopUpButton *modeB[3]; - + /* */ int textureIndex[8]; @@ -146,16 +146,16 @@ static void OpenExtractPanelFor(_Panel *panel, char *path); static void changedTabItem(struct WMTabViewDelegate *self, WMTabView *tabView, - WMTabViewItem *item); + WMTabViewItem *item); static WMTabViewDelegate tabviewDelegate = { NULL, - NULL, /* didChangeNumberOfItems */ - changedTabItem, /* didSelectItem */ - NULL, /* shouldSelectItem */ - NULL /* willSelectItem */ + NULL, /* didChangeNumberOfItems */ + changedTabItem, /* didSelectItem */ + NULL, /* shouldSelectItem */ + NULL /* willSelectItem */ }; @@ -173,151 +173,151 @@ static WMTabViewDelegate tabviewDelegate = { /* XPM */ static char * blueled_xpm[] = { -"8 8 17 1", -" c None", -". c #020204", -"+ c #16B6FC", -"@ c #176AFC", -"# c #163AFC", -"$ c #72D2FC", -"% c #224CF4", -"& c #76D6FC", -"* c #16AAFC", -"= c #CEE9FC", -"- c #229EFC", -"; c #164CFC", -"> c #FAFEFC", -", c #2482FC", -"' c #1652FC", -") c #1E76FC", -"! c #1A60FC", -" .... ", -" .=>-@. ", -".=>$@@'.", -".=$@!;;.", -".!@*+!#.", -".#'*+*,.", -" .@)@,. ", -" .... "}; + "8 8 17 1", + " c None", + ". c #020204", + "+ c #16B6FC", + "@ c #176AFC", + "# c #163AFC", + "$ c #72D2FC", + "% c #224CF4", + "& c #76D6FC", + "* c #16AAFC", + "= c #CEE9FC", + "- c #229EFC", + "; c #164CFC", + "> c #FAFEFC", + ", c #2482FC", + "' c #1652FC", + ") c #1E76FC", + "! c #1A60FC", + " .... ", + " .=>-@. ", + ".=>$@@'.", + ".=$@!;;.", + ".!@*+!#.", + ".#'*+*,.", + " .@)@,. ", + " .... "}; /* XPM */ static char *blueled2_xpm[] = { -/* width height num_colors chars_per_pixel */ -" 8 8 17 1", -/* colors */ -". c None", -"# c #090909", -"a c #4b63a4", -"b c #011578", -"c c #264194", -"d c #04338c", -"e c #989dac", -"f c #011a7c", -"g c #465c9c", -"h c #03278a", -"i c #6175ac", -"j c #011e74", -"k c #043a90", -"l c #042f94", -"m c #0933a4", -"n c #022184", -"o c #012998", -/* pixels */ -"..####..", -".#aimn#.", -"#aechnf#", -"#gchnjf#", -"#jndknb#", -"#bjdddl#", -".#nono#.", -"..####.." + /* width height num_colors chars_per_pixel */ + " 8 8 17 1", + /* colors */ + ". c None", + "# c #090909", + "a c #4b63a4", + "b c #011578", + "c c #264194", + "d c #04338c", + "e c #989dac", + "f c #011a7c", + "g c #465c9c", + "h c #03278a", + "i c #6175ac", + "j c #011e74", + "k c #043a90", + "l c #042f94", + "m c #0933a4", + "n c #022184", + "o c #012998", + /* pixels */ + "..####..", + ".#aimn#.", + "#aechnf#", + "#gchnjf#", + "#jndknb#", + "#bjdddl#", + ".#nono#.", + "..####.." }; /* XPM */ static char * hand_xpm[] = { -"22 21 19 1", -" c None", -". c #030305", -"+ c #7F7F7E", -"@ c #B5B5B6", -"# c #C5C5C6", -"$ c #969697", -"% c #FDFDFB", -"& c #F2F2F4", -"* c #E5E5E4", -"= c #ECECEC", -"- c #DCDCDC", -"; c #D2D2D0", -"> c #101010", -", c #767674", -"' c #676767", -") c #535355", -"! c #323234", -"~ c #3E3C56", -"{ c #333147", -" ", -" ..... ", -" ..+@##$. ", -" .%%%&@.......... ", -" .%*%%&#%%%%%%%%%$. ", -" .*#%%%%%%%%%&&&&==. ", -" .-%%%%%%%%%=*-;;;#$. ", -" .-%%%%%%%%&..>..... ", -" >-%%%%%%%%%*#+. ", -" >-%%%%%%%%%*@,. ", -" >#%%%%%%%%%*@'. ", -" >$&&%%%%%%=... ", -" .+@@;=&%%&;$,> ", -" .',$@####$+). ", -" .!',+$++,'. ", -" ..>>>>>. ", -" ", -" ~~{{{~~ ", -" {{{{{{{{{{{ ", -" ~~{{{~~ ", -" "}; + "22 21 19 1", + " c None", + ". c #030305", + "+ c #7F7F7E", + "@ c #B5B5B6", + "# c #C5C5C6", + "$ c #969697", + "% c #FDFDFB", + "& c #F2F2F4", + "* c #E5E5E4", + "= c #ECECEC", + "- c #DCDCDC", + "; c #D2D2D0", + "> c #101010", + ", c #767674", + "' c #676767", + ") c #535355", + "! c #323234", + "~ c #3E3C56", + "{ c #333147", + " ", + " ..... ", + " ..+@##$. ", + " .%%%&@.......... ", + " .%*%%&#%%%%%%%%%$. ", + " .*#%%%%%%%%%&&&&==. ", + " .-%%%%%%%%%=*-;;;#$. ", + " .-%%%%%%%%&..>..... ", + " >-%%%%%%%%%*#+. ", + " >-%%%%%%%%%*@,. ", + " >#%%%%%%%%%*@'. ", + " >$&&%%%%%%=... ", + " .+@@;=&%%&;$,> ", + " .',$@####$+). ", + " .!',+$++,'. ", + " ..>>>>>. ", + " ", + " ~~{{{~~ ", + " {{{{{{{{{{{ ", + " ~~{{{~~ ", + " "}; static char *sampleColors[] = { "black", - "#292929", - "#525252", - "#848484", - "#adadad", - "#d6d6d6", - "white", - "#d6d68c", - "#d6a57b", - "#8cd68c", - "#8cd6ce", - "#d68c8c", - "#8c9cd6", - "#bd86d6", - "#d68cbd", - "#d64a4a", - "#4a5ad6", - "#4ad6ce", - "#4ad65a", - "#ced64a", - "#d6844a", - "#8ad631", - "#ce29c6", - "#ce2973", - "black" + "#292929", + "#525252", + "#848484", + "#adadad", + "#d6d6d6", + "white", + "#d6d68c", + "#d6a57b", + "#8cd68c", + "#8cd6ce", + "#d68c8c", + "#8c9cd6", + "#bd86d6", + "#d68cbd", + "#d64a4a", + "#4a5ad6", + "#4ad6ce", + "#4ad65a", + "#ced64a", + "#d6844a", + "#8ad631", + "#ce29c6", + "#ce2973", + "black" }; static char *textureOptions[] = { - "FTitleBack", "(solid, black)", "[Focused]", - "UTitleBack", "(solid, gray)", "[Unfocused]", - "PTitleBack", "(solid, \"#616161\")", "[Owner of Focused]", - "ResizebarBack", "(solid, gray)", "[Resizebar]", - "MenuTitleBack", "(solid, black)", "[Menu Title]", - "MenuTextBack", "(solid, gray)", "[Menu Item]", - "IconBack", "(solid, gray)", "[Icon]" + "FTitleBack", "(solid, black)", "[Focused]", + "UTitleBack", "(solid, gray)", "[Unfocused]", + "PTitleBack", "(solid, \"#616161\")", "[Owner of Focused]", + "ResizebarBack", "(solid, gray)", "[Resizebar]", + "MenuTitleBack", "(solid, black)", "[Menu Title]", + "MenuTextBack", "(solid, gray)", "[Menu Item]", + "IconBack", "(solid, gray)", "[Icon]" }; @@ -349,17 +349,17 @@ static char *textureOptions[] = { static char *colorOptions[] = { "FTitleColor", "white", - "UTitleColor", "black", - "PTitleColor", "white", - "MenuTitleColor", "white", - "MenuTextColor", "black", - "MenuDisabledColor", "#616161", - "HighlightColor", "white", - "HighlightTextColor", "black", - "IconTitleColor", "white", - "IconTitleBack", "black", - "ClipTitleColor", "black", - "CClipTitleColor", "#454045" + "UTitleColor", "black", + "PTitleColor", "white", + "MenuTitleColor", "white", + "MenuTextColor", "black", + "MenuDisabledColor", "#616161", + "HighlightColor", "white", + "HighlightTextColor", "black", + "IconTitleColor", "white", + "IconTitleBack", "black", + "ClipTitleColor", "black", + "CClipTitleColor", "#454045" }; @@ -405,7 +405,7 @@ static void str2rcolor(RContext *rc, char *name, RColor *color) { XColor xcolor; - + XParseColor(rc->dpy, rc->cmap, name, &xcolor); color->alpha = 255; @@ -423,15 +423,15 @@ dumpRImage(char *path, RImage *image) f = fopen(path, "wb"); if (!f) { - wsyserror(path); - return; + wsyserror(path); + return; } fprintf(f, "%02x%02x%1x", image->width, image->height, channels); fwrite(image->data, 1, image->width * image->height * channels, f); if (fclose(f) < 0) { - wsyserror(path); + wsyserror(path); } } @@ -446,9 +446,9 @@ isPixmap(WMPropList *prop) p = WMGetFromPLArray(prop, 0); s = WMGetFromPLString(p); if (strcasecmp(&s[1], "pixmap")==0) - return 1; + return 1; else - return 0; + return 0; } @@ -466,7 +466,7 @@ drawResizebarBevel(RImage *img) black.alpha = 255; black.red = black.green = black.blue = 0; - + light.alpha = 0; light.red = light.green = light.blue = 80; @@ -480,10 +480,10 @@ drawResizebarBevel(RImage *img) ROperateLine(img, RAddOperation, cwidth+1, 2, cwidth+1, height-1, &light); ROperateLine(img, RSubtractOperation, width-cwidth-2, 2, width-cwidth-2, - height-1, &dark); - ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1, - height-1, &light); - + height-1, &dark); + ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1, + height-1, &light); + RDrawLine(img, 0, height-1, width-1, height-1, &black); RDrawLine(img, 0, 0, 0, height-1, &black); RDrawLine(img, width-1, 0, width-1, height-1, &black); @@ -496,31 +496,31 @@ drawMenuBevel(RImage *img) RColor light, dark, mid; int i; int iheight = img->height / 4; - + 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 < 4; i++) { - ROperateLine(img, RSubtractOperation, 0, i*iheight-2, - img->width-1, i*iheight-2, &mid); - - RDrawLine(img, 0, i*iheight-1, img->width-1, i*iheight-1, &dark); - - ROperateLine(img, RAddOperation, 1, i*iheight, - img->width-2, i*iheight, &light); + ROperateLine(img, RSubtractOperation, 0, i*iheight-2, + img->width-1, i*iheight-2, &mid); + + RDrawLine(img, 0, i*iheight-1, img->width-1, i*iheight-1, &dark); + + ROperateLine(img, RAddOperation, 1, i*iheight, + img->width-2, i*iheight, &light); } } static Pixmap renderTexture(WMScreen *scr, WMPropList *texture, int width, int height, - char *path, int border) + char *path, int border) { char *type; RImage *image = NULL; @@ -534,190 +534,190 @@ renderTexture(WMScreen *scr, WMPropList *texture, int width, int height, if (strcasecmp(type, "solid")==0) { - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - str2rcolor(rc, str, &rcolor); + str2rcolor(rc, str, &rcolor); - image = RCreateImage(width, height, False); - RClearImage(image, &rcolor); + image = RCreateImage(width, height, False); + RClearImage(image, &rcolor); } else if (strcasecmp(type, "igradient")==0) { - int t1, t2; - RColor c1[2], c2[2]; - - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - str2rcolor(rc, str, &c1[0]); - str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); - str2rcolor(rc, str, &c1[1]); - str = WMGetFromPLString(WMGetFromPLArray(texture, 3)); - t1 = atoi(str); - - str = WMGetFromPLString(WMGetFromPLArray(texture, 4)); - str2rcolor(rc, str, &c2[0]); - str = WMGetFromPLString(WMGetFromPLArray(texture, 5)); - str2rcolor(rc, str, &c2[1]); - str = WMGetFromPLString(WMGetFromPLArray(texture, 6)); - t2 = atoi(str); - - image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2); + int t1, t2; + RColor c1[2], c2[2]; + + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + str2rcolor(rc, str, &c1[0]); + str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); + str2rcolor(rc, str, &c1[1]); + str = WMGetFromPLString(WMGetFromPLArray(texture, 3)); + t1 = atoi(str); + + str = WMGetFromPLString(WMGetFromPLArray(texture, 4)); + str2rcolor(rc, str, &c2[0]); + str = WMGetFromPLString(WMGetFromPLArray(texture, 5)); + str2rcolor(rc, str, &c2[1]); + str = WMGetFromPLString(WMGetFromPLArray(texture, 6)); + t2 = atoi(str); + + image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2); } else if (strcasecmp(&type[1], "gradient")==0) { - int style; - RColor rcolor2; - - switch (toupper(type[0])) { - case 'V': - style = RVerticalGradient; - break; - case 'H': - style = RHorizontalGradient; - break; - default: - case 'D': - style = RDiagonalGradient; - break; - } - - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - str2rcolor(rc, str, &rcolor); - str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); - str2rcolor(rc, str, &rcolor2); - - image = RRenderGradient(width, height, &rcolor, &rcolor2, style); + int style; + RColor rcolor2; + + switch (toupper(type[0])) { + case 'V': + style = RVerticalGradient; + break; + case 'H': + style = RHorizontalGradient; + break; + default: + case 'D': + style = RDiagonalGradient; + break; + } + + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + str2rcolor(rc, str, &rcolor); + str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); + str2rcolor(rc, str, &rcolor2); + + image = RRenderGradient(width, height, &rcolor, &rcolor2, style); } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='T') { - int style; - RColor rcolor2; - int i; - RImage *grad, *timage; - char *path; - - switch (toupper(type[1])) { - case 'V': - style = RVerticalGradient; - break; - case 'H': - style = RHorizontalGradient; - break; - default: - case 'D': - style = RDiagonalGradient; - break; - } - - str = WMGetFromPLString(WMGetFromPLArray(texture, 3)); - str2rcolor(rc, str, &rcolor); - str = WMGetFromPLString(WMGetFromPLArray(texture, 4)); - str2rcolor(rc, str, &rcolor2); - - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - - if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL) + int style; + RColor rcolor2; + int i; + RImage *grad, *timage; + char *path; + + switch (toupper(type[1])) { + case 'V': + style = RVerticalGradient; + break; + case 'H': + style = RHorizontalGradient; + break; + default: + case 'D': + style = RDiagonalGradient; + break; + } + + str = WMGetFromPLString(WMGetFromPLArray(texture, 3)); + str2rcolor(rc, str, &rcolor); + str = WMGetFromPLString(WMGetFromPLArray(texture, 4)); + str2rcolor(rc, str, &rcolor2); + + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + + if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL) timage = RLoadImage(rc, path, 0); - if (!path || !timage) { - wwarning("could not load file '%s': %s", path, - RMessageForError(RErrorCode)); - } else { - grad = RRenderGradient(width, height, &rcolor, &rcolor2, style); + if (!path || !timage) { + wwarning("could not load file '%s': %s", path, + RMessageForError(RErrorCode)); + } else { + grad = RRenderGradient(width, height, &rcolor, &rcolor2, style); + + image = RMakeTiledImage(timage, width, height); + RReleaseImage(timage); - image = RMakeTiledImage(timage, width, height); - RReleaseImage(timage); + i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2))); - i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2))); - - RCombineImagesWithOpaqueness(image, grad, i); - RReleaseImage(grad); - } + RCombineImagesWithOpaqueness(image, grad, i); + RReleaseImage(grad); + } } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='M') { - int style; - RColor **colors; - int i, j; - - switch (toupper(type[1])) { - case 'V': - style = RVerticalGradient; - break; - case 'H': - style = RHorizontalGradient; - break; - default: - case 'D': - style = RDiagonalGradient; - break; - } - - j = WMGetPropListItemCount(texture); - - if (j > 0) { - colors = wmalloc(j * sizeof(RColor*)); - - for (i = 2; i < j; i++) { - str = WMGetFromPLString(WMGetFromPLArray(texture, i)); - colors[i-2] = wmalloc(sizeof(RColor)); - str2rcolor(rc, str, colors[i-2]); - } - colors[i-2] = NULL; - - image = RRenderMultiGradient(width, height, colors, style); - - for (i = 0; colors[i]!=NULL; i++) - wfree(colors[i]); - wfree(colors); - } + int style; + RColor **colors; + int i, j; + + switch (toupper(type[1])) { + case 'V': + style = RVerticalGradient; + break; + case 'H': + style = RHorizontalGradient; + break; + default: + case 'D': + style = RDiagonalGradient; + break; + } + + j = WMGetPropListItemCount(texture); + + if (j > 0) { + colors = wmalloc(j * sizeof(RColor*)); + + for (i = 2; i < j; i++) { + str = WMGetFromPLString(WMGetFromPLArray(texture, i)); + colors[i-2] = wmalloc(sizeof(RColor)); + str2rcolor(rc, str, colors[i-2]); + } + colors[i-2] = NULL; + + image = RRenderMultiGradient(width, height, colors, style); + + for (i = 0; colors[i]!=NULL; i++) + wfree(colors[i]); + wfree(colors); + } } else if (strcasecmp(&type[1], "pixmap")==0) { - RImage *timage = NULL; - char *path; - RColor color; + RImage *timage = NULL; + char *path; + RColor color; - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL) + if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL) timage = RLoadImage(rc, path, 0); - if (!path || !timage) { - wwarning("could not load file '%s': %s", path ? path : str, - RMessageForError(RErrorCode)); - } else { - str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); - str2rcolor(rc, str, &color); - - switch (toupper(type[0])) { - case 'T': - image = RMakeTiledImage(timage, width, height); - RReleaseImage(timage); - timage = image; - break; - case 'C': - image = RMakeCenteredImage(timage, width, height, &color); - RReleaseImage(timage); - timage = image; - break; - case 'S': - case 'M': - image = RScaleImage(timage, width, height); - RReleaseImage(timage); - timage = image; - break; - } - - } - wfree(path); + if (!path || !timage) { + wwarning("could not load file '%s': %s", path ? path : str, + RMessageForError(RErrorCode)); + } else { + str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); + str2rcolor(rc, str, &color); + + switch (toupper(type[0])) { + case 'T': + image = RMakeTiledImage(timage, width, height); + RReleaseImage(timage); + timage = image; + break; + case 'C': + image = RMakeCenteredImage(timage, width, height, &color); + RReleaseImage(timage); + timage = image; + break; + case 'S': + case 'M': + image = RScaleImage(timage, width, height); + RReleaseImage(timage); + timage = image; + break; + } + + } + wfree(path); } if (!image) - return None; + return None; if (path) { - dumpRImage(path, image); + dumpRImage(path, image); } - + if (border < 0) { - if (border == RESIZEBAR_BEVEL) { - drawResizebarBevel(image); - } else if (border == MENU_BEVEL) { - drawMenuBevel(image); - RBevelImage(image, RBEV_RAISED2); - } + if (border == RESIZEBAR_BEVEL) { + drawResizebarBevel(image); + } else if (border == MENU_BEVEL) { + drawMenuBevel(image); + RBevelImage(image, RBEV_RAISED2); + } } else if (border) { - RBevelImage(image, border); + RBevelImage(image, border); } RConvertImage(rc, image, &pixmap); @@ -737,21 +737,21 @@ renderMenu(_Panel *panel, WMPropList *texture, int width, int iheight) int i; switch (panel->menuStyle) { - case MSTYLE_NORMAL: - tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2); - - pix = XCreatePixmap(dpy, tmp, width, iheight*4, WMScreenDepth(scr)); - for (i = 0; i < 4; i++) { - XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight*i); - } - XFreePixmap(dpy, tmp); - break; - case MSTYLE_SINGLE: - pix = renderTexture(scr, texture, width, iheight*4, NULL, MENU_BEVEL); - break; - case MSTYLE_FLAT: - pix = renderTexture(scr, texture, width, iheight*4, NULL, RBEV_RAISED2); - break; + case MSTYLE_NORMAL: + tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2); + + pix = XCreatePixmap(dpy, tmp, width, iheight*4, WMScreenDepth(scr)); + for (i = 0; i < 4; i++) { + XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight*i); + } + XFreePixmap(dpy, tmp); + break; + case MSTYLE_SINGLE: + pix = renderTexture(scr, texture, width, iheight*4, NULL, MENU_BEVEL); + break; + case MSTYLE_FLAT: + pix = renderTexture(scr, texture, width, iheight*4, NULL, RBEV_RAISED2); + break; } XFreeGC(dpy, gc); @@ -770,22 +770,22 @@ renderPreview(_Panel *panel, GC gc, int part, int relief) item = WMGetListItem(panel->texLs, panel->textureIndex[part]); titem = (TextureListItem*)item->clientData; - pix = renderTexture(scr, titem->prop, - previewPositions[part].size.width, - previewPositions[part].size.height, - NULL, relief); + pix = renderTexture(scr, titem->prop, + previewPositions[part].size.width, + previewPositions[part].size.height, + NULL, relief); - XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0, - previewPositions[part].size.width, - previewPositions[part].size.height, - previewPositions[part].pos.x, - previewPositions[part].pos.y); + XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0, + previewPositions[part].size.width, + previewPositions[part].size.height, + previewPositions[part].pos.x, + previewPositions[part].pos.y); XCopyArea(WMScreenDisplay(scr), pix, panel->previewNoText, gc, 0, 0, - previewPositions[part].size.width, - previewPositions[part].size.height, - previewPositions[part].pos.x, - previewPositions[part].pos.y); + previewPositions[part].size.width, + previewPositions[part].size.height, + previewPositions[part].pos.x, + previewPositions[part].pos.y); XFreePixmap(WMScreenDisplay(scr), pix); } @@ -805,10 +805,10 @@ updatePreviewBox(_Panel *panel, int elements) if (panel->preview == None) { - WMColor *color; + WMColor *color; WMPixmap *p; - panel->previewNoText = XCreatePixmap(dpy, WMWidgetXID(panel->parent), + panel->previewNoText = XCreatePixmap(dpy, WMWidgetXID(panel->parent), 240-4, 215-4, WMScreenDepth(scr)); p = WMCreatePixmap(scr, 240-4, 215-4, WMScreenDepth(scr), False); @@ -816,109 +816,109 @@ updatePreviewBox(_Panel *panel, int elements) WMSetLabelImage(panel->prevL, p); WMReleasePixmap(p); - color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); - XFillRectangle(dpy, panel->preview, WMColorGC(color), - 0, 0, 240-4, 215-4); + color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); + XFillRectangle(dpy, panel->preview, WMColorGC(color), + 0, 0, 240-4, 215-4); XFillRectangle(dpy, panel->previewNoText, WMColorGC(color), 0, 0, 240-4, 215-4); - WMReleaseColor(color); + WMReleaseColor(color); } if (elements & (1<preview, WMColorGC(black), - previewPositions[PFOCUSED].pos.x-1, - previewPositions[PFOCUSED].pos.y-1, - previewPositions[PFOCUSED].size.width, + renderPreview(panel, gc, PFOCUSED, RBEV_RAISED2); + XDrawRectangle(dpy, panel->preview, WMColorGC(black), + previewPositions[PFOCUSED].pos.x-1, + previewPositions[PFOCUSED].pos.y-1, + previewPositions[PFOCUSED].size.width, previewPositions[PFOCUSED].size.height); - XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black), - previewPositions[PFOCUSED].pos.x-1, - previewPositions[PFOCUSED].pos.y-1, - previewPositions[PFOCUSED].size.width, + XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black), + previewPositions[PFOCUSED].pos.x-1, + previewPositions[PFOCUSED].pos.y-1, + previewPositions[PFOCUSED].size.width, previewPositions[PFOCUSED].size.height); - colorUpdate |= FTITLE_COL; + colorUpdate |= FTITLE_COL; } if (elements & (1<preview, WMColorGC(black), - previewPositions[PUNFOCUSED].pos.x-1, - previewPositions[PUNFOCUSED].pos.y-1, - previewPositions[PUNFOCUSED].size.width, - previewPositions[PUNFOCUSED].size.height); - XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black), - previewPositions[PUNFOCUSED].pos.x-1, - previewPositions[PUNFOCUSED].pos.y-1, - previewPositions[PUNFOCUSED].size.width, - previewPositions[PUNFOCUSED].size.height); - colorUpdate |= UTITLE_COL; + renderPreview(panel, gc, PUNFOCUSED, RBEV_RAISED2); + XDrawRectangle(dpy, panel->preview, WMColorGC(black), + previewPositions[PUNFOCUSED].pos.x-1, + previewPositions[PUNFOCUSED].pos.y-1, + previewPositions[PUNFOCUSED].size.width, + previewPositions[PUNFOCUSED].size.height); + XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black), + previewPositions[PUNFOCUSED].pos.x-1, + previewPositions[PUNFOCUSED].pos.y-1, + previewPositions[PUNFOCUSED].size.width, + previewPositions[PUNFOCUSED].size.height); + colorUpdate |= UTITLE_COL; } if (elements & (1<preview, WMColorGC(black), - previewPositions[POWNER].pos.x-1, - previewPositions[POWNER].pos.y-1, - previewPositions[POWNER].size.width, - previewPositions[POWNER].size.height); - XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black), - previewPositions[POWNER].pos.x-1, - previewPositions[POWNER].pos.y-1, - previewPositions[POWNER].size.width, - previewPositions[POWNER].size.height); - colorUpdate |= OTITLE_COL; + renderPreview(panel, gc, POWNER, RBEV_RAISED2); + XDrawRectangle(dpy, panel->preview, WMColorGC(black), + previewPositions[POWNER].pos.x-1, + previewPositions[POWNER].pos.y-1, + previewPositions[POWNER].size.width, + previewPositions[POWNER].size.height); + XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black), + previewPositions[POWNER].pos.x-1, + previewPositions[POWNER].pos.y-1, + previewPositions[POWNER].size.width, + previewPositions[POWNER].size.height); + colorUpdate |= OTITLE_COL; } if (elements & (1<texLs, panel->textureIndex[5]); - titem = (TextureListItem*)item->clientData; + item = WMGetListItem(panel->texLs, panel->textureIndex[5]); + titem = (TextureListItem*)item->clientData; - pix = renderMenu(panel, titem->prop, - previewPositions[PMITEM].size.width, - previewPositions[PMITEM].size.height/4); + pix = renderMenu(panel, titem->prop, + previewPositions[PMITEM].size.width, + previewPositions[PMITEM].size.height/4); - XCopyArea(dpy, pix, panel->preview, gc, 0, 0, - previewPositions[PMITEM].size.width, - previewPositions[PMITEM].size.height, - previewPositions[PMITEM].pos.x, - previewPositions[PMITEM].pos.y); + XCopyArea(dpy, pix, panel->preview, gc, 0, 0, + previewPositions[PMITEM].size.width, + previewPositions[PMITEM].size.height, + previewPositions[PMITEM].pos.x, + previewPositions[PMITEM].pos.y); - XCopyArea(dpy, pix, panel->previewNoText, gc, 0, 0, - previewPositions[PMITEM].size.width, - previewPositions[PMITEM].size.height, - previewPositions[PMITEM].pos.x, - previewPositions[PMITEM].pos.y); + XCopyArea(dpy, pix, panel->previewNoText, gc, 0, 0, + previewPositions[PMITEM].size.width, + previewPositions[PMITEM].size.height, + previewPositions[PMITEM].pos.x, + previewPositions[PMITEM].pos.y); - XFreePixmap(dpy, pix); + XFreePixmap(dpy, pix); - colorUpdate |= MITEM_COL|MDISAB_COL|MHIGH_COL|MHIGHT_COL; + colorUpdate |= MITEM_COL|MDISAB_COL|MHIGH_COL|MHIGHT_COL; } if (elements & (1<preview, gc, 29, 120, 29, 120+20*4+20); - XDrawLine(dpy, panel->preview, gc, 29, 119, 119, 119); + XDrawLine(dpy, panel->preview, gc, 29, 120, 29, 120+20*4+20); + XDrawLine(dpy, panel->preview, gc, 29, 119, 119, 119); - XDrawLine(dpy, panel->previewNoText, gc, 29, 120, 29, 120+20*4+20); - XDrawLine(dpy, panel->previewNoText, gc, 29, 119, 119, 119); + XDrawLine(dpy, panel->previewNoText, gc, 29, 120, 29, 120+20*4+20); + XDrawLine(dpy, panel->previewNoText, gc, 29, 119, 119, 119); } if (elements & (1<texLs, panel->textureIndex[6]); - titem = (TextureListItem*)item->clientData; + item = WMGetListItem(panel->texLs, panel->textureIndex[6]); + titem = (TextureListItem*)item->clientData; - renderPreview(panel, gc, PICON, - titem->ispixmap ? 0 : RBEV_RAISED3); + renderPreview(panel, gc, PICON, + titem->ispixmap ? 0 : RBEV_RAISED3); - colorUpdate |= ICONT_COL|ICONB_COL|CLIP_COL|CCLIP_COL; + colorUpdate |= ICONT_COL|ICONB_COL|CLIP_COL|CCLIP_COL; } if (colorUpdate) @@ -937,7 +937,7 @@ static void cancelNewTexture(void *data) { _Panel *panel = (_Panel*)data; - + HideTexturePanel(panel->texturePanel); } @@ -952,11 +952,11 @@ makeFileName(char *prefix) fname = wstrdup(prefix); while (access(fname, F_OK)==0) { - char buf[30]; + char buf[30]; - wfree(fname); - sprintf(buf, "%08lx.cache", time(NULL)); - fname = wstrconcat(prefix, buf); + wfree(fname); + sprintf(buf, "%08lx.cache", time(NULL)); + fname = wstrconcat(prefix, buf); } return fname; @@ -996,7 +996,7 @@ okNewTexture(void *data) titem->path = makeFileName(panel->fprefix); titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, - titem->path, 0); + titem->path, 0); item = WMAddListItem(panel->texLs, ""); item->clientData = titem; @@ -1021,10 +1021,10 @@ okEditTexture(void *data) HideTexturePanel(panel->texturePanel); if (titem->current) { - name = GetTexturePanelTextureName(panel->texturePanel); + name = GetTexturePanelTextureName(panel->texturePanel); - wfree(titem->title); - titem->title = name; + wfree(titem->title); + titem->title = name; } prop = GetTexturePanelTexture(panel->texturePanel); @@ -1041,13 +1041,13 @@ okEditTexture(void *data) XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview); titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop, - TEXPREV_WIDTH, TEXPREV_HEIGHT, - titem->path, 0); + TEXPREV_WIDTH, TEXPREV_HEIGHT, + titem->path, 0); WMRedisplayWidget(panel->texLs); if (titem->selectedFor) - updatePreviewBox(panel, titem->selectedFor); + updatePreviewBox(panel, titem->selectedFor); changePage(panel->secP, panel); } @@ -1065,7 +1065,7 @@ editTexture(WMWidget *w, void *data) titem = (TextureListItem*)item->clientData; SetTexturePanelPixmapPath(panel->texturePanel, - GetObjectForKey("PixmapPath")); + GetObjectForKey("PixmapPath")); SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop); @@ -1083,7 +1083,7 @@ newTexture(WMWidget *w, void *data) _Panel *panel = (_Panel*)data; SetTexturePanelPixmapPath(panel->texturePanel, - GetObjectForKey("PixmapPath")); + GetObjectForKey("PixmapPath")); SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL); @@ -1111,22 +1111,22 @@ deleteTexture(WMWidget *w, void *data) titem = (TextureListItem*)item->clientData; if (titem->selectedFor & (1 << section)) { - TextureListItem *titem2; + TextureListItem *titem2; - panel->textureIndex[section] = section; - item = WMGetListItem(panel->texLs, section); - titem2 = (TextureListItem*)item->clientData; - titem2->selectedFor |= 1 << section; + panel->textureIndex[section] = section; + item = WMGetListItem(panel->texLs, section); + titem2 = (TextureListItem*)item->clientData; + titem2->selectedFor |= 1 << section; } wfree(titem->title); wfree(titem->texture); WMReleasePropList(titem->prop); if (titem->path) { - if (remove(titem->path) < 0 && errno != ENOENT) { - wsyserror("could not remove file %s", titem->path); - } - wfree(titem->path); + if (remove(titem->path) < 0 && errno != ENOENT) { + wsyserror("could not remove file %s", titem->path); + } + wfree(titem->path); } wfree(titem); @@ -1151,12 +1151,12 @@ extractTexture(WMWidget *w, void *data) WMSetFilePanelCanChooseFiles(opanel, True); if (WMRunModalFilePanelForDirectory(opanel, panel->parent, wgethomedir(), - _("Select File"), NULL)) { - path = WMGetFilePanelFileName(opanel); + _("Select File"), NULL)) { + path = WMGetFilePanelFileName(opanel); - OpenExtractPanelFor(panel, path); + OpenExtractPanelFor(panel, path); - wfree(path); + wfree(path); } } @@ -1171,39 +1171,39 @@ changePage(WMWidget *w, void *data) WMScreen *scr = WMWidgetScreen(panel->box); RContext *rc = WMScreenRContext(scr); static WMPoint positions[] = { - {5, 10}, - {5, 40}, - {5, 70}, - {5, 100}, - {5, 120}, - {5, 160}, - {130, 150} + {5, 10}, + {5, 40}, + {5, 70}, + {5, 100}, + {5, 120}, + {5, 160}, + {130, 150} }; if (w) { - section = WMGetPopUpButtonSelectedItem(panel->secP); + section = WMGetPopUpButtonSelectedItem(panel->secP); - WMSelectListItem(panel->texLs, panel->textureIndex[section]); + WMSelectListItem(panel->texLs, panel->textureIndex[section]); - WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2); + WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2); - item = WMGetListItem(panel->texLs, panel->textureIndex[section]); + item = WMGetListItem(panel->texLs, panel->textureIndex[section]); - titem = (TextureListItem*)item->clientData; + titem = (TextureListItem*)item->clientData; } { - WMColor *color; + WMColor *color; - color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); - XFillRectangle(rc->dpy, panel->preview, WMColorGC(color), - positions[panel->oldsection].x, - positions[panel->oldsection].y, 22, 22); - WMReleaseColor(color); + color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); + XFillRectangle(rc->dpy, panel->preview, WMColorGC(color), + positions[panel->oldsection].x, + positions[panel->oldsection].y, 22, 22); + WMReleaseColor(color); } if (w) { - panel->oldsection = section; - WMDrawPixmap(panel->hand, panel->preview, positions[section].x, - positions[section].y); + panel->oldsection = section; + WMDrawPixmap(panel->hand, panel->preview, positions[section].x, + positions[section].y); } WMRedisplayWidget(panel->prevL); } @@ -1217,40 +1217,40 @@ previewClick(XEvent *event, void *clientData) int i; switch (panel->oldTabItem) { - case 0: - for (i = 0; i < sizeof(previewPositions)/sizeof(WMRect); i++) { - if (event->xbutton.x >= previewPositions[i].pos.x - && event->xbutton.y >= previewPositions[i].pos.y - && event->xbutton.x < previewPositions[i].pos.x - + previewPositions[i].size.width - && event->xbutton.y < previewPositions[i].pos.y - + previewPositions[i].size.height) { - - WMSetPopUpButtonSelectedItem(panel->secP, i); - changePage(panel->secP, panel); - return; - } - } - break; - case 1: - for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) { - if (event->xbutton.x >= previewColorPositions[i].pos.x - && event->xbutton.y >= previewColorPositions[i].pos.y - && event->xbutton.x < previewColorPositions[i].pos.x - + previewColorPositions[i].size.width - && event->xbutton.y < previewColorPositions[i].pos.y - + previewColorPositions[i].size.height) { - - /* yuck kluge */ - if (i == 7) - i = 4; - - WMSetPopUpButtonSelectedItem(panel->colP, i); - changeColorPage(panel->colP, panel); - return; - } - } - break; + case 0: + for (i = 0; i < sizeof(previewPositions)/sizeof(WMRect); i++) { + if (event->xbutton.x >= previewPositions[i].pos.x + && event->xbutton.y >= previewPositions[i].pos.y + && event->xbutton.x < previewPositions[i].pos.x + + previewPositions[i].size.width + && event->xbutton.y < previewPositions[i].pos.y + + previewPositions[i].size.height) { + + WMSetPopUpButtonSelectedItem(panel->secP, i); + changePage(panel->secP, panel); + return; + } + } + break; + case 1: + for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) { + if (event->xbutton.x >= previewColorPositions[i].pos.x + && event->xbutton.y >= previewColorPositions[i].pos.y + && event->xbutton.x < previewColorPositions[i].pos.x + + previewColorPositions[i].size.width + && event->xbutton.y < previewColorPositions[i].pos.y + + previewColorPositions[i].size.height) { + + /* yuck kluge */ + if (i == 7) + i = 4; + + WMSetPopUpButtonSelectedItem(panel->colP, i); + changeColorPage(panel->colP, panel); + return; + } + } + break; } } @@ -1270,9 +1270,9 @@ textureClick(WMWidget *w, void *data) titem = (TextureListItem*)item->clientData; if (titem->current) { - WMSetButtonEnabled(panel->delB, False); + WMSetButtonEnabled(panel->delB, False); } else { - WMSetButtonEnabled(panel->delB, True); + WMSetButtonEnabled(panel->delB, True); } } @@ -1312,8 +1312,8 @@ textureDoubleClick(WMWidget *w, void *data) static void -paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state, - WMRect *rect) +paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state, + WMRect *rect) { _Panel *panel = (_Panel*)WMGetHangedData(lPtr); WMScreen *scr = WMWidgetScreen(lPtr); @@ -1327,9 +1327,9 @@ paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state, item = WMGetListItem(lPtr, index); titem = (TextureListItem*)item->clientData; if (!titem) { - WMReleaseColor(back); - WMReleaseColor(black); - return; + WMReleaseColor(back); + WMReleaseColor(black); + return; } width = rect->size.width; @@ -1340,21 +1340,21 @@ paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state, XFillRectangle(dpy, d, WMColorGC(back), x, y, width, height); if (titem->preview) - XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0, - TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5); - + XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0, + TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5); + if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor) - WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6); + WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6); else if (titem->selectedFor) - WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6); + WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6); WMDrawString(scr, d, black, panel->boldFont, - x + TEXPREV_WIDTH + 22, y + 2, titem->title, - strlen(titem->title)); + x + TEXPREV_WIDTH + 22, y + 2, titem->title, + strlen(titem->title)); WMDrawString(scr, d, black, panel->smallFont, - x + TEXPREV_WIDTH + 14, y + 18, titem->texture, - strlen(titem->texture)); + x + TEXPREV_WIDTH + 14, y + 18, titem->texture, + strlen(titem->texture)); WMReleaseColor(back); @@ -1373,7 +1373,7 @@ loadRImage(WMScreen *scr, char *path) f = fopen(path, "rb"); if (!f) - return None; + return None; fscanf(f, "%02x%02x%1x", &w, &h, &d); @@ -1401,29 +1401,29 @@ fillTextureList(WMList *lPtr) textureList = WMGetUDObjectForKey(udb, "TextureList"); if (!textureList) - return; + return; for (i = 0; i < WMGetPropListItemCount(textureList); i++) { - WMListItem *item; - - texture = WMGetFromPLArray(textureList, i); - - titem = wmalloc(sizeof(TextureListItem)); - memset(titem, 0, sizeof(TextureListItem)); - - titem->title = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 0))); - titem->prop = WMRetainPropList(WMGetFromPLArray(texture, 1)); - titem->texture = WMGetPropListDescription(titem->prop, False); - titem->selectedFor = 0; - titem->path = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 2))); - - titem->preview = loadRImage(scr, titem->path); - if (!titem->preview) { - titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH, - TEXPREV_HEIGHT, NULL, 0); - } - item = WMAddListItem(lPtr, ""); - item->clientData = titem; + WMListItem *item; + + texture = WMGetFromPLArray(textureList, i); + + titem = wmalloc(sizeof(TextureListItem)); + memset(titem, 0, sizeof(TextureListItem)); + + titem->title = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 0))); + titem->prop = WMRetainPropList(WMGetFromPLArray(texture, 1)); + titem->texture = WMGetPropListDescription(titem->prop, False); + titem->selectedFor = 0; + titem->path = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 2))); + + titem->preview = loadRImage(scr, titem->path); + if (!titem->preview) { + titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH, + TEXPREV_HEIGHT, NULL, 0); + } + item = WMAddListItem(lPtr, ""); + item->clientData = titem; } } @@ -1436,29 +1436,29 @@ fillColorList(_Panel *panel) WMUserDefaults *udb = WMGetStandardUserDefaults(); WMScreen *scr = WMWidgetScreen(panel->box); int i; - + list = WMGetUDObjectForKey(udb, "ColorList"); if (!list) { - for (i = 0; i < 24; i++) { - color = WMCreateNamedColor(scr, sampleColors[i], False); - if (!color) - continue; - WMSetColorWellColor(panel->sampW[i], color); - WMReleaseColor(color); - } + for (i = 0; i < 24; i++) { + color = WMCreateNamedColor(scr, sampleColors[i], False); + if (!color) + continue; + WMSetColorWellColor(panel->sampW[i], color); + WMReleaseColor(color); + } } else { - WMPropList *c; - - for (i = 0; i < WMIN(24, WMGetPropListItemCount(list)); i++) { - c = WMGetFromPLArray(list, i); - if (!c || !WMIsPLString(c)) - continue; - color = WMCreateNamedColor(scr, WMGetFromPLString(c), False); - if (!color) - continue; - WMSetColorWellColor(panel->sampW[i], color); - WMReleaseColor(color); - } + WMPropList *c; + + for (i = 0; i < WMIN(24, WMGetPropListItemCount(list)); i++) { + c = WMGetFromPLArray(list, i); + if (!c || !WMIsPLString(c)) + continue; + color = WMCreateNamedColor(scr, WMGetFromPLString(c), False); + if (!color) + continue; + WMSetColorWellColor(panel->sampW[i], color); + WMReleaseColor(color); + } } } @@ -1474,40 +1474,40 @@ changeColorPage(WMWidget *w, void *data) WMScreen *scr = WMWidgetScreen(panel->box); RContext *rc = WMScreenRContext(scr); static WMPoint positions[] = { - {5, 10}, - {5, 40}, - {5, 70}, - {5, 120}, - {5, 140}, - {5, 160}, - {5, 180}, - {5, 180}, - {130, 140}, - {130, 140}, - {130, 140}, - {130, 140} + {5, 10}, + {5, 40}, + {5, 70}, + {5, 120}, + {5, 140}, + {5, 160}, + {5, 180}, + {5, 180}, + {130, 140}, + {130, 140}, + {130, 140}, + {130, 140} }; if (panel->preview) { - WMColor *color; + WMColor *color; - color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); - XFillRectangle(rc->dpy, panel->preview, WMColorGC(color), - positions[panel->oldcsection].x, - positions[panel->oldcsection].y, 22, 22); - WMReleaseColor(color); + color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); + XFillRectangle(rc->dpy, panel->preview, WMColorGC(color), + positions[panel->oldcsection].x, + positions[panel->oldcsection].y, 22, 22); + WMReleaseColor(color); } if (w) { - section = WMGetPopUpButtonSelectedItem(panel->colP); + section = WMGetPopUpButtonSelectedItem(panel->colP); - panel->oldcsection = section; - if (panel->preview) - WMDrawPixmap(panel->hand, panel->preview, positions[section].x, - positions[section].y); + panel->oldcsection = section; + if (panel->preview) + WMDrawPixmap(panel->hand, panel->preview, positions[section].x, + positions[section].y); - section = WMGetPopUpButtonSelectedItem(panel->colP); + section = WMGetPopUpButtonSelectedItem(panel->colP); - WMSetColorWellColor(panel->colW, panel->colors[section]); + WMSetColorWellColor(panel->colW, panel->colors[section]); } WMRedisplayWidget(panel->prevL); } @@ -1515,21 +1515,21 @@ changeColorPage(WMWidget *w, void *data) static void paintText(WMScreen *scr, Drawable d, WMColor *color, WMFont *font, - int x, int y, int w, int h, WMAlignment align, char *text) + int x, int y, int w, int h, WMAlignment align, char *text) { int l = strlen(text); switch (align) { - case WALeft: - x += 5; - break; - case WARight: - x += w - 5 - WMWidthOfString(font, text, l); - break; - default: - case WACenter: - x += (w - WMWidthOfString(font, text, l))/2; - break; + case WALeft: + x += 5; + break; + case WARight: + x += w - 5 - WMWidthOfString(font, text, l); + break; + default: + case WACenter: + x += (w - WMWidthOfString(font, text, l))/2; + break; } WMDrawString(scr, d, color, font, x, y + (h - WMFontHeight(font))/2, text, l); @@ -1551,67 +1551,67 @@ updateColorPreviewBox(_Panel *panel, int elements) if (elements & FTITLE_COL) { XCopyArea(dpy, pnot, d, gc, 30, 10, 190, 20, 30, 10); - paintText(scr, d, panel->colors[0], panel->boldFont, 30, 10, 190, 20, - panel->titleAlignment, _("Focused Window")); + paintText(scr, d, panel->colors[0], panel->boldFont, 30, 10, 190, 20, + panel->titleAlignment, _("Focused Window")); } if (elements & UTITLE_COL) { XCopyArea(dpy, pnot, d, gc, 30, 40, 190, 20, 30, 40); - paintText(scr, d, panel->colors[1], panel->boldFont, 30, 40, 190, 20, - panel->titleAlignment, _("Unfocused Window")); + paintText(scr, d, panel->colors[1], panel->boldFont, 30, 40, 190, 20, + panel->titleAlignment, _("Unfocused Window")); } if (elements & OTITLE_COL) { XCopyArea(dpy, pnot, d, gc, 30, 70, 190, 20, 30, 70); - paintText(scr, d, panel->colors[2], panel->boldFont, 30, 70, 190, 20, - panel->titleAlignment, _("Owner of Focused Window")); + paintText(scr, d, panel->colors[2], panel->boldFont, 30, 70, 190, 20, + panel->titleAlignment, _("Owner of Focused Window")); } if (elements & MTITLE_COL) { XCopyArea(dpy, pnot, d, gc, 30, 120, 90, 20, 30, 120); - paintText(scr, d, panel->colors[3], panel->boldFont, 30, 120, 90, 20, - WALeft, _("Menu Title")); + paintText(scr, d, panel->colors[3], panel->boldFont, 30, 120, 90, 20, + WALeft, _("Menu Title")); } if (elements & MITEM_COL) { XCopyArea(dpy, pnot, d, gc, 30, 140, 90, 20, 30, 140); - paintText(scr, d, panel->colors[4], panel->normalFont, 30, 140, 90, 20, - WALeft, _("Normal Item")); + paintText(scr, d, panel->colors[4], panel->normalFont, 30, 140, 90, 20, + WALeft, _("Normal Item")); XCopyArea(dpy, pnot, d, gc, 30, 200, 90, 20, 30, 200); - paintText(scr, d, panel->colors[4], panel->normalFont, 30, 200, 90, 20, - WALeft, _("Normal Item")); + paintText(scr, d, panel->colors[4], panel->normalFont, 30, 200, 90, 20, + WALeft, _("Normal Item")); } if (elements & MDISAB_COL) { XCopyArea(dpy, pnot, d, gc, 30, 160, 90, 20, 30, 160); - paintText(scr, d, panel->colors[5], panel->normalFont, 30, 160, 90, 20, - WALeft, _("Disabled Item")); + paintText(scr, d, panel->colors[5], panel->normalFont, 30, 160, 90, 20, + WALeft, _("Disabled Item")); } if (elements & MHIGH_COL) { - XFillRectangle(WMScreenDisplay(scr), d, WMColorGC(panel->colors[6]), - 31, 181, 87, 17); - XFillRectangle(WMScreenDisplay(scr), pnot, WMColorGC(panel->colors[6]), - 31, 181, 87, 17); - elements |= MHIGHT_COL; + XFillRectangle(WMScreenDisplay(scr), d, WMColorGC(panel->colors[6]), + 31, 181, 87, 17); + XFillRectangle(WMScreenDisplay(scr), pnot, WMColorGC(panel->colors[6]), + 31, 181, 87, 17); + elements |= MHIGHT_COL; } if (elements & MHIGHT_COL) { XCopyArea(dpy, pnot, d, gc, 30, 180, 90, 20, 30, 180); - paintText(scr, d, panel->colors[7], panel->normalFont, 30, 180, 90, 20, - WALeft, _("Highlighted")); - } -/* - if (elements & ICONT_COL) { - WRITE(_("Focused Window"), panel->colors[8], panel->boldFont, - 155, 130, 64); - } - if (elements & ICONB_COL) { - WRITE(_("Focused Window"), panel->colors[9], panel->boldFont, - 0, 0, 30); + paintText(scr, d, panel->colors[7], panel->normalFont, 30, 180, 90, 20, + WALeft, _("Highlighted")); } - if (elements & CLIP_COL) { - WRITE(_("Focused Window"), panel->colors[10], panel->boldFont, - 0, 0, 30); - } - if (elements & CCLIP_COL) { - WRITE(_("Focused Window"), panel->colors[11], panel->boldFont, - 0, 0, 30); - } - */ + /* + if (elements & ICONT_COL) { + WRITE(_("Focused Window"), panel->colors[8], panel->boldFont, + 155, 130, 64); + } + if (elements & ICONB_COL) { + WRITE(_("Focused Window"), panel->colors[9], panel->boldFont, + 0, 0, 30); + } + if (elements & CLIP_COL) { + WRITE(_("Focused Window"), panel->colors[10], panel->boldFont, + 0, 0, 30); + } + if (elements & CCLIP_COL) { + WRITE(_("Focused Window"), panel->colors[11], panel->boldFont, + 0, 0, 30); + } + */ WMRedisplayWidget(panel->prevL); } @@ -1634,39 +1634,39 @@ colorWellObserver(void *self, WMNotification *n) static void changedTabItem(struct WMTabViewDelegate *self, WMTabView *tabView, - WMTabViewItem *item) + WMTabViewItem *item) { _Panel *panel = self->data; int i; - i = WMGetTabViewItemIdentifier(item); + i = WMGetTabViewItemIdentifier(item); switch (i) { - case 0: - switch (panel->oldTabItem) { - case 1: - changeColorPage(NULL, panel); - break; - } - changePage(panel->secP, panel); - break; - case 1: - switch (panel->oldTabItem) { - case 0: - changePage(NULL, panel); - break; - } - changeColorPage(panel->colP, panel); - break; - case 3: - switch (panel->oldTabItem) { - case 0: - changePage(NULL, panel); - break; - case 1: - changeColorPage(NULL, panel); - break; - } - break; + case 0: + switch (panel->oldTabItem) { + case 1: + changeColorPage(NULL, panel); + break; + } + changePage(panel->secP, panel); + break; + case 1: + switch (panel->oldTabItem) { + case 0: + changePage(NULL, panel); + break; + } + changeColorPage(panel->colP, panel); + break; + case 3: + switch (panel->oldTabItem) { + case 0: + changePage(NULL, panel); + break; + case 1: + changeColorPage(NULL, panel); + break; + } + break; } panel->oldTabItem = i; @@ -1681,16 +1681,16 @@ menuStyleCallback(WMWidget *self, void *data) _Panel *panel = (_Panel*)data; if (self == panel->mstyB[0]) { - panel->menuStyle = MSTYLE_NORMAL; - updatePreviewBox(panel, 1<menuStyle = MSTYLE_NORMAL; + updatePreviewBox(panel, 1<mstyB[1]) { - panel->menuStyle = MSTYLE_SINGLE; - updatePreviewBox(panel, 1<menuStyle = MSTYLE_SINGLE; + updatePreviewBox(panel, 1<mstyB[2]) { - panel->menuStyle = MSTYLE_FLAT; - updatePreviewBox(panel, 1<menuStyle = MSTYLE_FLAT; + updatePreviewBox(panel, 1<taliB[0]) { - panel->titleAlignment = WALeft; - updatePreviewBox(panel, 1<titleAlignment = WALeft; + updatePreviewBox(panel, 1<taliB[1]) { - panel->titleAlignment = WACenter; - updatePreviewBox(panel, 1<titleAlignment = WACenter; + updatePreviewBox(panel, 1<taliB[2]) { - panel->titleAlignment = WARight; - updatePreviewBox(panel, 1<titleAlignment = WARight; + updatePreviewBox(panel, 1<fprefix = wstrconcat(wusergnusteppath(), "/.AppInfo"); if (access(panel->fprefix, F_OK)!=0) { - if (mkdir(panel->fprefix, 0755) < 0) { - wsyserror(panel->fprefix); - ok = False; - } + if (mkdir(panel->fprefix, 0755) < 0) { + wsyserror(panel->fprefix); + ok = False; + } } if (ok) { - tmp = wstrconcat(panel->fprefix, "/WPrefs/"); - wfree(panel->fprefix); - panel->fprefix = tmp; - if (access(panel->fprefix, F_OK)!=0) { - if (mkdir(panel->fprefix, 0755) < 0) { - wsyserror(panel->fprefix); - } - } + tmp = wstrconcat(panel->fprefix, "/WPrefs/"); + wfree(panel->fprefix); + panel->fprefix = tmp; + if (access(panel->fprefix, F_OK)!=0) { + if (mkdir(panel->fprefix, 0755) < 0) { + wsyserror(panel->fprefix); + } + } } panel->smallFont = WMSystemFontOfSize(scr, 10); @@ -1762,10 +1762,10 @@ createPanel(Panel *p) WMMoveWidget(panel->prevL, 15, 10); WMSetLabelRelief(panel->prevL, WRSunken); WMSetLabelImagePosition(panel->prevL, WIPImageOnly); - + WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask, - previewClick, panel); - + previewClick, panel); + /* tabview */ @@ -1798,8 +1798,8 @@ createPanel(Panel *p) WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus")); WMAddPopUpButtonItem(panel->secP, _("Menu Items")); WMAddPopUpButtonItem(panel->secP, _("Icon Background")); -/* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds")); - */ + /* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds")); + */ WMSetPopUpButtonSelectedItem(panel->secP, 0); WMSetPopUpButtonAction(panel->secP, changePage, panel); @@ -1813,8 +1813,8 @@ createPanel(Panel *p) WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel); WMSetBalloonTextForView(_("Double click in the texture you want to use\n" - "for the selected item."), - WMWidgetView(panel->texLs)); + "for the selected item."), + WMWidgetView(panel->texLs)); /* command buttons */ @@ -1831,7 +1831,7 @@ createPanel(Panel *p) SetButtonAlphaImage(scr, panel->newB, TNEW_FILE, NULL, NULL); WMSetBalloonTextForView(_("Create a new texture."), - WMWidgetView(panel->newB)); + WMWidgetView(panel->newB)); panel->ripB = WMCreateCommandButton(panel->texF); WMResizeWidget(panel->ripB, 57, 39); @@ -1843,7 +1843,7 @@ createPanel(Panel *p) SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE, NULL, NULL); WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."), - WMWidgetView(panel->ripB)); + WMWidgetView(panel->ripB)); WMSetButtonEnabled(panel->ripB, False); @@ -1856,7 +1856,7 @@ createPanel(Panel *p) SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE, NULL, NULL); WMSetButtonAction(panel->editB, editTexture, panel); WMSetBalloonTextForView(_("Edit the highlighted texture."), - WMWidgetView(panel->editB)); + WMWidgetView(panel->editB)); panel->delB = WMCreateCommandButton(panel->texF); WMResizeWidget(panel->delB, 57, 38); @@ -1868,7 +1868,7 @@ createPanel(Panel *p) WMSetButtonEnabled(panel->delB, False); WMSetButtonAction(panel->delB, deleteTexture, panel); WMSetBalloonTextForView(_("Delete the highlighted texture."), - WMWidgetView(panel->delB)); + WMWidgetView(panel->delB)); WMReleaseFont(font); @@ -1896,41 +1896,41 @@ createPanel(Panel *p) WMAddPopUpButtonItem(panel->colP, _("Menu Highlight Color")); WMAddPopUpButtonItem(panel->colP, _("Highlighted Menu Text Color")); /* - WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title")); - WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title Back")); - WMAddPopUpButtonItem(panel->colP, _("Clip Title")); - WMAddPopUpButtonItem(panel->colP, _("Collapsed Clip Title")); + WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title")); + WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title Back")); + WMAddPopUpButtonItem(panel->colP, _("Clip Title")); + WMAddPopUpButtonItem(panel->colP, _("Collapsed Clip Title")); */ WMSetPopUpButtonSelectedItem(panel->colP, 0); WMSetPopUpButtonAction(panel->colP, changeColorPage, panel); - + panel->colW = WMCreateColorWell(panel->colF); WMResizeWidget(panel->colW, 65, 50); WMMoveWidget(panel->colW, 30, 75); WMAddNotificationObserver(colorWellObserver, panel, - WMColorWellDidChangeNotification, panel->colW); + WMColorWellDidChangeNotification, panel->colW); for (i = 0; i < 4; i++) { - int j; - for (j = 0; j < 6; j++) { - panel->sampW[i+j*4] = WMCreateColorWell(panel->colF); - WMResizeWidget(panel->sampW[i+j*4], 22, 22); - WMMoveWidget(panel->sampW[i+j*4], 130 + i*22, 40 + j*22); - WSetColorWellBordered(panel->sampW[i+j*4], False); - } + int j; + for (j = 0; j < 6; j++) { + panel->sampW[i+j*4] = WMCreateColorWell(panel->colF); + WMResizeWidget(panel->sampW[i+j*4], 22, 22); + WMMoveWidget(panel->sampW[i+j*4], 130 + i*22, 40 + j*22); + WSetColorWellBordered(panel->sampW[i+j*4], False); + } } WMMapSubwidgets(panel->colF); - + #ifdef unfinished /*** root bg ***/ - + panel->bgF = WMCreateFrame(panel->box); WMSetFrameRelief(panel->bgF, WRFlat); - + item = WMCreateTabViewItemWithIdentifier(2); WMSetTabViewItemView(item, WMWidgetView(panel->bgF)); WMSetTabViewItemLabel(item, _("Background")); @@ -1946,10 +1946,10 @@ createPanel(Panel *p) WMMoveWidget(panel->selbgB, 5, 165); WMResizeWidget(panel->selbgB, 100, 24); WMSetButtonText(panel->selbgB, _("Browse...")); - - - - + + + + WMMapSubwidgets(panel->bgF); #endif /* unfinished */ /*** options ***/ @@ -1968,35 +1968,35 @@ createPanel(Panel *p) WMSetFrameTitle(panel->mstyF, _("Menu Style")); for (i = 0; i < 3; i++) { - WMPixmap *icon; - char *path; - - panel->mstyB[i] = WMCreateButton(panel->mstyF, WBTOnOff); - WMResizeWidget(panel->mstyB[i], 54, 54); - WMMoveWidget(panel->mstyB[i], 15 + i*65, 20); - WMSetButtonImagePosition(panel->mstyB[i], WIPImageOnly); - WMSetButtonAction(panel->mstyB[i], menuStyleCallback, panel); - switch (i) { - case 0: - path = LocateImage(MSTYLE1_FILE); - break; - case 1: - path = LocateImage(MSTYLE2_FILE); - break; - case 2: - path = LocateImage(MSTYLE3_FILE); - break; - } - if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonImage(panel->mstyB[i], icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); - } + WMPixmap *icon; + char *path; + + panel->mstyB[i] = WMCreateButton(panel->mstyF, WBTOnOff); + WMResizeWidget(panel->mstyB[i], 54, 54); + WMMoveWidget(panel->mstyB[i], 15 + i*65, 20); + WMSetButtonImagePosition(panel->mstyB[i], WIPImageOnly); + WMSetButtonAction(panel->mstyB[i], menuStyleCallback, panel); + switch (i) { + case 0: + path = LocateImage(MSTYLE1_FILE); + break; + case 1: + path = LocateImage(MSTYLE2_FILE); + break; + case 2: + path = LocateImage(MSTYLE3_FILE); + break; + } + if (path) { + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonImage(panel->mstyB[i], icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); + } } WMGroupButtons(panel->mstyB[0], panel->mstyB[1]); WMGroupButtons(panel->mstyB[0], panel->mstyB[2]); @@ -2010,27 +2010,27 @@ createPanel(Panel *p) WMSetFrameTitle(panel->taliF, _("Title Alignment")); for (i = 0; i < 3; i++) { - panel->taliB[i] = WMCreateRadioButton(panel->taliF); - WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel); - switch (i) { - case 0: - WMSetButtonText(panel->taliB[i], _("Left")); - break; - case 1: - WMSetButtonText(panel->taliB[i], _("Center")); - break; - case 2: - WMSetButtonText(panel->taliB[i], _("Right")); - break; - } - WMResizeWidget(panel->taliB[i], 90, 18); - WMMoveWidget(panel->taliB[i], 10, 15 + 20*i); + panel->taliB[i] = WMCreateRadioButton(panel->taliF); + WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel); + switch (i) { + case 0: + WMSetButtonText(panel->taliB[i], _("Left")); + break; + case 1: + WMSetButtonText(panel->taliB[i], _("Center")); + break; + case 2: + WMSetButtonText(panel->taliB[i], _("Right")); + break; + } + WMResizeWidget(panel->taliB[i], 90, 18); + WMMoveWidget(panel->taliB[i], 10, 15 + 20*i); } WMGroupButtons(panel->taliB[0], panel->taliB[1]); WMGroupButtons(panel->taliB[0], panel->taliB[2]); WMMapSubwidgets(panel->taliF); - + WMMapSubwidgets(panel->optF); /**/ @@ -2054,8 +2054,8 @@ createPanel(Panel *p) static void -setupTextureFor(WMList *list, char *key, char *defValue, char *title, - int index) +setupTextureFor(WMList *list, char *key, char *defValue, char *title, + int index) { WMListItem *item; TextureListItem *titem; @@ -2067,18 +2067,18 @@ setupTextureFor(WMList *list, char *key, char *defValue, char *title, titem->prop = GetObjectForKey(key); if (!titem->prop || !WMIsPLArray(titem->prop)) { /* Maybe also give a error message to stderr that the entry is bad? */ - titem->prop = WMCreatePropListFromDescription(defValue); + titem->prop = WMCreatePropListFromDescription(defValue); } else { - WMRetainPropList(titem->prop); + WMRetainPropList(titem->prop); } titem->texture = WMGetPropListDescription((WMPropList*)titem->prop, False); titem->current = 1; titem->selectedFor = 1<ispixmap = isPixmap(titem->prop); titem->preview = renderTexture(WMWidgetScreen(list), titem->prop, - TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0); + TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0); item = WMAddListItem(list, ""); item->clientData = titem; @@ -2094,41 +2094,41 @@ showData(_Panel *panel) str = GetStringForKey("MenuStyle"); if (str && strcasecmp(str, "flat")==0) { - panel->menuStyle = MSTYLE_FLAT; + panel->menuStyle = MSTYLE_FLAT; } else if (str && strcasecmp(str, "singletexture")==0) { - panel->menuStyle = MSTYLE_SINGLE; + panel->menuStyle = MSTYLE_SINGLE; } else { - panel->menuStyle = MSTYLE_NORMAL; + panel->menuStyle = MSTYLE_NORMAL; } str = GetStringForKey("TitleJustify"); if (str && strcasecmp(str, "left")==0) { - panel->titleAlignment = WALeft; + panel->titleAlignment = WALeft; } else if (str && strcasecmp(str, "right")==0) { - panel->titleAlignment = WARight; + panel->titleAlignment = WARight; } else { - panel->titleAlignment = WACenter; + panel->titleAlignment = WACenter; } for (i = 0; i < sizeof(colorOptions)/(2*sizeof(char*)); i++) { - WMColor *color; + WMColor *color; - str = GetStringForKey(colorOptions[i*2]); - if (!str) - str = colorOptions[i*2+1]; + str = GetStringForKey(colorOptions[i*2]); + if (!str) + str = colorOptions[i*2+1]; - if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) { - color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False); - } + if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) { + color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False); + } - panel->colors[i] = color; + panel->colors[i] = color; } changeColorPage(panel->colP, panel); for (i = 0; i < sizeof(textureOptions)/(3*sizeof(char*)); i++) { - setupTextureFor(panel->texLs, textureOptions[i*3], - textureOptions[i*3+1], textureOptions[i*3+2], i); - panel->textureIndex[i] = i; + setupTextureFor(panel->texLs, textureOptions[i*3], + textureOptions[i*3+1], textureOptions[i*3+2], i); + panel->textureIndex[i] = i; } updatePreviewBox(panel, EVERYTHING); @@ -2145,45 +2145,45 @@ storeData(_Panel *panel) int i; for (i = 0; i < sizeof(textureOptions)/(sizeof(char*)*3); i++) { - item = WMGetListItem(panel->texLs, panel->textureIndex[i]); - titem = (TextureListItem*)item->clientData; - SetObjectForKey(titem->prop, textureOptions[i*3]); + item = WMGetListItem(panel->texLs, panel->textureIndex[i]); + titem = (TextureListItem*)item->clientData; + SetObjectForKey(titem->prop, textureOptions[i*3]); } for (i = 0; i < 8; i++) { - char *str; + char *str; - str = WMGetColorRGBDescription(panel->colors[i]); + str = WMGetColorRGBDescription(panel->colors[i]); - if (str) { - SetStringForKey(str, colorOptions[i*2]); - wfree(str); - } + if (str) { + SetStringForKey(str, colorOptions[i*2]); + wfree(str); + } } switch (panel->menuStyle) { - case MSTYLE_SINGLE: - SetStringForKey("singletexture", "MenuStyle"); - break; - case MSTYLE_FLAT: - SetStringForKey("flat", "MenuStyle"); - break; - default: - case MSTYLE_NORMAL: - SetStringForKey("normal", "MenuStyle"); - break; + case MSTYLE_SINGLE: + SetStringForKey("singletexture", "MenuStyle"); + break; + case MSTYLE_FLAT: + SetStringForKey("flat", "MenuStyle"); + break; + default: + case MSTYLE_NORMAL: + SetStringForKey("normal", "MenuStyle"); + break; } switch (panel->titleAlignment) { - case WALeft: - SetStringForKey("left", "TitleJustify"); - break; - case WARight: - SetStringForKey("right", "TitleJustify"); - break; - default: - case WACenter: - SetStringForKey("center", "TitleJustify"); - break; + case WALeft: + SetStringForKey("left", "TitleJustify"); + break; + case WARight: + SetStringForKey("right", "TitleJustify"); + break; + default: + case WACenter: + SetStringForKey("center", "TitleJustify"); + break; } } @@ -2202,31 +2202,31 @@ prepareForClose(_Panel *panel) /* store list of textures */ for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) { - item = WMGetListItem(panel->texLs, i); - titem = (TextureListItem*)item->clientData; + item = WMGetListItem(panel->texLs, i); + titem = (TextureListItem*)item->clientData; - texture = WMCreatePLArray(WMCreatePLString(titem->title), - WMRetainPropList(titem->prop), - WMCreatePLString(titem->path), - NULL); + texture = WMCreatePLArray(WMCreatePLString(titem->title), + WMRetainPropList(titem->prop), + WMCreatePLString(titem->path), + NULL); - WMAddToPLArray(textureList, texture); + WMAddToPLArray(textureList, texture); } WMSetUDObjectForKey(udb, textureList, "TextureList"); WMReleasePropList(textureList); - + /* store list of colors */ textureList = WMCreatePLArray(NULL, NULL); for (i = 0; i < 24; i++) { - WMColor *color; - char *str; + WMColor *color; + char *str; - color = WMGetColorWellColor(panel->sampW[i]); + color = WMGetColorWellColor(panel->sampW[i]); - str = WMGetColorRGBDescription(color); - WMAddToPLArray(textureList, WMCreatePLString(str)); - wfree(str); + str = WMGetColorRGBDescription(color); + WMAddToPLArray(textureList, WMCreatePLString(str)); + wfree(str); } WMSetUDObjectForKey(udb, textureList, "ColorList"); WMReleasePropList(textureList); @@ -2243,11 +2243,11 @@ InitAppearance(WMScreen *scr, WMWindow *win) panel = wmalloc(sizeof(_Panel)); memset(panel, 0, sizeof(_Panel)); - + panel->sectionName = _("Appearance Preferences"); panel->description = _("Background texture configuration for windows,\n" - "menus and icons."); + "menus and icons."); panel->parent = win; @@ -2288,8 +2288,8 @@ OpenExtractPanelFor(_Panel *panel, char *path) epanel = wmalloc(sizeof(ExtractPanel)); epanel->win = WMCreatePanelWithStyleForWindow(panel->parent, "extract", - WMTitledWindowMask - |WMClosableWindowMask); + WMTitledWindowMask + |WMClosableWindowMask); WMResizeWidget(epanel->win, 245, 250); WMSetWindowTitle(epanel->win, _("Extract Texture")); @@ -2317,7 +2317,7 @@ OpenExtractPanelFor(_Panel *panel, char *path) WMResizeWidget(epanel->list, 225, 165); WMMoveWidget(epanel->list, 10, 30); - + epanel->closeB = WMCreateCommandButton(epanel->win); WMResizeWidget(epanel->closeB, 74, 24); @@ -2331,13 +2331,13 @@ OpenExtractPanelFor(_Panel *panel, char *path) WMMapSubwidgets(epanel->win); - + /* take textures from file */ - - + + WMRealizeWidget(epanel->win); - + WMMapWidget(epanel->win); } diff --git a/WPrefs.app/Configurations.c b/WPrefs.app/Configurations.c index e27ae727..8f3ad342 100644 --- a/WPrefs.app/Configurations.c +++ b/WPrefs.app/Configurations.c @@ -1,9 +1,9 @@ /* Configurations.c- misc. configurations - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -25,12 +25,12 @@ typedef struct _Panel { WMBox *box; - char *sectionName; + char *sectionName; char *description; CallbackRec callbacks; - + WMWidget *parent; WMFrame *icoF; @@ -58,7 +58,7 @@ typedef struct _Panel { WMLabel *dithL; WMLabel *dith1L; WMLabel *dith2L; - + int cmapSize; } _Panel; @@ -87,17 +87,17 @@ static void showData(_Panel *panel) { WMPerformButtonClick(panel->icoB[GetSpeedForKey("IconSlideSpeed")]); - + WMPerformButtonClick(panel->shaB[GetSpeedForKey("ShadeSpeed")]); - + if (GetBoolForKey("NewStyle")) { - WMPerformButtonClick(panel->newsB); + WMPerformButtonClick(panel->newsB); } else { - WMPerformButtonClick(panel->oldsB); + WMPerformButtonClick(panel->oldsB); } - + WMSetButtonSelected(panel->animB, !GetBoolForKey("DisableAnimations")); - + WMSetButtonSelected(panel->supB, GetBoolForKey("Superfluous")); WMSetButtonSelected(panel->sfxB, !GetBoolForKey("DisableSound")); @@ -105,7 +105,7 @@ showData(_Panel *panel) WMSetButtonSelected(panel->smoB, GetBoolForKey("SmoothWorkspaceBack")); WMSetButtonSelected(panel->dithB, GetBoolForKey("DisableDithering")); - + WMSetSliderValue(panel->dithS, GetIntegerForKey("ColormapSize")); updateLabel(panel->dithS, panel); @@ -119,19 +119,19 @@ updateLabel(WMWidget *self, void *data) _Panel *panel = (_Panel*)data; char buffer[64]; float fl; - + fl = WMGetSliderValue(sPtr); panel->cmapSize = (int)fl; - + sprintf(buffer, "%i", panel->cmapSize*panel->cmapSize*panel->cmapSize); WMSetLabelText(panel->dithL, buffer); } static void -createImages(WMScreen *scr, RContext *rc, RImage *xis, char *file, - WMPixmap **icon1, WMPixmap **icon2) +createImages(WMScreen *scr, RContext *rc, RImage *xis, char *file, + WMPixmap **icon1, WMPixmap **icon2) { RImage *icon; char *path; @@ -142,33 +142,32 @@ createImages(WMScreen *scr, RContext *rc, RImage *xis, char *file, path = LocateImage(file); if (!path) { - return; + return; } - + *icon1 = WMCreatePixmapFromFile(scr, path); if (!*icon1) { - wwarning(_("could not load icon %s"), path); - wfree(path); - return; + wwarning(_("could not load icon %s"), path); + wfree(path); + return; } icon = RLoadImage(rc, path, 0); if (!icon) { - wwarning(_("could not load icon %s"), path); - wfree(path); - return; + wwarning(_("could not load icon %s"), path); + wfree(path); + return; } RCombineImageWithColor(icon, &gray); if (xis) { - RCombineImagesWithOpaqueness(icon, xis, 180); - if (!(*icon2 = WMCreatePixmapFromRImage(scr, icon, 127))) - wwarning(_("could not process icon %s:"), file, RMessageForError(RErrorCode)); + RCombineImagesWithOpaqueness(icon, xis, 180); + if (!(*icon2 = WMCreatePixmapFromRImage(scr, icon, 127))) + wwarning(_("could not process icon %s:"), file, RMessageForError(RErrorCode)); } RReleaseImage(icon); wfree(path); } - static void createPanel(Panel *p) { @@ -181,14 +180,14 @@ createPanel(Panel *p) RContext *rc = WMScreenRContext(scr); WMFont *font = WMSystemFontOfSize(scr, 10); char *path; - + path = LocateImage(ARQUIVO_XIS); if (path) { - xis = RLoadImage(rc, path, 0); - if (!xis) { - wwarning(_("could not load image file %s"), path); - } - wfree(path); + xis = RLoadImage(rc, path, 0); + if (!xis) { + wwarning(_("could not load image file %s"), path); + } + wfree(path); } @@ -196,70 +195,70 @@ createPanel(Panel *p) WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /*********** Icon Slide Speed **********/ - + panel->icoF = WMCreateFrame(panel->box); WMResizeWidget(panel->icoF, 230, 45); WMMoveWidget(panel->icoF, 15, 10); WMSetFrameTitle(panel->icoF, _("Icon Slide Speed")); - + /*********** Shade Animation Speed **********/ panel->shaF = WMCreateFrame(panel->box); WMResizeWidget(panel->shaF, 230, 45); WMMoveWidget(panel->shaF, 15, 60); WMSetFrameTitle(panel->shaF, _("Shade Animation Speed")); - + buf1 = wmalloc(strlen(SPEED_IMAGE)+1); buf2 = wmalloc(strlen(SPEED_IMAGE_S)+1); - + for (i = 0; i < 5; i++) { - panel->icoB[i] = WMCreateCustomButton(panel->icoF, WBBStateChangeMask); - panel->shaB[i] = WMCreateCustomButton(panel->shaF, WBBStateChangeMask); - WMResizeWidget(panel->icoB[i], 40, 24); - WMMoveWidget(panel->icoB[i], 10+(40*i), 15); - WMResizeWidget(panel->shaB[i], 40, 24); - WMMoveWidget(panel->shaB[i], 10+(40*i), 15); - WMSetButtonBordered(panel->icoB[i], False); - WMSetButtonImagePosition(panel->icoB[i], WIPImageOnly); - if (i > 0) { - WMGroupButtons(panel->icoB[0], panel->icoB[i]); - } - WMSetButtonBordered(panel->shaB[i], False); - WMSetButtonImagePosition(panel->shaB[i], WIPImageOnly); - if (i > 0) { - WMGroupButtons(panel->shaB[0], panel->shaB[i]); - } - sprintf(buf1, SPEED_IMAGE, i); - sprintf(buf2, SPEED_IMAGE_S, i); - path = LocateImage(buf1); - if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonImage(panel->icoB[i], icon); - WMSetButtonImage(panel->shaB[i], icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); - } - path = LocateImage(buf2); - if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonAltImage(panel->icoB[i], icon); - WMSetButtonAltImage(panel->shaB[i], icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); - } + panel->icoB[i] = WMCreateCustomButton(panel->icoF, WBBStateChangeMask); + panel->shaB[i] = WMCreateCustomButton(panel->shaF, WBBStateChangeMask); + WMResizeWidget(panel->icoB[i], 40, 24); + WMMoveWidget(panel->icoB[i], 10+(40*i), 15); + WMResizeWidget(panel->shaB[i], 40, 24); + WMMoveWidget(panel->shaB[i], 10+(40*i), 15); + WMSetButtonBordered(panel->icoB[i], False); + WMSetButtonImagePosition(panel->icoB[i], WIPImageOnly); + if (i > 0) { + WMGroupButtons(panel->icoB[0], panel->icoB[i]); + } + WMSetButtonBordered(panel->shaB[i], False); + WMSetButtonImagePosition(panel->shaB[i], WIPImageOnly); + if (i > 0) { + WMGroupButtons(panel->shaB[0], panel->shaB[i]); + } + sprintf(buf1, SPEED_IMAGE, i); + sprintf(buf2, SPEED_IMAGE_S, i); + path = LocateImage(buf1); + if (path) { + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonImage(panel->icoB[i], icon); + WMSetButtonImage(panel->shaB[i], icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); + } + path = LocateImage(buf2); + if (path) { + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonAltImage(panel->icoB[i], icon); + WMSetButtonAltImage(panel->shaB[i], icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); + } } wfree(buf1); wfree(buf2); - + WMMapSubwidgets(panel->icoF); WMMapSubwidgets(panel->shaF); @@ -270,9 +269,9 @@ createPanel(Panel *p) WMMoveWidget(panel->smoF, 18, 115); WMSetFrameTitle(panel->smoF, _("Smooth Scaling")); WMSetBalloonTextForView(_("Smooth scaled background images, neutralizing\n" - "the `pixelization' effect. This will slow\n" - "down loading of background images considerably."), - WMWidgetView(panel->smoF)); + "the `pixelization' effect. This will slow\n" + "down loading of background images considerably."), + WMWidgetView(panel->smoF)); panel->smoB = WMCreateButton(panel->smoF, WBTToggle); WMResizeWidget(panel->smoB, 64, 64); @@ -280,28 +279,28 @@ createPanel(Panel *p) WMSetButtonImagePosition(panel->smoB, WIPImageOnly); path = LocateImage(SMOOTH_IMAGE); if (path) { - RImage *image, *scaled; - - image = RLoadImage(WMScreenRContext(scr), path, 0); - wfree(path); - - scaled = RScaleImage(image, 61, 61); - icon = WMCreatePixmapFromRImage(scr, scaled, 128); - RReleaseImage(scaled); - if (icon) { - WMSetButtonImage(panel->smoB, icon); - WMReleasePixmap(icon); - } - - scaled = RSmoothScaleImage(image, 61, 61); - icon = WMCreatePixmapFromRImage(scr, scaled, 128); - RReleaseImage(scaled); - if (icon) { - WMSetButtonAltImage(panel->smoB, icon); - WMReleasePixmap(icon); - } - - RReleaseImage(image); + RImage *image, *scaled; + + image = RLoadImage(WMScreenRContext(scr), path, 0); + wfree(path); + + scaled = RScaleImage(image, 61, 61); + icon = WMCreatePixmapFromRImage(scr, scaled, 128); + RReleaseImage(scaled); + if (icon) { + WMSetButtonImage(panel->smoB, icon); + WMReleasePixmap(icon); + } + + scaled = RSmoothScaleImage(image, 61, 61); + icon = WMCreatePixmapFromRImage(scr, scaled, 128); + RReleaseImage(scaled); + if (icon) { + WMSetButtonAltImage(panel->smoB, icon); + WMReleasePixmap(icon); + } + + RReleaseImage(image); } WMMapSubwidgets(panel->smoF); @@ -311,18 +310,18 @@ createPanel(Panel *p) WMResizeWidget(panel->titlF, 105, 110); WMMoveWidget(panel->titlF, 140, 115); WMSetFrameTitle(panel->titlF, _("Titlebar Style")); - + panel->newsB = WMCreateButton(panel->titlF, WBTOnOff); WMResizeWidget(panel->newsB, 74, 40); WMMoveWidget(panel->newsB, 15, 20); WMSetButtonImagePosition(panel->newsB, WIPImageOnly); path = LocateImage(NEWS_IMAGE); if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonImage(panel->newsB, icon); - WMReleasePixmap(icon); - } + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonImage(panel->newsB, icon); + WMReleasePixmap(icon); + } } panel->oldsB = WMCreateButton(panel->titlF, WBTOnOff); @@ -331,25 +330,25 @@ createPanel(Panel *p) WMSetButtonImagePosition(panel->oldsB, WIPImageOnly); path = LocateImage(OLDS_IMAGE); if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonImage(panel->oldsB, icon); - WMReleasePixmap(icon); - } - wfree(path); + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonImage(panel->oldsB, icon); + WMReleasePixmap(icon); + } + wfree(path); } WMGroupButtons(panel->newsB, panel->oldsB); - + WMMapSubwidgets(panel->titlF); /**************** Features ******************/ - + panel->animF = WMCreateFrame(panel->box); WMResizeWidget(panel->animF, 255, 115); WMMoveWidget(panel->animF, 255, 10); WMSetFrameTitle(panel->animF, _("Animations and Sound")); - + panel->animB = WMCreateButton(panel->animF, WBTToggle); WMResizeWidget(panel->animB, 64, 64); WMMoveWidget(panel->animB, 15, 20); @@ -358,16 +357,16 @@ createPanel(Panel *p) WMSetButtonImagePosition(panel->animB, WIPAbove); createImages(scr, rc, xis, ANIM_IMAGE, &altIcon, &icon); if (icon) { - WMSetButtonImage(panel->animB, icon); - WMReleasePixmap(icon); + WMSetButtonImage(panel->animB, icon); + WMReleasePixmap(icon); } if (altIcon) { - WMSetButtonAltImage(panel->animB, altIcon); - WMReleasePixmap(altIcon); + WMSetButtonAltImage(panel->animB, altIcon); + WMReleasePixmap(altIcon); } WMSetBalloonTextForView(_("Disable/enable animations such as those shown\n" - "for window miniaturization, shading etc."), - WMWidgetView(panel->animB)); + "for window miniaturization, shading etc."), + WMWidgetView(panel->animB)); panel->supB = WMCreateButton(panel->animF, WBTToggle); WMResizeWidget(panel->supB, 64, 64); @@ -377,19 +376,19 @@ createPanel(Panel *p) WMSetButtonImagePosition(panel->supB, WIPAbove); createImages(scr, rc, xis, SUPERF_IMAGE, &altIcon, &icon); if (icon) { - WMSetButtonImage(panel->supB, icon); - WMReleasePixmap(icon); + WMSetButtonImage(panel->supB, icon); + WMReleasePixmap(icon); } if (altIcon) { - WMSetButtonAltImage(panel->supB, altIcon); - WMReleasePixmap(altIcon); + WMSetButtonAltImage(panel->supB, altIcon); + WMReleasePixmap(altIcon); } WMSetBalloonTextForView(_("Disable/enable `superfluous' features and\n" - "animations. These include the `ghosting' of the\n" - "dock when it's being moved to another side and\n" - "the explosion animation when undocking icons."), - WMWidgetView(panel->supB)); - + "animations. These include the `ghosting' of the\n" + "dock when it's being moved to another side and\n" + "the explosion animation when undocking icons."), + WMWidgetView(panel->supB)); + panel->sfxB = WMCreateButton(panel->animF, WBTToggle); WMResizeWidget(panel->sfxB, 64, 64); WMMoveWidget(panel->sfxB, 175, 20); @@ -398,40 +397,40 @@ createPanel(Panel *p) WMSetButtonImagePosition(panel->sfxB, WIPAbove); createImages(scr, rc, xis, SOUND_IMAGE, &altIcon, &icon); if (icon) { - WMSetButtonImage(panel->sfxB, icon); - WMReleasePixmap(icon); + WMSetButtonImage(panel->sfxB, icon); + WMReleasePixmap(icon); } if (altIcon) { - WMSetButtonAltImage(panel->sfxB, altIcon); - WMReleasePixmap(altIcon); + WMSetButtonAltImage(panel->sfxB, altIcon); + WMReleasePixmap(altIcon); } WMSetBalloonTextForView(_("Disable/enable support for sound effects played\n" - "for actions like shading and closing a window.\n" - "You will need a module distributed separately\n" - "for this. You can get it at:\n" - "http://shadowmere.student.utwente.nl/"), - WMWidgetView(panel->sfxB)); - + "for actions like shading and closing a window.\n" + "You will need a module distributed separately\n" + "for this. You can get it at:\n" + "http://shadowmere.student.utwente.nl/"), + WMWidgetView(panel->sfxB)); + panel->noteL = WMCreateLabel(panel->animF); WMResizeWidget(panel->noteL, 235, 28); WMMoveWidget(panel->noteL, 10, 85); WMSetLabelFont(panel->noteL, font); WMSetLabelText(panel->noteL, _("Note: sound requires a module distributed\nseparately")); - + WMMapSubwidgets(panel->animF); - + /*********** Dithering **********/ panel->cmapSize = 4; - + panel->dithF = WMCreateFrame(panel->box); WMResizeWidget(panel->dithF, 255, 95); WMMoveWidget(panel->dithF, 255, 130); WMSetFrameTitle(panel->dithF, _("Dithering colormap for 8bpp")); WMSetBalloonTextForView(_("Number of colors to reserve for Window Maker\n" - "on displays that support only 8bpp (PseudoColor)."), - WMWidgetView(panel->dithF)); - + "on displays that support only 8bpp (PseudoColor)."), + WMWidgetView(panel->dithF)); + panel->dithB = WMCreateSwitchButton(panel->dithF); WMResizeWidget(panel->dithB, 235, 32); WMMoveWidget(panel->dithB, 15, 15); @@ -450,7 +449,7 @@ createPanel(Panel *p) WMSetSliderMaxValue(panel->dithS, 6); WMSetSliderContinuous(panel->dithS, True); WMSetSliderAction(panel->dithS, updateLabel, panel); - + panel->dith1L = WMCreateLabel(panel->dithF); WMResizeWidget(panel->dith1L, 70, 35); WMMoveWidget(panel->dith1L, 5, 50); @@ -466,14 +465,14 @@ createPanel(Panel *p) WMSetLabelText(panel->dith2L, _("More colors for\nWindow Maker")); WMMapSubwidgets(panel->dithF); - + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); - + if (xis) - RReleaseImage(xis); + RReleaseImage(xis); WMReleaseFont(font); - + showData(panel); } @@ -484,26 +483,26 @@ storeData(_Panel *panel) int i; for (i=0; i<5; i++) { - if (WMGetButtonSelected(panel->icoB[i])) - break; + if (WMGetButtonSelected(panel->icoB[i])) + break; } SetSpeedForKey(i, "IconSlideSpeed"); for (i=0; i<5; i++) { - if (WMGetButtonSelected(panel->shaB[i])) - break; + if (WMGetButtonSelected(panel->shaB[i])) + break; } SetSpeedForKey(i, "ShadeSpeed"); SetBoolForKey(WMGetButtonSelected(panel->newsB), "NewStyle"); - + SetBoolForKey(!WMGetButtonSelected(panel->animB), "DisableAnimations"); SetBoolForKey(WMGetButtonSelected(panel->supB), "Superfluous"); SetBoolForKey(!WMGetButtonSelected(panel->sfxB), "DisableSound"); SetBoolForKey(WMGetButtonSelected(panel->smoB), "SmoothWorkspaceBack"); - + SetBoolForKey(WMGetButtonSelected(panel->dithB), "DisableDithering"); SetIntegerForKey(WMGetSliderValue(panel->dithS), "ColormapSize"); } @@ -521,8 +520,8 @@ InitConfigurations(WMScreen *scr, WMWidget *parent) panel->sectionName = _("Other Configurations"); panel->description = _("Animation speeds, titlebar styles, various option\n" - "toggling and number of colors to reserve for\n" - "Window Maker on 8bit displays."); + "toggling and number of colors to reserve for\n" + "Window Maker on 8bit displays."); panel->parent = parent; @@ -533,3 +532,5 @@ InitConfigurations(WMScreen *scr, WMWidget *parent) return panel; } + + diff --git a/WPrefs.app/Expert.c b/WPrefs.app/Expert.c index 974e9fdb..34585136 100644 --- a/WPrefs.app/Expert.c +++ b/WPrefs.app/Expert.c @@ -1,9 +1,9 @@ /* Expert.c- expert user options - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -30,7 +30,7 @@ typedef struct _Panel { char *description; CallbackRec callbacks; - + WMWidget *parent; WMButton *swi[8]; @@ -55,7 +55,7 @@ showData(_Panel *panel) WMSetButtonSelected(panel->swi[5], GetBoolForKey("DontConfirmKill")); WMSetButtonSelected(panel->swi[6], GetBoolForKey("DisableBlinking")); //if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box))) - WMSetButtonSelected(panel->swi[7], GetBoolForKey("AntialiasedText")); + WMSetButtonSelected(panel->swi[7], GetBoolForKey("AntialiasedText")); } @@ -69,11 +69,11 @@ createPanel(Panel *p) WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); for (i=0; i<8; i++) { - panel->swi[i] = WMCreateSwitchButton(panel->box); - WMResizeWidget(panel->swi[i], FRAME_WIDTH-40, 25); - WMMoveWidget(panel->swi[i], 20, 20+i*25); + panel->swi[i] = WMCreateSwitchButton(panel->box); + WMResizeWidget(panel->swi[i], FRAME_WIDTH-40, 25); + WMMoveWidget(panel->swi[i], 20, 20+i*25); } - + WMSetButtonText(panel->swi[0], _("Disable miniwindows (icons for miniaturized windows). For use with KDE/GNOME.")); WMSetButtonText(panel->swi[1], _("Do not set non-WindowMaker specific parameters (do not use xset).")); WMSetButtonText(panel->swi[2], _("Automatically save session when exiting Window Maker.")); @@ -84,11 +84,11 @@ createPanel(Panel *p) WMSetButtonText(panel->swi[7], _("Smooth font edges (needs restart).")); //if (!WMHasAntialiasingSupport(WMWidgetScreen(panel->box))) - WMSetButtonEnabled(panel->swi[7], True); + WMSetButtonEnabled(panel->swi[7], True); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); - + showData(panel); } @@ -108,7 +108,7 @@ storeDefaults(_Panel *panel) SetBoolForKey(WMGetButtonSelected(panel->swi[5]), "DontConfirmKill"); SetBoolForKey(WMGetButtonSelected(panel->swi[6]), "DisableBlinking"); //if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box))) - SetBoolForKey(WMGetButtonSelected(panel->swi[7]), "AntialiasedText"); + SetBoolForKey(WMGetButtonSelected(panel->swi[7]), "AntialiasedText"); } @@ -123,14 +123,15 @@ InitExpert(WMScreen *scr, WMWidget *parent) panel->sectionName = _("Expert User Preferences"); panel->description = _("Options for people who know what they're doing...\n" - "Also have some other misc. options."); + "Also have some other misc. options."); panel->parent = parent; panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeDefaults; - + AddSection(panel, ICON_FILE); return panel; } + diff --git a/WPrefs.app/Focus.c b/WPrefs.app/Focus.c index 3fbf1cda..f735ebc5 100644 --- a/WPrefs.app/Focus.c +++ b/WPrefs.app/Focus.c @@ -1,9 +1,9 @@ /* Focus.c- input and colormap focus stuff - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -31,25 +31,25 @@ typedef struct _Panel { char *description; CallbackRec callbacks; - + WMWidget *parent; - + WMFrame *kfocF; WMButton *kfocB[2]; - + WMFrame *cfocF; WMButton *autB; WMButton *manB; - + WMFrame *raisF; WMButton *raisB[5]; WMTextField *raisT; WMLabel *raisL; - + WMFrame *optF; WMButton *ignB; WMButton *newB; - + char raiseDelaySelected; } _Panel; @@ -67,33 +67,33 @@ showData(_Panel *panel) char *str; int i; char buffer[32]; - + str = GetStringForKey("FocusMode"); if (!str) - str = "manual"; + str = "manual"; if (strcasecmp(str, "manual")==0 || strcasecmp(str, "clicktofocus")==0) - WMSetButtonSelected(panel->kfocB[0], 1); - else if (strcasecmp(str, "auto")==0 || strcasecmp(str, "semiauto")==0 - || strcasecmp(str, "sloppy")==0) - WMSetButtonSelected(panel->kfocB[1], 1); + WMSetButtonSelected(panel->kfocB[0], 1); + else if (strcasecmp(str, "auto")==0 || strcasecmp(str, "semiauto")==0 + || strcasecmp(str, "sloppy")==0) + WMSetButtonSelected(panel->kfocB[1], 1); else { - wwarning(_("bad option value %s for option FocusMode. Using default Manual"), - str); - WMSetButtonSelected(panel->kfocB[0], 1); + wwarning(_("bad option value %s for option FocusMode. Using default Manual"), + str); + WMSetButtonSelected(panel->kfocB[0], 1); } /**/ str = GetStringForKey("ColormapMode"); if (!str) - str = "auto"; + str = "auto"; if (strcasecmp(str, "manual")==0 || strcasecmp(str, "clicktofocus")==0) { - WMPerformButtonClick(panel->manB); + WMPerformButtonClick(panel->manB); } else if (strcasecmp(str, "auto")==0 || strcasecmp(str, "focusfollowsmouse")==0) { - WMPerformButtonClick(panel->autB); + WMPerformButtonClick(panel->autB); } else { - wwarning(_("bad option value %s for option ColormapMode. Using default Auto"), - str); - WMPerformButtonClick(panel->manB); + wwarning(_("bad option value %s for option ColormapMode. Using default Auto"), + str); + WMPerformButtonClick(panel->manB); } /**/ @@ -102,21 +102,21 @@ showData(_Panel *panel) WMSetTextFieldText(panel->raisT, buffer); switch (i) { - case 0: - WMPerformButtonClick(panel->raisB[0]); - break; - case 10: - WMPerformButtonClick(panel->raisB[1]); - break; - case 100: - WMPerformButtonClick(panel->raisB[2]); - break; - case 350: - WMPerformButtonClick(panel->raisB[3]); - break; - case 800: - WMPerformButtonClick(panel->raisB[4]); - break; + case 0: + WMPerformButtonClick(panel->raisB[0]); + break; + case 10: + WMPerformButtonClick(panel->raisB[1]); + break; + case 100: + WMPerformButtonClick(panel->raisB[2]); + break; + case 350: + WMPerformButtonClick(panel->raisB[3]); + break; + case 800: + WMPerformButtonClick(panel->raisB[4]); + break; } /**/ @@ -134,25 +134,25 @@ storeData(_Panel *panel) int i; if (WMGetButtonSelected(panel->kfocB[1])) - str = "sloppy"; + str = "sloppy"; else - str = "manual"; - + str = "manual"; + SetStringForKey(str, "FocusMode"); if (WMGetButtonSelected(panel->manB)) { - SetStringForKey("manual", "ColormapMode"); + SetStringForKey("manual", "ColormapMode"); } else { - SetStringForKey("auto", "ColormapMode"); + SetStringForKey("auto", "ColormapMode"); } - + str = WMGetTextFieldText(panel->raisT); if (sscanf(str, "%i", &i)!=1) - i = 0; + i = 0; SetIntegerForKey(i, "RaiseDelay"); - + SetBoolForKey(WMGetButtonSelected(panel->ignB), "IgnoreFocusClick"); - SetBoolForKey(WMGetButtonSelected(panel->newB), "AutoFocus"); + SetBoolForKey(WMGetButtonSelected(panel->newB), "AutoFocus"); } @@ -163,15 +163,15 @@ pushDelayButton(WMWidget *w, void *data) panel->raiseDelaySelected = 1; if (w == panel->raisB[0]) { - WMSetTextFieldText(panel->raisT, "OFF"); + WMSetTextFieldText(panel->raisT, "OFF"); } else if (w == panel->raisB[1]) { - WMSetTextFieldText(panel->raisT, "10"); + WMSetTextFieldText(panel->raisT, "10"); } else if (w == panel->raisB[2]) { - WMSetTextFieldText(panel->raisT, "100"); + WMSetTextFieldText(panel->raisT, "100"); } else if (w == panel->raisB[3]) { - WMSetTextFieldText(panel->raisT, "350"); + WMSetTextFieldText(panel->raisT, "350"); } else if (w == panel->raisB[4]) { - WMSetTextFieldText(panel->raisT, "800"); + WMSetTextFieldText(panel->raisT, "800"); } } @@ -183,10 +183,10 @@ raiseTextChanged(void *observerData, WMNotification *notification) int i; if (panel->raiseDelaySelected) { - for (i=0; i<5; i++) { - WMSetButtonSelected(panel->raisB[i], False); - } - panel->raiseDelaySelected = 0; + for (i=0; i<5; i++) { + WMSetButtonSelected(panel->raisB[i], False); + } + panel->raiseDelaySelected = 0; } } @@ -206,7 +206,7 @@ createPanel(Panel *p) panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - + /***************** Input Focus Mode *****************/ panel->kfocF = WMCreateFrame(panel->box); WMResizeWidget(panel->kfocF, 240, 130); @@ -214,29 +214,29 @@ createPanel(Panel *p) WMSetFrameTitle(panel->kfocF, _("Input Focus Mode")); { - WMBox *box = WMCreateBox(panel->kfocF); - WMSetViewExpandsToParent(WMWidgetView(box), 10, 15, 10, 10); - WMSetBoxHorizontal(box, False); - - panel->kfocB[0] = WMCreateRadioButton(box); + WMBox *box = WMCreateBox(panel->kfocF); + WMSetViewExpandsToParent(WMWidgetView(box), 10, 15, 10, 10); + WMSetBoxHorizontal(box, False); + + panel->kfocB[0] = WMCreateRadioButton(box); WMSetButtonText(panel->kfocB[0], _("Manual: Click on the window to set "\ - "keyboard input focus")); - WMAddBoxSubview(box, WMWidgetView(panel->kfocB[0]), True, True, - 20, 0, 0); - - panel->kfocB[1] = WMCreateRadioButton(box); - WMGroupButtons(panel->kfocB[0], panel->kfocB[1]); - WMSetButtonText(panel->kfocB[1], _("Auto: Set keyboard input focus to "\ - "the window under the mouse pointer")); - WMAddBoxSubview(box, WMWidgetView(panel->kfocB[1]), True, True, - 20, 0, 0); - - WMMapSubwidgets(box); - WMMapWidget(box); + "keyboard input focus")); + WMAddBoxSubview(box, WMWidgetView(panel->kfocB[0]), True, True, + 20, 0, 0); + + panel->kfocB[1] = WMCreateRadioButton(box); + WMGroupButtons(panel->kfocB[0], panel->kfocB[1]); + WMSetButtonText(panel->kfocB[1], _("Auto: Set keyboard input focus to "\ + "the window under the mouse pointer")); + WMAddBoxSubview(box, WMWidgetView(panel->kfocB[1]), True, True, + 20, 0, 0); + + WMMapSubwidgets(box); + WMMapWidget(box); } - + /***************** Colormap Installation Mode ****************/ - + panel->cfocF = WMCreateFrame(panel->box); WMResizeWidget(panel->cfocF, 240, 70); WMMoveWidget(panel->cfocF, 15, 150); @@ -252,84 +252,84 @@ createPanel(Panel *p) WMMoveWidget(panel->autB, 10, 43); WMSetButtonText(panel->autB, _("...that is under the mouse pointer.")); WMGroupButtons(panel->manB, panel->autB); - + WMMapSubwidgets(panel->cfocF); - + /***************** Automatic window raise delay *****************/ panel->raisF = WMCreateFrame(panel->box); WMResizeWidget(panel->raisF, 245, 70); WMMoveWidget(panel->raisF, 265, 15); WMSetFrameTitle(panel->raisF, _("Automatic Window Raise Delay")); - + buf1 = wmalloc(strlen(DELAY_ICON)+1); buf2 = wmalloc(strlen(DELAY_ICON_S)+1); - + for (i = 0; i < 5; i++) { - char *path; - - panel->raisB[i] = WMCreateCustomButton(panel->raisF, - WBBStateChangeMask); - WMResizeWidget(panel->raisB[i], 25, 25); - WMMoveWidget(panel->raisB[i], 10+(30*i), 25); - WMSetButtonBordered(panel->raisB[i], False); - WMSetButtonImagePosition(panel->raisB[i], WIPImageOnly); - WMSetButtonAction(panel->raisB[i], pushDelayButton, panel); - if (i>0) - WMGroupButtons(panel->raisB[0], panel->raisB[i]); - sprintf(buf1, DELAY_ICON, i); - sprintf(buf2, DELAY_ICON_S, i); - path = LocateImage(buf1); - if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonImage(panel->raisB[i], icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); - } - path = LocateImage(buf2); - if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonAltImage(panel->raisB[i], icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); - } + char *path; + + panel->raisB[i] = WMCreateCustomButton(panel->raisF, + WBBStateChangeMask); + WMResizeWidget(panel->raisB[i], 25, 25); + WMMoveWidget(panel->raisB[i], 10+(30*i), 25); + WMSetButtonBordered(panel->raisB[i], False); + WMSetButtonImagePosition(panel->raisB[i], WIPImageOnly); + WMSetButtonAction(panel->raisB[i], pushDelayButton, panel); + if (i>0) + WMGroupButtons(panel->raisB[0], panel->raisB[i]); + sprintf(buf1, DELAY_ICON, i); + sprintf(buf2, DELAY_ICON_S, i); + path = LocateImage(buf1); + if (path) { + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonImage(panel->raisB[i], icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); + } + path = LocateImage(buf2); + if (path) { + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonAltImage(panel->raisB[i], icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); + } } wfree(buf1); wfree(buf2); - + panel->raisT = WMCreateTextField(panel->raisF); WMResizeWidget(panel->raisT, 36, 20); WMMoveWidget(panel->raisT, 165, 30); - WMAddNotificationObserver(raiseTextChanged, panel, - WMTextDidChangeNotification, panel->raisT); + WMAddNotificationObserver(raiseTextChanged, panel, + WMTextDidChangeNotification, panel->raisT); color = WMDarkGrayColor(scr); font = WMSystemFontOfSize(scr, 10); - + panel->raisL = WMCreateLabel(panel->raisF); WMResizeWidget(panel->raisL, 36, 16); WMMoveWidget(panel->raisL, 205, 35); WMSetLabelText(panel->raisL, _("msec")); WMSetLabelTextColor(panel->raisL, color); WMSetLabelFont(panel->raisL, font); - + WMReleaseColor(color); WMReleaseFont(font); WMMapSubwidgets(panel->raisF); - + /***************** Options ****************/ panel->optF = WMCreateFrame(panel->box); WMResizeWidget(panel->optF, 245, 125); WMMoveWidget(panel->optF, 265, 95); - + panel->ignB = WMCreateSwitchButton(panel->optF); WMResizeWidget(panel->ignB, 225, 50); WMMoveWidget(panel->ignB, 10, 10); @@ -343,10 +343,10 @@ createPanel(Panel *p) WMMapSubwidgets(panel->optF); - + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); - + showData(panel); } @@ -363,14 +363,15 @@ InitFocus(WMScreen *scr, WMWindow *win) panel->sectionName = _("Window Focus Preferences"); panel->description = _("Keyboard focus switching policy, colormap switching\n" - "policy for 8bpp displays and other related options."); + "policy for 8bpp displays and other related options."); panel->parent = win; panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeData; - + AddSection(panel, ICON_FILE); return panel; } + diff --git a/WPrefs.app/Font.c b/WPrefs.app/Font.c dissimilarity index 69% index a6d01074..329c3bf5 100644 --- a/WPrefs.app/Font.c +++ b/WPrefs.app/Font.c @@ -1,2100 +1,2100 @@ -/* Font.c- text/font settings - * - * WPrefs - Window Maker Preferences Program - * - * Copyright (c) 1999-2003 Alfredo K. Kojima - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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, - * USA. - */ - - -#include "WPrefs.h" -#include -#include - -typedef struct _Panel { - WMBox *box; - char *sectionName; - - char *description; - - CallbackRec callbacks; - - WMWidget *parent; - - - WMLabel *prevL; - - WMFontPanel *fontPanel; - - WMPopUpButton *fontSel; - WMFrame *multiF; - WMButton *togMulti; - WMFrame *langF; - WMPopUpButton *langP; - WMFrame *aaF; - WMButton *togAA; - - /* single byte */ - WMTextField *fontT; - WMButton *changeB; - - /* multibyte */ - WMLabel *fsetL; - WMList *fsetLs; - - WMButton *addB; - WMButton *editB; - WMButton *remB; - - WMButton *upB; - WMButton *downB; - - WMColor *white; - WMColor *black; - WMColor *light; - WMColor *dark; - - WMColor *back; - WMColor *colors[9]; - - Pixmap preview; - WMPixmap *previewPix; - WMPixmap *hand; - WMPixmap *up_arrow; - WMPixmap *down_arrow; - WMPixmap *alt_up_arrow; - WMPixmap *alt_down_arrow; - - int oldsection; - char menuStyle; - char titleAlignment; - Bool MultiByteText; - - Bool AntialiasedText; -} _Panel; - - - -#define ICON_FILE "fonts" - -static WMRect previewPositions[] = { -#define WINTITLE 0 - {{30, 10},{190, 20}}, -#define DISTITLE 1 - {{30, 35},{90, 64}}, -#define PMTITLE 2 - {{30, 105},{90, 20}}, -#define PMITEM 3 - {{30, 125},{90, 20*4}}, -#define PCLIP 4 - {{156, 35},{64, 64}}, -#define PICON 5 - {{156, 105},{64, 64}} -}; -#define EVERYTHING 0xff - -static char *colorOptions[] = { -#define FTITLE (1<<0) - "FTitleColor", "white", -#define DISCOL (1<<1) /* Display uses white always */ -#define MTITLE (1<<2) - "MenuTitleColor", "white", -#define MITEM (1<<3) - "MenuTextColor", "black", -#define CLIP (1<<4) - "ClipTitleColor", "black", -#define CCLIP (1<<4) - "ClipTitleColor", "#454045", -#define ICONT (1<<5) - "IconTitleColor", "white", -#define ICONB (1<<5) - "IconTitleBack", "black" -}; - -#define MSTYLE_NORMAL 0 -#define MSTYLE_SINGLE 1 -#define MSTYLE_FLAT 2 - - -#define RESIZEBAR_BEVEL -1 -#define MENU_BEVEL -2 -#define CLIP_BUTTON_SIZE 23 -#define ICON_SIZE 64 - - -static char *textureOptions[] = { - "FTitleBack", - NULL, - "MenuTitleBack", - "MenuTextBack", - "IconBack", - "IconBack" -}; - -/* XPM */ -static char * hand_xpm[] = { -"22 21 19 1", -" c None", -". c #030305", -"+ c #7F7F7E", -"@ c #B5B5B6", -"# c #C5C5C6", -"$ c #969697", -"% c #FDFDFB", -"& c #F2F2F4", -"* c #E5E5E4", -"= c #ECECEC", -"- c #DCDCDC", -"; c #D2D2D0", -"> c #101010", -", c #767674", -"' c #676767", -") c #535355", -"! c #323234", -"~ c #3E3C56", -"{ c #333147", -" ", -" ..... ", -" ..+@##$. ", -" .%%%&@.......... ", -" .%*%%&#%%%%%%%%%$. ", -" .*#%%%%%%%%%&&&&==. ", -" .-%%%%%%%%%=*-;;;#$. ", -" .-%%%%%%%%&..>..... ", -" >-%%%%%%%%%*#+. ", -" >-%%%%%%%%%*@,. ", -" >#%%%%%%%%%*@'. ", -" >$&&%%%%%%=... ", -" .+@@;=&%%&;$,> ", -" .',$@####$+). ", -" .!',+$++,'. ", -" ..>>>>>. ", -" ", -" ~~{{{~~ ", -" {{{{{{{{{{{ ", -" ~~{{{~~ ", -" "}; - -static char *up_arrow_xpm[] = { -"9 9 3 1", -". c #acaaac", -"% c #525552", -"# c #000000", -"....%....", -"....#....", -"...%#%...", -"...###...", -"..%###%..", -"..#####..", -".%#####%.", -".#######.", -"%#######%" -}; - -static char *down_arrow_xpm[] = { -"9 9 3 1", -". c #acaaac", -"% c #525552", -"# c #000000", -"%#######%", -".#######.", -".%#####%.", -"..#####..", -"..%###%..", -"...###...", -"...%#%...", -"....#....", -"....%...." -}; - -static char *alt_up_arrow_xpm[] = { -"9 9 2 1", -". c #ffffff", -"% c #525552", -"....%....", -"....%....", -"...%%%...", -"...%%%...", -"..%%%%%..", -"..%%%%%..", -".%%%%%%%.", -".%%%%%%%.", -"%%%%%%%%%" -}; - -static char *alt_down_arrow_xpm[] = { -"9 9 2 1", -". c #ffffff", -"% c #525552", -"%%%%%%%%%", -".%%%%%%%.", -".%%%%%%%.", -"..%%%%%..", -"..%%%%%..", -"...%%%...", -"...%%%...", -"....%....", -"....%...." -}; -/* XPM */ - -static WMPropList *CurrentFontArray = NULL; -//static WMPropList *CurrentMenuTitleFont = NULL; -//static WMPropList *CurrentMenuTextFont = NULL; -//static WMPropList *CurrentIconTitleFont = NULL; -//static WMPropList *CurrentClipTitleFont = NULL; -//static WMPropList *CurrentLargeDisplayFont = NULL; - -static WMPropList *DefaultWindowTitleFont = NULL; -static WMPropList *DefaultMenuTitleFont = NULL; -static WMPropList *DefaultMenuTextFont = NULL; -static WMPropList *DefaultIconTitleFont = NULL; -static WMPropList *DefaultClipTitleFont = NULL; -static WMPropList *DefaultLargeDisplayFont = NULL; - -static void changePage(WMWidget *w, void *data); -static void setLanguageType(void *data, Bool multiByte); -static void refillFontSetList(void *data); -static void readFontEncodings(void *data); -static void changeLanguageAction(WMWidget *w, void *data); -static void checkListForArrows(void *data); - -static char* getFontEncoding(void *data); -static char* getFontSampleString(void *data); - -/* note single element */ -static WMFont* getFontForPreview(void *data, int element); -static WMFont* getDefaultSystemFont(void *data, int element); - -static WMPropList* getDefaultFontProp(void *data, char *encoding, int section); -static WMPropList* getCurrentFontProp(void *data, int section); - -static Bool isEncodingMultiByte(void *data); - -static void -str2rcolor(RContext *rc, char *name, RColor *color) -{ - XColor xcolor; - - XParseColor(rc->dpy, rc->cmap, name, &xcolor); - - color->alpha = 255; - color->red = xcolor.red >> 8; - color->green = xcolor.green >> 8; - color->blue = xcolor.blue >> 8; -} - -static void -drawMenuBevel(RImage *img) -{ - RColor light, dark, mid; - int i; - int iheight = img->height / 4; - - 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 < 4; i++) { - ROperateLine(img, RSubtractOperation, 0, i*iheight-2, - img->width-1, i*iheight-2, &mid); - - RDrawLine(img, 0, i*iheight-1, img->width-1, i*iheight-1, &dark); - - ROperateLine(img, RAddOperation, 1, i*iheight, - img->width-2, i*iheight, &light); - } -} - -static void -paintTitle(WMScreen *scr, Drawable d, WMColor *color, WMFont *font, - int part, WMAlignment align, char *text) -{ - int l = strlen(text); - int x = previewPositions[part].pos.x; - int y = previewPositions[part].pos.y; - int w = previewPositions[part].size.width; - int h = previewPositions[part].size.height; - - switch (align) { - case WALeft: - x += 5; - break; - case WARight: - x += w - 5 - WMWidthOfString(font, text, l); - break; - default: - case WACenter: - x += (w - WMWidthOfString(font, text, l))/2; - break; - } - WMDrawString(scr, d, color, font, x, - y + (h - WMFontHeight(font))/2, text, l); -} - -static void -paintItems(WMScreen *scr, Drawable d, WMColor *color, WMFont *font, - int part, char *text) -{ - int l = strlen(text); - int x = previewPositions[part].pos.x; - int y = previewPositions[part].pos.y; - //int w = previewPositions[part].size.width; - int h = previewPositions[part].size.height/4; - int i; - for( i = 0; i < 4 ; i++) { - WMDrawString(scr, d, color, font, x+5, - y+(20*i)+(h - WMFontHeight(font))/2, text, l); - } -} - -static void -paintIcon(WMScreen *scr,Drawable d, WMColor *color, WMColor *Iback, - WMFont *font, int part, char *text) -{ - Display *dpy = WMScreenDisplay(scr); - int l = strlen(text); - int x = previewPositions[part].pos.x+1; - int y = previewPositions[part].pos.y+1; - int w = previewPositions[part].size.width-2; - int h = WMFontHeight(font)+2; - - XFillRectangle(dpy, d, WMColorGC(Iback), x, y, w, h); - x += (w - WMWidthOfString(font, text, l))/2; - WMDrawString(scr, d, color, font, x, - y + (h - WMFontHeight(font))/2, text, l); - -} - -static void -drawFonts(_Panel *panel, int elements) -{ - WMScreen *scr = WMWidgetScreen(panel->box); - WMPixmap *pixmap; - Pixmap d; - - pixmap = WMGetLabelImage(panel->prevL); - d = WMGetPixmapXID(pixmap); - - if(elements & FTITLE) { - paintTitle(scr, d, panel->colors[0], getFontForPreview(panel, WINTITLE), - WINTITLE, panel->titleAlignment, _("Window Title Font")); - } - if(elements & DISCOL) { - paintTitle(scr, d, panel->white, getFontForPreview(panel, DISTITLE), - DISTITLE, WACenter, _("Display")); - } - if(elements & MTITLE) { - paintTitle(scr, d, panel->colors[1], getFontForPreview(panel, PMTITLE), - PMTITLE, WALeft, _("Menu Title")); - } - if(elements & MITEM) { - paintItems(scr, d, panel->colors[2], getFontForPreview(panel, PMITEM), - PMITEM, _("Menu Item")); - } - if(elements & CLIP) { - WMDrawString(scr, d, panel->colors[4], - getFontForPreview(panel, PCLIP), 169,37, "1",1); - WMDrawString(scr, d, panel->colors[3], - getFontForPreview(panel, PCLIP),179, 84, _("Clip title"), 10); - } - if(elements & ICONT) { - paintIcon(scr, d, panel->colors[5], panel->colors[6], - getFontForPreview(panel, PICON), PICON, _("Icon Title")); - } -} - -static void -dumpRImage(char *path, RImage *image) -{ - FILE *f; - int channels = (image->format == RRGBAFormat ? 4 : 3); - - f = fopen(path, "w"); - if (!f) { - wsyserror(path); - return; - } - fprintf(f, "%02x%02x%1x", image->width, image->height, channels); - - fwrite(image->data, 1, image->width * image->height * channels, f); - - if (fclose(f) < 0) { - wsyserror(path); - } -} - -/*static int -isPixmap(WMPropList *prop) -{ - WMPropList *p; - char *s; - - p = WMGetFromPLArray(prop, 0); - s = WMGetFromPLString(p); - if (strcasecmp(&s[1], "pixmap")==0) - return 1; - else - return 0; -}*/ - -static Pixmap -renderTexture(WMScreen *scr, WMPropList *texture, int width, int height, - char *path, int border) -{ - char *type; - RImage *image = NULL; - Pixmap pixmap; - RContext *rc = WMScreenRContext(scr); - char *str; - RColor rcolor; - - - type = WMGetFromPLString(WMGetFromPLArray(texture, 0)); - - if (strcasecmp(type, "solid")==0) { - - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - - str2rcolor(rc, str, &rcolor); - - image = RCreateImage(width, height, False); - RClearImage(image, &rcolor); - } else if (strcasecmp(type, "igradient")==0) { - int t1, t2; - RColor c1[2], c2[2]; - - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - str2rcolor(rc, str, &c1[0]); - str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); - str2rcolor(rc, str, &c1[1]); - str = WMGetFromPLString(WMGetFromPLArray(texture, 3)); - t1 = atoi(str); - - str = WMGetFromPLString(WMGetFromPLArray(texture, 4)); - str2rcolor(rc, str, &c2[0]); - str = WMGetFromPLString(WMGetFromPLArray(texture, 5)); - str2rcolor(rc, str, &c2[1]); - str = WMGetFromPLString(WMGetFromPLArray(texture, 6)); - t2 = atoi(str); - - image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2); - } else if (strcasecmp(&type[1], "gradient")==0) { - int style; - RColor rcolor2; - - switch (toupper(type[0])) { - case 'V': - style = RVerticalGradient; - break; - case 'H': - style = RHorizontalGradient; - break; - default: - case 'D': - style = RDiagonalGradient; - break; - } - - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - str2rcolor(rc, str, &rcolor); - str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); - str2rcolor(rc, str, &rcolor2); - - image = RRenderGradient(width, height, &rcolor, &rcolor2, style); - } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='T') { - int style; - RColor rcolor2; - int i; - RImage *grad, *timage; - char *path; - - switch (toupper(type[1])) { - case 'V': - style = RVerticalGradient; - break; - case 'H': - style = RHorizontalGradient; - break; - default: - case 'D': - style = RDiagonalGradient; - break; - } - - str = WMGetFromPLString(WMGetFromPLArray(texture, 3)); - str2rcolor(rc, str, &rcolor); - str = WMGetFromPLString(WMGetFromPLArray(texture, 4)); - str2rcolor(rc, str, &rcolor2); - - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - - if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL) - timage = RLoadImage(rc, path, 0); - - if (!path || !timage) { - wwarning("could not load file '%s': %s", path, - RMessageForError(RErrorCode)); - } else { - grad = RRenderGradient(width, height, &rcolor, &rcolor2, style); - - image = RMakeTiledImage(timage, width, height); - RReleaseImage(timage); - - i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2))); - - RCombineImagesWithOpaqueness(image, grad, i); - RReleaseImage(grad); - } - } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='M') { - int style; - RColor **colors; - int i, j; - - switch (toupper(type[1])) { - case 'V': - style = RVerticalGradient; - break; - case 'H': - style = RHorizontalGradient; - break; - default: - case 'D': - style = RDiagonalGradient; - break; - } - - j = WMGetPropListItemCount(texture); - - if (j > 0) { - colors = wmalloc(j * sizeof(RColor*)); - - for (i = 2; i < j; i++) { - str = WMGetFromPLString(WMGetFromPLArray(texture, i)); - colors[i-2] = wmalloc(sizeof(RColor)); - str2rcolor(rc, str, colors[i-2]); - } - colors[i-2] = NULL; - - image = RRenderMultiGradient(width, height, colors, style); - - for (i = 0; colors[i]!=NULL; i++) - wfree(colors[i]); - wfree(colors); - } - } else if (strcasecmp(&type[1], "pixmap")==0) { - RImage *timage = NULL; - char *path; - RColor color; - - str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); - - if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL) - timage = RLoadImage(rc, path, 0); - - if (!path || !timage) { - wwarning("could not load file '%s': %s", path ? path : str, - RMessageForError(RErrorCode)); - } else { - str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); - str2rcolor(rc, str, &color); - - switch (toupper(type[0])) { - case 'T': - image = RMakeTiledImage(timage, width, height); - RReleaseImage(timage); - timage = image; - break; - case 'C': - image = RMakeCenteredImage(timage, width, height, &color); - RReleaseImage(timage); - timage = image; - break; - case 'S': - case 'M': - image = RScaleImage(timage, width, height); - RReleaseImage(timage); - timage = image; - break; - } - - } - wfree(path); - } - - if (!image) - return None; - - if (path) { - dumpRImage(path, image); - } - - if (border < 0) { - if (border == MENU_BEVEL) { - drawMenuBevel(image); - RBevelImage(image, RBEV_RAISED2); - } - } else if (border) { - RBevelImage(image, border); - } - - RConvertImage(rc, image, &pixmap); - RReleaseImage(image); - - return pixmap; -} - -static Pixmap -renderMenu(_Panel *panel, WMPropList *texture, int width, int iheight) -{ - WMScreen *scr = WMWidgetScreen(panel->parent); - Display *dpy = WMScreenDisplay(scr); - Pixmap pix, tmp; - //RContext *rc = WMScreenRContext(scr); - GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL); - int i; - - switch (panel->menuStyle) { - case MSTYLE_NORMAL: - tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2); - - pix = XCreatePixmap(dpy, tmp, width, iheight*4, WMScreenDepth(scr)); - for (i = 0; i < 4; i++) { - XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight*i); - } - XFreePixmap(dpy, tmp); - break; - case MSTYLE_SINGLE: - pix = renderTexture(scr, texture, width, iheight*4, NULL, MENU_BEVEL); - break; - case MSTYLE_FLAT: - pix = renderTexture(scr, texture, width, iheight*4, NULL, RBEV_RAISED2); - break; - } - XFreeGC(dpy, gc); - - return pix; -} - -static void -renderClip(_Panel *panel, GC gc, int part, int relief) -{ - WMScreen *scr = WMWidgetScreen(panel->box); - Display *dpy = WMScreenDisplay(scr); - RContext *rc = WMScreenRContext(scr); - WMPropList *prop; - Pixmap pix; - XImage *original; - XPoint p[4]; - RImage *tile; - RColor black; - RColor dark; - RColor light; - int pt, tp; - int as; - - prop = GetObjectForKey(textureOptions[part]); - - pix = renderTexture(scr, prop, - previewPositions[part].size.width, - previewPositions[part].size.height, - NULL, relief); - - - original = XGetImage(dpy, pix, 0, 0, 64, 64, - AllPlanes, ZPixmap); - if (!original){ - wwarning(_("error capturing \"original\" tile image"), - RMessageForError(RErrorCode)); - } - tile = RCreateImageFromXImage(rc, original, NULL); - - XDestroyImage(original); - XFreePixmap(WMScreenDisplay(scr), pix); - - pt = CLIP_BUTTON_SIZE*ICON_SIZE/64; - tp = ICON_SIZE-1 - pt; - as = pt - 15; - - black.alpha = 255; - black.red = black.green = black.blue = 0; - - dark.alpha = 0; - dark.red = dark.green = dark.blue = 60; - - light.alpha = 0; - light.red = light.green = light.blue = 80; - - - /* top right */ - ROperateLine(tile, RSubtractOperation, tp, 0, ICON_SIZE-2, - pt-1, &dark); - RDrawLine(tile, tp-1, 0, ICON_SIZE-1, pt+1, &black); - ROperateLine(tile, RAddOperation, tp, 2, ICON_SIZE-3, - pt, &light); - - /* arrow bevel */ - ROperateLine(tile, RSubtractOperation, ICON_SIZE - 7 - as, 4, - ICON_SIZE - 5, 4, &dark); - ROperateLine(tile, RSubtractOperation, ICON_SIZE - 6 - as, 5, - ICON_SIZE - 5, 6 + as, &dark); - ROperateLine(tile, RAddOperation, ICON_SIZE - 5, 4, ICON_SIZE - 5, 6 + as, - &light); - - /* bottom left */ - ROperateLine(tile, RAddOperation, 2, tp+2, pt-2, - ICON_SIZE-3, &dark); - RDrawLine(tile, 0, tp-1, pt+1, ICON_SIZE-1, &black); - ROperateLine(tile, RSubtractOperation, 0, tp-2, pt+1, - ICON_SIZE-2, &light); - - /* arrow bevel */ - ROperateLine(tile, RSubtractOperation, 4, ICON_SIZE - 7 - as, 4, - ICON_SIZE - 5, &dark); - ROperateLine(tile, RSubtractOperation, 5, ICON_SIZE - 6 - as, - 6 + as, ICON_SIZE - 5, &dark); - ROperateLine(tile, RAddOperation, 4, ICON_SIZE - 5, 6 + as, ICON_SIZE - 5, - &light); - - RConvertImage(rc, tile, &pix); - - /* top right arrow */ - p[0].x = p[3].x = ICON_SIZE-5-as; - p[0].y = p[3].y = 5; - p[1].x = ICON_SIZE-6; - p[1].y = 5; - p[2].x = ICON_SIZE-6; - p[2].y = 4+as; - XFillPolygon(dpy, pix, WMColorGC(panel->colors[4]), p, 3, Convex, CoordModeOrigin); - XDrawLines(dpy, pix, WMColorGC(panel->colors[4]), p, 4, CoordModeOrigin); - - /* bottom left arrow */ - p[0].x = p[3].x = 5; - p[0].y = p[3].y = ICON_SIZE-5-as; - p[1].x = 5; - p[1].y = ICON_SIZE-6; - p[2].x = 4+as; - p[2].y = ICON_SIZE-6; - XFillPolygon(dpy, pix, WMColorGC(panel->colors[4]), p, 3, Convex, CoordModeOrigin); - XDrawLines(dpy, pix, WMColorGC(panel->colors[4]), p, 4, CoordModeOrigin); - - XCopyArea(dpy, pix, panel->preview, gc, 0, 0, - previewPositions[part].size.width, - previewPositions[part].size.height, - previewPositions[part].pos.x, - previewPositions[part].pos.y); - - RReleaseImage(tile); - XFreePixmap(WMScreenDisplay(scr), pix); -} - -static void -renderPreview(_Panel *panel, GC gc, int part, int relief) -{ - WMPropList *prop; - Pixmap pix; - WMScreen *scr = WMWidgetScreen(panel->box); - - prop = GetObjectForKey(textureOptions[part]); - - pix = renderTexture(scr, prop, - previewPositions[part].size.width, - previewPositions[part].size.height, - NULL, relief); - XCopyArea(WMScreenDisplay(scr), pix, - panel->preview, gc, 0, 0, - previewPositions[part].size.width, - previewPositions[part].size.height, - previewPositions[part].pos.x, - previewPositions[part].pos.y); - - XFreePixmap(WMScreenDisplay(scr), pix); -} - -static void -paintPreviewBox(Panel *panel, int elements) -{ - WMScreen *scr = WMWidgetScreen(panel->parent); - Display *dpy = WMScreenDisplay(scr); - //int refresh = 0; - GC gc; - WMColor *black = WMBlackColor(scr); - Pixmap mitem; - - gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL); - - if (panel->preview == None) { - WMPixmap *pix; - - panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->parent), - 240-4, 190-4, WMScreenDepth(scr)); - - pix = WMCreatePixmapFromXPixmaps(scr, panel->preview, None, - 240-4, 190-4, WMScreenDepth(scr)); - - WMSetLabelImage(panel->prevL, pix); - WMReleasePixmap(pix); - } - XFillRectangle(dpy, panel->preview, WMColorGC(panel->back), - 0, 0, 240-4, 190-4); - - if (elements & (1<preview, WMColorGC(black), - previewPositions[WINTITLE].pos.x-1, - previewPositions[WINTITLE].pos.y-1, - previewPositions[WINTITLE].size.width, - previewPositions[WINTITLE].size.height); - } - if (elements & (1<preview, WMColorGC(panel->back), - previewPositions[DISTITLE].pos.x-1, - previewPositions[DISTITLE].pos.y-1, - previewPositions[DISTITLE].size.width, - previewPositions[DISTITLE].size.height); - } - if (elements & (1<preview, WMColorGC(black), - previewPositions[PMTITLE].pos.x-1, - previewPositions[PMTITLE].pos.y-1, - previewPositions[PMTITLE].size.width, - previewPositions[PMTITLE].size.height); - } - if (elements & (1<preview, gc, 0, 0, - previewPositions[PMITEM].size.width, - previewPositions[PMITEM].size.height, - previewPositions[PMITEM].pos.x, - previewPositions[PMITEM].pos.y); - - XFreePixmap(dpy, mitem); - } - if (elements & (1<preview, gc, 29, 125, 29, 125+20*4+25); - XDrawLine(dpy, panel->preview, gc, 119, 125, 119, 125+20*4+25); - } - if (elements & (1<preview, WMColorGC(black), - previewPositions[PCLIP].pos.x-1, - previewPositions[PCLIP].pos.y-1, - previewPositions[PCLIP].size.width, - previewPositions[PCLIP].size.height); - } - if (elements & (1<preview, WMColorGC(black), - previewPositions[PICON].pos.x-1, - previewPositions[PICON].pos.y-1, - previewPositions[PICON].size.width, - previewPositions[PICON].size.height); - } - drawFonts(panel, elements); - WMRedisplayWidget(panel->prevL); - XFreeGC(dpy, gc); - WMReleaseColor(black); -} - -static void -paintTextField(void *data, int section) -{ - _Panel *panel = (_Panel*)data; - //char *sample = NULL; - int encoding; - encoding = WMGetPopUpButtonSelectedItem(panel->langP); - WMSetTextFieldFont(panel->fontT, getFontForPreview(panel, section)); - switch(encoding) { - case 0: /* Current Font in theme */ - WMSetTextFieldText(panel->fontT, - "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); - break; - case 1: /* default */ - WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); - // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); - break; - case 2: /* latin1 iso8859-1 */ - WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); - // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); - break; - case 3: /* latin2 iso8859-2 */ - WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); - // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); - break; - case 4: /* Greek iso8859-7 */ - WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); - // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); - break; -/* luckily all these happen to have the MultiByte chars in the same places */ - case 5: /* Japanese jisx0208.1983 */ - WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); - // "Window Maker ÀßÄê¥æ¡¼¥Æ¥£¥ê¥Æ¥£"); - break; - case 6: /* Korean ksc5601.1987 */ - WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); - // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤"); - break; - case 7: /* korean2 daewoo */ - WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); - // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤"); - break; - case 8: /* Russian koi8-r */ - WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); - // "ó×ÏÊÓÔ×Á Window Maker"); - break; - case 9: /* Ukranian koi8-u */ - WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); - // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); - break; - } -} - -static void -previewClick(XEvent *event, void *clientData) -{ - _Panel *panel = (_Panel*)clientData; - int i; - - for (i = 0; i < sizeof(previewPositions)/sizeof(WMRect); i++) { - if (event->xbutton.x >= previewPositions[i].pos.x - && event->xbutton.y >= previewPositions[i].pos.y - && event->xbutton.x < previewPositions[i].pos.x - + previewPositions[i].size.width - && event->xbutton.y < previewPositions[i].pos.y - + previewPositions[i].size.height) { - - WMSetPopUpButtonSelectedItem(panel->fontSel, i); - changePage(panel->fontSel, panel); - return; - } - } -} - -static void -changePage(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - int section; - WMScreen *scr = WMWidgetScreen(panel->box); - RContext *rc = WMScreenRContext(scr); - static WMPoint positions[] = { - {5, 15}, - {5, 62}, - {5, 110}, - {5, 140}, - {130, 62}, - {130, 132} - }; - - if (w) { - section = WMGetPopUpButtonSelectedItem(panel->fontSel); - } - { - WMColor *color; - - color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); - XFillRectangle(rc->dpy, panel->preview, WMColorGC(color), - positions[panel->oldsection].x, - positions[panel->oldsection].y, 22, 22); - WMReleaseColor(color); - } - if (w) { - panel->oldsection = section; - WMDrawPixmap(panel->hand, panel->preview, positions[section].x, - positions[section].y); - } - WMRedisplayWidget(panel->prevL); - paintTextField(panel, section); - refillFontSetList(panel); -} - -static void -setLanguageType(void *data, Bool multiByte) -{ - _Panel *p = (_Panel*)data; - - if (multiByte) { - WMMapWidget(p->fsetL); - WMMapWidget(p->fsetLs); - WMMapWidget(p->addB); - WMMapWidget(p->editB); - WMMapWidget(p->remB); - WMMapWidget(p->upB); - WMMapWidget(p->downB); - - WMUnmapWidget(p->fontT); - WMUnmapWidget(p->changeB); - } else { - WMUnmapWidget(p->fsetL); - WMUnmapWidget(p->fsetLs); - WMUnmapWidget(p->addB); - WMUnmapWidget(p->editB); - WMUnmapWidget(p->remB); - WMUnmapWidget(p->upB); - WMUnmapWidget(p->downB); - - WMMapWidget(p->fontT); - WMMapWidget(p->changeB); - } -} - -static void -refillFontSetList(void *data) -{ - _Panel *panel = (_Panel*)data; - WMPropList *array; - char *encoding = getFontEncoding(panel); - int section = WMGetPopUpButtonSelectedItem(panel->fontSel); - int i; - //int pos; - WMClearList(panel->fsetLs); - if(!encoding) { - array = getCurrentFontProp(panel, section); - } else { - array = getDefaultFontProp(panel, encoding, section); - } - if(!array){ - wwarning("error not Font prop given"); - } else { - for (i = 0; i < WMGetPropListItemCount(array); i++) { - WMGetFromPLArray(array, i); - WMAddListItem( panel->fsetLs, - WMGetFromPLString( - WMGetFromPLArray(array, i))); - } - WMReleasePropList(array); - WMSelectListItem(panel->fsetLs, 0); - } - - checkListForArrows(panel); -} - -static void -insertCurrentFont(char *data, char *type) -{ - WMPropList *key; - WMPropList *array; - char *tmp, *str; - - key = WMCreatePLString(type); - array = WMCreatePLArray(NULL); - - str = wstrdup(data); - tmp = strtok(str, ","); - while(tmp) { - WMAddToPLArray(array, WMCreatePLString(tmp)); - tmp = strtok(NULL, ","); - } - wfree(str); - - - WMPutInPLDictionary(CurrentFontArray, key, array); -} - -static void -readFontEncodings(void *data) -{ - _Panel *panel = (_Panel*)data; - WMPropList *pl = NULL; - char *path; - char *msg; - - path = WMPathForResourceOfType("font.data", NULL); - if (!path) { - msg = _("Could not locate font information file WPrefs.app/font.data"); - goto error; - } - - pl = WMReadPropListFromFile(path); - if (!pl) { - msg = _("Could not read font information file WPrefs.app/font.data"); - goto error; - } else { - int i; - WMPropList *key = WMCreatePLString("Encodings"); - WMPropList *array; - WMMenuItem *mi; - - array = WMGetFromPLDictionary(pl, key); - WMReleasePropList(key); - if (!array || !WMIsPLArray(array)) { - msg = _("Invalid data in font information file WPrefs.app/font.data.\n" - "Encodings data not found."); - goto error; - } - - WMAddPopUpButtonItem(panel->langP, _("Current")); - - for (i = 0; i < WMGetPropListItemCount(array); i++) { - WMPropList *item, *str; - - item = WMGetFromPLArray(array, i); - str = WMGetFromPLArray(item, 0); - mi = WMAddPopUpButtonItem(panel->langP, WMGetFromPLString(str)); - WMSetMenuItemRepresentedObject(mi, WMRetainPropList(item)); - } - WMSetPopUpButtonSelectedItem(panel->langP, 0); - - - key = WMCreatePLString("WindowTitleFont"); - DefaultWindowTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); - WMReleasePropList(key); - - key = WMCreatePLString("MenuTitleFont"); - DefaultMenuTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); - WMReleasePropList(key); - - key = WMCreatePLString("MenuTextFont"); - DefaultMenuTextFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); - WMReleasePropList(key); - - key = WMCreatePLString("IconTitleFont"); - DefaultIconTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); - WMReleasePropList(key); - - key = WMCreatePLString("ClipTitleFont"); - DefaultClipTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); - WMReleasePropList(key); - - key = WMCreatePLString("LargeDisplayFont"); - DefaultLargeDisplayFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); - WMReleasePropList(key); - } - - WMReleasePropList(pl); - return; -error: - if (pl) - WMReleasePropList(pl); - - WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, - _("Error"), msg, _("OK"), NULL, NULL); -} - -static void -checkListForArrows(void *data) -{ - _Panel *panel = (_Panel*)data; - int list; - list = WMGetListNumberOfRows(panel->fsetLs); - - if(list > 1) - { - if(WMGetListSelectedItemRow(panel->fsetLs) == 0) { - WMSetButtonEnabled(panel->upB, False); - WMSetButtonEnabled(panel->downB, True); - } else if(WMGetListSelectedItemRow(panel->fsetLs) == list-1) { - WMSetButtonEnabled(panel->downB, False); - WMSetButtonEnabled(panel->upB, True); - } else { - WMSetButtonEnabled(panel->upB, True); - WMSetButtonEnabled(panel->downB, True); - } - - } else { - WMSetButtonEnabled(panel->upB, False); - WMSetButtonEnabled(panel->downB, False); - } - /* added to control the Remove button */ - if(list > 1) - WMSetButtonEnabled(panel->remB, True); - else - WMSetButtonEnabled(panel->remB, False); -} - -static char* -fontOfLang(void *data, char *encoding, int section) -{ - _Panel *panel = (_Panel*)data; - WMPropList *array; - char *buf = NULL; - int i; - - if(!encoding) - array = getCurrentFontProp(panel, section); - else - array = getDefaultFontProp(panel, encoding, section); - - if(!array) { - wwarning("error no font prop given"); - return NULL; - } else { - for(i=0; ibox); - int section; - - section = WMGetPopUpButtonSelectedItem(w); - - if(isEncodingMultiByte(panel)) { - setLanguageType(panel, True); - } else { - if(panel->MultiByteText) setLanguageType(panel, True); - else setLanguageType(panel, False); - } - - paintPreviewBox(panel, EVERYTHING); - changePage(panel->fontSel, panel); -} - -static WMFont* -getFontForPreview(void *data, int element) -{ - _Panel *panel = (_Panel*)data; - WMFont *font; - char *fname; - WMScreen *scr = WMWidgetScreen(panel->box); - char *encoding = getFontEncoding(panel); - fname = fontOfLang(panel, encoding, element); - //if (WMHasAntialiasingSupport(scr)) { - if(panel->AntialiasedText) { - // fix this -Dan font = WMCreateFontWithFlags(scr, fname, WFAntialiased); - font = WMCreateFont(scr, fname); - } else { - font = WMCreateFont(scr, fname); - } - //} else { - // font = WMCreateFont(scr, fname); - //} - if(!font) { - char *msg; - int length; - length = strlen("\"")+ - strlen(fname)+strlen("\" was not loaded correctly. Make sure the font is available for that encoding.\nLoadind default system font."); - msg = wmalloc(length +1); - snprintf(msg, length + 1, - "\"%s\" was not loaded correctly. Make sure the font is available for that encoding.\nLoading default system font.", - fname); - WMRunAlertPanel(WMWidgetScreen(panel->parent),panel->parent, - _("Warning"), msg, _("OK"), NULL, NULL); - font = getDefaultSystemFont(panel, element); - } - return font; -} - -static char* -getFontSampleString(void *data) -{ - _Panel *panel = (_Panel*)data; - //WMScreen *scr = WMWidgetScreen(panel->box); - WMMenuItem *mi; - WMPropList *pl; - int section; - - section = WMGetPopUpButtonSelectedItem(panel->langP); - mi = WMGetPopUpButtonMenuItem(panel->langP, section); - pl = WMGetMenuItemRepresentedObject(mi); - - if (!pl) { - return NULL; - } else { - char *sample; - sample = WMGetFromPLString(WMGetFromPLArray(pl,3)); - return sample; - } -} - -static char* -getFontEncoding(void *data) -{ - _Panel *panel = (_Panel*)data; - //WMScreen *scr = WMWidgetScreen(panel->box); - WMMenuItem *mi; - WMPropList *pl; - int section; - - section = WMGetPopUpButtonSelectedItem(panel->langP); - mi = WMGetPopUpButtonMenuItem(panel->langP, section); - pl = WMGetMenuItemRepresentedObject(mi); - - if (!pl) { - return NULL; - } else { - char *encoding; - encoding = WMGetFromPLString(WMGetFromPLArray(pl,2)); - return encoding; - } -} - -static Bool -isEncodingMultiByte(void *data) -{ - _Panel *panel = (_Panel*)data; - //WMScreen *scr = WMWidgetScreen(panel->box); - WMMenuItem *mi; - WMPropList *pl; - int section; - - section = WMGetPopUpButtonSelectedItem(panel->langP); - mi = WMGetPopUpButtonMenuItem(panel->langP, section); - pl = WMGetMenuItemRepresentedObject(mi); - - if (!pl) { - return False; - } else { - char *multiByte; - int res; - multiByte = WMGetFromPLString(WMGetFromPLArray(pl,1)); - res = atoi(multiByte); - if(res) - return True; - else - return False; - } -} - -static WMPropList* -getCurrentFontProp(void *data, int section) -{ - WMPropList *array; - switch (section) { - case 0: - array = WMRetainPropList( - WMGetFromPLDictionary(CurrentFontArray, - WMCreatePLString("WindowTitleFont"))); - break; - case 1: - array = WMRetainPropList( - WMGetFromPLDictionary(CurrentFontArray, - WMCreatePLString("LargeDisplayFont"))); - break; - case 2: - array = WMRetainPropList( - WMGetFromPLDictionary(CurrentFontArray, - WMCreatePLString("MenuTitleFont"))); - break; - case 3: - array = WMRetainPropList( - WMGetFromPLDictionary(CurrentFontArray, - WMCreatePLString("MenuTextFont"))); - break; - case 4: - array = WMRetainPropList( - WMGetFromPLDictionary(CurrentFontArray, - WMCreatePLString("ClipTitleFont"))); - break; - case 5: - array = WMRetainPropList( - WMGetFromPLDictionary(CurrentFontArray, - WMCreatePLString("IconTitleFont"))); - break; - } - if(!WMIsPLArray(array)) { - return NULL; - } else { - return array; - } -} - -static WMPropList* -getDefaultFontProp(void *data, char *encoding, int section) -{ - WMPropList *array; - WMPropList *key = WMCreatePLString(encoding); - switch (section) { - case 0: - array = WMRetainPropList( - WMGetFromPLDictionary(DefaultWindowTitleFont, key)); - WMReleasePropList(key); - break; - case 1: - array = WMRetainPropList( - WMGetFromPLDictionary(DefaultLargeDisplayFont, key)); - WMReleasePropList(key); - break; - case 2: - array = WMRetainPropList( - WMGetFromPLDictionary(DefaultMenuTitleFont, key)); - WMReleasePropList(key); - break; - case 3: - array = WMRetainPropList( - WMGetFromPLDictionary(DefaultMenuTextFont, key)); - WMReleasePropList(key); - break; - case 4: - array = WMRetainPropList( - WMGetFromPLDictionary(DefaultClipTitleFont, key)); - WMReleasePropList(key); - break; - case 5: - array = WMRetainPropList( - WMGetFromPLDictionary(DefaultIconTitleFont, key)); - WMReleasePropList(key); - break; - } - if(!WMIsPLArray(array)) { - return NULL; - } else { - return array; - } -} - -static WMFont* -getDefaultSystemFont(void *data, int element) -{ - _Panel *panel = (_Panel*)data; - WMScreen *scr = WMWidgetScreen(panel->box); - - switch(element) { - case 0: - case 2: - return WMBoldSystemFontOfSize(scr, 12); - case 1: - return WMBoldSystemFontOfSize(scr, 24); - case 4: - case 5: - return WMSystemFontOfSize(scr, 8); - case 3: - default: - return WMSystemFontOfSize(scr, 12); - } -} - -static void -multiClick(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - if(!panel->MultiByteText) { - WMSetButtonText(panel->togMulti, _("Yes")); - setLanguageType(panel, True); - panel->MultiByteText = True; - } else { - WMSetButtonText(panel->togMulti, _("Auto")); - if(isEncodingMultiByte(panel)) setLanguageType(panel, True); - else setLanguageType(panel, False); - panel->MultiByteText = False; - } -} - -static void -toggleAA(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - //int section; - if(panel->AntialiasedText) - panel->AntialiasedText = False; - else - panel->AntialiasedText = True; - /* hmm now i gotta redraw all the fonts in the preview section - * and the text field - */ - paintPreviewBox(panel, EVERYTHING); - changePage(panel->fontSel, panel); - if(isEncodingMultiByte(panel)) setLanguageType(panel, True); -} - -static void -listClick(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - - checkListForArrows(panel); -} - -static void -moveUpListItem(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - WMListItem *tmp; - int pos; - char *listtext; - WMPropList *array; - WMPropList *string; - char *encoding = getFontEncoding(panel); - int section = WMGetPopUpButtonSelectedItem(panel->fontSel); - - if(!encoding) - array = getCurrentFontProp(panel, section); - else - array = getDefaultFontProp(panel, encoding, section); - - pos = WMGetListSelectedItemRow(panel->fsetLs); - - tmp = WMGetListItem(panel->fsetLs, pos); - listtext = wstrdup(tmp->text); - string = WMCreatePLString(listtext); - - WMRemoveListItem(panel->fsetLs, pos); - WMDeleteFromPLArray(array, pos); - WMInsertListItem(panel->fsetLs, pos-1, listtext); - WMInsertInPLArray(array, pos-1, string); - - paintPreviewBox(panel, EVERYTHING); - changePage(panel->fontSel, panel); - - WMSelectListItem(panel->fsetLs, pos-1); - checkListForArrows(panel); -} - -static void -moveDownListItem(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - WMListItem *tmp; - int pos; - char *listtext; - WMPropList *array; - WMPropList *string; - char *encoding = getFontEncoding(panel); - int section = WMGetPopUpButtonSelectedItem(panel->fontSel); - - if(!encoding) - array = getCurrentFontProp(panel, section); - else - array = getDefaultFontProp(panel, encoding, section); - - pos = WMGetListSelectedItemRow(panel->fsetLs); - - tmp = WMGetListItem(panel->fsetLs, pos); - listtext = wstrdup(tmp->text); - string = WMCreatePLString(listtext); - WMRemoveListItem(panel->fsetLs, pos); - WMDeleteFromPLArray(array, pos); - WMInsertListItem(panel->fsetLs, pos+1, listtext); - WMInsertInPLArray(array, pos+1, string); - - paintPreviewBox(panel, EVERYTHING); - changePage(panel->fontSel, panel); - - WMSelectListItem(panel->fsetLs, pos+1); - checkListForArrows(panel); -} - -static void -addButtonAction(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - char *chosenFont; - int pos; - WMPropList *array; - WMPropList *string; - char *encoding = getFontEncoding(panel); - int section = WMGetPopUpButtonSelectedItem(panel->fontSel); - - if(!encoding) - array = getCurrentFontProp(panel, section); - else - array = getDefaultFontProp(panel, encoding, section); - - WMHideFontPanel(panel->fontPanel); - chosenFont = WMGetFontName(WMGetFontPanelFont(panel->fontPanel)); - string = WMCreatePLString(chosenFont); - pos = WMGetListSelectedItemRow(panel->fsetLs); - WMInsertListItem(panel->fsetLs, pos+1, chosenFont); - WMInsertInPLArray(array, pos+1, string); - WMSelectListItem(panel->fsetLs, pos+1); - - paintPreviewBox(panel, EVERYTHING); - changePage(panel->fontSel, panel); -} - -static void -changeButtonAction(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - char *chosenFont; - int pos; - WMPropList *array; - WMPropList *string; - char *encoding = getFontEncoding(panel); - int section = WMGetPopUpButtonSelectedItem(panel->fontSel); - - if(!encoding) - array = getCurrentFontProp(panel, section); - else - array = getDefaultFontProp(panel, encoding, section); - - WMHideFontPanel(panel->fontPanel); - - chosenFont = WMGetFontName(WMGetFontPanelFont(panel->fontPanel)); - string = WMCreatePLString(chosenFont); - - pos = WMGetListSelectedItemRow(panel->fsetLs); - WMRemoveListItem(panel->fsetLs, pos); - WMDeleteFromPLArray(array, pos); - WMInsertListItem(panel->fsetLs, pos, chosenFont); - WMInsertInPLArray(array, pos, string); - WMSelectListItem(panel->fsetLs, pos); - - paintPreviewBox(panel, EVERYTHING); - changePage(panel->fontSel, panel); -} - -static void -changeButtonClick(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - - WMSetFontPanelAction(panel->fontPanel, changeButtonAction, panel); - WMShowFontPanel(panel->fontPanel); -} - -static void -addButtonClick(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - - WMSetFontPanelAction(panel->fontPanel, addButtonAction, panel); - WMShowFontPanel(panel->fontPanel); -} - -static void -removeButtonClick(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - int pos; - int list; - WMPropList *array; - char *encoding = getFontEncoding(panel); - int section = WMGetPopUpButtonSelectedItem(panel->fontSel); - - if(!encoding) - array = getCurrentFontProp(panel, section); - else - array = getDefaultFontProp(panel, encoding, section); - - pos = WMGetListSelectedItemRow(panel->fsetLs); - WMRemoveListItem(panel->fsetLs, pos); - WMDeleteFromPLArray(array, pos); - - list = WMGetListNumberOfRows(panel->fsetLs); - if(list != 0) { - if(list > pos) - WMSelectListItem(panel->fsetLs, pos); - else if(list == pos) - WMSelectListItem(panel->fsetLs, list-1); - else - WMSelectListItem(panel->fsetLs, 0); - } - checkListForArrows(panel); - - paintPreviewBox(panel, EVERYTHING); - changePage(panel->fontSel, panel); -} - -static void -showData(_Panel *panel) -{ - //WMScreen *scr = WMWidgetScreen(panel->parent); - char *str; - int i; - - CurrentFontArray = WMCreatePLDictionary(NULL, NULL); - - str = GetStringForKey("WindowTitleFont"); - insertCurrentFont(wstrdup(str), "WindowTitleFont"); - - str = GetStringForKey("LargeDisplayFont"); - insertCurrentFont(wstrdup(str), "LargeDisplayFont"); - - str = GetStringForKey("MenuTitleFont"); - insertCurrentFont(wstrdup(str), "MenuTitleFont"); - - str = GetStringForKey("MenuTextFont"); - insertCurrentFont(wstrdup(str), "MenuTextFont"); - - str = GetStringForKey("ClipTitleFont"); - insertCurrentFont(wstrdup(str), "ClipTitleFont"); - - str = GetStringForKey("IconTitleFont"); - insertCurrentFont(wstrdup(str), "IconTitleFont"); - - /* i put this here cause it needs to be known before we paint */ - readFontEncodings(panel); - - str = GetStringForKey("MenuStyle"); - if (str && strcasecmp(str, "flat")==0) { - panel->menuStyle = MSTYLE_FLAT; - } else if (str && strcasecmp(str, "singletexture")==0) { - panel->menuStyle = MSTYLE_SINGLE; - } else { - panel->menuStyle = MSTYLE_NORMAL; - } - - str = GetStringForKey("TitleJustify"); - if (str && strcasecmp(str, "left")==0) { - panel->titleAlignment = WALeft; - } else if (str && strcasecmp(str, "right")==0) { - panel->titleAlignment = WARight; - } else { - panel->titleAlignment = WACenter; - } - for (i = 0; i < sizeof(colorOptions)/(2*sizeof(char*)); i++) { - WMColor *color; - - str = GetStringForKey(colorOptions[i*2]); - if (!str) - str = colorOptions[i*2+1]; - - if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) { - color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False); - } - panel->colors[i] = color; - } - - str = GetStringForKey("MultiByteText"); - if (str) - { - if (strcasecmp(str, "YES")==0) { - setLanguageType(panel, True); - WMSetButtonText(panel->togMulti, "Yes"); - printf("yes multi\n"); - panel->MultiByteText = True; - } else if (strcasecmp(str, "AUTO") == 0) { - char *locale; - locale = setlocale(LC_CTYPE, NULL); - if(locale != NULL - && (strncmp(locale, "ja", 2) == 0 - || strncmp(locale, "zh", 2) == 0 - || strncmp(locale, "ko", 2) == 0)) { - setLanguageType(panel, True); - WMSetButtonText(panel->togMulti, "Auto"); - printf("auto multi\n"); - panel->MultiByteText = True; - } else { - setLanguageType(panel, False); - WMSetButtonText(panel->togMulti, "Auto"); - panel->MultiByteText = False; - } - } - } else { - char *locale; - locale = setlocale(LC_CTYPE, NULL); - if(locale != NULL - && (strncmp(locale, "ja", 2) == 0 - || strncmp(locale, "zh", 2) == 0 - || strncmp(locale, "ko", 2) == 0)) { - setLanguageType(panel, True); - WMSetButtonText(panel->togMulti, "Auto"); - printf("auto multi\n"); - panel->MultiByteText = True; - } else { - setLanguageType(panel, False); - WMSetButtonText(panel->togMulti, "Auto"); - panel->MultiByteText = False; - } - } - /* gotta check for Antialiasing AFTER MultiByte incase the use has both - * to maintain behavior in Current Fonts set or i could add another if - * statement to setLanguageType =) */ - //if (WMHasAntialiasingSupport(scr)) { - WMMapWidget(panel->togAA); - if(GetBoolForKey("AntialiasedText")){ - WMSetButtonSelected(panel->togAA, True); - panel->AntialiasedText = True; - } else { - WMSetButtonSelected(panel->togAA, False); - panel->AntialiasedText = False; - } - //} else { - // WMUnmapWidget(panel->togAA); - //} - - - paintPreviewBox(panel, EVERYTHING); -} - -static void -createPanel(Panel *p) -{ - _Panel *panel = (_Panel*)p; - WMScreen *scr = WMWidgetScreen(panel->parent); - - - panel->box = WMCreateBox(panel->parent); - WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - - panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm); - panel->up_arrow = WMCreatePixmapFromXPMData(scr, up_arrow_xpm); - panel->down_arrow = WMCreatePixmapFromXPMData(scr, down_arrow_xpm); - panel->alt_up_arrow = WMCreatePixmapFromXPMData(scr, alt_up_arrow_xpm); - panel->alt_down_arrow = WMCreatePixmapFromXPMData(scr, alt_down_arrow_xpm); - - panel->prevL = WMCreateLabel(panel->box); - WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 45); - WMMoveWidget(panel->prevL, 15, 35); - WMSetLabelRelief(panel->prevL, WRSunken); - WMSetLabelImagePosition(panel->prevL, WIPImageOnly); - - WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask, - previewClick, panel); - - /* Widget Selection */ - panel->fontSel = WMCreatePopUpButton(panel->box); - WMResizeWidget(panel->fontSel, 135, 20); - WMMoveWidget(panel->fontSel, 15, 10); - WMAddPopUpButtonItem(panel->fontSel, _("Window Title Font")); - WMAddPopUpButtonItem(panel->fontSel, _("Large Display Font")); - WMAddPopUpButtonItem(panel->fontSel, _("Menu Title Font")); - WMAddPopUpButtonItem(panel->fontSel, _("Menu Item Font" )); - WMAddPopUpButtonItem(panel->fontSel, _("Clip Title Font")); - WMAddPopUpButtonItem(panel->fontSel, _("Icon Title Font")); - - WMSetPopUpButtonSelectedItem(panel->fontSel, 0); - - WMSetPopUpButtonAction(panel->fontSel, changePage, panel); - - /* MultiByteText toggle */ - panel->multiF = WMCreateFrame(panel->box); - WMResizeWidget(panel->multiF, 70, 50); - WMMoveWidget(panel->multiF, 440, 10); - WMSetFrameTitle(panel->multiF, _("MultiByte")); - - - panel->togMulti = WMCreateCommandButton(panel->multiF); - WMResizeWidget(panel->togMulti, 40, 20); - WMMoveWidget(panel->togMulti, 15, 20); - WMSetButtonAction(panel->togMulti, multiClick, panel); - - WMMapSubwidgets(panel->multiF); - - /* language selection */ - panel->langF = WMCreateFrame(panel->box); - WMResizeWidget(panel->langF, 165, 50); - WMMoveWidget(panel->langF, 265, 10); - WMSetFrameTitle(panel->langF, _("Default Font Encodings")); - - panel->langP = WMCreatePopUpButton(panel->langF); - WMResizeWidget(panel->langP, 135, 20); - WMMoveWidget(panel->langP, 15, 20); - - WMSetPopUpButtonAction(panel->langP, changeLanguageAction, panel); - - WMMapSubwidgets(panel->langF); - - /* Antialiasing */ - //if (WMHasAntialiasingSupport(scr)) { - panel->togAA = WMCreateSwitchButton(panel->box); - WMResizeWidget(panel->togAA, 110, 20); - WMMoveWidget(panel->togAA, 155, 10); - WMSetButtonText(panel->togAA, _("Smooth Fonts")); - WMSetBalloonTextForView(_("Smooth Font edges for the eye candy\n" - "requires a restart after saving"), - WMWidgetView(panel->togAA)); - WMSetButtonAction(panel->togAA, toggleAA, panel); - //} - /* multibyte */ - panel->fsetL = WMCreateLabel(panel->box); - WMResizeWidget(panel->fsetL, 245, 20); - WMMoveWidget(panel->fsetL, 265, 70); - WMSetLabelText(panel->fsetL, _("Font Set")); - WMSetLabelRelief(panel->fsetL, WRSunken); - WMSetLabelTextAlignment(panel->fsetL, WACenter); - { - WMFont *font; - WMColor *color; - - color = WMDarkGrayColor(scr); - font = WMBoldSystemFontOfSize(scr, 12); - - WMSetWidgetBackgroundColor(panel->fsetL, color); - WMSetLabelFont(panel->fsetL, font); - - WMReleaseFont(font); - WMReleaseColor(color); - - color = WMWhiteColor(scr); - WMSetLabelTextColor(panel->fsetL, color); - WMReleaseColor(color); - } - - panel->fsetLs = WMCreateList(panel->box); - WMResizeWidget(panel->fsetLs, 245, 86); - WMMoveWidget(panel->fsetLs, 265, 92); - WMSetListAction(panel->fsetLs, listClick, panel); - WMSetListDoubleAction(panel->fsetLs, changeButtonClick, panel); - - panel->addB = WMCreateCommandButton(panel->box); - WMResizeWidget(panel->addB, 78, 24); - WMMoveWidget(panel->addB, 265, 201); - WMSetButtonText(panel->addB, _("Add...")); - WMSetButtonAction(panel->addB, addButtonClick, panel); - - panel->editB = WMCreateCommandButton(panel->box); - WMResizeWidget(panel->editB, 78, 24); - WMMoveWidget(panel->editB, 348, 201); - WMSetButtonText(panel->editB, _("Change...")); - WMSetButtonAction(panel->editB, changeButtonClick, panel); - - panel->remB = WMCreateCommandButton(panel->box); - WMResizeWidget(panel->remB, 78, 24); - WMMoveWidget(panel->remB, 431, 201); - WMSetButtonText(panel->remB, _("Remove")); - WMSetButtonAction(panel->remB, removeButtonClick, panel); - - /* happy Up/Down buttons */ - panel->upB = WMCreateCommandButton(panel->box); - WMResizeWidget(panel->upB, 16, 16); - WMMoveWidget(panel->upB, 265, 182); - WMSetButtonImage(panel->upB, panel->up_arrow); - WMSetButtonAltImage(panel->upB, panel->alt_up_arrow); - WMSetButtonImagePosition(panel->upB, WIPImageOnly); - WMSetButtonImageDimsWhenDisabled(panel->upB, True); - WMSetButtonAction(panel->upB, moveUpListItem, panel); - - panel->downB = WMCreateCommandButton(panel->box); - WMResizeWidget(panel->downB, 16, 16); - WMMoveWidget(panel->downB, 286, 182); - WMSetButtonImage(panel->downB, panel->down_arrow); - WMSetButtonAltImage(panel->downB, panel->alt_down_arrow); - WMSetButtonImagePosition(panel->downB, WIPImageOnly); - WMSetButtonImageDimsWhenDisabled(panel->downB, True); - WMSetButtonAction(panel->downB, moveDownListItem, panel); - - /* single byte */ - panel->fontT = WMCreateTextField(panel->box); - WMResizeWidget(panel->fontT, 245, 30); - WMMoveWidget(panel->fontT, 265, 120); - - panel->changeB = WMCreateCommandButton(panel->box); - WMResizeWidget(panel->changeB, 104, 24); - WMMoveWidget(panel->changeB, 335, 160); - WMSetButtonText(panel->changeB, _("Change...")); - WMSetButtonAction(panel->changeB, changeButtonClick, panel); - - - panel->black = WMBlackColor(scr); - panel->white = WMWhiteColor(scr); - panel->light = WMGrayColor(scr); - panel->dark = WMDarkGrayColor(scr); - panel->back = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); - - /* Font Panel !!!!! */ - panel->fontPanel = WMGetFontPanel(scr); - -#if 0 - for (i = 0; Languages[i].language != NULL; i++) { - WMAddPopUpButtonItem(panel->langP, Languages[i].language); - } - - for (i = 0; Options[i].description != NULL; i++) { - WMAddListItem(panel->settingLs, Options[i].description); - } -#endif - WMRealizeWidget(panel->box); - WMMapSubwidgets(panel->box); - - showData(panel); - changePage(panel->fontSel, panel); -} - -static void -storeData(Panel *p) -{ - _Panel *panel = (_Panel*)p; - int i; - - char *encoding = getFontEncoding(panel); - - for(i=0;i < 6; i++) - { - switch(i) { - case 0: - SetStringForKey(fontOfLang(panel, encoding, i), - "WindowTitleFont"); - break; - case 1: - SetStringForKey(fontOfLang(panel, encoding, i), - "LargeDisplayFont"); - break; - case 2: - SetStringForKey(fontOfLang(panel, encoding, i), - "MenuTitleFont"); - break; - case 3: - SetStringForKey(fontOfLang(panel, encoding, i), - "MenuTextFont"); - break; - case 4: - SetStringForKey(fontOfLang(panel, encoding, i), - "ClipTitleFont"); - break; - case 5: - SetStringForKey(fontOfLang(panel, encoding, i), - "IconTitleFont"); - break; - } - } - - //if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box))) - SetBoolForKey(WMGetButtonSelected(panel->togAA), "AntialiasedText"); - - if(panel->MultiByteText) - SetStringForKey("YES", "MultiByteText"); - else { - if(isEncodingMultiByte(panel)) SetStringForKey("YES", "MultiByteText"); - else SetStringForKey("AUTO", "MultiByteText"); - } -} - -static void -prepClosure(Panel *p) -{ - _Panel *panel = (_Panel*)p; - WMFreeFontPanel(panel->fontPanel); - WMReleasePropList(CurrentFontArray); - /* and what ever else i've forgotten or overlooked - * maybe someone will add them */ -} - -Panel* -InitFont(WMScreen *scr, WMWidget *parent) -{ - _Panel *panel; - - panel = wmalloc(sizeof(_Panel)); - memset(panel, 0, sizeof(_Panel)); - - panel->sectionName = _("Font Preferences"); - panel->description = _("Font Configurations for Windows, Menus etc"); - - panel->parent = parent; - - panel->callbacks.createWidgets = createPanel; - panel->callbacks.updateDomain = storeData; - panel->callbacks.prepareForClose = prepClosure; - - AddSection(panel, ICON_FILE); - - return panel; -} - +/* Font.c- text/font settings + * + * WPrefs - Window Maker Preferences Program + * + * Copyright (c) 1999-2003 Alfredo K. Kojima + * + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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, + * USA. + */ + + +#include "WPrefs.h" +#include +#include + +typedef struct _Panel { + WMBox *box; + char *sectionName; + + char *description; + + CallbackRec callbacks; + + WMWidget *parent; + + + WMLabel *prevL; + + WMFontPanel *fontPanel; + + WMPopUpButton *fontSel; + WMFrame *multiF; + WMButton *togMulti; + WMFrame *langF; + WMPopUpButton *langP; + WMFrame *aaF; + WMButton *togAA; + + /* single byte */ + WMTextField *fontT; + WMButton *changeB; + + /* multibyte */ + WMLabel *fsetL; + WMList *fsetLs; + + WMButton *addB; + WMButton *editB; + WMButton *remB; + + WMButton *upB; + WMButton *downB; + + WMColor *white; + WMColor *black; + WMColor *light; + WMColor *dark; + + WMColor *back; + WMColor *colors[9]; + + Pixmap preview; + WMPixmap *previewPix; + WMPixmap *hand; + WMPixmap *up_arrow; + WMPixmap *down_arrow; + WMPixmap *alt_up_arrow; + WMPixmap *alt_down_arrow; + + int oldsection; + char menuStyle; + char titleAlignment; + Bool MultiByteText; + + Bool AntialiasedText; +} _Panel; + + + +#define ICON_FILE "fonts" + +static WMRect previewPositions[] = { +#define WINTITLE 0 + {{30, 10},{190, 20}}, +#define DISTITLE 1 + {{30, 35},{90, 64}}, +#define PMTITLE 2 + {{30, 105},{90, 20}}, +#define PMITEM 3 + {{30, 125},{90, 20*4}}, +#define PCLIP 4 + {{156, 35},{64, 64}}, +#define PICON 5 + {{156, 105},{64, 64}} +}; +#define EVERYTHING 0xff + +static char *colorOptions[] = { +#define FTITLE (1<<0) + "FTitleColor", "white", +#define DISCOL (1<<1) /* Display uses white always */ +#define MTITLE (1<<2) + "MenuTitleColor", "white", +#define MITEM (1<<3) + "MenuTextColor", "black", +#define CLIP (1<<4) + "ClipTitleColor", "black", +#define CCLIP (1<<4) + "ClipTitleColor", "#454045", +#define ICONT (1<<5) + "IconTitleColor", "white", +#define ICONB (1<<5) + "IconTitleBack", "black" +}; + +#define MSTYLE_NORMAL 0 +#define MSTYLE_SINGLE 1 +#define MSTYLE_FLAT 2 + + +#define RESIZEBAR_BEVEL -1 +#define MENU_BEVEL -2 +#define CLIP_BUTTON_SIZE 23 +#define ICON_SIZE 64 + + +static char *textureOptions[] = { + "FTitleBack", + NULL, + "MenuTitleBack", + "MenuTextBack", + "IconBack", + "IconBack" +}; + +/* XPM */ +static char * hand_xpm[] = { + "22 21 19 1", + " c None", + ". c #030305", + "+ c #7F7F7E", + "@ c #B5B5B6", + "# c #C5C5C6", + "$ c #969697", + "% c #FDFDFB", + "& c #F2F2F4", + "* c #E5E5E4", + "= c #ECECEC", + "- c #DCDCDC", + "; c #D2D2D0", + "> c #101010", + ", c #767674", + "' c #676767", + ") c #535355", + "! c #323234", + "~ c #3E3C56", + "{ c #333147", + " ", + " ..... ", + " ..+@##$. ", + " .%%%&@.......... ", + " .%*%%&#%%%%%%%%%$. ", + " .*#%%%%%%%%%&&&&==. ", + " .-%%%%%%%%%=*-;;;#$. ", + " .-%%%%%%%%&..>..... ", + " >-%%%%%%%%%*#+. ", + " >-%%%%%%%%%*@,. ", + " >#%%%%%%%%%*@'. ", + " >$&&%%%%%%=... ", + " .+@@;=&%%&;$,> ", + " .',$@####$+). ", + " .!',+$++,'. ", + " ..>>>>>. ", + " ", + " ~~{{{~~ ", + " {{{{{{{{{{{ ", + " ~~{{{~~ ", + " "}; + +static char *up_arrow_xpm[] = { + "9 9 3 1", + ". c #acaaac", + "% c #525552", + "# c #000000", + "....%....", + "....#....", + "...%#%...", + "...###...", + "..%###%..", + "..#####..", + ".%#####%.", + ".#######.", + "%#######%" +}; + +static char *down_arrow_xpm[] = { + "9 9 3 1", + ". c #acaaac", + "% c #525552", + "# c #000000", + "%#######%", + ".#######.", + ".%#####%.", + "..#####..", + "..%###%..", + "...###...", + "...%#%...", + "....#....", + "....%...." +}; + +static char *alt_up_arrow_xpm[] = { + "9 9 2 1", + ". c #ffffff", + "% c #525552", + "....%....", + "....%....", + "...%%%...", + "...%%%...", + "..%%%%%..", + "..%%%%%..", + ".%%%%%%%.", + ".%%%%%%%.", + "%%%%%%%%%" +}; + +static char *alt_down_arrow_xpm[] = { + "9 9 2 1", + ". c #ffffff", + "% c #525552", + "%%%%%%%%%", + ".%%%%%%%.", + ".%%%%%%%.", + "..%%%%%..", + "..%%%%%..", + "...%%%...", + "...%%%...", + "....%....", + "....%...." +}; +/* XPM */ + +static WMPropList *CurrentFontArray = NULL; +//static WMPropList *CurrentMenuTitleFont = NULL; +//static WMPropList *CurrentMenuTextFont = NULL; +//static WMPropList *CurrentIconTitleFont = NULL; +//static WMPropList *CurrentClipTitleFont = NULL; +//static WMPropList *CurrentLargeDisplayFont = NULL; + +static WMPropList *DefaultWindowTitleFont = NULL; +static WMPropList *DefaultMenuTitleFont = NULL; +static WMPropList *DefaultMenuTextFont = NULL; +static WMPropList *DefaultIconTitleFont = NULL; +static WMPropList *DefaultClipTitleFont = NULL; +static WMPropList *DefaultLargeDisplayFont = NULL; + +static void changePage(WMWidget *w, void *data); +static void setLanguageType(void *data, Bool multiByte); +static void refillFontSetList(void *data); +static void readFontEncodings(void *data); +static void changeLanguageAction(WMWidget *w, void *data); +static void checkListForArrows(void *data); + +static char* getFontEncoding(void *data); +static char* getFontSampleString(void *data); + +/* note single element */ +static WMFont* getFontForPreview(void *data, int element); +static WMFont* getDefaultSystemFont(void *data, int element); + +static WMPropList* getDefaultFontProp(void *data, char *encoding, int section); +static WMPropList* getCurrentFontProp(void *data, int section); + +static Bool isEncodingMultiByte(void *data); + +static void +str2rcolor(RContext *rc, char *name, RColor *color) +{ + XColor xcolor; + + XParseColor(rc->dpy, rc->cmap, name, &xcolor); + + color->alpha = 255; + color->red = xcolor.red >> 8; + color->green = xcolor.green >> 8; + color->blue = xcolor.blue >> 8; +} + +static void +drawMenuBevel(RImage *img) +{ + RColor light, dark, mid; + int i; + int iheight = img->height / 4; + + 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 < 4; i++) { + ROperateLine(img, RSubtractOperation, 0, i*iheight-2, + img->width-1, i*iheight-2, &mid); + + RDrawLine(img, 0, i*iheight-1, img->width-1, i*iheight-1, &dark); + + ROperateLine(img, RAddOperation, 1, i*iheight, + img->width-2, i*iheight, &light); + } +} + +static void +paintTitle(WMScreen *scr, Drawable d, WMColor *color, WMFont *font, + int part, WMAlignment align, char *text) +{ + int l = strlen(text); + int x = previewPositions[part].pos.x; + int y = previewPositions[part].pos.y; + int w = previewPositions[part].size.width; + int h = previewPositions[part].size.height; + + switch (align) { + case WALeft: + x += 5; + break; + case WARight: + x += w - 5 - WMWidthOfString(font, text, l); + break; + default: + case WACenter: + x += (w - WMWidthOfString(font, text, l))/2; + break; + } + WMDrawString(scr, d, color, font, x, + y + (h - WMFontHeight(font))/2, text, l); +} + +static void +paintItems(WMScreen *scr, Drawable d, WMColor *color, WMFont *font, + int part, char *text) +{ + int l = strlen(text); + int x = previewPositions[part].pos.x; + int y = previewPositions[part].pos.y; + //int w = previewPositions[part].size.width; + int h = previewPositions[part].size.height/4; + int i; + for( i = 0; i < 4 ; i++) { + WMDrawString(scr, d, color, font, x+5, + y+(20*i)+(h - WMFontHeight(font))/2, text, l); + } +} + +static void +paintIcon(WMScreen *scr,Drawable d, WMColor *color, WMColor *Iback, + WMFont *font, int part, char *text) +{ + Display *dpy = WMScreenDisplay(scr); + int l = strlen(text); + int x = previewPositions[part].pos.x+1; + int y = previewPositions[part].pos.y+1; + int w = previewPositions[part].size.width-2; + int h = WMFontHeight(font)+2; + + XFillRectangle(dpy, d, WMColorGC(Iback), x, y, w, h); + x += (w - WMWidthOfString(font, text, l))/2; + WMDrawString(scr, d, color, font, x, + y + (h - WMFontHeight(font))/2, text, l); + +} + +static void +drawFonts(_Panel *panel, int elements) +{ + WMScreen *scr = WMWidgetScreen(panel->box); + WMPixmap *pixmap; + Pixmap d; + + pixmap = WMGetLabelImage(panel->prevL); + d = WMGetPixmapXID(pixmap); + + if(elements & FTITLE) { + paintTitle(scr, d, panel->colors[0], getFontForPreview(panel, WINTITLE), + WINTITLE, panel->titleAlignment, _("Window Title Font")); + } + if(elements & DISCOL) { + paintTitle(scr, d, panel->white, getFontForPreview(panel, DISTITLE), + DISTITLE, WACenter, _("Display")); + } + if(elements & MTITLE) { + paintTitle(scr, d, panel->colors[1], getFontForPreview(panel, PMTITLE), + PMTITLE, WALeft, _("Menu Title")); + } + if(elements & MITEM) { + paintItems(scr, d, panel->colors[2], getFontForPreview(panel, PMITEM), + PMITEM, _("Menu Item")); + } + if(elements & CLIP) { + WMDrawString(scr, d, panel->colors[4], + getFontForPreview(panel, PCLIP), 169,37, "1",1); + WMDrawString(scr, d, panel->colors[3], + getFontForPreview(panel, PCLIP),179, 84, _("Clip title"), 10); + } + if(elements & ICONT) { + paintIcon(scr, d, panel->colors[5], panel->colors[6], + getFontForPreview(panel, PICON), PICON, _("Icon Title")); + } +} + +static void +dumpRImage(char *path, RImage *image) +{ + FILE *f; + int channels = (image->format == RRGBAFormat ? 4 : 3); + + f = fopen(path, "w"); + if (!f) { + wsyserror(path); + return; + } + fprintf(f, "%02x%02x%1x", image->width, image->height, channels); + + fwrite(image->data, 1, image->width * image->height * channels, f); + + if (fclose(f) < 0) { + wsyserror(path); + } +} + +/*static int + isPixmap(WMPropList *prop) + { + WMPropList *p; + char *s; + + p = WMGetFromPLArray(prop, 0); + s = WMGetFromPLString(p); + if (strcasecmp(&s[1], "pixmap")==0) + return 1; + else + return 0; + }*/ + +static Pixmap +renderTexture(WMScreen *scr, WMPropList *texture, int width, int height, + char *path, int border) +{ + char *type; + RImage *image = NULL; + Pixmap pixmap; + RContext *rc = WMScreenRContext(scr); + char *str; + RColor rcolor; + + + type = WMGetFromPLString(WMGetFromPLArray(texture, 0)); + + if (strcasecmp(type, "solid")==0) { + + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + + str2rcolor(rc, str, &rcolor); + + image = RCreateImage(width, height, False); + RClearImage(image, &rcolor); + } else if (strcasecmp(type, "igradient")==0) { + int t1, t2; + RColor c1[2], c2[2]; + + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + str2rcolor(rc, str, &c1[0]); + str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); + str2rcolor(rc, str, &c1[1]); + str = WMGetFromPLString(WMGetFromPLArray(texture, 3)); + t1 = atoi(str); + + str = WMGetFromPLString(WMGetFromPLArray(texture, 4)); + str2rcolor(rc, str, &c2[0]); + str = WMGetFromPLString(WMGetFromPLArray(texture, 5)); + str2rcolor(rc, str, &c2[1]); + str = WMGetFromPLString(WMGetFromPLArray(texture, 6)); + t2 = atoi(str); + + image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2); + } else if (strcasecmp(&type[1], "gradient")==0) { + int style; + RColor rcolor2; + + switch (toupper(type[0])) { + case 'V': + style = RVerticalGradient; + break; + case 'H': + style = RHorizontalGradient; + break; + default: + case 'D': + style = RDiagonalGradient; + break; + } + + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + str2rcolor(rc, str, &rcolor); + str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); + str2rcolor(rc, str, &rcolor2); + + image = RRenderGradient(width, height, &rcolor, &rcolor2, style); + } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='T') { + int style; + RColor rcolor2; + int i; + RImage *grad, *timage; + char *path; + + switch (toupper(type[1])) { + case 'V': + style = RVerticalGradient; + break; + case 'H': + style = RHorizontalGradient; + break; + default: + case 'D': + style = RDiagonalGradient; + break; + } + + str = WMGetFromPLString(WMGetFromPLArray(texture, 3)); + str2rcolor(rc, str, &rcolor); + str = WMGetFromPLString(WMGetFromPLArray(texture, 4)); + str2rcolor(rc, str, &rcolor2); + + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + + if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL) + timage = RLoadImage(rc, path, 0); + + if (!path || !timage) { + wwarning("could not load file '%s': %s", path, + RMessageForError(RErrorCode)); + } else { + grad = RRenderGradient(width, height, &rcolor, &rcolor2, style); + + image = RMakeTiledImage(timage, width, height); + RReleaseImage(timage); + + i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2))); + + RCombineImagesWithOpaqueness(image, grad, i); + RReleaseImage(grad); + } + } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='M') { + int style; + RColor **colors; + int i, j; + + switch (toupper(type[1])) { + case 'V': + style = RVerticalGradient; + break; + case 'H': + style = RHorizontalGradient; + break; + default: + case 'D': + style = RDiagonalGradient; + break; + } + + j = WMGetPropListItemCount(texture); + + if (j > 0) { + colors = wmalloc(j * sizeof(RColor*)); + + for (i = 2; i < j; i++) { + str = WMGetFromPLString(WMGetFromPLArray(texture, i)); + colors[i-2] = wmalloc(sizeof(RColor)); + str2rcolor(rc, str, colors[i-2]); + } + colors[i-2] = NULL; + + image = RRenderMultiGradient(width, height, colors, style); + + for (i = 0; colors[i]!=NULL; i++) + wfree(colors[i]); + wfree(colors); + } + } else if (strcasecmp(&type[1], "pixmap")==0) { + RImage *timage = NULL; + char *path; + RColor color; + + str = WMGetFromPLString(WMGetFromPLArray(texture, 1)); + + if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL) + timage = RLoadImage(rc, path, 0); + + if (!path || !timage) { + wwarning("could not load file '%s': %s", path ? path : str, + RMessageForError(RErrorCode)); + } else { + str = WMGetFromPLString(WMGetFromPLArray(texture, 2)); + str2rcolor(rc, str, &color); + + switch (toupper(type[0])) { + case 'T': + image = RMakeTiledImage(timage, width, height); + RReleaseImage(timage); + timage = image; + break; + case 'C': + image = RMakeCenteredImage(timage, width, height, &color); + RReleaseImage(timage); + timage = image; + break; + case 'S': + case 'M': + image = RScaleImage(timage, width, height); + RReleaseImage(timage); + timage = image; + break; + } + + } + wfree(path); + } + + if (!image) + return None; + + if (path) { + dumpRImage(path, image); + } + + if (border < 0) { + if (border == MENU_BEVEL) { + drawMenuBevel(image); + RBevelImage(image, RBEV_RAISED2); + } + } else if (border) { + RBevelImage(image, border); + } + + RConvertImage(rc, image, &pixmap); + RReleaseImage(image); + + return pixmap; +} + +static Pixmap +renderMenu(_Panel *panel, WMPropList *texture, int width, int iheight) +{ + WMScreen *scr = WMWidgetScreen(panel->parent); + Display *dpy = WMScreenDisplay(scr); + Pixmap pix, tmp; + //RContext *rc = WMScreenRContext(scr); + GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL); + int i; + + switch (panel->menuStyle) { + case MSTYLE_NORMAL: + tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2); + + pix = XCreatePixmap(dpy, tmp, width, iheight*4, WMScreenDepth(scr)); + for (i = 0; i < 4; i++) { + XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight*i); + } + XFreePixmap(dpy, tmp); + break; + case MSTYLE_SINGLE: + pix = renderTexture(scr, texture, width, iheight*4, NULL, MENU_BEVEL); + break; + case MSTYLE_FLAT: + pix = renderTexture(scr, texture, width, iheight*4, NULL, RBEV_RAISED2); + break; + } + XFreeGC(dpy, gc); + + return pix; +} + +static void +renderClip(_Panel *panel, GC gc, int part, int relief) +{ + WMScreen *scr = WMWidgetScreen(panel->box); + Display *dpy = WMScreenDisplay(scr); + RContext *rc = WMScreenRContext(scr); + WMPropList *prop; + Pixmap pix; + XImage *original; + XPoint p[4]; + RImage *tile; + RColor black; + RColor dark; + RColor light; + int pt, tp; + int as; + + prop = GetObjectForKey(textureOptions[part]); + + pix = renderTexture(scr, prop, + previewPositions[part].size.width, + previewPositions[part].size.height, + NULL, relief); + + + original = XGetImage(dpy, pix, 0, 0, 64, 64, + AllPlanes, ZPixmap); + if (!original){ + wwarning(_("error capturing \"original\" tile image"), + RMessageForError(RErrorCode)); + } + tile = RCreateImageFromXImage(rc, original, NULL); + + XDestroyImage(original); + XFreePixmap(WMScreenDisplay(scr), pix); + + pt = CLIP_BUTTON_SIZE*ICON_SIZE/64; + tp = ICON_SIZE-1 - pt; + as = pt - 15; + + black.alpha = 255; + black.red = black.green = black.blue = 0; + + dark.alpha = 0; + dark.red = dark.green = dark.blue = 60; + + light.alpha = 0; + light.red = light.green = light.blue = 80; + + + /* top right */ + ROperateLine(tile, RSubtractOperation, tp, 0, ICON_SIZE-2, + pt-1, &dark); + RDrawLine(tile, tp-1, 0, ICON_SIZE-1, pt+1, &black); + ROperateLine(tile, RAddOperation, tp, 2, ICON_SIZE-3, + pt, &light); + + /* arrow bevel */ + ROperateLine(tile, RSubtractOperation, ICON_SIZE - 7 - as, 4, + ICON_SIZE - 5, 4, &dark); + ROperateLine(tile, RSubtractOperation, ICON_SIZE - 6 - as, 5, + ICON_SIZE - 5, 6 + as, &dark); + ROperateLine(tile, RAddOperation, ICON_SIZE - 5, 4, ICON_SIZE - 5, 6 + as, + &light); + + /* bottom left */ + ROperateLine(tile, RAddOperation, 2, tp+2, pt-2, + ICON_SIZE-3, &dark); + RDrawLine(tile, 0, tp-1, pt+1, ICON_SIZE-1, &black); + ROperateLine(tile, RSubtractOperation, 0, tp-2, pt+1, + ICON_SIZE-2, &light); + + /* arrow bevel */ + ROperateLine(tile, RSubtractOperation, 4, ICON_SIZE - 7 - as, 4, + ICON_SIZE - 5, &dark); + ROperateLine(tile, RSubtractOperation, 5, ICON_SIZE - 6 - as, + 6 + as, ICON_SIZE - 5, &dark); + ROperateLine(tile, RAddOperation, 4, ICON_SIZE - 5, 6 + as, ICON_SIZE - 5, + &light); + + RConvertImage(rc, tile, &pix); + + /* top right arrow */ + p[0].x = p[3].x = ICON_SIZE-5-as; + p[0].y = p[3].y = 5; + p[1].x = ICON_SIZE-6; + p[1].y = 5; + p[2].x = ICON_SIZE-6; + p[2].y = 4+as; + XFillPolygon(dpy, pix, WMColorGC(panel->colors[4]), p, 3, Convex, CoordModeOrigin); + XDrawLines(dpy, pix, WMColorGC(panel->colors[4]), p, 4, CoordModeOrigin); + + /* bottom left arrow */ + p[0].x = p[3].x = 5; + p[0].y = p[3].y = ICON_SIZE-5-as; + p[1].x = 5; + p[1].y = ICON_SIZE-6; + p[2].x = 4+as; + p[2].y = ICON_SIZE-6; + XFillPolygon(dpy, pix, WMColorGC(panel->colors[4]), p, 3, Convex, CoordModeOrigin); + XDrawLines(dpy, pix, WMColorGC(panel->colors[4]), p, 4, CoordModeOrigin); + + XCopyArea(dpy, pix, panel->preview, gc, 0, 0, + previewPositions[part].size.width, + previewPositions[part].size.height, + previewPositions[part].pos.x, + previewPositions[part].pos.y); + + RReleaseImage(tile); + XFreePixmap(WMScreenDisplay(scr), pix); +} + +static void +renderPreview(_Panel *panel, GC gc, int part, int relief) +{ + WMPropList *prop; + Pixmap pix; + WMScreen *scr = WMWidgetScreen(panel->box); + + prop = GetObjectForKey(textureOptions[part]); + + pix = renderTexture(scr, prop, + previewPositions[part].size.width, + previewPositions[part].size.height, + NULL, relief); + XCopyArea(WMScreenDisplay(scr), pix, + panel->preview, gc, 0, 0, + previewPositions[part].size.width, + previewPositions[part].size.height, + previewPositions[part].pos.x, + previewPositions[part].pos.y); + + XFreePixmap(WMScreenDisplay(scr), pix); +} + +static void +paintPreviewBox(Panel *panel, int elements) +{ + WMScreen *scr = WMWidgetScreen(panel->parent); + Display *dpy = WMScreenDisplay(scr); + //int refresh = 0; + GC gc; + WMColor *black = WMBlackColor(scr); + Pixmap mitem; + + gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL); + + if (panel->preview == None) { + WMPixmap *pix; + + panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->parent), + 240-4, 190-4, WMScreenDepth(scr)); + + pix = WMCreatePixmapFromXPixmaps(scr, panel->preview, None, + 240-4, 190-4, WMScreenDepth(scr)); + + WMSetLabelImage(panel->prevL, pix); + WMReleasePixmap(pix); + } + XFillRectangle(dpy, panel->preview, WMColorGC(panel->back), + 0, 0, 240-4, 190-4); + + if (elements & (1<preview, WMColorGC(black), + previewPositions[WINTITLE].pos.x-1, + previewPositions[WINTITLE].pos.y-1, + previewPositions[WINTITLE].size.width, + previewPositions[WINTITLE].size.height); + } + if (elements & (1<preview, WMColorGC(panel->back), + previewPositions[DISTITLE].pos.x-1, + previewPositions[DISTITLE].pos.y-1, + previewPositions[DISTITLE].size.width, + previewPositions[DISTITLE].size.height); + } + if (elements & (1<preview, WMColorGC(black), + previewPositions[PMTITLE].pos.x-1, + previewPositions[PMTITLE].pos.y-1, + previewPositions[PMTITLE].size.width, + previewPositions[PMTITLE].size.height); + } + if (elements & (1<preview, gc, 0, 0, + previewPositions[PMITEM].size.width, + previewPositions[PMITEM].size.height, + previewPositions[PMITEM].pos.x, + previewPositions[PMITEM].pos.y); + + XFreePixmap(dpy, mitem); + } + if (elements & (1<preview, gc, 29, 125, 29, 125+20*4+25); + XDrawLine(dpy, panel->preview, gc, 119, 125, 119, 125+20*4+25); + } + if (elements & (1<preview, WMColorGC(black), + previewPositions[PCLIP].pos.x-1, + previewPositions[PCLIP].pos.y-1, + previewPositions[PCLIP].size.width, + previewPositions[PCLIP].size.height); + } + if (elements & (1<preview, WMColorGC(black), + previewPositions[PICON].pos.x-1, + previewPositions[PICON].pos.y-1, + previewPositions[PICON].size.width, + previewPositions[PICON].size.height); + } + drawFonts(panel, elements); + WMRedisplayWidget(panel->prevL); + XFreeGC(dpy, gc); + WMReleaseColor(black); +} + +static void +paintTextField(void *data, int section) +{ + _Panel *panel = (_Panel*)data; + //char *sample = NULL; + int encoding; + encoding = WMGetPopUpButtonSelectedItem(panel->langP); + WMSetTextFieldFont(panel->fontT, getFontForPreview(panel, section)); + switch(encoding) { + case 0: /* Current Font in theme */ + WMSetTextFieldText(panel->fontT, + "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); + break; + case 1: /* default */ + WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); + // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); + break; + case 2: /* latin1 iso8859-1 */ + WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); + // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); + break; + case 3: /* latin2 iso8859-2 */ + WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); + // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); + break; + case 4: /* Greek iso8859-7 */ + WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); + // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); + break; + /* luckily all these happen to have the MultiByte chars in the same places */ + case 5: /* Japanese jisx0208.1983 */ + WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); + // "Window Maker ÀßÄê¥æ¡¼¥Æ¥£¥ê¥Æ¥£"); + break; + case 6: /* Korean ksc5601.1987 */ + WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); + // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤"); + break; + case 7: /* korean2 daewoo */ + WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); + // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤"); + break; + case 8: /* Russian koi8-r */ + WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); + // "ó×ÏÊÓÔ×Á Window Maker"); + break; + case 9: /* Ukranian koi8-u */ + WMSetTextFieldText(panel->fontT, getFontSampleString(panel)); + // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd"); + break; + } +} + +static void +previewClick(XEvent *event, void *clientData) +{ + _Panel *panel = (_Panel*)clientData; + int i; + + for (i = 0; i < sizeof(previewPositions)/sizeof(WMRect); i++) { + if (event->xbutton.x >= previewPositions[i].pos.x + && event->xbutton.y >= previewPositions[i].pos.y + && event->xbutton.x < previewPositions[i].pos.x + + previewPositions[i].size.width + && event->xbutton.y < previewPositions[i].pos.y + + previewPositions[i].size.height) { + + WMSetPopUpButtonSelectedItem(panel->fontSel, i); + changePage(panel->fontSel, panel); + return; + } + } +} + +static void +changePage(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + int section; + WMScreen *scr = WMWidgetScreen(panel->box); + RContext *rc = WMScreenRContext(scr); + static WMPoint positions[] = { + {5, 15}, + {5, 62}, + {5, 110}, + {5, 140}, + {130, 62}, + {130, 132} + }; + + if (w) { + section = WMGetPopUpButtonSelectedItem(panel->fontSel); + } + { + WMColor *color; + + color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); + XFillRectangle(rc->dpy, panel->preview, WMColorGC(color), + positions[panel->oldsection].x, + positions[panel->oldsection].y, 22, 22); + WMReleaseColor(color); + } + if (w) { + panel->oldsection = section; + WMDrawPixmap(panel->hand, panel->preview, positions[section].x, + positions[section].y); + } + WMRedisplayWidget(panel->prevL); + paintTextField(panel, section); + refillFontSetList(panel); +} + +static void +setLanguageType(void *data, Bool multiByte) +{ + _Panel *p = (_Panel*)data; + + if (multiByte) { + WMMapWidget(p->fsetL); + WMMapWidget(p->fsetLs); + WMMapWidget(p->addB); + WMMapWidget(p->editB); + WMMapWidget(p->remB); + WMMapWidget(p->upB); + WMMapWidget(p->downB); + + WMUnmapWidget(p->fontT); + WMUnmapWidget(p->changeB); + } else { + WMUnmapWidget(p->fsetL); + WMUnmapWidget(p->fsetLs); + WMUnmapWidget(p->addB); + WMUnmapWidget(p->editB); + WMUnmapWidget(p->remB); + WMUnmapWidget(p->upB); + WMUnmapWidget(p->downB); + + WMMapWidget(p->fontT); + WMMapWidget(p->changeB); + } +} + +static void +refillFontSetList(void *data) +{ + _Panel *panel = (_Panel*)data; + WMPropList *array; + char *encoding = getFontEncoding(panel); + int section = WMGetPopUpButtonSelectedItem(panel->fontSel); + int i; + //int pos; + WMClearList(panel->fsetLs); + if(!encoding) { + array = getCurrentFontProp(panel, section); + } else { + array = getDefaultFontProp(panel, encoding, section); + } + if(!array){ + wwarning("error not Font prop given"); + } else { + for (i = 0; i < WMGetPropListItemCount(array); i++) { + WMGetFromPLArray(array, i); + WMAddListItem( panel->fsetLs, + WMGetFromPLString( + WMGetFromPLArray(array, i))); + } + WMReleasePropList(array); + WMSelectListItem(panel->fsetLs, 0); + } + + checkListForArrows(panel); +} + +static void +insertCurrentFont(char *data, char *type) +{ + WMPropList *key; + WMPropList *array; + char *tmp, *str; + + key = WMCreatePLString(type); + array = WMCreatePLArray(NULL); + + str = wstrdup(data); + tmp = strtok(str, ","); + while(tmp) { + WMAddToPLArray(array, WMCreatePLString(tmp)); + tmp = strtok(NULL, ","); + } + wfree(str); + + + WMPutInPLDictionary(CurrentFontArray, key, array); +} + +static void +readFontEncodings(void *data) +{ + _Panel *panel = (_Panel*)data; + WMPropList *pl = NULL; + char *path; + char *msg; + + path = WMPathForResourceOfType("font.data", NULL); + if (!path) { + msg = _("Could not locate font information file WPrefs.app/font.data"); + goto error; + } + + pl = WMReadPropListFromFile(path); + if (!pl) { + msg = _("Could not read font information file WPrefs.app/font.data"); + goto error; + } else { + int i; + WMPropList *key = WMCreatePLString("Encodings"); + WMPropList *array; + WMMenuItem *mi; + + array = WMGetFromPLDictionary(pl, key); + WMReleasePropList(key); + if (!array || !WMIsPLArray(array)) { + msg = _("Invalid data in font information file WPrefs.app/font.data.\n" + "Encodings data not found."); + goto error; + } + + WMAddPopUpButtonItem(panel->langP, _("Current")); + + for (i = 0; i < WMGetPropListItemCount(array); i++) { + WMPropList *item, *str; + + item = WMGetFromPLArray(array, i); + str = WMGetFromPLArray(item, 0); + mi = WMAddPopUpButtonItem(panel->langP, WMGetFromPLString(str)); + WMSetMenuItemRepresentedObject(mi, WMRetainPropList(item)); + } + WMSetPopUpButtonSelectedItem(panel->langP, 0); + + + key = WMCreatePLString("WindowTitleFont"); + DefaultWindowTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); + WMReleasePropList(key); + + key = WMCreatePLString("MenuTitleFont"); + DefaultMenuTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); + WMReleasePropList(key); + + key = WMCreatePLString("MenuTextFont"); + DefaultMenuTextFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); + WMReleasePropList(key); + + key = WMCreatePLString("IconTitleFont"); + DefaultIconTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); + WMReleasePropList(key); + + key = WMCreatePLString("ClipTitleFont"); + DefaultClipTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); + WMReleasePropList(key); + + key = WMCreatePLString("LargeDisplayFont"); + DefaultLargeDisplayFont = WMRetainPropList(WMGetFromPLDictionary(pl, key)); + WMReleasePropList(key); + } + + WMReleasePropList(pl); + return; +error: + if (pl) + WMReleasePropList(pl); + + WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, + _("Error"), msg, _("OK"), NULL, NULL); +} + +static void +checkListForArrows(void *data) +{ + _Panel *panel = (_Panel*)data; + int list; + list = WMGetListNumberOfRows(panel->fsetLs); + + if(list > 1) + { + if(WMGetListSelectedItemRow(panel->fsetLs) == 0) { + WMSetButtonEnabled(panel->upB, False); + WMSetButtonEnabled(panel->downB, True); + } else if(WMGetListSelectedItemRow(panel->fsetLs) == list-1) { + WMSetButtonEnabled(panel->downB, False); + WMSetButtonEnabled(panel->upB, True); + } else { + WMSetButtonEnabled(panel->upB, True); + WMSetButtonEnabled(panel->downB, True); + } + + } else { + WMSetButtonEnabled(panel->upB, False); + WMSetButtonEnabled(panel->downB, False); + } + /* added to control the Remove button */ + if(list > 1) + WMSetButtonEnabled(panel->remB, True); + else + WMSetButtonEnabled(panel->remB, False); +} + +static char* +fontOfLang(void *data, char *encoding, int section) +{ + _Panel *panel = (_Panel*)data; + WMPropList *array; + char *buf = NULL; + int i; + + if(!encoding) + array = getCurrentFontProp(panel, section); + else + array = getDefaultFontProp(panel, encoding, section); + + if(!array) { + wwarning("error no font prop given"); + return NULL; + } else { + for(i=0; ibox); + int section; + + section = WMGetPopUpButtonSelectedItem(w); + + if(isEncodingMultiByte(panel)) { + setLanguageType(panel, True); + } else { + if(panel->MultiByteText) setLanguageType(panel, True); + else setLanguageType(panel, False); + } + + paintPreviewBox(panel, EVERYTHING); + changePage(panel->fontSel, panel); +} + +static WMFont* +getFontForPreview(void *data, int element) +{ + _Panel *panel = (_Panel*)data; + WMFont *font; + char *fname; + WMScreen *scr = WMWidgetScreen(panel->box); + char *encoding = getFontEncoding(panel); + fname = fontOfLang(panel, encoding, element); + //if (WMHasAntialiasingSupport(scr)) { + if(panel->AntialiasedText) { + // fix this -Dan font = WMCreateFontWithFlags(scr, fname, WFAntialiased); + font = WMCreateFont(scr, fname); + } else { + font = WMCreateFont(scr, fname); + } + //} else { + // font = WMCreateFont(scr, fname); + //} + if(!font) { + char *msg; + int length; + length = strlen("\"")+ + strlen(fname)+strlen("\" was not loaded correctly. Make sure the font is available for that encoding.\nLoadind default system font."); + msg = wmalloc(length +1); + snprintf(msg, length + 1, + "\"%s\" was not loaded correctly. Make sure the font is available for that encoding.\nLoading default system font.", + fname); + WMRunAlertPanel(WMWidgetScreen(panel->parent),panel->parent, + _("Warning"), msg, _("OK"), NULL, NULL); + font = getDefaultSystemFont(panel, element); + } + return font; +} + +static char* +getFontSampleString(void *data) +{ + _Panel *panel = (_Panel*)data; + //WMScreen *scr = WMWidgetScreen(panel->box); + WMMenuItem *mi; + WMPropList *pl; + int section; + + section = WMGetPopUpButtonSelectedItem(panel->langP); + mi = WMGetPopUpButtonMenuItem(panel->langP, section); + pl = WMGetMenuItemRepresentedObject(mi); + + if (!pl) { + return NULL; + } else { + char *sample; + sample = WMGetFromPLString(WMGetFromPLArray(pl,3)); + return sample; + } +} + +static char* +getFontEncoding(void *data) +{ + _Panel *panel = (_Panel*)data; + //WMScreen *scr = WMWidgetScreen(panel->box); + WMMenuItem *mi; + WMPropList *pl; + int section; + + section = WMGetPopUpButtonSelectedItem(panel->langP); + mi = WMGetPopUpButtonMenuItem(panel->langP, section); + pl = WMGetMenuItemRepresentedObject(mi); + + if (!pl) { + return NULL; + } else { + char *encoding; + encoding = WMGetFromPLString(WMGetFromPLArray(pl,2)); + return encoding; + } +} + +static Bool +isEncodingMultiByte(void *data) +{ + _Panel *panel = (_Panel*)data; + //WMScreen *scr = WMWidgetScreen(panel->box); + WMMenuItem *mi; + WMPropList *pl; + int section; + + section = WMGetPopUpButtonSelectedItem(panel->langP); + mi = WMGetPopUpButtonMenuItem(panel->langP, section); + pl = WMGetMenuItemRepresentedObject(mi); + + if (!pl) { + return False; + } else { + char *multiByte; + int res; + multiByte = WMGetFromPLString(WMGetFromPLArray(pl,1)); + res = atoi(multiByte); + if(res) + return True; + else + return False; + } +} + +static WMPropList* +getCurrentFontProp(void *data, int section) +{ + WMPropList *array; + switch (section) { + case 0: + array = WMRetainPropList( + WMGetFromPLDictionary(CurrentFontArray, + WMCreatePLString("WindowTitleFont"))); + break; + case 1: + array = WMRetainPropList( + WMGetFromPLDictionary(CurrentFontArray, + WMCreatePLString("LargeDisplayFont"))); + break; + case 2: + array = WMRetainPropList( + WMGetFromPLDictionary(CurrentFontArray, + WMCreatePLString("MenuTitleFont"))); + break; + case 3: + array = WMRetainPropList( + WMGetFromPLDictionary(CurrentFontArray, + WMCreatePLString("MenuTextFont"))); + break; + case 4: + array = WMRetainPropList( + WMGetFromPLDictionary(CurrentFontArray, + WMCreatePLString("ClipTitleFont"))); + break; + case 5: + array = WMRetainPropList( + WMGetFromPLDictionary(CurrentFontArray, + WMCreatePLString("IconTitleFont"))); + break; + } + if(!WMIsPLArray(array)) { + return NULL; + } else { + return array; + } +} + +static WMPropList* +getDefaultFontProp(void *data, char *encoding, int section) +{ + WMPropList *array; + WMPropList *key = WMCreatePLString(encoding); + switch (section) { + case 0: + array = WMRetainPropList( + WMGetFromPLDictionary(DefaultWindowTitleFont, key)); + WMReleasePropList(key); + break; + case 1: + array = WMRetainPropList( + WMGetFromPLDictionary(DefaultLargeDisplayFont, key)); + WMReleasePropList(key); + break; + case 2: + array = WMRetainPropList( + WMGetFromPLDictionary(DefaultMenuTitleFont, key)); + WMReleasePropList(key); + break; + case 3: + array = WMRetainPropList( + WMGetFromPLDictionary(DefaultMenuTextFont, key)); + WMReleasePropList(key); + break; + case 4: + array = WMRetainPropList( + WMGetFromPLDictionary(DefaultClipTitleFont, key)); + WMReleasePropList(key); + break; + case 5: + array = WMRetainPropList( + WMGetFromPLDictionary(DefaultIconTitleFont, key)); + WMReleasePropList(key); + break; + } + if(!WMIsPLArray(array)) { + return NULL; + } else { + return array; + } +} + +static WMFont* +getDefaultSystemFont(void *data, int element) +{ + _Panel *panel = (_Panel*)data; + WMScreen *scr = WMWidgetScreen(panel->box); + + switch(element) { + case 0: + case 2: + return WMBoldSystemFontOfSize(scr, 12); + case 1: + return WMBoldSystemFontOfSize(scr, 24); + case 4: + case 5: + return WMSystemFontOfSize(scr, 8); + case 3: + default: + return WMSystemFontOfSize(scr, 12); + } +} + +static void +multiClick(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + if(!panel->MultiByteText) { + WMSetButtonText(panel->togMulti, _("Yes")); + setLanguageType(panel, True); + panel->MultiByteText = True; + } else { + WMSetButtonText(panel->togMulti, _("Auto")); + if(isEncodingMultiByte(panel)) setLanguageType(panel, True); + else setLanguageType(panel, False); + panel->MultiByteText = False; + } +} + +static void +toggleAA(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + //int section; + if(panel->AntialiasedText) + panel->AntialiasedText = False; + else + panel->AntialiasedText = True; + /* hmm now i gotta redraw all the fonts in the preview section + * and the text field + */ + paintPreviewBox(panel, EVERYTHING); + changePage(panel->fontSel, panel); + if(isEncodingMultiByte(panel)) setLanguageType(panel, True); +} + +static void +listClick(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + + checkListForArrows(panel); +} + +static void +moveUpListItem(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + WMListItem *tmp; + int pos; + char *listtext; + WMPropList *array; + WMPropList *string; + char *encoding = getFontEncoding(panel); + int section = WMGetPopUpButtonSelectedItem(panel->fontSel); + + if(!encoding) + array = getCurrentFontProp(panel, section); + else + array = getDefaultFontProp(panel, encoding, section); + + pos = WMGetListSelectedItemRow(panel->fsetLs); + + tmp = WMGetListItem(panel->fsetLs, pos); + listtext = wstrdup(tmp->text); + string = WMCreatePLString(listtext); + + WMRemoveListItem(panel->fsetLs, pos); + WMDeleteFromPLArray(array, pos); + WMInsertListItem(panel->fsetLs, pos-1, listtext); + WMInsertInPLArray(array, pos-1, string); + + paintPreviewBox(panel, EVERYTHING); + changePage(panel->fontSel, panel); + + WMSelectListItem(panel->fsetLs, pos-1); + checkListForArrows(panel); +} + +static void +moveDownListItem(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + WMListItem *tmp; + int pos; + char *listtext; + WMPropList *array; + WMPropList *string; + char *encoding = getFontEncoding(panel); + int section = WMGetPopUpButtonSelectedItem(panel->fontSel); + + if(!encoding) + array = getCurrentFontProp(panel, section); + else + array = getDefaultFontProp(panel, encoding, section); + + pos = WMGetListSelectedItemRow(panel->fsetLs); + + tmp = WMGetListItem(panel->fsetLs, pos); + listtext = wstrdup(tmp->text); + string = WMCreatePLString(listtext); + WMRemoveListItem(panel->fsetLs, pos); + WMDeleteFromPLArray(array, pos); + WMInsertListItem(panel->fsetLs, pos+1, listtext); + WMInsertInPLArray(array, pos+1, string); + + paintPreviewBox(panel, EVERYTHING); + changePage(panel->fontSel, panel); + + WMSelectListItem(panel->fsetLs, pos+1); + checkListForArrows(panel); +} + +static void +addButtonAction(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + char *chosenFont; + int pos; + WMPropList *array; + WMPropList *string; + char *encoding = getFontEncoding(panel); + int section = WMGetPopUpButtonSelectedItem(panel->fontSel); + + if(!encoding) + array = getCurrentFontProp(panel, section); + else + array = getDefaultFontProp(panel, encoding, section); + + WMHideFontPanel(panel->fontPanel); + chosenFont = WMGetFontName(WMGetFontPanelFont(panel->fontPanel)); + string = WMCreatePLString(chosenFont); + pos = WMGetListSelectedItemRow(panel->fsetLs); + WMInsertListItem(panel->fsetLs, pos+1, chosenFont); + WMInsertInPLArray(array, pos+1, string); + WMSelectListItem(panel->fsetLs, pos+1); + + paintPreviewBox(panel, EVERYTHING); + changePage(panel->fontSel, panel); +} + +static void +changeButtonAction(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + char *chosenFont; + int pos; + WMPropList *array; + WMPropList *string; + char *encoding = getFontEncoding(panel); + int section = WMGetPopUpButtonSelectedItem(panel->fontSel); + + if(!encoding) + array = getCurrentFontProp(panel, section); + else + array = getDefaultFontProp(panel, encoding, section); + + WMHideFontPanel(panel->fontPanel); + + chosenFont = WMGetFontName(WMGetFontPanelFont(panel->fontPanel)); + string = WMCreatePLString(chosenFont); + + pos = WMGetListSelectedItemRow(panel->fsetLs); + WMRemoveListItem(panel->fsetLs, pos); + WMDeleteFromPLArray(array, pos); + WMInsertListItem(panel->fsetLs, pos, chosenFont); + WMInsertInPLArray(array, pos, string); + WMSelectListItem(panel->fsetLs, pos); + + paintPreviewBox(panel, EVERYTHING); + changePage(panel->fontSel, panel); +} + +static void +changeButtonClick(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + + WMSetFontPanelAction(panel->fontPanel, changeButtonAction, panel); + WMShowFontPanel(panel->fontPanel); +} + +static void +addButtonClick(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + + WMSetFontPanelAction(panel->fontPanel, addButtonAction, panel); + WMShowFontPanel(panel->fontPanel); +} + +static void +removeButtonClick(WMWidget *w, void *data) +{ + _Panel *panel = (_Panel*)data; + int pos; + int list; + WMPropList *array; + char *encoding = getFontEncoding(panel); + int section = WMGetPopUpButtonSelectedItem(panel->fontSel); + + if(!encoding) + array = getCurrentFontProp(panel, section); + else + array = getDefaultFontProp(panel, encoding, section); + + pos = WMGetListSelectedItemRow(panel->fsetLs); + WMRemoveListItem(panel->fsetLs, pos); + WMDeleteFromPLArray(array, pos); + + list = WMGetListNumberOfRows(panel->fsetLs); + if(list != 0) { + if(list > pos) + WMSelectListItem(panel->fsetLs, pos); + else if(list == pos) + WMSelectListItem(panel->fsetLs, list-1); + else + WMSelectListItem(panel->fsetLs, 0); + } + checkListForArrows(panel); + + paintPreviewBox(panel, EVERYTHING); + changePage(panel->fontSel, panel); +} + +static void +showData(_Panel *panel) +{ + //WMScreen *scr = WMWidgetScreen(panel->parent); + char *str; + int i; + + CurrentFontArray = WMCreatePLDictionary(NULL, NULL); + + str = GetStringForKey("WindowTitleFont"); + insertCurrentFont(wstrdup(str), "WindowTitleFont"); + + str = GetStringForKey("LargeDisplayFont"); + insertCurrentFont(wstrdup(str), "LargeDisplayFont"); + + str = GetStringForKey("MenuTitleFont"); + insertCurrentFont(wstrdup(str), "MenuTitleFont"); + + str = GetStringForKey("MenuTextFont"); + insertCurrentFont(wstrdup(str), "MenuTextFont"); + + str = GetStringForKey("ClipTitleFont"); + insertCurrentFont(wstrdup(str), "ClipTitleFont"); + + str = GetStringForKey("IconTitleFont"); + insertCurrentFont(wstrdup(str), "IconTitleFont"); + + /* i put this here cause it needs to be known before we paint */ + readFontEncodings(panel); + + str = GetStringForKey("MenuStyle"); + if (str && strcasecmp(str, "flat")==0) { + panel->menuStyle = MSTYLE_FLAT; + } else if (str && strcasecmp(str, "singletexture")==0) { + panel->menuStyle = MSTYLE_SINGLE; + } else { + panel->menuStyle = MSTYLE_NORMAL; + } + + str = GetStringForKey("TitleJustify"); + if (str && strcasecmp(str, "left")==0) { + panel->titleAlignment = WALeft; + } else if (str && strcasecmp(str, "right")==0) { + panel->titleAlignment = WARight; + } else { + panel->titleAlignment = WACenter; + } + for (i = 0; i < sizeof(colorOptions)/(2*sizeof(char*)); i++) { + WMColor *color; + + str = GetStringForKey(colorOptions[i*2]); + if (!str) + str = colorOptions[i*2+1]; + + if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) { + color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False); + } + panel->colors[i] = color; + } + + str = GetStringForKey("MultiByteText"); + if (str) + { + if (strcasecmp(str, "YES")==0) { + setLanguageType(panel, True); + WMSetButtonText(panel->togMulti, "Yes"); + printf("yes multi\n"); + panel->MultiByteText = True; + } else if (strcasecmp(str, "AUTO") == 0) { + char *locale; + locale = setlocale(LC_CTYPE, NULL); + if(locale != NULL + && (strncmp(locale, "ja", 2) == 0 + || strncmp(locale, "zh", 2) == 0 + || strncmp(locale, "ko", 2) == 0)) { + setLanguageType(panel, True); + WMSetButtonText(panel->togMulti, "Auto"); + printf("auto multi\n"); + panel->MultiByteText = True; + } else { + setLanguageType(panel, False); + WMSetButtonText(panel->togMulti, "Auto"); + panel->MultiByteText = False; + } + } + } else { + char *locale; + locale = setlocale(LC_CTYPE, NULL); + if(locale != NULL + && (strncmp(locale, "ja", 2) == 0 + || strncmp(locale, "zh", 2) == 0 + || strncmp(locale, "ko", 2) == 0)) { + setLanguageType(panel, True); + WMSetButtonText(panel->togMulti, "Auto"); + printf("auto multi\n"); + panel->MultiByteText = True; + } else { + setLanguageType(panel, False); + WMSetButtonText(panel->togMulti, "Auto"); + panel->MultiByteText = False; + } + } + /* gotta check for Antialiasing AFTER MultiByte incase the use has both + * to maintain behavior in Current Fonts set or i could add another if + * statement to setLanguageType =) */ + //if (WMHasAntialiasingSupport(scr)) { + WMMapWidget(panel->togAA); + if(GetBoolForKey("AntialiasedText")){ + WMSetButtonSelected(panel->togAA, True); + panel->AntialiasedText = True; + } else { + WMSetButtonSelected(panel->togAA, False); + panel->AntialiasedText = False; + } + //} else { + // WMUnmapWidget(panel->togAA); + //} + + + paintPreviewBox(panel, EVERYTHING); +} + +static void +createPanel(Panel *p) +{ + _Panel *panel = (_Panel*)p; + WMScreen *scr = WMWidgetScreen(panel->parent); + + + panel->box = WMCreateBox(panel->parent); + WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); + + panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm); + panel->up_arrow = WMCreatePixmapFromXPMData(scr, up_arrow_xpm); + panel->down_arrow = WMCreatePixmapFromXPMData(scr, down_arrow_xpm); + panel->alt_up_arrow = WMCreatePixmapFromXPMData(scr, alt_up_arrow_xpm); + panel->alt_down_arrow = WMCreatePixmapFromXPMData(scr, alt_down_arrow_xpm); + + panel->prevL = WMCreateLabel(panel->box); + WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 45); + WMMoveWidget(panel->prevL, 15, 35); + WMSetLabelRelief(panel->prevL, WRSunken); + WMSetLabelImagePosition(panel->prevL, WIPImageOnly); + + WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask, + previewClick, panel); + + /* Widget Selection */ + panel->fontSel = WMCreatePopUpButton(panel->box); + WMResizeWidget(panel->fontSel, 135, 20); + WMMoveWidget(panel->fontSel, 15, 10); + WMAddPopUpButtonItem(panel->fontSel, _("Window Title Font")); + WMAddPopUpButtonItem(panel->fontSel, _("Large Display Font")); + WMAddPopUpButtonItem(panel->fontSel, _("Menu Title Font")); + WMAddPopUpButtonItem(panel->fontSel, _("Menu Item Font" )); + WMAddPopUpButtonItem(panel->fontSel, _("Clip Title Font")); + WMAddPopUpButtonItem(panel->fontSel, _("Icon Title Font")); + + WMSetPopUpButtonSelectedItem(panel->fontSel, 0); + + WMSetPopUpButtonAction(panel->fontSel, changePage, panel); + + /* MultiByteText toggle */ + panel->multiF = WMCreateFrame(panel->box); + WMResizeWidget(panel->multiF, 70, 50); + WMMoveWidget(panel->multiF, 440, 10); + WMSetFrameTitle(panel->multiF, _("MultiByte")); + + + panel->togMulti = WMCreateCommandButton(panel->multiF); + WMResizeWidget(panel->togMulti, 40, 20); + WMMoveWidget(panel->togMulti, 15, 20); + WMSetButtonAction(panel->togMulti, multiClick, panel); + + WMMapSubwidgets(panel->multiF); + + /* language selection */ + panel->langF = WMCreateFrame(panel->box); + WMResizeWidget(panel->langF, 165, 50); + WMMoveWidget(panel->langF, 265, 10); + WMSetFrameTitle(panel->langF, _("Default Font Encodings")); + + panel->langP = WMCreatePopUpButton(panel->langF); + WMResizeWidget(panel->langP, 135, 20); + WMMoveWidget(panel->langP, 15, 20); + + WMSetPopUpButtonAction(panel->langP, changeLanguageAction, panel); + + WMMapSubwidgets(panel->langF); + + /* Antialiasing */ + //if (WMHasAntialiasingSupport(scr)) { + panel->togAA = WMCreateSwitchButton(panel->box); + WMResizeWidget(panel->togAA, 110, 20); + WMMoveWidget(panel->togAA, 155, 10); + WMSetButtonText(panel->togAA, _("Smooth Fonts")); + WMSetBalloonTextForView(_("Smooth Font edges for the eye candy\n" + "requires a restart after saving"), + WMWidgetView(panel->togAA)); + WMSetButtonAction(panel->togAA, toggleAA, panel); + //} + /* multibyte */ + panel->fsetL = WMCreateLabel(panel->box); + WMResizeWidget(panel->fsetL, 245, 20); + WMMoveWidget(panel->fsetL, 265, 70); + WMSetLabelText(panel->fsetL, _("Font Set")); + WMSetLabelRelief(panel->fsetL, WRSunken); + WMSetLabelTextAlignment(panel->fsetL, WACenter); + { + WMFont *font; + WMColor *color; + + color = WMDarkGrayColor(scr); + font = WMBoldSystemFontOfSize(scr, 12); + + WMSetWidgetBackgroundColor(panel->fsetL, color); + WMSetLabelFont(panel->fsetL, font); + + WMReleaseFont(font); + WMReleaseColor(color); + + color = WMWhiteColor(scr); + WMSetLabelTextColor(panel->fsetL, color); + WMReleaseColor(color); + } + + panel->fsetLs = WMCreateList(panel->box); + WMResizeWidget(panel->fsetLs, 245, 86); + WMMoveWidget(panel->fsetLs, 265, 92); + WMSetListAction(panel->fsetLs, listClick, panel); + WMSetListDoubleAction(panel->fsetLs, changeButtonClick, panel); + + panel->addB = WMCreateCommandButton(panel->box); + WMResizeWidget(panel->addB, 78, 24); + WMMoveWidget(panel->addB, 265, 201); + WMSetButtonText(panel->addB, _("Add...")); + WMSetButtonAction(panel->addB, addButtonClick, panel); + + panel->editB = WMCreateCommandButton(panel->box); + WMResizeWidget(panel->editB, 78, 24); + WMMoveWidget(panel->editB, 348, 201); + WMSetButtonText(panel->editB, _("Change...")); + WMSetButtonAction(panel->editB, changeButtonClick, panel); + + panel->remB = WMCreateCommandButton(panel->box); + WMResizeWidget(panel->remB, 78, 24); + WMMoveWidget(panel->remB, 431, 201); + WMSetButtonText(panel->remB, _("Remove")); + WMSetButtonAction(panel->remB, removeButtonClick, panel); + + /* happy Up/Down buttons */ + panel->upB = WMCreateCommandButton(panel->box); + WMResizeWidget(panel->upB, 16, 16); + WMMoveWidget(panel->upB, 265, 182); + WMSetButtonImage(panel->upB, panel->up_arrow); + WMSetButtonAltImage(panel->upB, panel->alt_up_arrow); + WMSetButtonImagePosition(panel->upB, WIPImageOnly); + WMSetButtonImageDimsWhenDisabled(panel->upB, True); + WMSetButtonAction(panel->upB, moveUpListItem, panel); + + panel->downB = WMCreateCommandButton(panel->box); + WMResizeWidget(panel->downB, 16, 16); + WMMoveWidget(panel->downB, 286, 182); + WMSetButtonImage(panel->downB, panel->down_arrow); + WMSetButtonAltImage(panel->downB, panel->alt_down_arrow); + WMSetButtonImagePosition(panel->downB, WIPImageOnly); + WMSetButtonImageDimsWhenDisabled(panel->downB, True); + WMSetButtonAction(panel->downB, moveDownListItem, panel); + + /* single byte */ + panel->fontT = WMCreateTextField(panel->box); + WMResizeWidget(panel->fontT, 245, 30); + WMMoveWidget(panel->fontT, 265, 120); + + panel->changeB = WMCreateCommandButton(panel->box); + WMResizeWidget(panel->changeB, 104, 24); + WMMoveWidget(panel->changeB, 335, 160); + WMSetButtonText(panel->changeB, _("Change...")); + WMSetButtonAction(panel->changeB, changeButtonClick, panel); + + + panel->black = WMBlackColor(scr); + panel->white = WMWhiteColor(scr); + panel->light = WMGrayColor(scr); + panel->dark = WMDarkGrayColor(scr); + panel->back = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); + + /* Font Panel !!!!! */ + panel->fontPanel = WMGetFontPanel(scr); + +#if 0 + for (i = 0; Languages[i].language != NULL; i++) { + WMAddPopUpButtonItem(panel->langP, Languages[i].language); + } + + for (i = 0; Options[i].description != NULL; i++) { + WMAddListItem(panel->settingLs, Options[i].description); + } +#endif + WMRealizeWidget(panel->box); + WMMapSubwidgets(panel->box); + + showData(panel); + changePage(panel->fontSel, panel); +} + +static void +storeData(Panel *p) +{ + _Panel *panel = (_Panel*)p; + int i; + + char *encoding = getFontEncoding(panel); + + for(i=0;i < 6; i++) + { + switch(i) { + case 0: + SetStringForKey(fontOfLang(panel, encoding, i), + "WindowTitleFont"); + break; + case 1: + SetStringForKey(fontOfLang(panel, encoding, i), + "LargeDisplayFont"); + break; + case 2: + SetStringForKey(fontOfLang(panel, encoding, i), + "MenuTitleFont"); + break; + case 3: + SetStringForKey(fontOfLang(panel, encoding, i), + "MenuTextFont"); + break; + case 4: + SetStringForKey(fontOfLang(panel, encoding, i), + "ClipTitleFont"); + break; + case 5: + SetStringForKey(fontOfLang(panel, encoding, i), + "IconTitleFont"); + break; + } + } + + //if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box))) + SetBoolForKey(WMGetButtonSelected(panel->togAA), "AntialiasedText"); + + if(panel->MultiByteText) + SetStringForKey("YES", "MultiByteText"); + else { + if(isEncodingMultiByte(panel)) SetStringForKey("YES", "MultiByteText"); + else SetStringForKey("AUTO", "MultiByteText"); + } +} + +static void +prepClosure(Panel *p) +{ + _Panel *panel = (_Panel*)p; + WMFreeFontPanel(panel->fontPanel); + WMReleasePropList(CurrentFontArray); + /* and what ever else i've forgotten or overlooked + * maybe someone will add them */ +} + +Panel* +InitFont(WMScreen *scr, WMWidget *parent) +{ + _Panel *panel; + + panel = wmalloc(sizeof(_Panel)); + memset(panel, 0, sizeof(_Panel)); + + panel->sectionName = _("Font Preferences"); + panel->description = _("Font Configurations for Windows, Menus etc"); + + panel->parent = parent; + + panel->callbacks.createWidgets = createPanel; + panel->callbacks.updateDomain = storeData; + panel->callbacks.prepareForClose = prepClosure; + + AddSection(panel, ICON_FILE); + + return panel; +} + diff --git a/WPrefs.app/Icons.c b/WPrefs.app/Icons.c index c89b857a..954904c1 100644 --- a/WPrefs.app/Icons.c +++ b/WPrefs.app/Icons.c @@ -1,9 +1,9 @@ /* Icons.c- icon preferences - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -32,9 +32,9 @@ typedef struct _Panel { char *description; CallbackRec callbacks; - + WMWidget *parent; - + WMFrame *posF; WMFrame *posVF; WMFrame *posV; @@ -47,7 +47,7 @@ typedef struct _Panel { WMFrame *optF; WMButton *arrB; WMButton *omnB; - + WMFrame *sizeF; WMPopUpButton *sizeP; @@ -65,36 +65,36 @@ showIconLayout(WMWidget *widget, void *data) _Panel *panel = (_Panel*)data; int w, h; int i; - + for (i=0; i<8; i++) { - if (panel->posB[i] == widget) { - panel->iconPos = i; - break; - } + if (panel->posB[i] == widget) { + panel->iconPos = i; + break; + } } if (panel->iconPos & 1) { - w = 32; - h = 8; + w = 32; + h = 8; } else { - w = 8; - h = 32; + w = 8; + h = 32; } WMResizeWidget(panel->posV, w, h); - + switch (panel->iconPos & ~1) { - case 0: - WMMoveWidget(panel->posV, 2, 2); - break; - case 2: - WMMoveWidget(panel->posV, 95-2-w, 2); - break; - case 4: - WMMoveWidget(panel->posV, 2, 70-2-h); - break; - default: - WMMoveWidget(panel->posV, 95-2-w, 70-2-h); - break; + case 0: + WMMoveWidget(panel->posV, 2, 2); + break; + case 2: + WMMoveWidget(panel->posV, 95-2-w, 2); + break; + case 4: + WMMoveWidget(panel->posV, 2, 70-2-h); + break; + default: + WMMoveWidget(panel->posV, 95-2-w, 70-2-h); + break; } } @@ -105,56 +105,56 @@ showData(_Panel *panel) int i; char *str; char *def = "blh"; - + WMSetButtonSelected(panel->arrB, GetBoolForKey("AutoArrangeIcons")); - + WMSetButtonSelected(panel->omnB, GetBoolForKey("StickyIcons")); - + str = GetStringForKey("IconPosition"); if (!str) - str = def; + str = def; if (strlen(str)!=3) { - wwarning("bad value %s for option IconPosition. Using default blh", - str); - str = def; + wwarning("bad value %s for option IconPosition. Using default blh", + str); + str = def; } if (str[0]=='t' || str[0]=='T') { - i = 0; + i = 0; } else { - i = 4; + i = 4; } if (str[1]=='r' || str[1]=='R') { - i += 2; + i += 2; } if (str[2]=='v' || str[2]=='V') { - i += 0; + i += 0; } else { - i += 1; + i += 1; } panel->iconPos = i; WMPerformButtonClick(panel->posB[i]); - + i = GetIntegerForKey("IconSize"); i = (i-24)/8; - + if (i<0) - i = 0; + i = 0; else if (i>9) - i = 9; + i = 9; WMSetPopUpButtonSelectedItem(panel->sizeP, i); - + str = GetStringForKey("IconificationStyle"); if (!str) - str = "zoom"; + str = "zoom"; if (strcasecmp(str, "none")==0) - WMPerformButtonClick(panel->animB[3]); + WMPerformButtonClick(panel->animB[3]); else if (strcasecmp(str, "twist")==0) - WMPerformButtonClick(panel->animB[1]); + WMPerformButtonClick(panel->animB[1]); else if (strcasecmp(str, "flip")==0) - WMPerformButtonClick(panel->animB[2]); + WMPerformButtonClick(panel->animB[2]); else { - WMPerformButtonClick(panel->animB[0]); + WMPerformButtonClick(panel->animB[0]); } } @@ -172,7 +172,7 @@ createPanel(Panel *p) panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - + /***************** Positioning of Icons *****************/ panel->posF = WMCreateFrame(panel->box); WMResizeWidget(panel->posF, 260, 135); @@ -180,11 +180,11 @@ createPanel(Panel *p) WMSetFrameTitle(panel->posF, _("Icon Positioning")); for (i=0; i<8; i++) { - panel->posB[i] = WMCreateButton(panel->posF, WBTOnOff); - WMSetButtonAction(panel->posB[i], showIconLayout, panel); + panel->posB[i] = WMCreateButton(panel->posF, WBTOnOff); + WMSetButtonAction(panel->posB[i], showIconLayout, panel); - if (i>0) - WMGroupButtons(panel->posB[0], panel->posB[i]); + if (i>0) + WMGroupButtons(panel->posB[0], panel->posB[i]); } WMMoveWidget(panel->posB[1], 70, 23); WMResizeWidget(panel->posB[1], 47, 15); @@ -206,8 +206,8 @@ createPanel(Panel *p) WMMoveWidget(panel->posB[6], 70+95, 38+35); WMResizeWidget(panel->posB[6], 15, 35); - color = WMCreateRGBColor(WMWidgetScreen(panel->parent), 0x5100, 0x5100, - 0x7100, True); + color = WMCreateRGBColor(WMWidgetScreen(panel->parent), 0x5100, 0x5100, + 0x7100, True); panel->posVF = WMCreateFrame(panel->posF); WMResizeWidget(panel->posVF, 95, 70); WMMoveWidget(panel->posVF, 70, 38); @@ -217,9 +217,9 @@ createPanel(Panel *p) panel->posV = WMCreateFrame(panel->posVF); WMSetFrameRelief(panel->posV, WRSimple); - + WMMapSubwidgets(panel->posF); - + /***************** Animation ****************/ panel->animF = WMCreateFrame(panel->box); WMResizeWidget(panel->animF, 205, 135); @@ -227,9 +227,9 @@ createPanel(Panel *p) WMSetFrameTitle(panel->animF, _("Iconification Animation")); for (i=0; i<4; i++) { - panel->animB[i] = WMCreateRadioButton(panel->animF); - WMResizeWidget(panel->animB[i], 170, 20); - WMMoveWidget(panel->animB[i], 20, 24+i*25); + panel->animB[i] = WMCreateRadioButton(panel->animF); + WMResizeWidget(panel->animB[i], 170, 20); + WMMoveWidget(panel->animB[i], 20, 24+i*25); } WMGroupButtons(panel->animB[0], panel->animB[1]); WMGroupButtons(panel->animB[0], panel->animB[2]); @@ -246,15 +246,15 @@ createPanel(Panel *p) panel->optF = WMCreateFrame(panel->box); WMResizeWidget(panel->optF, 260, 70); WMMoveWidget(panel->optF, 25, 150); -/* WMSetFrameTitle(panel->optF, _("Icon Display"));*/ - + /* WMSetFrameTitle(panel->optF, _("Icon Display"));*/ + panel->arrB = WMCreateSwitchButton(panel->optF); WMResizeWidget(panel->arrB, 235, 20); WMMoveWidget(panel->arrB, 15, 15); WMSetButtonText(panel->arrB, _("Auto-arrange icons")); WMSetBalloonTextForView(_("Keep icons and miniwindows arranged all the time."), - WMWidgetView(panel->arrB)); + WMWidgetView(panel->arrB)); panel->omnB = WMCreateSwitchButton(panel->optF); WMResizeWidget(panel->omnB, 235, 20); @@ -262,10 +262,10 @@ createPanel(Panel *p) WMSetButtonText(panel->omnB, _("Omnipresent miniwindows")); WMSetBalloonTextForView(_("Make miniwindows be present in all workspaces."), - WMWidgetView(panel->omnB)); + WMWidgetView(panel->omnB)); WMMapSubwidgets(panel->optF); - + /***************** Icon Size ****************/ panel->sizeF = WMCreateFrame(panel->box); WMResizeWidget(panel->sizeF, 205, 70); @@ -273,21 +273,21 @@ createPanel(Panel *p) WMSetFrameTitle(panel->sizeF, _("Icon Size")); WMSetBalloonTextForView(_("The size of the dock/application icon and miniwindows"), - WMWidgetView(panel->sizeF)); + WMWidgetView(panel->sizeF)); panel->sizeP = WMCreatePopUpButton(panel->sizeF); WMResizeWidget(panel->sizeP, 156, 20); WMMoveWidget(panel->sizeP, 25, 30); for (i=24; i<=96; i+=8) { - sprintf(buf, "%ix%i", i, i); - WMAddPopUpButtonItem(panel->sizeP, buf); + sprintf(buf, "%ix%i", i, i); + WMAddPopUpButtonItem(panel->sizeP, buf); } - + WMMapSubwidgets(panel->sizeF); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); - + showData(panel); } @@ -301,35 +301,35 @@ storeData(_Panel *panel) SetBoolForKey(WMGetButtonSelected(panel->omnB), "StickyIcons"); SetIntegerForKey(WMGetPopUpButtonSelectedItem(panel->sizeP)*8+24, - "IconSize"); + "IconSize"); buf[3] = 0; if (panel->iconPos < 4) { - buf[0] = 't'; + buf[0] = 't'; } else { - buf[0] = 'b'; + buf[0] = 'b'; } if (panel->iconPos & 2) { - buf[1] = 'r'; + buf[1] = 'r'; } else { - buf[1] = 'l'; + buf[1] = 'l'; } if (panel->iconPos & 1) { - buf[2] = 'h'; + buf[2] = 'h'; } else { - buf[2] = 'v'; + buf[2] = 'v'; } SetStringForKey(buf, "IconPosition"); if (WMGetButtonSelected(panel->animB[0])) - SetStringForKey("zoom", "IconificationStyle"); + SetStringForKey("zoom", "IconificationStyle"); else if (WMGetButtonSelected(panel->animB[1])) - SetStringForKey("twist", "IconificationStyle"); + SetStringForKey("twist", "IconificationStyle"); else if (WMGetButtonSelected(panel->animB[2])) - SetStringForKey("flip", "IconificationStyle"); - else - SetStringForKey("none", "IconificationStyle"); + SetStringForKey("flip", "IconificationStyle"); + else + SetStringForKey("none", "IconificationStyle"); } @@ -345,7 +345,7 @@ InitIcons(WMScreen *scr, WMWidget *parent) panel->sectionName = _("Icon Preferences"); panel->description = _("Icon/Miniwindow handling options. Icon positioning\n" - "area, sizes of icons, miniaturization animation style."); + "area, sizes of icons, miniaturization animation style."); panel->parent = parent; @@ -356,3 +356,4 @@ InitIcons(WMScreen *scr, WMWidget *parent) return panel; } + diff --git a/WPrefs.app/KeyboardSettings.c b/WPrefs.app/KeyboardSettings.c index 9fe91ddd..5f46ec29 100644 --- a/WPrefs.app/KeyboardSettings.c +++ b/WPrefs.app/KeyboardSettings.c @@ -1,9 +1,9 @@ /* KeyboardSettings.c- keyboard options (equivalent to xset) - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -38,12 +38,12 @@ typedef struct _Panel { WMButton *delaB[4]; WMLabel *dmsL; WMTextField *dmsT; - + WMFrame *rateF; WMButton *rateB[4]; WMLabel *rmsL; WMTextField *rmsT; - + WMTextField *testT; } _Panel; @@ -65,38 +65,38 @@ createPanel(Panel *p) panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - + /**************** Initial Key Repeat ***************/ panel->delaF = WMCreateFrame(panel->box); WMResizeWidget(panel->delaF, 495, 60); WMMoveWidget(panel->delaF, 15, 10); WMSetFrameTitle(panel->delaF, _("Initial Key Repeat")); - + for (i = 0; i < 4; i++) { - panel->delaB[i] = WMCreateButton(panel->delaF, WBTOnOff); - WMResizeWidget(panel->delaB[i], 60, 20); - WMMoveWidget(panel->delaB[i], 70+i*60, 25); - if (i>0) - WMGroupButtons(panel->delaB[0], panel->delaB[i]); - switch (i) { - case 0: - WMSetButtonText(panel->delaB[i], "....a"); - break; - case 1: - WMSetButtonText(panel->delaB[i], "...a"); - break; - case 2: - WMSetButtonText(panel->delaB[i], "..a"); - break; - case 3: - WMSetButtonText(panel->delaB[i], ".a"); - break; - } + panel->delaB[i] = WMCreateButton(panel->delaF, WBTOnOff); + WMResizeWidget(panel->delaB[i], 60, 20); + WMMoveWidget(panel->delaB[i], 70+i*60, 25); + if (i>0) + WMGroupButtons(panel->delaB[0], panel->delaB[i]); + switch (i) { + case 0: + WMSetButtonText(panel->delaB[i], "....a"); + break; + case 1: + WMSetButtonText(panel->delaB[i], "...a"); + break; + case 2: + WMSetButtonText(panel->delaB[i], "..a"); + break; + case 3: + WMSetButtonText(panel->delaB[i], ".a"); + break; + } } panel->dmsT = WMCreateTextField(panel->delaF); WMResizeWidget(panel->dmsT, 50, 20); WMMoveWidget(panel->dmsT, 345, 25); -/* WMSetTextFieldAlignment(panel->dmsT, WARight);*/ + /* WMSetTextFieldAlignment(panel->dmsT, WARight);*/ panel->dmsL = WMCreateLabel(panel->delaF); WMResizeWidget(panel->dmsL, 30, 16); @@ -104,48 +104,48 @@ createPanel(Panel *p) WMSetLabelTextColor(panel->dmsL, color); WMSetLabelFont(panel->dmsL, font); WMSetLabelText(panel->dmsL, "msec"); - + WMMapSubwidgets(panel->delaF); - + /**************** Key Repeat Rate ***************/ panel->rateF = WMCreateFrame(panel->box); WMResizeWidget(panel->rateF, 495, 60); WMMoveWidget(panel->rateF, 15, 95); WMSetFrameTitle(panel->rateF, _("Key Repeat Rate")); - + for (i = 0; i < 4; i++) { - panel->rateB[i] = WMCreateButton(panel->rateF, WBTOnOff); - WMResizeWidget(panel->rateB[i], 60, 20); - WMMoveWidget(panel->rateB[i], 70+i*60, 25); - if (i>0) - WMGroupButtons(panel->rateB[0], panel->rateB[i]); - switch (i) { - case 0: - WMSetButtonText(panel->rateB[i], "a....a"); - break; - case 1: - WMSetButtonText(panel->rateB[i], "a...a"); - break; - case 2: - WMSetButtonText(panel->rateB[i], "a..a"); - break; - case 3: - WMSetButtonText(panel->rateB[i], "a.a"); - break; - } + panel->rateB[i] = WMCreateButton(panel->rateF, WBTOnOff); + WMResizeWidget(panel->rateB[i], 60, 20); + WMMoveWidget(panel->rateB[i], 70+i*60, 25); + if (i>0) + WMGroupButtons(panel->rateB[0], panel->rateB[i]); + switch (i) { + case 0: + WMSetButtonText(panel->rateB[i], "a....a"); + break; + case 1: + WMSetButtonText(panel->rateB[i], "a...a"); + break; + case 2: + WMSetButtonText(panel->rateB[i], "a..a"); + break; + case 3: + WMSetButtonText(panel->rateB[i], "a.a"); + break; + } } panel->rmsT = WMCreateTextField(panel->rateF); WMResizeWidget(panel->rmsT, 50, 20); WMMoveWidget(panel->rmsT, 345, 25); -/* WMSetTextFieldAlignment(panel->rmsT, WARight);*/ - + /* WMSetTextFieldAlignment(panel->rmsT, WARight);*/ + panel->rmsL = WMCreateLabel(panel->rateF); WMResizeWidget(panel->rmsL, 30, 16); WMMoveWidget(panel->rmsL, 400, 30); WMSetLabelTextColor(panel->rmsL, color); WMSetLabelFont(panel->rmsL, font); WMSetLabelText(panel->rmsL, "msec"); - + WMMapSubwidgets(panel->rateF); panel->testT = WMCreateTextField(panel->box); @@ -155,7 +155,7 @@ createPanel(Panel *p) WMReleaseColor(color); WMReleaseFont(font); - + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); } @@ -175,10 +175,11 @@ InitKeyboardSettings(WMScreen *scr, WMWidget *parent) panel->description = _("Not done"); panel->parent = parent; - + panel->callbacks.createWidgets = createPanel; - + AddSection(panel, ICON_FILE); return panel; } + diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c index fadee5da..38d9a4dc 100644 --- a/WPrefs.app/KeyboardShortcuts.c +++ b/WPrefs.app/KeyboardShortcuts.c @@ -1,9 +1,9 @@ /* KeyboardShortcuts.c- keyboard shortcut bindings - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -43,7 +43,7 @@ typedef struct _Panel { WMLabel *actL; WMList *actLs; - + WMFrame *shoF; WMTextField *shoT; WMButton *cleB; @@ -70,61 +70,61 @@ typedef struct _Panel { /* must be in the same order as the corresponding items in actions list */ static char *keyOptions[] = { "RootMenuKey", - "WindowListKey", - "WindowMenuKey", - "HideKey", - "HideOthersKey", - "MiniaturizeKey", - "CloseKey", - "MaximizeKey", - "VMaximizeKey", - "HMaximizeKey", - "RaiseKey", - "LowerKey", - "RaiseLowerKey", - "ShadeKey", - "MoveResizeKey", - "SelectKey", - "FocusNextKey", - "FocusPrevKey", - "NextWorkspaceKey", - "PrevWorkspaceKey", - "NextWorkspaceLayerKey", - "PrevWorkspaceLayerKey", - "Workspace1Key", - "Workspace2Key", - "Workspace3Key", - "Workspace4Key", - "Workspace5Key", - "Workspace6Key", - "Workspace7Key", - "Workspace8Key", - "Workspace9Key", - "Workspace10Key", - "WindowShortcut1Key", - "WindowShortcut2Key", - "WindowShortcut3Key", - "WindowShortcut4Key", - "WindowShortcut5Key", - "WindowShortcut6Key", - "WindowShortcut7Key", - "WindowShortcut8Key", - "WindowShortcut9Key", - "WindowShortcut10Key", - "ScreenSwitchKey", + "WindowListKey", + "WindowMenuKey", + "HideKey", + "HideOthersKey", + "MiniaturizeKey", + "CloseKey", + "MaximizeKey", + "VMaximizeKey", + "HMaximizeKey", + "RaiseKey", + "LowerKey", + "RaiseLowerKey", + "ShadeKey", + "MoveResizeKey", + "SelectKey", + "FocusNextKey", + "FocusPrevKey", + "NextWorkspaceKey", + "PrevWorkspaceKey", + "NextWorkspaceLayerKey", + "PrevWorkspaceLayerKey", + "Workspace1Key", + "Workspace2Key", + "Workspace3Key", + "Workspace4Key", + "Workspace5Key", + "Workspace6Key", + "Workspace7Key", + "Workspace8Key", + "Workspace9Key", + "Workspace10Key", + "WindowShortcut1Key", + "WindowShortcut2Key", + "WindowShortcut3Key", + "WindowShortcut4Key", + "WindowShortcut5Key", + "WindowShortcut6Key", + "WindowShortcut7Key", + "WindowShortcut8Key", + "WindowShortcut9Key", + "WindowShortcut10Key", + "ScreenSwitchKey", #ifdef VIRTUAL_DESKTOP - "VirtualEdgeLeftKey", - "VirtualEdgeRightKey", - "VirtualEdgeUpKey", - "VirtualEdgeDownKey", + "VirtualEdgeLeftKey", + "VirtualEdgeRightKey", + "VirtualEdgeUpKey", + "VirtualEdgeDownKey", #endif - "ClipRaiseKey", - "ClipLowerKey", + "ClipRaiseKey", + "ClipLowerKey", #ifndef XKB_MODELOCK - "ClipRaiseLowerKey" + "ClipRaiseLowerKey" #else - "ClipRaiseLowerKey", - "ToggleKbdModeKey" + "ClipRaiseLowerKey", + "ToggleKbdModeKey" #endif /* XKB_MODELOCK */ }; @@ -134,111 +134,108 @@ static char *keyOptions[] = { /* from Xlib */ static void -XConvertCase(sym, lower, upper) - register KeySym sym; - KeySym *lower; - KeySym *upper; +XConvertCase(register KeySym sym, KeySym *lower, KeySym *upper) { *lower = sym; *upper = sym; switch(sym >> 8) { case 0: /* Latin 1 */ - if ((sym >= XK_A) && (sym <= XK_Z)) - *lower += (XK_a - XK_A); - else if ((sym >= XK_a) && (sym <= XK_z)) - *upper -= (XK_a - XK_A); - else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis)) - *lower += (XK_agrave - XK_Agrave); - else if ((sym >= XK_agrave) && (sym <= XK_odiaeresis)) - *upper -= (XK_agrave - XK_Agrave); - else if ((sym >= XK_Ooblique) && (sym <= XK_Thorn)) - *lower += (XK_oslash - XK_Ooblique); - else if ((sym >= XK_oslash) && (sym <= XK_thorn)) - *upper -= (XK_oslash - XK_Ooblique); - break; + if ((sym >= XK_A) && (sym <= XK_Z)) + *lower += (XK_a - XK_A); + else if ((sym >= XK_a) && (sym <= XK_z)) + *upper -= (XK_a - XK_A); + else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis)) + *lower += (XK_agrave - XK_Agrave); + else if ((sym >= XK_agrave) && (sym <= XK_odiaeresis)) + *upper -= (XK_agrave - XK_Agrave); + else if ((sym >= XK_Ooblique) && (sym <= XK_Thorn)) + *lower += (XK_oslash - XK_Ooblique); + else if ((sym >= XK_oslash) && (sym <= XK_thorn)) + *upper -= (XK_oslash - XK_Ooblique); + break; case 1: /* Latin 2 */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym == XK_Aogonek) - *lower = XK_aogonek; - else if (sym >= XK_Lstroke && sym <= XK_Sacute) - *lower += (XK_lstroke - XK_Lstroke); - else if (sym >= XK_Scaron && sym <= XK_Zacute) - *lower += (XK_scaron - XK_Scaron); - else if (sym >= XK_Zcaron && sym <= XK_Zabovedot) - *lower += (XK_zcaron - XK_Zcaron); - else if (sym == XK_aogonek) - *upper = XK_Aogonek; - else if (sym >= XK_lstroke && sym <= XK_sacute) - *upper -= (XK_lstroke - XK_Lstroke); - else if (sym >= XK_scaron && sym <= XK_zacute) - *upper -= (XK_scaron - XK_Scaron); - else if (sym >= XK_zcaron && sym <= XK_zabovedot) - *upper -= (XK_zcaron - XK_Zcaron); - else if (sym >= XK_Racute && sym <= XK_Tcedilla) - *lower += (XK_racute - XK_Racute); - else if (sym >= XK_racute && sym <= XK_tcedilla) - *upper -= (XK_racute - XK_Racute); - break; + /* Assume the KeySym is a legal value (ignore discontinuities) */ + if (sym == XK_Aogonek) + *lower = XK_aogonek; + else if (sym >= XK_Lstroke && sym <= XK_Sacute) + *lower += (XK_lstroke - XK_Lstroke); + else if (sym >= XK_Scaron && sym <= XK_Zacute) + *lower += (XK_scaron - XK_Scaron); + else if (sym >= XK_Zcaron && sym <= XK_Zabovedot) + *lower += (XK_zcaron - XK_Zcaron); + else if (sym == XK_aogonek) + *upper = XK_Aogonek; + else if (sym >= XK_lstroke && sym <= XK_sacute) + *upper -= (XK_lstroke - XK_Lstroke); + else if (sym >= XK_scaron && sym <= XK_zacute) + *upper -= (XK_scaron - XK_Scaron); + else if (sym >= XK_zcaron && sym <= XK_zabovedot) + *upper -= (XK_zcaron - XK_Zcaron); + else if (sym >= XK_Racute && sym <= XK_Tcedilla) + *lower += (XK_racute - XK_Racute); + else if (sym >= XK_racute && sym <= XK_tcedilla) + *upper -= (XK_racute - XK_Racute); + break; case 2: /* Latin 3 */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= XK_Hstroke && sym <= XK_Hcircumflex) - *lower += (XK_hstroke - XK_Hstroke); - else if (sym >= XK_Gbreve && sym <= XK_Jcircumflex) - *lower += (XK_gbreve - XK_Gbreve); - else if (sym >= XK_hstroke && sym <= XK_hcircumflex) - *upper -= (XK_hstroke - XK_Hstroke); - else if (sym >= XK_gbreve && sym <= XK_jcircumflex) - *upper -= (XK_gbreve - XK_Gbreve); - else if (sym >= XK_Cabovedot && sym <= XK_Scircumflex) - *lower += (XK_cabovedot - XK_Cabovedot); - else if (sym >= XK_cabovedot && sym <= XK_scircumflex) - *upper -= (XK_cabovedot - XK_Cabovedot); - break; + /* Assume the KeySym is a legal value (ignore discontinuities) */ + if (sym >= XK_Hstroke && sym <= XK_Hcircumflex) + *lower += (XK_hstroke - XK_Hstroke); + else if (sym >= XK_Gbreve && sym <= XK_Jcircumflex) + *lower += (XK_gbreve - XK_Gbreve); + else if (sym >= XK_hstroke && sym <= XK_hcircumflex) + *upper -= (XK_hstroke - XK_Hstroke); + else if (sym >= XK_gbreve && sym <= XK_jcircumflex) + *upper -= (XK_gbreve - XK_Gbreve); + else if (sym >= XK_Cabovedot && sym <= XK_Scircumflex) + *lower += (XK_cabovedot - XK_Cabovedot); + else if (sym >= XK_cabovedot && sym <= XK_scircumflex) + *upper -= (XK_cabovedot - XK_Cabovedot); + break; case 3: /* Latin 4 */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= XK_Rcedilla && sym <= XK_Tslash) - *lower += (XK_rcedilla - XK_Rcedilla); - else if (sym >= XK_rcedilla && sym <= XK_tslash) - *upper -= (XK_rcedilla - XK_Rcedilla); - else if (sym == XK_ENG) - *lower = XK_eng; - else if (sym == XK_eng) - *upper = XK_ENG; - else if (sym >= XK_Amacron && sym <= XK_Umacron) - *lower += (XK_amacron - XK_Amacron); - else if (sym >= XK_amacron && sym <= XK_umacron) - *upper -= (XK_amacron - XK_Amacron); - break; + /* Assume the KeySym is a legal value (ignore discontinuities) */ + if (sym >= XK_Rcedilla && sym <= XK_Tslash) + *lower += (XK_rcedilla - XK_Rcedilla); + else if (sym >= XK_rcedilla && sym <= XK_tslash) + *upper -= (XK_rcedilla - XK_Rcedilla); + else if (sym == XK_ENG) + *lower = XK_eng; + else if (sym == XK_eng) + *upper = XK_ENG; + else if (sym >= XK_Amacron && sym <= XK_Umacron) + *lower += (XK_amacron - XK_Amacron); + else if (sym >= XK_amacron && sym <= XK_umacron) + *upper -= (XK_amacron - XK_Amacron); + break; case 6: /* Cyrillic */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= XK_Serbian_DJE && sym <= XK_Serbian_DZE) - *lower -= (XK_Serbian_DJE - XK_Serbian_dje); - else if (sym >= XK_Serbian_dje && sym <= XK_Serbian_dze) - *upper += (XK_Serbian_DJE - XK_Serbian_dje); - else if (sym >= XK_Cyrillic_YU && sym <= XK_Cyrillic_HARDSIGN) - *lower -= (XK_Cyrillic_YU - XK_Cyrillic_yu); - else if (sym >= XK_Cyrillic_yu && sym <= XK_Cyrillic_hardsign) - *upper += (XK_Cyrillic_YU - XK_Cyrillic_yu); + /* Assume the KeySym is a legal value (ignore discontinuities) */ + if (sym >= XK_Serbian_DJE && sym <= XK_Serbian_DZE) + *lower -= (XK_Serbian_DJE - XK_Serbian_dje); + else if (sym >= XK_Serbian_dje && sym <= XK_Serbian_dze) + *upper += (XK_Serbian_DJE - XK_Serbian_dje); + else if (sym >= XK_Cyrillic_YU && sym <= XK_Cyrillic_HARDSIGN) + *lower -= (XK_Cyrillic_YU - XK_Cyrillic_yu); + else if (sym >= XK_Cyrillic_yu && sym <= XK_Cyrillic_hardsign) + *upper += (XK_Cyrillic_YU - XK_Cyrillic_yu); break; case 7: /* Greek */ - /* Assume the KeySym is a legal value (ignore discontinuities) */ - if (sym >= XK_Greek_ALPHAaccent && sym <= XK_Greek_OMEGAaccent) - *lower += (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent); - else if (sym >= XK_Greek_alphaaccent && sym <= XK_Greek_omegaaccent && - sym != XK_Greek_iotaaccentdieresis && - sym != XK_Greek_upsilonaccentdieresis) - *upper -= (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent); - else if (sym >= XK_Greek_ALPHA && sym <= XK_Greek_OMEGA) - *lower += (XK_Greek_alpha - XK_Greek_ALPHA); - else if (sym >= XK_Greek_alpha && sym <= XK_Greek_omega && - sym != XK_Greek_finalsmallsigma) - *upper -= (XK_Greek_alpha - XK_Greek_ALPHA); + /* Assume the KeySym is a legal value (ignore discontinuities) */ + if (sym >= XK_Greek_ALPHAaccent && sym <= XK_Greek_OMEGAaccent) + *lower += (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent); + else if (sym >= XK_Greek_alphaaccent && sym <= XK_Greek_omegaaccent && + sym != XK_Greek_iotaaccentdieresis && + sym != XK_Greek_upsilonaccentdieresis) + *upper -= (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent); + else if (sym >= XK_Greek_ALPHA && sym <= XK_Greek_OMEGA) + *lower += (XK_Greek_alpha - XK_Greek_ALPHA); + else if (sym >= XK_Greek_alpha && sym <= XK_Greek_omega && + sym != XK_Greek_finalsmallsigma) + *upper -= (XK_Greek_alpha - XK_Greek_ALPHA); break; case 0x14: /* Armenian */ - if (sym >= XK_Armenian_AYB && sym <= XK_Armenian_fe) { - *lower = sym | 1; - *upper = sym & ~1; - } + if (sym >= XK_Armenian_AYB && sym <= XK_Armenian_fe) { + *lower = sym | 1; + *upper = sym & ~1; + } break; } } @@ -254,49 +251,49 @@ captureShortcut(Display *dpy, _Panel *panel) char *key = NULL; while (panel->capturing) { - XAllowEvents(dpy, AsyncKeyboard, CurrentTime); - WMNextEvent(dpy, &ev); - if (ev.type==KeyPress && ev.xkey.keycode!=0) { - ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0); + XAllowEvents(dpy, AsyncKeyboard, CurrentTime); + WMNextEvent(dpy, &ev); + if (ev.type==KeyPress && ev.xkey.keycode!=0) { + ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0); if (!IsModifierKey(ksym)) { XConvertCase(ksym, &lksym, &uksym); - key=XKeysymToString(uksym); - + key=XKeysymToString(uksym); + panel->capturing = 0; - break; - } - } - WMHandleEvent(&ev); + break; + } + } + WMHandleEvent(&ev); } - + if (!key) - return NULL; - + return NULL; + buffer[0] = 0; - + if (ev.xkey.state & ControlMask) { - strcat(buffer, "Control+"); - } + strcat(buffer, "Control+"); + } if (ev.xkey.state & ShiftMask) { - strcat(buffer, "Shift+"); - } + strcat(buffer, "Shift+"); + } if (ev.xkey.state & Mod1Mask) { - strcat(buffer, "Mod1+"); - } + strcat(buffer, "Mod1+"); + } if (ev.xkey.state & Mod2Mask) { - strcat(buffer, "Mod2+"); - } + strcat(buffer, "Mod2+"); + } if (ev.xkey.state & Mod3Mask) { - strcat(buffer, "Mod3+"); - } + strcat(buffer, "Mod3+"); + } if (ev.xkey.state & Mod4Mask) { - strcat(buffer, "Mod4+"); - } + strcat(buffer, "Mod4+"); + } if (ev.xkey.state & Mod5Mask) { - strcat(buffer, "Mod5+"); + strcat(buffer, "Mod5+"); } strcat(buffer, key); - + return wstrdup(buffer); } @@ -307,28 +304,28 @@ captureClick(WMWidget *w, void *data) _Panel *panel = (_Panel*)data; Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->parent)); char *shortcut; - + if (!panel->capturing) { - panel->capturing = 1; - WMSetButtonText(w, _("Cancel")); - WMSetLabelText(panel->instructionsL, _("Press the desired shortcut key(s) or click Cancel to stop capturing.")); - XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, - GrabModeAsync, CurrentTime); - shortcut = captureShortcut(dpy, panel); - if (shortcut) { - int row = WMGetListSelectedItemRow(panel->actLs); - - WMSetTextFieldText(panel->shoT, shortcut); - if (row>=0) { - if (panel->shortcuts[row]) - wfree(panel->shortcuts[row]); - panel->shortcuts[row] = shortcut; - - WMRedisplayWidget(panel->actLs); - } else { - wfree(shortcut); - } - } + panel->capturing = 1; + WMSetButtonText(w, _("Cancel")); + WMSetLabelText(panel->instructionsL, _("Press the desired shortcut key(s) or click Cancel to stop capturing.")); + XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, + GrabModeAsync, CurrentTime); + shortcut = captureShortcut(dpy, panel); + if (shortcut) { + int row = WMGetListSelectedItemRow(panel->actLs); + + WMSetTextFieldText(panel->shoT, shortcut); + if (row>=0) { + if (panel->shortcuts[row]) + wfree(panel->shortcuts[row]); + panel->shortcuts[row] = shortcut; + + WMRedisplayWidget(panel->actLs); + } else { + wfree(shortcut); + } + } } panel->capturing = 0; WMSetButtonText(w, _("Capture")); @@ -347,10 +344,10 @@ clearShortcut(WMWidget *w, void *data) WMSetTextFieldText(panel->shoT, NULL); if (row>=0) { - if (panel->shortcuts[row]) - wfree(panel->shortcuts[row]); - panel->shortcuts[row]=NULL; - WMRedisplayWidget(panel->actLs); + if (panel->shortcuts[row]) + wfree(panel->shortcuts[row]); + panel->shortcuts[row]=NULL; + WMRedisplayWidget(panel->actLs); } } @@ -359,18 +356,18 @@ clearShortcut(WMWidget *w, void *data) static void typedKeys(void *observerData, WMNotification *notification) { - _Panel *panel = (_Panel*)observerData; + _Panel *panel = (_Panel*)observerData; int row = WMGetListSelectedItemRow(panel->actLs); if (row<0) - return; + return; if (panel->shortcuts[row]) - wfree(panel->shortcuts[row]); + wfree(panel->shortcuts[row]); panel->shortcuts[row] = WMGetTextFieldText(panel->shoT); if (strlen(panel->shortcuts[row])==0) { - wfree(panel->shortcuts[row]); - panel->shortcuts[row] = NULL; + wfree(panel->shortcuts[row]); + panel->shortcuts[row] = NULL; } WMRedisplayWidget(panel->actLs); } @@ -382,7 +379,7 @@ listClick(WMWidget *w, void *data) { _Panel *panel = (_Panel*)data; int row = WMGetListSelectedItemRow(w); - + WMSetTextFieldText(panel->shoT, panel->shortcuts[row]); } @@ -392,13 +389,13 @@ trimstr(char *str) { char *p = str; int i; - + while (isspace(*p)) p++; p = wstrdup(p); i = strlen(p); while (isspace(p[i]) && i>0) { - p[i]=0; - i--; + p[i]=0; + i--; } return p; @@ -413,20 +410,20 @@ showData(_Panel *panel) for (i=0; iactionCount; i++) { - str = GetStringForKey(keyOptions[i]); - if (panel->shortcuts[i]) - wfree(panel->shortcuts[i]); - if (str) - panel->shortcuts[i] = trimstr(str); - else - panel->shortcuts[i] = NULL; - - if (panel->shortcuts[i] && - (strcasecmp(panel->shortcuts[i], "none")==0 - || strlen(panel->shortcuts[i])==0)) { - wfree(panel->shortcuts[i]); - panel->shortcuts[i] = NULL; - } + str = GetStringForKey(keyOptions[i]); + if (panel->shortcuts[i]) + wfree(panel->shortcuts[i]); + if (str) + panel->shortcuts[i] = trimstr(str); + else + panel->shortcuts[i] = NULL; + + if (panel->shortcuts[i] && + (strcasecmp(panel->shortcuts[i], "none")==0 + || strlen(panel->shortcuts[i])==0)) { + wfree(panel->shortcuts[i]); + panel->shortcuts[i] = NULL; + } } WMRedisplayWidget(panel->actLs); } @@ -434,7 +431,7 @@ showData(_Panel *panel) static void paintItem(WMList *lPtr, int index, Drawable d, char *text, int state, - WMRect *rect) + WMRect *rect) { int width, height, x, y; _Panel *panel = (_Panel*)WMGetHangedData(lPtr); @@ -450,11 +447,11 @@ paintItem(WMList *lPtr, int index, Drawable d, char *text, int state, XFillRectangle(dpy, d, WMColorGC(backColor), x, y, width, height); if (panel->shortcuts[index]) { - WMPixmap *pix = WMGetSystemPixmap(scr, WSICheckMark); - WMSize size = WMGetPixmapSize(pix); - - WMDrawPixmap(pix, d, x+(20-size.width)/2, (height-size.height)/2+y); - WMReleasePixmap(pix); + WMPixmap *pix = WMGetSystemPixmap(scr, WSICheckMark); + WMSize size = WMGetPixmapSize(pix); + + WMDrawPixmap(pix, d, x+(20-size.width)/2, (height-size.height)/2+y); + WMReleasePixmap(pix); } WMDrawString(scr, d, panel->black, panel->font, x+20, y, text, strlen(text)); @@ -463,7 +460,7 @@ paintItem(WMList *lPtr, int index, Drawable d, char *text, int state, static void createPanel(Panel *p) -{ +{ _Panel *panel = (_Panel*)p; WMScreen *scr = WMWidgetScreen(panel->parent); WMColor *color; @@ -490,16 +487,16 @@ createPanel(Panel *p) WMSetLabelRelief(panel->actL, WRSunken); WMSetLabelTextAlignment(panel->actL, WACenter); color = WMDarkGrayColor(scr); - WMSetWidgetBackgroundColor(panel->actL, color); + WMSetWidgetBackgroundColor(panel->actL, color); WMReleaseColor(color); WMSetLabelTextColor(panel->actL, panel->white); - + panel->actLs = WMCreateList(panel->box); WMResizeWidget(panel->actLs, 280, 190); WMMoveWidget(panel->actLs, 20, 32); WMSetListUserDrawProc(panel->actLs, paintItem); WMHangData(panel->actLs, panel); - + WMAddListItem(panel->actLs, _("Open applications menu")); WMAddListItem(panel->actLs, _("Open window list menu")); WMAddListItem(panel->actLs, _("Open window commands menu")); @@ -568,13 +565,13 @@ createPanel(Panel *p) WMResizeWidget(panel->shoF, 190, 210); WMMoveWidget(panel->shoF, 315, 10); WMSetFrameTitle(panel->shoF, _("Shortcut")); - + panel->shoT = WMCreateTextField(panel->shoF); WMResizeWidget(panel->shoT, 160, 20); WMMoveWidget(panel->shoT, 15, 65); WMAddNotificationObserver(typedKeys, panel, - WMTextDidChangeNotification, panel->shoT); - + WMTextDidChangeNotification, panel->shoT); + panel->cleB = WMCreateCommandButton(panel->shoF); WMResizeWidget(panel->cleB, 75, 24); WMMoveWidget(panel->cleB, 15, 95); @@ -586,7 +583,7 @@ createPanel(Panel *p) WMMoveWidget(panel->defB, 100, 95); WMSetButtonText(panel->defB, _("Capture")); WMSetButtonAction(panel->defB, captureClick, panel); - + panel->instructionsL = WMCreateLabel(panel->shoF); WMResizeWidget(panel->instructionsL, 160, 55); WMMoveWidget(panel->instructionsL, 15, 140); @@ -595,13 +592,13 @@ createPanel(Panel *p) WMSetLabelText(panel->instructionsL, _("Click on Capture to interactively define the shortcut key.")); WMMapSubwidgets(panel->shoF); - + WMReleaseFont(boldFont); - + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); - - + + showData(panel); } @@ -611,22 +608,22 @@ storeData(_Panel *panel) { int i; char *str; - + for (i=0; iactionCount; i++) { - str = NULL; - if (panel->shortcuts[i]) { - str = trimstr(panel->shortcuts[i]); - if (strlen(str)==0) { - wfree(str); - str = NULL; - } - } - if (str) { - SetStringForKey(str, keyOptions[i]); - wfree(str); - } else { - SetStringForKey("None", keyOptions[i]); - } + str = NULL; + if (panel->shortcuts[i]) { + str = trimstr(panel->shortcuts[i]); + if (strlen(str)==0) { + wfree(str); + str = NULL; + } + } + if (str) { + SetStringForKey(str, keyOptions[i]); + wfree(str); + } else { + SetStringForKey("None", keyOptions[i]); + } } } @@ -654,3 +651,4 @@ InitKeyboardShortcuts(WMScreen *scr, WMWidget *parent) return panel; } + diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c index c6450cef..1d067ea4 100644 --- a/WPrefs.app/Menu.c +++ b/WPrefs.app/Menu.c @@ -1,9 +1,9 @@ /* Menu.c- menu definition - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 2000-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -55,7 +55,7 @@ typedef struct _Panel { CallbackRec callbacks; WMWidget *parent; - + WMFont *boldFont; WMFont *normalFont; WMColor *white; @@ -65,7 +65,7 @@ typedef struct _Panel { WMPixmap *markerPix[LastInfo]; WMPopUpButton *typeP; - + WMWidget *itemPad[3]; int currentPad; @@ -103,15 +103,15 @@ typedef struct _Panel { WMFrame *paramF; WMTextField *paramT; - + WMButton *quickB; - + Bool dontAsk; /* whether to comfirm submenu remove */ Bool dontSave; - + Bool capturing; - + /* about the currently selected item */ WEditMenuItem *currentItem; InfoType currentType; @@ -122,27 +122,27 @@ typedef struct _Panel { typedef struct { InfoType type; union { - struct { - int command; - char *parameter; - char *shortcut; - } command; - struct { - char *command; - char *shortcut; - } exec; - struct { - char *path; - } external; - struct { - char *command; - unsigned cached:1; - } pipe; - struct { - char *directory; - char *command; - unsigned stripExt:1; - } directory; + struct { + int command; + char *parameter; + char *shortcut; + } command; + struct { + char *command; + char *shortcut; + } exec; + struct { + char *path; + } external; + struct { + char *command; + unsigned cached:1; + } pipe; + struct { + char *directory; + char *command; + unsigned stripExt:1; + } directory; } param; } ItemData; @@ -150,17 +150,17 @@ typedef struct { static char *commandNames[] = { "ARRANGE_ICONS", - "HIDE_OTHERS", - "SHOW_ALL", - "EXIT", - "SHUTDOWN", - "RESTART", - "RESTART", - "SAVE_SESSION", - "CLEAR_SESSION", - "REFRESH", - "INFO_PANEL", - "LEGAL_PANEL" + "HIDE_OTHERS", + "SHOW_ALL", + "EXIT", + "SHUTDOWN", + "RESTART", + "RESTART", + "SAVE_SESSION", + "CLEAR_SESSION", + "REFRESH", + "INFO_PANEL", + "LEGAL_PANEL" }; @@ -175,23 +175,23 @@ static char *commandNames[] = { static void showData(_Panel *panel); -static void updateMenuItem(_Panel *panel, WEditMenuItem *item, - WMWidget *changedWidget); +static void updateMenuItem(_Panel *panel, WEditMenuItem *item, + WMWidget *changedWidget); -static void menuItemSelected(struct WEditMenuDelegate *delegate, - WEditMenu *menu, WEditMenuItem *item); +static void menuItemSelected(struct WEditMenuDelegate *delegate, + WEditMenu *menu, WEditMenuItem *item); static void menuItemDeselected(struct WEditMenuDelegate *delegate, - WEditMenu *menu, WEditMenuItem *item); + WEditMenu *menu, WEditMenuItem *item); static void menuItemCloned(struct WEditMenuDelegate *delegate, WEditMenu *menu, - WEditMenuItem *origItem, WEditMenuItem *newItem); + WEditMenuItem *origItem, WEditMenuItem *newItem); static void menuItemEdited(struct WEditMenuDelegate *delegate, WEditMenu *menu, - WEditMenuItem *item); + WEditMenuItem *item); -static Bool shouldRemoveItem(struct WEditMenuDelegate *delegate, - WEditMenu *menu, WEditMenuItem *item); +static Bool shouldRemoveItem(struct WEditMenuDelegate *delegate, + WEditMenu *menu, WEditMenuItem *item); static void freeItemData(ItemData *data); @@ -200,11 +200,11 @@ static void freeItemData(ItemData *data); static WEditMenuDelegate menuDelegate = { NULL, - menuItemCloned, - menuItemEdited, - menuItemSelected, - menuItemDeselected, - shouldRemoveItem + menuItemCloned, + menuItemEdited, + menuItemSelected, + menuItemDeselected, + shouldRemoveItem }; @@ -214,7 +214,7 @@ dataChanged(void *self, WMNotification *notif) _Panel *panel = (_Panel*)self; WEditMenuItem *item = panel->currentItem; WMWidget *w = (WMWidget*)WMGetNotificationObject(notif); - + updateMenuItem(panel, item, w); } @@ -224,7 +224,7 @@ buttonClicked(WMWidget *w, void *data) { _Panel *panel = (_Panel*)data; WEditMenuItem *item = panel->currentItem; - + updateMenuItem(panel, item, w); } @@ -237,14 +237,14 @@ icommandLClicked(WMWidget *w, void *data) cmd = WMGetListSelectedItemRow(w); if (cmd == 3 || cmd == 4) { - WMMapWidget(panel->quickB); + WMMapWidget(panel->quickB); } else { - WMUnmapWidget(panel->quickB); + WMUnmapWidget(panel->quickB); } if (cmd == 6) { - WMMapWidget(panel->paramF); + WMMapWidget(panel->paramF); } else { - WMUnmapWidget(panel->paramF); + WMUnmapWidget(panel->paramF); } } @@ -295,47 +295,47 @@ captureShortcut(Display *dpy, _Panel *panel) char *key = NULL; while (panel->capturing) { - XAllowEvents(dpy, AsyncKeyboard, CurrentTime); - WMNextEvent(dpy, &ev); - if (ev.type==KeyPress && ev.xkey.keycode!=0) { - ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0); - if (!IsModifierKey(ksym)) { - key=XKeysymToString(ksym); - panel->capturing = 0; - break; - } - } - WMHandleEvent(&ev); + XAllowEvents(dpy, AsyncKeyboard, CurrentTime); + WMNextEvent(dpy, &ev); + if (ev.type==KeyPress && ev.xkey.keycode!=0) { + ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0); + if (!IsModifierKey(ksym)) { + key=XKeysymToString(ksym); + panel->capturing = 0; + break; + } + } + WMHandleEvent(&ev); } - + if (!key) - return NULL; - + return NULL; + buffer[0] = 0; - + if (ev.xkey.state & ControlMask) { - strcat(buffer, "Control+"); - } + strcat(buffer, "Control+"); + } if (ev.xkey.state & ShiftMask) { - strcat(buffer, "Shift+"); - } + strcat(buffer, "Shift+"); + } if (ev.xkey.state & Mod1Mask) { - strcat(buffer, "Mod1+"); - } + strcat(buffer, "Mod1+"); + } if (ev.xkey.state & Mod2Mask) { - strcat(buffer, "Mod2+"); - } + strcat(buffer, "Mod2+"); + } if (ev.xkey.state & Mod3Mask) { - strcat(buffer, "Mod3+"); - } + strcat(buffer, "Mod3+"); + } if (ev.xkey.state & Mod4Mask) { - strcat(buffer, "Mod4+"); - } + strcat(buffer, "Mod4+"); + } if (ev.xkey.state & Mod5Mask) { - strcat(buffer, "Mod5+"); + strcat(buffer, "Mod5+"); } strcat(buffer, key); - + return wstrdup(buffer); } @@ -348,24 +348,24 @@ sgrabClicked(WMWidget *w, void *data) Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->parent)); char *shortcut; - + if (w == panel->sclearB) { - WMSetTextFieldText(panel->shortT, ""); - updateMenuItem(panel, panel->currentItem, panel->shortT); - return; + WMSetTextFieldText(panel->shortT, ""); + updateMenuItem(panel, panel->currentItem, panel->shortT); + return; } - + if (!panel->capturing) { - panel->capturing = 1; - WMSetButtonText(w, _("Cancel")); - XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, - GrabModeAsync, CurrentTime); - shortcut = captureShortcut(dpy, panel); - if (shortcut) { - WMSetTextFieldText(panel->shortT, shortcut); - updateMenuItem(panel, panel->currentItem, panel->shortT); - wfree(shortcut); - } + panel->capturing = 1; + WMSetButtonText(w, _("Cancel")); + XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, + GrabModeAsync, CurrentTime); + shortcut = captureShortcut(dpy, panel); + if (shortcut) { + WMSetTextFieldText(panel->shortT, shortcut); + updateMenuItem(panel, panel->currentItem, panel->shortT); + wfree(shortcut); + } } panel->capturing = 0; WMSetButtonText(w, _("Capture")); @@ -378,10 +378,10 @@ changedItemPad(WMWidget *w, void *data) { _Panel *panel = (_Panel*)data; int padn = WMGetPopUpButtonSelectedItem(w); - + WMUnmapWidget(panel->itemPad[panel->currentPad]); WMMapWidget(panel->itemPad[padn]); - + panel->currentPad = padn; } @@ -413,9 +413,9 @@ putNewItem(_Panel *panel, WEditMenu *menu, int type, char *title) data = NEW(ItemData); data->type = type; - WSetEditMenuItemData(item, data, (WMCallback*)freeItemData); + WSetEditMenuItemData(item, data, (WMCallback*)freeItemData); WSetEditMenuItemImage(item, panel->markerPix[type]); - + return data; } @@ -424,7 +424,7 @@ static WEditMenu* makeFactoryMenu(WMWidget *parent, int width) { WEditMenu *pad; - + pad = WCreateEditMenuPad(parent); WMResizeWidget(pad, width, 10); WSetEditMenuMinSize(pad, wmksize(width, 0)); @@ -433,7 +433,7 @@ makeFactoryMenu(WMWidget *parent, int width) WSetEditMenuEditable(pad, False); WSetEditMenuIsFactory(pad, True); WSetEditMenuDelegate(pad, &menuDelegate); - + return pad; } @@ -454,7 +454,7 @@ createPanel(_Panel *p) menuDelegate.data = panel; - + panel->boldFont = bold; panel->normalFont = font; @@ -463,41 +463,41 @@ createPanel(_Panel *p) panel->gray = gray; { - Pixmap pix; - Display *dpy = WMScreenDisplay(scr); - GC gc; - WMPixmap *pixm; + Pixmap pix; + Display *dpy = WMScreenDisplay(scr); + GC gc; + WMPixmap *pixm; - pixm = WMCreatePixmap(scr, 7, 7, WMScreenDepth(scr), True); + pixm = WMCreatePixmap(scr, 7, 7, WMScreenDepth(scr), True); - pix = WMGetPixmapXID(pixm); + pix = WMGetPixmapXID(pixm); - XDrawLine(dpy, pix, WMColorGC(black), 0, 3, 6, 3); - XDrawLine(dpy, pix, WMColorGC(black), 3, 0, 3, 6); - /* - XDrawLine(dpy, pix, WMColorGC(black), 1, 0, 3, 3); - XDrawLine(dpy, pix, WMColorGC(black), 1, 6, 3, 3); - XDrawLine(dpy, pix, WMColorGC(black), 0, 0, 0, 6); - */ + XDrawLine(dpy, pix, WMColorGC(black), 0, 3, 6, 3); + XDrawLine(dpy, pix, WMColorGC(black), 3, 0, 3, 6); + /* + XDrawLine(dpy, pix, WMColorGC(black), 1, 0, 3, 3); + XDrawLine(dpy, pix, WMColorGC(black), 1, 6, 3, 3); + XDrawLine(dpy, pix, WMColorGC(black), 0, 0, 0, 6); + */ - pix = WMGetPixmapMaskXID(pixm); + pix = WMGetPixmapMaskXID(pixm); - gc = XCreateGC(dpy, pix, 0, NULL); + gc = XCreateGC(dpy, pix, 0, NULL); - XSetForeground(dpy, gc, 0); - XFillRectangle(dpy, pix, gc, 0, 0, 7, 7); + XSetForeground(dpy, gc, 0); + XFillRectangle(dpy, pix, gc, 0, 0, 7, 7); - XSetForeground(dpy, gc, 1); - XDrawLine(dpy, pix, gc, 0, 3, 6, 3); - XDrawLine(dpy, pix, gc, 3, 0, 3, 6); + XSetForeground(dpy, gc, 1); + XDrawLine(dpy, pix, gc, 0, 3, 6, 3); + XDrawLine(dpy, pix, gc, 3, 0, 3, 6); - panel->markerPix[ExternalInfo] = pixm; - panel->markerPix[PipeInfo] = pixm; - panel->markerPix[DirectoryInfo] = pixm; - panel->markerPix[WSMenuInfo] = pixm; - panel->markerPix[WWindowListInfo] = pixm; + panel->markerPix[ExternalInfo] = pixm; + panel->markerPix[PipeInfo] = pixm; + panel->markerPix[DirectoryInfo] = pixm; + panel->markerPix[WSMenuInfo] = pixm; + panel->markerPix[WWindowListInfo] = pixm; - XFreeGC(dpy, gc); + XFreeGC(dpy, gc); } panel->box = WMCreateBox(panel->parent); @@ -510,154 +510,154 @@ createPanel(_Panel *p) WMAddPopUpButtonItem(panel->typeP, _("New Items")); WMAddPopUpButtonItem(panel->typeP, _("Sample Commands")); WMAddPopUpButtonItem(panel->typeP, _("Sample Submenus")); - + WMSetPopUpButtonAction(panel->typeP, changedItemPad, panel); WMSetPopUpButtonSelectedItem(panel->typeP, 0); { - WEditMenu *pad; - WEditMenu *smenu; - ItemData *data; - - pad = makeFactoryMenu(panel->box, 150); - WMMoveWidget(pad, 10, 40); - - data = putNewItem(panel, pad, ExecInfo, _("Run Program")); - data = putNewItem(panel, pad, CommandInfo, _("Internal Command")); - smenu = putNewSubmenu(pad, _("Submenu")); - data = putNewItem(panel, pad, ExternalInfo, _("External Submenu")); - data = putNewItem(panel, pad, PipeInfo, _("Generated Submenu")); - data = putNewItem(panel, pad, DirectoryInfo, _("Directory Contents")); - data = putNewItem(panel, pad, WSMenuInfo, _("Workspace Menu")); - data = putNewItem(panel, pad, WWindowListInfo, _("Window List Menu")); - - panel->itemPad[0] = pad; + WEditMenu *pad; + WEditMenu *smenu; + ItemData *data; + + pad = makeFactoryMenu(panel->box, 150); + WMMoveWidget(pad, 10, 40); + + data = putNewItem(panel, pad, ExecInfo, _("Run Program")); + data = putNewItem(panel, pad, CommandInfo, _("Internal Command")); + smenu = putNewSubmenu(pad, _("Submenu")); + data = putNewItem(panel, pad, ExternalInfo, _("External Submenu")); + data = putNewItem(panel, pad, PipeInfo, _("Generated Submenu")); + data = putNewItem(panel, pad, DirectoryInfo, _("Directory Contents")); + data = putNewItem(panel, pad, WSMenuInfo, _("Workspace Menu")); + data = putNewItem(panel, pad, WWindowListInfo, _("Window List Menu")); + + panel->itemPad[0] = pad; } { - WEditMenu *pad; - ItemData *data; - WMScrollView *sview; + WEditMenu *pad; + ItemData *data; + WMScrollView *sview; + + sview = WMCreateScrollView(panel->box); + WMResizeWidget(sview, 150, 180); + WMMoveWidget(sview, 10, 40); + WMSetScrollViewHasVerticalScroller(sview, True); - sview = WMCreateScrollView(panel->box); - WMResizeWidget(sview, 150, 180); - WMMoveWidget(sview, 10, 40); - WMSetScrollViewHasVerticalScroller(sview, True); + pad = makeFactoryMenu(panel->box, 130); - pad = makeFactoryMenu(panel->box, 130); + WMSetScrollViewContentView(sview, WMWidgetView(pad)); - WMSetScrollViewContentView(sview, WMWidgetView(pad)); + data = putNewItem(panel, pad, ExecInfo, _("XTerm")); + data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; - data = putNewItem(panel, pad, ExecInfo, _("XTerm")); - data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; + data = putNewItem(panel, pad, ExecInfo, _("rxvt")); + data->param.exec.command = "rxvt"; - data = putNewItem(panel, pad, ExecInfo, _("rxvt")); - data->param.exec.command = "rxvt"; + data = putNewItem(panel, pad, ExecInfo, _("ETerm")); + data->param.exec.command = "eterm"; - data = putNewItem(panel, pad, ExecInfo, _("ETerm")); - data->param.exec.command = "eterm"; + data = putNewItem(panel, pad, ExecInfo, _("Run...")); + data->param.exec.command = _("%a(Run,Type command to run)"); - data = putNewItem(panel, pad, ExecInfo, _("Run...")); - data->param.exec.command = _("%a(Run,Type command to run)"); + data = putNewItem(panel, pad, ExecInfo, _("Netscape")); + data->param.exec.command = "netscape"; - data = putNewItem(panel, pad, ExecInfo, _("Netscape")); - data->param.exec.command = "netscape"; + data = putNewItem(panel, pad, ExecInfo, _("gimp")); + data->param.exec.command = "gimp"; - data = putNewItem(panel, pad, ExecInfo, _("gimp")); - data->param.exec.command = "gimp"; + data = putNewItem(panel, pad, ExecInfo, _("epic")); + data->param.exec.command = "xterm -e epic"; - data = putNewItem(panel, pad, ExecInfo, _("epic")); - data->param.exec.command = "xterm -e epic"; + data = putNewItem(panel, pad, ExecInfo, _("ee")); + data->param.exec.command = "ee"; - data = putNewItem(panel, pad, ExecInfo, _("ee")); - data->param.exec.command = "ee"; + data = putNewItem(panel, pad, ExecInfo, _("xv")); + data->param.exec.command = "xv"; - data = putNewItem(panel, pad, ExecInfo, _("xv")); - data->param.exec.command = "xv"; + data = putNewItem(panel, pad, ExecInfo, _("Acrobat Reader")); + data->param.exec.command = "acroread || /usr/local/Acrobat4/bin/acroread"; - data = putNewItem(panel, pad, ExecInfo, _("Acrobat Reader")); - data->param.exec.command = "acroread || /usr/local/Acrobat4/bin/acroread"; + data = putNewItem(panel, pad, ExecInfo, _("ghostview")); + data->param.exec.command = "gv"; - data = putNewItem(panel, pad, ExecInfo, _("ghostview")); - data->param.exec.command = "gv"; + data = putNewItem(panel, pad, CommandInfo, _("Exit Window Maker")); + data->param.command.command = 3; - data = putNewItem(panel, pad, CommandInfo, _("Exit Window Maker")); - data->param.command.command = 3; + WMMapWidget(pad); - WMMapWidget(pad); - - panel->itemPad[1] = sview; + panel->itemPad[1] = sview; } - + { - WEditMenu *pad, *smenu; - ItemData *data; - WMScrollView *sview; + WEditMenu *pad, *smenu; + ItemData *data; + WMScrollView *sview; + + sview = WMCreateScrollView(panel->box); + WMResizeWidget(sview, 150, 180); + WMMoveWidget(sview, 10, 40); + WMSetScrollViewHasVerticalScroller(sview, True); + + pad = makeFactoryMenu(panel->box, 130); - sview = WMCreateScrollView(panel->box); - WMResizeWidget(sview, 150, 180); - WMMoveWidget(sview, 10, 40); - WMSetScrollViewHasVerticalScroller(sview, True); + WMSetScrollViewContentView(sview, WMWidgetView(pad)); - pad = makeFactoryMenu(panel->box, 130); + data = putNewItem(panel, pad, ExternalInfo, _("Debian Menu")); + data->param.pipe.command = "/etc/X11/WindowMaker/menu.hook"; - WMSetScrollViewContentView(sview, WMWidgetView(pad)); + data = putNewItem(panel, pad, PipeInfo, _("RedHat Menu")); + data->param.pipe.command = "wmconfig --output wmaker"; - data = putNewItem(panel, pad, ExternalInfo, _("Debian Menu")); - data->param.pipe.command = "/etc/X11/WindowMaker/menu.hook"; - - data = putNewItem(panel, pad, PipeInfo, _("RedHat Menu")); - data->param.pipe.command = "wmconfig --output wmaker"; + data = putNewItem(panel, pad, PipeInfo, _("Menu Conectiva")); + data->param.pipe.command = "wmconfig --output wmaker"; - data = putNewItem(panel, pad, PipeInfo, _("Menu Conectiva")); - data->param.pipe.command = "wmconfig --output wmaker"; + data = putNewItem(panel, pad, DirectoryInfo, _("Themes")); + data->param.directory.command = "setstyle"; + data->param.directory.directory = "/usr/share/WindowMaker/Themes /usr/local/share/WindowMaker/Themes $HOME/GNUstep/Library/WindowMaker/Themes"; + data->param.directory.stripExt = 1; - data = putNewItem(panel, pad, DirectoryInfo, _("Themes")); - data->param.directory.command = "setstyle"; - data->param.directory.directory = "/usr/share/WindowMaker/Themes /usr/local/share/WindowMaker/Themes $HOME/GNUstep/Library/WindowMaker/Themes"; - data->param.directory.stripExt = 1; - - data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (scale)")); - data->param.directory.command = "wmsetbg -u -s"; - data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; - data->param.directory.stripExt = 1; + data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (scale)")); + data->param.directory.command = "wmsetbg -u -s"; + data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; + data->param.directory.stripExt = 1; - data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (tile)")); - data->param.directory.command = "wmsetbg -u -t"; - data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; - data->param.directory.stripExt = 1; - - smenu = putNewSubmenu(pad, _("Assorted XTerms")); + data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (tile)")); + data->param.directory.command = "wmsetbg -u -t"; + data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; + data->param.directory.stripExt = 1; - data = putNewItem(panel, smenu, ExecInfo, _("XTerm Yellow on Blue")); - data->param.exec.command = "xterm -sb -sl 2000 -bg midnightblue -fg yellow"; + smenu = putNewSubmenu(pad, _("Assorted XTerms")); - data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Black")); - data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; + data = putNewItem(panel, smenu, ExecInfo, _("XTerm Yellow on Blue")); + data->param.exec.command = "xterm -sb -sl 2000 -bg midnightblue -fg yellow"; - data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on White")); - data->param.exec.command = "xterm -sb -sl 2000 -bg white -fg black"; + data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Black")); + data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; - data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on Beige")); - data->param.exec.command = "xterm -sb -sl 2000 -bg '#bbbb99' -fg black"; + data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on White")); + data->param.exec.command = "xterm -sb -sl 2000 -bg white -fg black"; - data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Green")); - data->param.exec.command = "xterm -sb -sl 2000 -bg '#228822' -fg white"; + data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on Beige")); + data->param.exec.command = "xterm -sb -sl 2000 -bg '#bbbb99' -fg black"; - data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Olive")); - data->param.exec.command = "xterm -sb -sl 2000 -bg '#335533' -fg white"; + data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Green")); + data->param.exec.command = "xterm -sb -sl 2000 -bg '#228822' -fg white"; - data = putNewItem(panel, smenu, ExecInfo, _("XTerm Blue on Blue")); - data->param.exec.command = "xterm -sb -sl 2000 -bg '#112244' -fg '#88aabb'"; + data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Olive")); + data->param.exec.command = "xterm -sb -sl 2000 -bg '#335533' -fg white"; - data = putNewItem(panel, smenu, ExecInfo, _("XTerm BIG FONTS")); - data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white -fn 10x20"; + data = putNewItem(panel, smenu, ExecInfo, _("XTerm Blue on Blue")); + data->param.exec.command = "xterm -sb -sl 2000 -bg '#112244' -fg '#88aabb'"; - WMMapWidget(pad); - - panel->itemPad[2] = sview; + data = putNewItem(panel, smenu, ExecInfo, _("XTerm BIG FONTS")); + data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white -fn 10x20"; + + WMMapWidget(pad); + + panel->itemPad[2] = sview; } @@ -666,11 +666,11 @@ createPanel(_Panel *p) panel->optionsF = WMCreateFrame(panel->box); WMResizeWidget(panel->optionsF, width, FRAME_HEIGHT - 15); WMMoveWidget(panel->optionsF, 10 + 150 + 10, 5); - + width -= 20; /* command */ - + panel->commandF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->commandF, width, 50); WMMoveWidget(panel->commandF, 10, 20); @@ -688,8 +688,8 @@ createPanel(_Panel *p) WMSetButtonAction(panel->browseB, browseForFile, panel); WMAddNotificationObserver(dataChanged, panel, - WMTextDidChangeNotification, - panel->commandT); + WMTextDidChangeNotification, + panel->commandT); #if 0 panel->xtermC = WMCreateSwitchButton(panel->commandF); @@ -712,18 +712,18 @@ createPanel(_Panel *p) WMMoveWidget(panel->pathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, - WMTextDidChangeNotification, - panel->pathT); - + WMTextDidChangeNotification, + panel->pathT); + label = WMCreateLabel(panel->pathF); WMResizeWidget(label, width - 20, 80); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter the path for a file containing a menu\n" - "or a list of directories with the programs you\n" - "want to have listed in the menu. Ex:\n" - "~/GNUstep/Library/WindowMaker/menu\n" - "or\n" - "/usr/X11R6/bin ~/xbin")); + "or a list of directories with the programs you\n" + "want to have listed in the menu. Ex:\n" + "~/GNUstep/Library/WindowMaker/menu\n" + "or\n" + "/usr/X11R6/bin ~/xbin")); WMMapSubwidgets(panel->pathF); @@ -740,23 +740,23 @@ createPanel(_Panel *p) WMMoveWidget(panel->pipeT, 10, 20); WMAddNotificationObserver(dataChanged, panel, - WMTextDidChangeNotification, - panel->pipeT); + WMTextDidChangeNotification, + panel->pipeT); label = WMCreateLabel(panel->pipeF); WMResizeWidget(label, width - 20, 40); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter a command that outputs a menu\n" - "definition to stdout when invoked.")); + "definition to stdout when invoked.")); + - panel->pipeCacheB = WMCreateSwitchButton(panel->pipeF); WMResizeWidget(panel->pipeCacheB, width - 20, 40); WMMoveWidget(panel->pipeCacheB, 10, 110); - WMSetButtonText(panel->pipeCacheB, - _("Cache menu contents after opening for\n" - "the first time")); + WMSetButtonText(panel->pipeCacheB, + _("Cache menu contents after opening for\n" + "the first time")); WMMapSubwidgets(panel->pipeF); @@ -773,15 +773,15 @@ createPanel(_Panel *p) WMMoveWidget(panel->dcommandT, 10, 20); WMAddNotificationObserver(dataChanged, panel, - WMTextDidChangeNotification, - panel->dcommandT); + WMTextDidChangeNotification, + panel->dcommandT); label = WMCreateLabel(panel->dcommandF); WMResizeWidget(label, width - 20, 45); WMMoveWidget(label, 10, 40); WMSetLabelText(label, _("Enter the command you want to use to open the\n" - "files in the directories listed below.")); + "files in the directories listed below.")); WMMapSubwidgets(panel->dcommandF); @@ -796,8 +796,8 @@ createPanel(_Panel *p) WMMoveWidget(panel->dpathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, - WMTextDidChangeNotification, - panel->dpathT); + WMTextDidChangeNotification, + panel->dpathT); panel->dstripB = WMCreateSwitchButton(panel->dpathF); WMResizeWidget(panel->dstripB, width - 20, 20); @@ -805,7 +805,7 @@ createPanel(_Panel *p) WMSetButtonText(panel->dstripB, _("Strip extensions from file names")); WMSetButtonAction(panel->dstripB, buttonClicked, panel); - + WMMapSubwidgets(panel->dpathF); @@ -821,8 +821,8 @@ createPanel(_Panel *p) WMMoveWidget(panel->shortT, 10, 20); WMAddNotificationObserver(dataChanged, panel, - WMTextDidChangeNotification, - panel->shortT); + WMTextDidChangeNotification, + panel->shortT); panel->sgrabB = WMCreateCommandButton(panel->shortF); WMResizeWidget(panel->sgrabB, 70, 24); @@ -843,12 +843,12 @@ createPanel(_Panel *p) panel->icommandL = WMCreateList(panel->optionsF); WMResizeWidget(panel->icommandL, width, 80); WMMoveWidget(panel->icommandL, 10, 20); - + WMSetListAction(panel->icommandL, icommandLClicked, panel); WMAddNotificationObserver(dataChanged, panel, - WMListSelectionDidChangeNotification, - panel->icommandL); + WMListSelectionDidChangeNotification, + panel->icommandL); WMInsertListItem(panel->icommandL, 0, _("Arrange Icons")); WMInsertListItem(panel->icommandL, 1, _("Hide All Windows Except For The Focused One")); @@ -876,8 +876,8 @@ createPanel(_Panel *p) WMMoveWidget(panel->paramT, 10, 20); WMAddNotificationObserver(dataChanged, panel, - WMTextDidChangeNotification, - panel->paramT); + WMTextDidChangeNotification, + panel->paramT); WMMapSubwidgets(panel->paramF); @@ -892,25 +892,25 @@ createPanel(_Panel *p) label = WMCreateLabel(panel->optionsF); WMResizeWidget(label, width+5, FRAME_HEIGHT - 50); WMMoveWidget(label, 7, 20); - WMSetLabelText(label, - _("Instructions:\n\n" - " - drag items from the left to the menu to add new items\n" - " - drag items out of the menu to remove items\n" - " - drag items in menu to change their position\n" - " - drag items with Control pressed to copy them\n" - " - double click in a menu item to change the label\n" - " - click on a menu item to change related information")); + WMSetLabelText(label, + _("Instructions:\n\n" + " - drag items from the left to the menu to add new items\n" + " - drag items out of the menu to remove items\n" + " - drag items in menu to change their position\n" + " - drag items with Control pressed to copy them\n" + " - double click in a menu item to change the label\n" + " - click on a menu item to change related information")); WMMapWidget(label); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); WMMapWidget(panel->box); - + { - int i; - for (i = 0; i < 3; i++) - WMUnmapWidget(panel->itemPad[i]); + int i; + for (i = 0; i < 3; i++) + WMUnmapWidget(panel->itemPad[i]); } changedItemPad(panel->typeP, panel); @@ -932,20 +932,20 @@ createPanel(_Panel *p) panel->currentType = NoInfo; showData(panel); - + { - WMPoint pos; - - pos = WMGetViewScreenPosition(WMWidgetView(panel->box)); - - if (pos.x < 200) { - pos.x += FRAME_WIDTH + 20; - } else { - pos.x = 10; - } - - pos.y = WMAX(pos.y - 100, 0); - + WMPoint pos; + + pos = WMGetViewScreenPosition(WMWidgetView(panel->box)); + + if (pos.x < 200) { + pos.x += FRAME_WIDTH + 20; + } else { + pos.x = 10; + } + + pos.y = WMAX(pos.y - 100, 0); + if (panel->menu) WEditMenuShowAt(panel->menu, pos.x, pos.y); } @@ -961,31 +961,31 @@ freeItemData(ItemData *data) /* TODO */ switch (data->type) { - case CommandInfo: - CFREE(data->param.command.parameter); - CFREE(data->param.command.shortcut); - break; - - case ExecInfo: - CFREE(data->param.exec.command); - CFREE(data->param.exec.shortcut); - break; - - case PipeInfo: - CFREE(data->param.pipe.command); - break; - - case ExternalInfo: - CFREE(data->param.external.path); - break; - - case DirectoryInfo: - CFREE(data->param.directory.command); - CFREE(data->param.directory.directory); - break; - - default: - break; + case CommandInfo: + CFREE(data->param.command.parameter); + CFREE(data->param.command.shortcut); + break; + + case ExecInfo: + CFREE(data->param.exec.command); + CFREE(data->param.exec.shortcut); + break; + + case PipeInfo: + CFREE(data->param.pipe.command); + break; + + case ExternalInfo: + CFREE(data->param.external.path); + break; + + case DirectoryInfo: + CFREE(data->param.directory.command); + CFREE(data->param.directory.directory); + break; + + default: + break; } wfree(data); @@ -1002,132 +1002,132 @@ parseCommand(WMPropList *item) char *parameter = NULL; char *shortcut = NULL; int i = 1; - - + + p = WMGetFromPLArray(item, i++); command = WMGetFromPLString(p); if (strcmp(command, "SHORTCUT") == 0) { - p = WMGetFromPLArray(item, i++); - shortcut = WMGetFromPLString(p); - p = WMGetFromPLArray(item, i++); - command = WMGetFromPLString(p); + p = WMGetFromPLArray(item, i++); + shortcut = WMGetFromPLString(p); + p = WMGetFromPLArray(item, i++); + command = WMGetFromPLString(p); } p = WMGetFromPLArray(item, i++); if (p) - parameter = WMGetFromPLString(p); + parameter = WMGetFromPLString(p); if (strcmp(command, "EXEC") == 0 || strcmp(command, "SHEXEC") == 0) { - - data->type = ExecInfo; - - data->param.exec.command = wstrdup(parameter); - if (shortcut) - data->param.exec.shortcut = wstrdup(shortcut); - + + data->type = ExecInfo; + + data->param.exec.command = wstrdup(parameter); + if (shortcut) + data->param.exec.shortcut = wstrdup(shortcut); + } else if (strcmp(command, "OPEN_MENU") == 0) { - char *p; - /* - * dir menu, menu file - * dir WITH - * |pipe - */ - p = parameter; - while (isspace(*p) && *p) p++; - if (*p == '|') { - if (*(p+1) == '|') { - p++; - data->param.pipe.cached = 0; - } else { - data->param.pipe.cached = 1; - } - data->type = PipeInfo; - data->param.pipe.command = wtrimspace(p+1); - } else { - char *s; - - p = wstrdup(p); - - s = strstr(p, "WITH"); - if (s) { - char **tokens; - char **ctokens; - int tokn; - int i, j; - - data->type = DirectoryInfo; - - *s = '\0'; - s += 5; - while (*s && isspace(*s)) s++; - data->param.directory.command = wstrdup(s); - - wtokensplit(p, &tokens, &tokn); - wfree(p); - - ctokens = wmalloc(sizeof(char*)*tokn); - - for (i = 0, j = 0; i < tokn; i++) { - if (strcmp(tokens[i], "-noext") == 0) { - wfree(tokens[i]); - data->param.directory.stripExt = 1; - } else { - ctokens[j++] = tokens[i]; - } - } - data->param.directory.directory = wtokenjoin(ctokens, j); - wfree(ctokens); - - wtokenfree(tokens, tokn); - } else { - data->type = ExternalInfo; - data->param.external.path = p; - } - } + char *p; + /* + * dir menu, menu file + * dir WITH + * |pipe + */ + p = parameter; + while (isspace(*p) && *p) p++; + if (*p == '|') { + if (*(p+1) == '|') { + p++; + data->param.pipe.cached = 0; + } else { + data->param.pipe.cached = 1; + } + data->type = PipeInfo; + data->param.pipe.command = wtrimspace(p+1); + } else { + char *s; + + p = wstrdup(p); + + s = strstr(p, "WITH"); + if (s) { + char **tokens; + char **ctokens; + int tokn; + int i, j; + + data->type = DirectoryInfo; + + *s = '\0'; + s += 5; + while (*s && isspace(*s)) s++; + data->param.directory.command = wstrdup(s); + + wtokensplit(p, &tokens, &tokn); + wfree(p); + + ctokens = wmalloc(sizeof(char*)*tokn); + + for (i = 0, j = 0; i < tokn; i++) { + if (strcmp(tokens[i], "-noext") == 0) { + wfree(tokens[i]); + data->param.directory.stripExt = 1; + } else { + ctokens[j++] = tokens[i]; + } + } + data->param.directory.directory = wtokenjoin(ctokens, j); + wfree(ctokens); + + wtokenfree(tokens, tokn); + } else { + data->type = ExternalInfo; + data->param.external.path = p; + } + } } else if (strcmp(command, "WORKSPACE_MENU") == 0) { - data->type = WSMenuInfo; + data->type = WSMenuInfo; } else if (strcmp(command, "WINDOWS_MENU") == 0) { - data->type = WWindowListInfo; + data->type = WWindowListInfo; } else { - int cmd; - - if (strcmp(command, "ARRANGE_ICONS") == 0) { - cmd = 0; - } else if (strcmp(command, "HIDE_OTHERS") == 0) { - cmd = 1; - } else if (strcmp(command, "SHOW_ALL") == 0) { - cmd = 2; - } else if (strcmp(command, "EXIT") == 0) { - cmd = 3; - } else if (strcmp(command, "SHUTDOWN") == 0) { - cmd = 4; - } else if (strcmp(command, "RESTART") == 0) { - if (parameter) { - cmd = 6; - } else { - cmd = 5; - } - } else if (strcmp(command, "SAVE_SESSION") == 0) { - cmd = 7; - } else if (strcmp(command, "CLEAR_SESSION") == 0) { - cmd = 8; - } else if (strcmp(command, "REFRESH") == 0) { - cmd = 9; - } else if (strcmp(command, "INFO_PANEL") == 0) { - cmd = 10; - } else if (strcmp(command, "LEGAL_PANEL") == 0) { - cmd = 11; - } else { - wwarning(_("unknown command '%s' in menu"), command); - goto error; - } - - data->type = CommandInfo; - - data->param.command.command = cmd; - if (shortcut) - data->param.command.shortcut = wstrdup(shortcut); - if (parameter) - data->param.command.parameter = wstrdup(parameter); + int cmd; + + if (strcmp(command, "ARRANGE_ICONS") == 0) { + cmd = 0; + } else if (strcmp(command, "HIDE_OTHERS") == 0) { + cmd = 1; + } else if (strcmp(command, "SHOW_ALL") == 0) { + cmd = 2; + } else if (strcmp(command, "EXIT") == 0) { + cmd = 3; + } else if (strcmp(command, "SHUTDOWN") == 0) { + cmd = 4; + } else if (strcmp(command, "RESTART") == 0) { + if (parameter) { + cmd = 6; + } else { + cmd = 5; + } + } else if (strcmp(command, "SAVE_SESSION") == 0) { + cmd = 7; + } else if (strcmp(command, "CLEAR_SESSION") == 0) { + cmd = 8; + } else if (strcmp(command, "REFRESH") == 0) { + cmd = 9; + } else if (strcmp(command, "INFO_PANEL") == 0) { + cmd = 10; + } else if (strcmp(command, "LEGAL_PANEL") == 0) { + cmd = 11; + } else { + wwarning(_("unknown command '%s' in menu"), command); + goto error; + } + + data->type = CommandInfo; + + data->param.command.command = cmd; + if (shortcut) + data->param.command.shortcut = wstrdup(shortcut); + if (parameter) + data->param.command.parameter = wstrdup(parameter); } return data; @@ -1145,45 +1145,45 @@ static void updateFrameTitle(_Panel *panel, char *title, InfoType type) { if (type != NoInfo) { - char *tmp; - - switch (type) { - case ExecInfo: - tmp = wstrconcat(title, _(": Execute Program")); - break; - - case CommandInfo: - tmp = wstrconcat(title, _(": Perform Internal Command")); - break; - - case ExternalInfo: - tmp = wstrconcat(title, _(": Open a Submenu")); - break; - - case PipeInfo: - tmp = wstrconcat(title, _(": Program Generated Submenu")); - break; - - case DirectoryInfo: - tmp = wstrconcat(title, _(": Directory Contents Menu")); - break; - - case WSMenuInfo: - tmp = wstrconcat(title, _(": Open Workspaces Submenu")); - break; - - case WWindowListInfo: - tmp = wstrconcat(title, _(": Open Window List Submenu")); - break; - - default: - tmp = NULL; - break; - } - WMSetFrameTitle(panel->optionsF, tmp); - wfree(tmp); + char *tmp; + + switch (type) { + case ExecInfo: + tmp = wstrconcat(title, _(": Execute Program")); + break; + + case CommandInfo: + tmp = wstrconcat(title, _(": Perform Internal Command")); + break; + + case ExternalInfo: + tmp = wstrconcat(title, _(": Open a Submenu")); + break; + + case PipeInfo: + tmp = wstrconcat(title, _(": Program Generated Submenu")); + break; + + case DirectoryInfo: + tmp = wstrconcat(title, _(": Directory Contents Menu")); + break; + + case WSMenuInfo: + tmp = wstrconcat(title, _(": Open Workspaces Submenu")); + break; + + case WWindowListInfo: + tmp = wstrconcat(title, _(": Open Window List Submenu")); + break; + + default: + tmp = NULL; + break; + } + WMSetFrameTitle(panel->optionsF, tmp); + wfree(tmp); } else { - WMSetFrameTitle(panel->optionsF, NULL); + WMSetFrameTitle(panel->optionsF, NULL); } } @@ -1193,25 +1193,25 @@ static void changeInfoType(_Panel *panel, char *title, InfoType type) { WMWidget **w; - + if (panel->currentType != type) { - w = panel->sections[panel->currentType]; + w = panel->sections[panel->currentType]; - while (*w) { - WMUnmapWidget(*w); - w++; - } - WMUnmapWidget(panel->paramF); - WMUnmapWidget(panel->quickB); + while (*w) { + WMUnmapWidget(*w); + w++; + } + WMUnmapWidget(panel->paramF); + WMUnmapWidget(panel->quickB); - w = panel->sections[type]; - - while (*w) { - WMMapWidget(*w); - w++; - } + w = panel->sections[type]; + + while (*w) { + WMMapWidget(*w); + w++; + } } updateFrameTitle(panel, title, type); @@ -1222,93 +1222,93 @@ changeInfoType(_Panel *panel, char *title, InfoType type) -static void +static void updateMenuItem(_Panel *panel, WEditMenuItem *item, WMWidget *changedWidget) { - ItemData *data = WGetEditMenuItemData(item); - + ItemData *data = WGetEditMenuItemData(item); + assert(data != NULL); #define REPLACE(v, d) if (v) wfree(v); v = d switch (data->type) { - case ExecInfo: - if (changedWidget == panel->commandT) { - REPLACE(data->param.exec.command, - WMGetTextFieldText(panel->commandT)); - } - if (changedWidget == panel->shortT) { - REPLACE(data->param.exec.shortcut, - WMGetTextFieldText(panel->shortT)); - } - break; - - case CommandInfo: - if (changedWidget == panel->icommandL) { - data->param.command.command = - WMGetListSelectedItemRow(panel->icommandL); - } - switch (data->param.command.command) { - case 3: - case 4: - if (changedWidget == panel->quickB) { - REPLACE(data->param.command.parameter, - WMGetButtonSelected(panel->quickB) - ? wstrdup("QUICK") : NULL); - } - break; - - case 6: - if (changedWidget == panel->paramT) { - REPLACE(data->param.command.parameter, - WMGetTextFieldText(panel->paramT)); - } - break; - } - if (changedWidget == panel->shortT) { - REPLACE(data->param.command.shortcut, - WMGetTextFieldText(panel->shortT)); - } - - - break; - - case PipeInfo: - if (changedWidget == panel->pipeT) { - REPLACE(data->param.pipe.command, - WMGetTextFieldText(panel->pipeT)); - } - if (changedWidget == panel->pipeCacheB) { - data->param.pipe.cached = - WMGetButtonSelected(panel->pipeCacheB); - } - break; - - case ExternalInfo: - if (changedWidget == panel->pathT) { - REPLACE(data->param.external.path, - WMGetTextFieldText(panel->pathT)); - } - break; - - case DirectoryInfo: - if (changedWidget == panel->dpathT) { - REPLACE(data->param.directory.directory, - WMGetTextFieldText(panel->dpathT)); - } - if (changedWidget == panel->dcommandT) { - REPLACE(data->param.directory.command, - WMGetTextFieldText(panel->dcommandT)); - } - if (changedWidget == panel->dstripB) { - data->param.directory.stripExt = - WMGetButtonSelected(panel->dstripB); - } - break; - - default: - assert(0); - break; + case ExecInfo: + if (changedWidget == panel->commandT) { + REPLACE(data->param.exec.command, + WMGetTextFieldText(panel->commandT)); + } + if (changedWidget == panel->shortT) { + REPLACE(data->param.exec.shortcut, + WMGetTextFieldText(panel->shortT)); + } + break; + + case CommandInfo: + if (changedWidget == panel->icommandL) { + data->param.command.command = + WMGetListSelectedItemRow(panel->icommandL); + } + switch (data->param.command.command) { + case 3: + case 4: + if (changedWidget == panel->quickB) { + REPLACE(data->param.command.parameter, + WMGetButtonSelected(panel->quickB) + ? wstrdup("QUICK") : NULL); + } + break; + + case 6: + if (changedWidget == panel->paramT) { + REPLACE(data->param.command.parameter, + WMGetTextFieldText(panel->paramT)); + } + break; + } + if (changedWidget == panel->shortT) { + REPLACE(data->param.command.shortcut, + WMGetTextFieldText(panel->shortT)); + } + + + break; + + case PipeInfo: + if (changedWidget == panel->pipeT) { + REPLACE(data->param.pipe.command, + WMGetTextFieldText(panel->pipeT)); + } + if (changedWidget == panel->pipeCacheB) { + data->param.pipe.cached = + WMGetButtonSelected(panel->pipeCacheB); + } + break; + + case ExternalInfo: + if (changedWidget == panel->pathT) { + REPLACE(data->param.external.path, + WMGetTextFieldText(panel->pathT)); + } + break; + + case DirectoryInfo: + if (changedWidget == panel->dpathT) { + REPLACE(data->param.directory.directory, + WMGetTextFieldText(panel->dpathT)); + } + if (changedWidget == panel->dcommandT) { + REPLACE(data->param.directory.command, + WMGetTextFieldText(panel->dcommandT)); + } + if (changedWidget == panel->dstripB) { + data->param.directory.stripExt = + WMGetButtonSelected(panel->dstripB); + } + break; + + default: + assert(0); + break; } #undef REPLACE @@ -1318,49 +1318,49 @@ updateMenuItem(_Panel *panel, WEditMenuItem *item, WMWidget *changedWidget) static void menuItemCloned(WEditMenuDelegate *delegate, WEditMenu *menu, - WEditMenuItem *origItem, WEditMenuItem *newItem) + WEditMenuItem *origItem, WEditMenuItem *newItem) { ItemData *data = WGetEditMenuItemData(origItem); ItemData *newData; - + if (!data) - return; - + return; + #define DUP(s) (s) ? wstrdup(s) : NULL newData = NEW(ItemData); newData->type = data->type; - + switch (data->type) { - case ExecInfo: - newData->param.exec.command = DUP(data->param.exec.command); - newData->param.exec.shortcut = DUP(data->param.exec.shortcut); - break; - - case CommandInfo: - newData->param.command.command = data->param.command.command; - newData->param.command.parameter = DUP(data->param.command.parameter); - newData->param.command.shortcut = DUP(data->param.command.shortcut); - break; - - case PipeInfo: - newData->param.pipe.command = DUP(data->param.pipe.command); - newData->param.pipe.cached = data->param.pipe.cached; - break; - - case ExternalInfo: - newData->param.external.path = DUP(data->param.external.path); - break; - - case DirectoryInfo: - newData->param.directory.directory = DUP(data->param.directory.directory); - newData->param.directory.command = DUP(data->param.directory.command); - newData->param.directory.stripExt = data->param.directory.stripExt; - break; - - default: - break; + case ExecInfo: + newData->param.exec.command = DUP(data->param.exec.command); + newData->param.exec.shortcut = DUP(data->param.exec.shortcut); + break; + + case CommandInfo: + newData->param.command.command = data->param.command.command; + newData->param.command.parameter = DUP(data->param.command.parameter); + newData->param.command.shortcut = DUP(data->param.command.shortcut); + break; + + case PipeInfo: + newData->param.pipe.command = DUP(data->param.pipe.command); + newData->param.pipe.cached = data->param.pipe.cached; + break; + + case ExternalInfo: + newData->param.external.path = DUP(data->param.external.path); + break; + + case DirectoryInfo: + newData->param.directory.directory = DUP(data->param.directory.directory); + newData->param.directory.command = DUP(data->param.directory.command); + newData->param.directory.stripExt = data->param.directory.stripExt; + break; + + default: + break; } #undef DUP @@ -1380,7 +1380,7 @@ menuItemEdited(struct WEditMenuDelegate *delegate, WEditMenu *menu, submenu = WGetEditMenuSubmenu(menu, item); if (submenu) { - WSetEditMenuTitle(submenu, WGetEditMenuItemTitle(item)); + WSetEditMenuTitle(submenu, WGetEditMenuItemTitle(item)); } } @@ -1392,34 +1392,34 @@ shouldRemoveItem(struct WEditMenuDelegate *delegate, WEditMenu *menu, _Panel *panel = (_Panel*)delegate->data; if (panel->dontAsk) - return True; + return True; if (WGetEditMenuSubmenu(menu, item)) { - int res; - - res = WMRunAlertPanel(WMWidgetScreen(menu), NULL, - _("Remove Submenu"), - _("Removing this item will destroy all items inside\n" - "the submenu. Do you really want to do that?"), - _("Yes"), _("No"), - _("Yes, don't ask again.")); - switch (res) { - case WAPRDefault: - return True; - case WAPRAlternate: - return False; - case WAPROther: - panel->dontAsk = True; - return True; - } + int res; + + res = WMRunAlertPanel(WMWidgetScreen(menu), NULL, + _("Remove Submenu"), + _("Removing this item will destroy all items inside\n" + "the submenu. Do you really want to do that?"), + _("Yes"), _("No"), + _("Yes, don't ask again.")); + switch (res) { + case WAPRDefault: + return True; + case WAPRAlternate: + return False; + case WAPROther: + panel->dontAsk = True; + return True; + } } return True; } -static void +static void menuItemDeselected(WEditMenuDelegate *delegate, WEditMenu *menu, - WEditMenuItem *item) + WEditMenuItem *item) { _Panel *panel = (_Panel*)delegate->data; @@ -1427,70 +1427,70 @@ menuItemDeselected(WEditMenuDelegate *delegate, WEditMenu *menu, } -static void +static void menuItemSelected(WEditMenuDelegate *delegate, WEditMenu *menu, - WEditMenuItem *item) + WEditMenuItem *item) { ItemData *data = WGetEditMenuItemData(item); _Panel *panel = (_Panel*)delegate->data; - + panel->currentItem = item; - + if (data) { - changeInfoType(panel, WGetEditMenuItemTitle(item), data->type); - - switch (data->type) { - case NoInfo: - break; - - case ExecInfo: - WMSetTextFieldText(panel->commandT, data->param.exec.command); - WMSetTextFieldText(panel->shortT, data->param.exec.shortcut); - break; - - case CommandInfo: - WMSelectListItem(panel->icommandL, - data->param.command.command); - WMSetListPosition(panel->icommandL, - data->param.command.command - 2); - WMSetTextFieldText(panel->shortT, data->param.command.shortcut); - - switch (data->param.command.command) { - case 3: - case 4: - WMSetButtonSelected(panel->quickB, - data->param.command.parameter!=NULL); - break; - case 6: - WMSetTextFieldText(panel->paramT, - data->param.command.parameter); - break; - } - - icommandLClicked(panel->icommandL, panel); - break; - - case PipeInfo: - WMSetTextFieldText(panel->pipeT, data->param.pipe.command); - WMSetButtonSelected(panel->pipeCacheB, data->param.pipe.cached); - break; - - case ExternalInfo: - WMSetTextFieldText(panel->pathT, data->param.external.path); - break; - - case DirectoryInfo: - WMSetTextFieldText(panel->dpathT, data->param.directory.directory); - WMSetTextFieldText(panel->dcommandT, data->param.directory.command); - WMSetButtonSelected(panel->dstripB, data->param.directory.stripExt); - break; - - case WSMenuInfo: - break; - - default: - break; - } + changeInfoType(panel, WGetEditMenuItemTitle(item), data->type); + + switch (data->type) { + case NoInfo: + break; + + case ExecInfo: + WMSetTextFieldText(panel->commandT, data->param.exec.command); + WMSetTextFieldText(panel->shortT, data->param.exec.shortcut); + break; + + case CommandInfo: + WMSelectListItem(panel->icommandL, + data->param.command.command); + WMSetListPosition(panel->icommandL, + data->param.command.command - 2); + WMSetTextFieldText(panel->shortT, data->param.command.shortcut); + + switch (data->param.command.command) { + case 3: + case 4: + WMSetButtonSelected(panel->quickB, + data->param.command.parameter!=NULL); + break; + case 6: + WMSetTextFieldText(panel->paramT, + data->param.command.parameter); + break; + } + + icommandLClicked(panel->icommandL, panel); + break; + + case PipeInfo: + WMSetTextFieldText(panel->pipeT, data->param.pipe.command); + WMSetButtonSelected(panel->pipeCacheB, data->param.pipe.cached); + break; + + case ExternalInfo: + WMSetTextFieldText(panel->pathT, data->param.external.path); + break; + + case DirectoryInfo: + WMSetTextFieldText(panel->dpathT, data->param.directory.directory); + WMSetTextFieldText(panel->dcommandT, data->param.directory.command); + WMSetButtonSelected(panel->dstripB, data->param.directory.stripExt); + break; + + case WSMenuInfo: + break; + + default: + break; + } } } @@ -1505,41 +1505,41 @@ buildSubmenu(_Panel *panel, WMPropList *pl) char *title; WMPropList *tp, *bp; int i; - + tp = WMGetFromPLArray(pl, 0); title = WMGetFromPLString(tp); menu = WCreateEditMenu(scr, title); - + for (i = 1; i < WMGetPropListItemCount(pl); i++) { - WMPropList *pi; - - pi = WMGetFromPLArray(pl, i); - - tp = WMGetFromPLArray(pi, 0); - bp = WMGetFromPLArray(pi, 1); - - title = WMGetFromPLString(tp); - - if (!bp || WMIsPLArray(bp)) { /* it's a submenu */ - WEditMenu *submenu; - - submenu = buildSubmenu(panel, pi); - - item = WAddMenuItemWithTitle(menu, title); - - WSetEditMenuSubmenu(menu, item, submenu); - } else { - ItemData *data; - - item = WAddMenuItemWithTitle(menu, title); - - data = parseCommand(pi); - - if (panel->markerPix[data->type]) - WSetEditMenuItemImage(item, panel->markerPix[data->type]); - WSetEditMenuItemData(item, data, (WMCallback*)freeItemData); - } + WMPropList *pi; + + pi = WMGetFromPLArray(pl, i); + + tp = WMGetFromPLArray(pi, 0); + bp = WMGetFromPLArray(pi, 1); + + title = WMGetFromPLString(tp); + + if (!bp || WMIsPLArray(bp)) { /* it's a submenu */ + WEditMenu *submenu; + + submenu = buildSubmenu(panel, pi); + + item = WAddMenuItemWithTitle(menu, title); + + WSetEditMenuSubmenu(menu, item, submenu); + } else { + ItemData *data; + + item = WAddMenuItemWithTitle(menu, title); + + data = parseCommand(pi); + + if (panel->markerPix[data->type]) + WSetEditMenuItemImage(item, panel->markerPix[data->type]); + WSetEditMenuItemData(item, data, (WMCallback*)freeItemData); + } } WSetEditMenuAcceptsDrop(menu, True); @@ -1574,31 +1574,31 @@ getDefaultMenu(_Panel *panel) menu = WMReadPropListFromFile(menuPath); if (!menu) { - wwarning("%s:could not read property list menu", menuPath); - - if (strcmp("%s/Library/WindowMaker/plmenu", - _("%s/Library/WindowMaker/plmenu"))!=0) { - - sprintf(menuPath, "%s/Library/WindowMaker/plmenu", gspath); - menu = WMReadPropListFromFile(menuPath); - wwarning("%s:could not read property list menu", menuPath); - } - if (!menu) { - char buffer[512]; - - sprintf(buffer, _("Could not open default menu from '%s'"), - menuPath); - WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, - _("Error"), buffer, _("OK"), NULL, NULL); - } + wwarning("%s:could not read property list menu", menuPath); + + if (strcmp("%s/Library/WindowMaker/plmenu", + _("%s/Library/WindowMaker/plmenu"))!=0) { + + sprintf(menuPath, "%s/Library/WindowMaker/plmenu", gspath); + menu = WMReadPropListFromFile(menuPath); + wwarning("%s:could not read property list menu", menuPath); + } + if (!menu) { + char buffer[512]; + + sprintf(buffer, _("Could not open default menu from '%s'"), + menuPath); + WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, + _("Error"), buffer, _("OK"), NULL, NULL); + } } wfree(menuPath); if (menu) { - pmenu = menu; + pmenu = menu; } else { - pmenu = NULL; + pmenu = NULL; } return pmenu; @@ -1619,29 +1619,29 @@ showData(_Panel *panel) strcat(menuPath, "/Defaults/WMRootMenu"); pmenu = WMReadPropListFromFile(menuPath); - + if (!pmenu || !WMIsPLArray(pmenu)) { - int res; - - res = WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, - _("Warning"), - _("The menu file format currently in use is not supported\n" - "by this tool. Do you want to discard the current menu\n" - "to use this tool?"), - _("Yes, Discard and Update"), - _("No, Keep Current Menu"), NULL); - - if (res == WAPRDefault) { - pmenu = getDefaultMenu(panel); - - if (!pmenu) { - pmenu = WMCreatePLArray(WMCreatePLString("Applications"), - NULL); - } - } else { - panel->dontSave = True; - return; - } + int res; + + res = WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, + _("Warning"), + _("The menu file format currently in use is not supported\n" + "by this tool. Do you want to discard the current menu\n" + "to use this tool?"), + _("Yes, Discard and Update"), + _("No, Keep Current Menu"), NULL); + + if (res == WAPRDefault) { + pmenu = getDefaultMenu(panel); + + if (!pmenu) { + pmenu = WMCreatePLArray(WMCreatePLString("Applications"), + NULL); + } + } else { + panel->dontSave = True; + return; + } } panel->menuPath = menuPath; @@ -1656,10 +1656,10 @@ static Bool notblank(char *s) { if (s) { - while (*s++) { - if (!isspace(*s)) - return True; - } + while (*s++) { + if (!isspace(*s)) + return True; + } } return False; } @@ -1675,124 +1675,124 @@ processData(char *title, ItemData *data) int i; if (!pscut) { - pscut = WMCreatePLString("SHORTCUT"); - pomenu = WMCreatePLString("OPEN_MENU"); + pscut = WMCreatePLString("SHORTCUT"); + pomenu = WMCreatePLString("OPEN_MENU"); } item = WMCreatePLArray(WMCreatePLString(title), NULL); - + switch (data->type) { - case ExecInfo: - if (data->param.exec.command == NULL) - return NULL; + case ExecInfo: + if (data->param.exec.command == NULL) + return NULL; #if 1 - if (strpbrk(data->param.exec.command, "&$*|>param.exec.command, "&$*|>param.exec.shortcut)) { - WMAddToPLArray(item, pscut); - WMAddToPLArray(item, - WMCreatePLString(data->param.exec.shortcut)); - } - - WMAddToPLArray(item, WMCreatePLString(s1)); - WMAddToPLArray(item, WMCreatePLString(data->param.exec.command)); - break; - - case CommandInfo: - if (notblank(data->param.command.shortcut)) { - WMAddToPLArray(item, pscut); - WMAddToPLArray(item, - WMCreatePLString(data->param.command.shortcut)); - } - - i = data->param.command.command; - - WMAddToPLArray(item, WMCreatePLString(commandNames[i])); - - switch (i) { - case 3: - case 4: - if (data->param.command.parameter) { - WMAddToPLArray(item, - WMCreatePLString(data->param.command.parameter)); - } - break; - - case 6: /* restart */ - if (data->param.command.parameter) { - WMAddToPLArray(item, - WMCreatePLString(data->param.command.parameter)); - } - break; - } - - break; - - case PipeInfo: - if (!data->param.pipe.command) - return NULL; - WMAddToPLArray(item, pomenu); - if (data->param.pipe.cached) - s1 = wstrconcat("| ", data->param.pipe.command); - else - s1 = wstrconcat("|| ", data->param.pipe.command); - WMAddToPLArray(item, WMCreatePLString(s1)); - wfree(s1); - break; - - case ExternalInfo: - if (!data->param.external.path) - return NULL; - WMAddToPLArray(item, pomenu); - WMAddToPLArray(item, WMCreatePLString(data->param.external.path)); - break; - - case DirectoryInfo: - if (!data->param.directory.directory - || !data->param.directory.command) - return NULL; - { - int l; - char *tmp; - - l = strlen(data->param.directory.directory); - l += strlen(data->param.directory.command); - l += 32; - - WMAddToPLArray(item, pomenu); - - tmp = wmalloc(l); - sprintf(tmp, "%s%s WITH %s", - data->param.directory.stripExt ? "-noext " : "", - data->param.directory.directory, - data->param.directory.command); - - WMAddToPLArray(item, WMCreatePLString(tmp)); - wfree(tmp); - } - break; - - case WSMenuInfo: - WMAddToPLArray(item, WMCreatePLString("WORKSPACE_MENU")); - break; - - case WWindowListInfo: - WMAddToPLArray(item, WMCreatePLString("WINDOWS_MENU")); - break; - - default: - assert(0); - break; + if (notblank(data->param.exec.shortcut)) { + WMAddToPLArray(item, pscut); + WMAddToPLArray(item, + WMCreatePLString(data->param.exec.shortcut)); + } + + WMAddToPLArray(item, WMCreatePLString(s1)); + WMAddToPLArray(item, WMCreatePLString(data->param.exec.command)); + break; + + case CommandInfo: + if (notblank(data->param.command.shortcut)) { + WMAddToPLArray(item, pscut); + WMAddToPLArray(item, + WMCreatePLString(data->param.command.shortcut)); + } + + i = data->param.command.command; + + WMAddToPLArray(item, WMCreatePLString(commandNames[i])); + + switch (i) { + case 3: + case 4: + if (data->param.command.parameter) { + WMAddToPLArray(item, + WMCreatePLString(data->param.command.parameter)); + } + break; + + case 6: /* restart */ + if (data->param.command.parameter) { + WMAddToPLArray(item, + WMCreatePLString(data->param.command.parameter)); + } + break; + } + + break; + + case PipeInfo: + if (!data->param.pipe.command) + return NULL; + WMAddToPLArray(item, pomenu); + if (data->param.pipe.cached) + s1 = wstrconcat("| ", data->param.pipe.command); + else + s1 = wstrconcat("|| ", data->param.pipe.command); + WMAddToPLArray(item, WMCreatePLString(s1)); + wfree(s1); + break; + + case ExternalInfo: + if (!data->param.external.path) + return NULL; + WMAddToPLArray(item, pomenu); + WMAddToPLArray(item, WMCreatePLString(data->param.external.path)); + break; + + case DirectoryInfo: + if (!data->param.directory.directory + || !data->param.directory.command) + return NULL; + { + int l; + char *tmp; + + l = strlen(data->param.directory.directory); + l += strlen(data->param.directory.command); + l += 32; + + WMAddToPLArray(item, pomenu); + + tmp = wmalloc(l); + sprintf(tmp, "%s%s WITH %s", + data->param.directory.stripExt ? "-noext " : "", + data->param.directory.directory, + data->param.directory.command); + + WMAddToPLArray(item, WMCreatePLString(tmp)); + wfree(tmp); + } + break; + + case WSMenuInfo: + WMAddToPLArray(item, WMCreatePLString("WORKSPACE_MENU")); + break; + + case WWindowListInfo: + WMAddToPLArray(item, WMCreatePLString("WINDOWS_MENU")); + break; + + default: + assert(0); + break; } - + return item; } @@ -1805,8 +1805,8 @@ processSubmenu(WEditMenu *menu) WMPropList *pl; char *s; int i; - - + + s = WGetEditMenuTitle(menu); pl = WMCreatePLString(s); @@ -1814,35 +1814,35 @@ processSubmenu(WEditMenu *menu) i = 0; while ((item = WGetEditMenuItem(menu, i++))) { - WEditMenu *submenu; + WEditMenu *submenu; + + s = WGetEditMenuItemTitle(item); - s = WGetEditMenuItemTitle(item); - - submenu = WGetEditMenuSubmenu(menu, item); - if (submenu) { - pl = processSubmenu(submenu); - } else { - pl = processData(s, WGetEditMenuItemData(item)); - } + submenu = WGetEditMenuSubmenu(menu, item); + if (submenu) { + pl = processSubmenu(submenu); + } else { + pl = processData(s, WGetEditMenuItemData(item)); + } - if (!pl) - continue; + if (!pl) + continue; - WMAddToPLArray(pmenu, pl); + WMAddToPLArray(pmenu, pl); } - + return pmenu; } - + static WMPropList* buildPLFromMenu(_Panel *panel) { WMPropList *menu; - + menu = processSubmenu(panel->menu); - + return menu; } @@ -1855,7 +1855,7 @@ storeData(_Panel *panel) WMPropList *menu; if (panel->dontSave) - return; + return; menu = buildPLFromMenu(panel); @@ -1888,7 +1888,7 @@ Panel* InitMenu(WMScreen *scr, WMWidget *parent) { _Panel *panel; - + panel = wmalloc(sizeof(_Panel)); memset(panel, 0, sizeof(_Panel)); @@ -1900,10 +1900,10 @@ InitMenu(WMScreen *scr, WMWidget *parent) panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeData; - panel->callbacks.showPanel = showMenus; + panel->callbacks.showPanel = showMenus; panel->callbacks.hidePanel = hideMenus; - + AddSection(panel, ICON_FILE); return panel; diff --git a/WPrefs.app/MenuPreferences.c b/WPrefs.app/MenuPreferences.c index 43905266..cf4e3245 100644 --- a/WPrefs.app/MenuPreferences.c +++ b/WPrefs.app/MenuPreferences.c @@ -1,9 +1,9 @@ /* MenuPreferences.c- menu related preferences - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -31,16 +31,16 @@ typedef struct _Panel { char *description; CallbackRec callbacks; - + WMWidget *parent; WMFrame *scrF; WMButton *scrB[5]; - + WMFrame *aliF; WMButton *aliyB; WMButton *alinB; - + WMFrame *optF; WMButton *autoB; WMButton *wrapB; @@ -61,14 +61,14 @@ static void showData(_Panel *panel) { WMPerformButtonClick(panel->scrB[GetSpeedForKey("MenuScrollSpeed")]); - + if (GetBoolForKey("AlignSubmenus")) - WMPerformButtonClick(panel->aliyB); + WMPerformButtonClick(panel->aliyB); else - WMPerformButtonClick(panel->alinB); - + WMPerformButtonClick(panel->alinB); + WMSetButtonSelected(panel->wrapB, GetBoolForKey("WrapMenus")); - + WMSetButtonSelected(panel->autoB, GetBoolForKey("ScrollableMenus")); } @@ -77,10 +77,10 @@ static void storeData(_Panel *panel) { int i; - + for (i=0; i<5; i++) { - if (WMGetButtonSelected(panel->scrB[i])) - break; + if (WMGetButtonSelected(panel->scrB[i])) + break; } SetSpeedForKey(i, "MenuScrollSpeed"); @@ -100,52 +100,52 @@ createPanel(Panel *p) int i; char *buf1, *buf2; char *path; - + panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - + /***************** Menu Scroll Speed ****************/ panel->scrF = WMCreateFrame(panel->box); WMResizeWidget(panel->scrF, 235, 90); WMMoveWidget(panel->scrF, 25, 20); WMSetFrameTitle(panel->scrF, _("Menu Scrolling Speed")); - + buf1 = wmalloc(strlen(SPEED_IMAGE)+1); buf2 = wmalloc(strlen(SPEED_IMAGE_S)+1); for (i = 0; i < 5; i++) { - panel->scrB[i] = WMCreateCustomButton(panel->scrF, WBBStateChangeMask); - WMResizeWidget(panel->scrB[i], 40, 40); - WMMoveWidget(panel->scrB[i], 15+(40*i), 30); - WMSetButtonBordered(panel->scrB[i], False); - WMSetButtonImagePosition(panel->scrB[i], WIPImageOnly); - if (i > 0) { - WMGroupButtons(panel->scrB[0], panel->scrB[i]); - } - sprintf(buf1, SPEED_IMAGE, i); - sprintf(buf2, SPEED_IMAGE_S, i); - path = LocateImage(buf1); - if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonImage(panel->scrB[i], icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); - } - path = LocateImage(buf2); - if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonAltImage(panel->scrB[i], icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); - } + panel->scrB[i] = WMCreateCustomButton(panel->scrF, WBBStateChangeMask); + WMResizeWidget(panel->scrB[i], 40, 40); + WMMoveWidget(panel->scrB[i], 15+(40*i), 30); + WMSetButtonBordered(panel->scrB[i], False); + WMSetButtonImagePosition(panel->scrB[i], WIPImageOnly); + if (i > 0) { + WMGroupButtons(panel->scrB[0], panel->scrB[i]); + } + sprintf(buf1, SPEED_IMAGE, i); + sprintf(buf2, SPEED_IMAGE_S, i); + path = LocateImage(buf1); + if (path) { + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonImage(panel->scrB[i], icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); + } + path = LocateImage(buf2); + if (path) { + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonAltImage(panel->scrB[i], icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); + } } wfree(buf1); wfree(buf2); @@ -153,26 +153,26 @@ createPanel(Panel *p) WMMapSubwidgets(panel->scrF); /***************** Submenu Alignment ****************/ - + panel->aliF = WMCreateFrame(panel->box); WMResizeWidget(panel->aliF, 220, 90); WMMoveWidget(panel->aliF, 280, 20); WMSetFrameTitle(panel->aliF, _("Submenu Alignment")); - + panel->alinB = WMCreateButton(panel->aliF, WBTOnOff); WMResizeWidget(panel->alinB, 48, 48); WMMoveWidget(panel->alinB, 56, 25); WMSetButtonImagePosition(panel->alinB, WIPImageOnly); path = LocateImage(MENU_ALIGN1); if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonImage(panel->alinB, icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonImage(panel->alinB, icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); } panel->aliyB = WMCreateButton(panel->aliF, WBTOnOff); WMResizeWidget(panel->aliyB, 48, 48); @@ -180,24 +180,24 @@ createPanel(Panel *p) WMSetButtonImagePosition(panel->aliyB, WIPImageOnly); path = LocateImage(MENU_ALIGN2); if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonImage(panel->aliyB, icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonImage(panel->aliyB, icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); } WMGroupButtons(panel->alinB, panel->aliyB); - + WMMapSubwidgets(panel->aliF); - + /***************** Options ****************/ panel->optF = WMCreateFrame(panel->box); WMResizeWidget(panel->optF, 475, 80); WMMoveWidget(panel->optF, 25, 130); - + panel->wrapB = WMCreateSwitchButton(panel->optF); WMResizeWidget(panel->wrapB, 440, 32); WMMoveWidget(panel->wrapB, 25, 8); @@ -207,9 +207,9 @@ createPanel(Panel *p) WMResizeWidget(panel->autoB, 440, 32); WMMoveWidget(panel->autoB, 25, 45); WMSetButtonText(panel->autoB, _("Scroll off-screen menus when pointer is moved over them.")); - + WMMapSubwidgets(panel->optF); - + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); @@ -229,10 +229,10 @@ InitMenuPreferences(WMScreen *scr, WMWidget *parent) panel->sectionName = _("Menu Preferences"); panel->description = _("Menu usability related options. Scrolling speed,\n" - "alignment of submenus etc."); + "alignment of submenus etc."); panel->parent = parent; - + panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeData; @@ -240,3 +240,4 @@ InitMenuPreferences(WMScreen *scr, WMWidget *parent) return panel; } + diff --git a/WPrefs.app/MouseSettings.c b/WPrefs.app/MouseSettings.c index 0e1b616b..1b4b4290 100644 --- a/WPrefs.app/MouseSettings.c +++ b/WPrefs.app/MouseSettings.c @@ -1,10 +1,10 @@ /* MouseSettings.c- mouse options (some are equivalent to xset) - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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. */ @@ -45,9 +45,9 @@ typedef struct _Panel { char *description; CallbackRec callbacks; - + WMWidget *parent; - + WMFrame *speedF; WMLabel *speedL; WMSlider *speedS; @@ -55,13 +55,13 @@ typedef struct _Panel { WMTextField *acceT; WMLabel *threL; WMTextField *threT; - + WMFrame *ddelaF; WMButton *ddelaB[5]; WMTextField *ddelaT; WMLabel *ddelaL; DoubleTest *tester; - + WMFrame *menuF; WMLabel *button1L; WMLabel *button2L; @@ -96,7 +96,7 @@ typedef struct _Panel { -static char *modifierNames[8]; +static char *modifierNames[8]; static char *buttonActions[4]; @@ -114,7 +114,7 @@ static void setMouseAccel(WMScreen *scr, float accel, int threshold) { int n, d; - + d = 10; n = accel*d; @@ -132,37 +132,37 @@ speedChange(WMWidget *w, void *data) char *tmp; if (w == NULL) { - float accel; - - tmp = WMGetTextFieldText(panel->acceT); - if (sscanf(tmp, "%f", &accel)!=1 || accel < 0) { - WMRunAlertPanel(WMWidgetScreen(panel->acceT), GetWindow(panel), - _("Error"), - _("Invalid mouse acceleration value. Must be a positive real value."), - _("OK"), NULL, NULL); - wfree(tmp); - return; - } - panel->acceleration = accel; - wfree(tmp); + float accel; + + tmp = WMGetTextFieldText(panel->acceT); + if (sscanf(tmp, "%f", &accel)!=1 || accel < 0) { + WMRunAlertPanel(WMWidgetScreen(panel->acceT), GetWindow(panel), + _("Error"), + _("Invalid mouse acceleration value. Must be a positive real value."), + _("OK"), NULL, NULL); + wfree(tmp); + return; + } + panel->acceleration = accel; + wfree(tmp); } else { - i = (int)WMGetSliderValue(panel->speedS); - - panel->acceleration = 0.25+(i*0.25); + i = (int)WMGetSliderValue(panel->speedS); + + panel->acceleration = 0.25+(i*0.25); - sprintf(buffer, "%.2f", 0.25+(i*0.25)); - WMSetTextFieldText(panel->acceT, buffer); + sprintf(buffer, "%.2f", 0.25+(i*0.25)); + WMSetTextFieldText(panel->acceT, buffer); } tmp = WMGetTextFieldText(panel->threT); - if (sscanf(tmp, "%i", &threshold)!=1 || threshold < 0 - || threshold > panel->maxThreshold) { - WMRunAlertPanel(WMWidgetScreen(panel->parent), GetWindow(panel), _("Error"), - _("Invalid mouse acceleration threshold value. Must be the number of pixels to travel before accelerating."), - _("OK"), NULL, NULL); + if (sscanf(tmp, "%i", &threshold)!=1 || threshold < 0 + || threshold > panel->maxThreshold) { + WMRunAlertPanel(WMWidgetScreen(panel->parent), GetWindow(panel), _("Error"), + _("Invalid mouse acceleration threshold value. Must be the number of pixels to travel before accelerating."), + _("OK"), NULL, NULL); } else { - setMouseAccel(WMWidgetScreen(panel->parent), panel->acceleration, - threshold); + setMouseAccel(WMWidgetScreen(panel->parent), panel->acceleration, + threshold); } wfree(tmp); } @@ -186,11 +186,11 @@ doubleClick(WMWidget *w, void *data) char buffer[32]; for (i=0; i<5; i++) { - if (panel->ddelaB[i]==w) - break; + if (panel->ddelaB[i]==w) + break; } WINGsConfiguration.doubleClickDelay = DELAY(i); - + sprintf(buffer, "%i", DELAY(i)); WMSetTextFieldText(panel->ddelaT, buffer); } @@ -200,16 +200,16 @@ static int getButtonAction(char *str) { if (!str) - return -2; + return -2; if (strcasecmp(str, "None")==0) - return 0; + return 0; else if (strcasecmp(str, "OpenApplicationsMenu")==0) - return 1; + return 1; else if (strcasecmp(str, "OpenWindowListMenu")==0) - return 2; + return 2; else if (strcasecmp(str, "SelectWindows")==0) - return 3; + return 3; else return -1; @@ -220,14 +220,14 @@ static int getWheelAction(char *str) { if (!str) - return -2; + return -2; if (strcasecmp(str, "None")==0) - return 0; + return 0; else if (strcasecmp(str, "SwitchWorkspaces")==0) - return 1; + return 1; else - return -1; + return -1; } @@ -236,9 +236,9 @@ static void getMouseParameters(Display *dpy, float *accel, int *thre) { int n, d; - + XGetPointerControl(dpy, &n, &d, thre); - + *accel = (float)n/(float)d; } @@ -265,7 +265,7 @@ showData(_Panel *panel) a = i; } WMSetPopUpButtonSelectedItem(panel->button1P, a); - + str = GetStringForKey("MouseMiddleButtonAction"); i = getButtonAction(str); if (i<0) { @@ -277,7 +277,7 @@ showData(_Panel *panel) b = i; } WMSetPopUpButtonSelectedItem(panel->button2P, b); - + str = GetStringForKey("MouseRightButtonAction"); i = getButtonAction(str); if (i<0) { @@ -303,12 +303,12 @@ showData(_Panel *panel) WMSetPopUpButtonSelectedItem(panel->wheelP, w); WMSetButtonSelected(panel->disaB, GetBoolForKey("DisableWSMouseActions")); - + /**/ getMouseParameters(dpy, &accel, &a); panel->maxThreshold = WidthOfScreen(DefaultScreenOfDisplay(dpy)); if (a > panel->maxThreshold) { - panel->maxThreshold = a; + panel->maxThreshold = a; } sprintf(buffer, "%i", a); WMSetTextFieldText(panel->threT, buffer); @@ -324,38 +324,38 @@ showData(_Panel *panel) /* find best match */ a = -1; for (i=0; i<5; i++) { - if (DELAY(i) == b) - a = i; + if (DELAY(i) == b) + a = i; } if (a >= 0) - WMPerformButtonClick(panel->ddelaB[a]); + WMPerformButtonClick(panel->ddelaB[a]); sprintf(buffer, "%i", b); WMSetTextFieldText(panel->ddelaT, buffer); /**/ str = GetStringForKey("ModifierKey"); if (!str) - str = "mod1"; + str = "mod1"; a = ModifierFromKey(dpy, str); if (a != -1) { - str = modifierNames[a]; - - a = 0; - for (i=0; igrabP); i++) { - if (strstr(WMGetPopUpButtonItem(panel->grabP, i), str)) { - WMSetPopUpButtonSelectedItem(panel->grabP, i); - a = 1; - break; - } - } + str = modifierNames[a]; + + a = 0; + for (i=0; igrabP); i++) { + if (strstr(WMGetPopUpButtonItem(panel->grabP, i), str)) { + WMSetPopUpButtonSelectedItem(panel->grabP, i); + a = 1; + break; + } + } } if (a < 1) { - sscanf(WMGetPopUpButtonItem(panel->grabP, 0), "%s", buffer); - WMSetPopUpButtonSelectedItem(panel->grabP, 0); - wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"), - str, buffer); + sscanf(WMGetPopUpButtonItem(panel->grabP, 0), "%s", buffer); + WMSetPopUpButtonSelectedItem(panel->grabP, 0); + wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"), + str, buffer); } } @@ -370,84 +370,84 @@ fillModifierPopUp(WMPopUpButton *pop) char *str; char buffer[64]; - + mapping = XGetModifierMapping(dpy); if (!mapping || mapping->max_keypermod==0) { - WMAddPopUpButtonItem(pop, "Mod1"); - WMAddPopUpButtonItem(pop, "Mod2"); - WMAddPopUpButtonItem(pop, "Mod3"); - WMAddPopUpButtonItem(pop, "Mod4"); - WMAddPopUpButtonItem(pop, "Mod5"); - wwarning(_("could not retrieve keyboard modifier mapping")); - return; + WMAddPopUpButtonItem(pop, "Mod1"); + WMAddPopUpButtonItem(pop, "Mod2"); + WMAddPopUpButtonItem(pop, "Mod3"); + WMAddPopUpButtonItem(pop, "Mod4"); + WMAddPopUpButtonItem(pop, "Mod5"); + wwarning(_("could not retrieve keyboard modifier mapping")); + return; } - - + + for (j=0; j<8; j++) { - int idx; - char *array[8]; - int a; - KeySym ksym; - int k; - char *ptr; - char *tmp; - - a = 0; - memset(array, 0, sizeof(char*)*8); - for (i=0; i < mapping->max_keypermod; i++) { - idx = i+j*mapping->max_keypermod; - if (mapping->modifiermap[idx]!=0) { - int l; - for (l=0; l<4; l++) { - ksym = XKeycodeToKeysym(dpy, mapping->modifiermap[idx], l); - if (ksym!=NoSymbol) - break; - } - if (ksym!=NoSymbol) - str = XKeysymToString(ksym); - else - str = NULL; - if (str && !strstr(str, "_Lock") && !strstr(str, "Shift") - && !strstr(str, "Control")) { - array[a++] = wstrdup(str); - } - } - } - - for (k=0; kmax_keypermod; i++) { + idx = i+j*mapping->max_keypermod; + if (mapping->modifiermap[idx]!=0) { + int l; + for (l=0; l<4; l++) { + ksym = XKeycodeToKeysym(dpy, mapping->modifiermap[idx], l); + if (ksym!=NoSymbol) + break; + } + if (ksym!=NoSymbol) + str = XKeysymToString(ksym); + else + str = NULL; + if (str && !strstr(str, "_Lock") && !strstr(str, "Shift") + && !strstr(str, "Control")) { + array[a++] = wstrdup(str); + } + } + } + + for (k=0; k0) { - if (array[a]) - wfree(array[a]); - } + WMAddPopUpButtonItem(pop, buffer); + for (i=k+1; i0) { + if (array[a]) + wfree(array[a]); + } } - + if (mapping) - XFreeModifiermap(mapping); + XFreeModifiermap(mapping); } @@ -466,30 +466,30 @@ createPanel(Panel *p) color.red = 0xae; color.green = 0xaa; color.blue = 0xae; - + panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - + /**************** Mouse Speed ****************/ panel->speedF = WMCreateFrame(panel->box); WMResizeWidget(panel->speedF, 245, 100); WMMoveWidget(panel->speedF, 15, 5); WMSetFrameTitle(panel->speedF, _("Mouse Speed")); - + panel->speedL = WMCreateLabel(panel->speedF); WMResizeWidget(panel->speedL, 40, 46); WMMoveWidget(panel->speedL, 15, 14); WMSetLabelImagePosition(panel->speedL, WIPImageOnly); path = LocateImage(SPEED_ICON_FILE); if (path) { - icon = WMCreateBlendedPixmapFromFile(scr, path, &color); - if (icon) { - WMSetLabelImage(panel->speedL, icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon %s"), path); - } - wfree(path); + icon = WMCreateBlendedPixmapFromFile(scr, path, &color); + if (icon) { + WMSetLabelImage(panel->speedL, icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon %s"), path); + } + wfree(path); } panel->speedS = WMCreateSlider(panel->speedF); @@ -510,7 +510,7 @@ createPanel(Panel *p) WMResizeWidget(panel->acceT, 40, 20); WMMoveWidget(panel->acceT, 80, 65); WMAddNotificationObserver(returnPressed, panel, - WMTextDidEndEditingNotification, panel->acceT); + WMTextDidEndEditingNotification, panel->acceT); panel->threL = WMCreateLabel(panel->speedF); @@ -518,60 +518,60 @@ createPanel(Panel *p) WMMoveWidget(panel->threL, 120, 67); WMSetLabelTextAlignment(panel->threL, WARight); WMSetLabelText(panel->threL, _("Threshold:")); - + panel->threT = WMCreateTextField(panel->speedF); WMResizeWidget(panel->threT, 30, 20); WMMoveWidget(panel->threT, 200, 65); WMAddNotificationObserver(returnPressed, panel, - WMTextDidEndEditingNotification, panel->threT); + WMTextDidEndEditingNotification, panel->threT); WMMapSubwidgets(panel->speedF); - + /***************** Doubleclick Delay ****************/ panel->ddelaF = WMCreateFrame(panel->box); WMResizeWidget(panel->ddelaF, 245, 105); WMMoveWidget(panel->ddelaF, 15, 115); WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay")); - + buf1 = wmalloc(strlen(DELAY_ICON)+2); buf2 = wmalloc(strlen(DELAY_ICON_S)+2); - + for (i = 0; i < 5; i++) { - panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF, - WBBStateChangeMask); - WMResizeWidget(panel->ddelaB[i], 25, 25); - WMMoveWidget(panel->ddelaB[i], 30+(40*i), 25); - WMSetButtonBordered(panel->ddelaB[i], False); - WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly); - WMSetButtonAction(panel->ddelaB[i], doubleClick, panel); - if (i>0) { - WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]); - } - sprintf(buf1, DELAY_ICON, i+1); - sprintf(buf2, DELAY_ICON_S, i+1); - path = LocateImage(buf1); - if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonImage(panel->ddelaB[i], icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); - } - path = LocateImage(buf2); - if (path) { - icon = WMCreatePixmapFromFile(scr, path); - if (icon) { - WMSetButtonAltImage(panel->ddelaB[i], icon); - WMReleasePixmap(icon); - } else { - wwarning(_("could not load icon file %s"), path); - } - wfree(path); - } + panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF, + WBBStateChangeMask); + WMResizeWidget(panel->ddelaB[i], 25, 25); + WMMoveWidget(panel->ddelaB[i], 30+(40*i), 25); + WMSetButtonBordered(panel->ddelaB[i], False); + WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly); + WMSetButtonAction(panel->ddelaB[i], doubleClick, panel); + if (i>0) { + WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]); + } + sprintf(buf1, DELAY_ICON, i+1); + sprintf(buf2, DELAY_ICON_S, i+1); + path = LocateImage(buf1); + if (path) { + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonImage(panel->ddelaB[i], icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); + } + path = LocateImage(buf2); + if (path) { + icon = WMCreatePixmapFromFile(scr, path); + if (icon) { + WMSetButtonAltImage(panel->ddelaB[i], icon); + WMReleasePixmap(icon); + } else { + wwarning(_("could not load icon file %s"), path); + } + wfree(path); + } } wfree(buf1); wfree(buf2); @@ -588,15 +588,15 @@ createPanel(Panel *p) WMResizeWidget(panel->ddelaL, 40, 16); WMMoveWidget(panel->ddelaL, 185, 70); { - WMFont *font; - WMColor *color; - - font = WMSystemFontOfSize(scr, 10); - color = WMDarkGrayColor(scr); - WMSetLabelTextColor(panel->ddelaL, color); - WMSetLabelFont(panel->ddelaL, font); - WMReleaseFont(font); - WMReleaseColor(color); + WMFont *font; + WMColor *color; + + font = WMSystemFontOfSize(scr, 10); + color = WMDarkGrayColor(scr); + WMSetLabelTextColor(panel->ddelaL, color); + WMSetLabelFont(panel->ddelaL, font); + WMReleaseFont(font); + WMReleaseColor(color); } WMSetLabelText(panel->ddelaL, _("msec")); @@ -622,13 +622,13 @@ createPanel(Panel *p) panel->button1P = WMCreatePopUpButton(panel->menuF); WMResizeWidget(panel->button1P, 135, 20); WMMoveWidget(panel->button1P, 95, 45); - + panel->button2L = WMCreateLabel(panel->menuF); WMResizeWidget(panel->button2L, 87, 20); WMMoveWidget(panel->button2L, 5, 73); WMSetLabelTextAlignment(panel->button2L, WARight); WMSetLabelText(panel->button2L, _("Middle Button")); - + panel->button2P = WMCreatePopUpButton(panel->menuF); WMResizeWidget(panel->button2P, 135, 20); WMMoveWidget(panel->button2P, 95, 73); @@ -672,22 +672,22 @@ createPanel(Panel *p) WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier")); WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n" - "involve dragging windows with the mouse,\n" - "clicking inside the window."), - WMWidgetView(panel->grabF)); + "involve dragging windows with the mouse,\n" + "clicking inside the window."), + WMWidgetView(panel->grabF)); panel->grabP = WMCreatePopUpButton(panel->grabF); WMResizeWidget(panel->grabP, 160, 20); WMMoveWidget(panel->grabP, 40, 20); fillModifierPopUp(panel->grabP); - + WMMapSubwidgets(panel->grabF); - + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); - - + + showData(panel); } @@ -700,35 +700,35 @@ storeCommandInScript(char *cmd, char *line) char buffer[128]; path = wstrconcat(wusergnusteppath(), "/Library/WindowMaker/autostart"); - + f = fopen(path, "rb"); if (!f) { - f = fopen(path, "wb"); - if (!f) { - wsyserror(_("could not create %s"), path); - goto end; - } - fprintf(f, "#!/bin/sh\n"); - fputs(line, f); - fputs("\n", f); + f = fopen(path, "wb"); + if (!f) { + wsyserror(_("could not create %s"), path); + goto end; + } + fprintf(f, "#!/bin/sh\n"); + fputs(line, f); + fputs("\n", f); } else { - int len = strlen(cmd); - int ok = 0; - char *tmppath; - FILE *fo; - - tmppath = wstrconcat(wusergnusteppath(), - "/Library/WindowMaker/autostart.tmp"); - fo = fopen(tmppath, "wb"); - if (!fo) { + int len = strlen(cmd); + int ok = 0; + char *tmppath; + FILE *fo; + + tmppath = wstrconcat(wusergnusteppath(), + "/Library/WindowMaker/autostart.tmp"); + fo = fopen(tmppath, "wb"); + if (!fo) { wsyserror(_("could not create temporary file %s"), tmppath); wfree(tmppath); - goto end; - } + goto end; + } - while (!feof(f)) { - if (!fgets(buffer, 127, f)) { - break; + while (!feof(f)) { + if (!fgets(buffer, 127, f)) { + break; } if (buffer[0] == '\n') { /* don't write empty lines, else the file will grow @@ -736,26 +736,26 @@ storeCommandInScript(char *cmd, char *line) */ continue; } - if (strncmp(buffer, cmd, len)==0) { - if (!ok) { - fputs(line, fo); - fputs("\n", fo); - ok = 1; - } - } else { - fputs(buffer, fo); - } - } - if (!ok) { - fputs(line, fo); - fputs("\n", fo); - } - fclose(fo); - - if (rename(tmppath, path)!=0) { - wsyserror(_("could not rename file %s to %s\n"), tmppath, path); - } - wfree(tmppath); + if (strncmp(buffer, cmd, len)==0) { + if (!ok) { + fputs(line, fo); + fputs("\n", fo); + ok = 1; + } + } else { + fputs(buffer, fo); + } + } + if (!ok) { + fputs(line, fo); + fputs("\n", fo); + } + fclose(fo); + + if (rename(tmppath, path)!=0) { + wsyserror(_("could not rename file %s to %s\n"), tmppath, path); + } + wfree(tmppath); } sprintf(buffer, "chmod u+x %s", path); system(buffer); @@ -763,7 +763,7 @@ storeCommandInScript(char *cmd, char *line) end: wfree(path); if (f) - fclose(f); + fclose(f); } @@ -778,22 +778,22 @@ storeData(_Panel *panel) WMUserDefaults *udb = WMGetStandardUserDefaults(); if (!WMGetUDBoolForKey(udb, "NoXSetStuff")) { - tmp = WMGetTextFieldText(panel->threT); - if (strlen(tmp)==0) { - wfree(tmp); - tmp = wstrdup("4"); - } + tmp = WMGetTextFieldText(panel->threT); + if (strlen(tmp)==0) { + wfree(tmp); + tmp = wstrdup("4"); + } - sprintf(buffer, XSET" m %i/%i %s\n", (int)(panel->acceleration*10), - 10, tmp); - storeCommandInScript(XSET" m", buffer); + sprintf(buffer, XSET" m %i/%i %s\n", (int)(panel->acceleration*10), + 10, tmp); + storeCommandInScript(XSET" m", buffer); - wfree(tmp); + wfree(tmp); } tmp = WMGetTextFieldText(panel->ddelaT); if (sscanf(tmp, "%i", &i) == 1 && i > 0) - SetIntegerForKey(i, "DoubleClickTime"); + SetIntegerForKey(i, "DoubleClickTime"); SetBoolForKey(WMGetButtonSelected(panel->disaB), "DisableWSMouseActions"); @@ -802,15 +802,15 @@ storeData(_Panel *panel) i = WMGetPopUpButtonSelectedItem(panel->button2P); SetStringForKey(button[i], "MouseMiddleButtonAction"); - + i = WMGetPopUpButtonSelectedItem(panel->button3P); SetStringForKey(button[i], "MouseRightButtonAction"); - + i = WMGetPopUpButtonSelectedItem(panel->wheelP); SetStringForKey(wheel[i], "MouseWheelAction"); - + tmp = WMGetPopUpButtonItem(panel->grabP, - WMGetPopUpButtonSelectedItem(panel->grabP)); + WMGetPopUpButtonSelectedItem(panel->grabP)); tmp = wstrdup(tmp); p = strchr(tmp, ' '); *p = 0; @@ -849,7 +849,7 @@ InitMouseSettings(WMScreen *scr, WMWidget *parent) panel->sectionName = _("Mouse Preferences"); panel->description = _("Mouse speed/acceleration, double click delay,\n" - "mouse button bindings etc."); + "mouse button bindings etc."); panel->parent = parent; @@ -860,3 +860,4 @@ InitMouseSettings(WMScreen *scr, WMWidget *parent) return panel; } + diff --git a/WPrefs.app/Paths.c b/WPrefs.app/Paths.c index ec4485d8..8a72d4aa 100644 --- a/WPrefs.app/Paths.c +++ b/WPrefs.app/Paths.c @@ -1,9 +1,9 @@ /* Paths.c- pixmap/icon paths - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -29,11 +29,11 @@ typedef struct _Panel { char *sectionName; char *description; - + CallbackRec callbacks; WMWidget *parent; - + WMTabView *tabv; WMFrame *pixF; @@ -67,7 +67,7 @@ addPathToList(WMList *list, int index, char *path) item = WMInsertListItem(list, index, path); if (access(fpath, X_OK)!=0) { - item->uflags = 1; + item->uflags = 1; } wfree(fpath); } @@ -78,36 +78,36 @@ showData(_Panel *panel) { WMPropList *array, *val; int i; - + array = GetObjectForKey("IconPath"); if (!array || !WMIsPLArray(array)) { - if (array) - wwarning(_("bad value in option IconPath. Using default path list")); - addPathToList(panel->icoL, -1, "~/pixmaps"); - addPathToList(panel->icoL, -1, "~/GNUstep/Library/Icons"); - addPathToList(panel->icoL, -1, "/usr/include/X11/pixmaps"); - addPathToList(panel->icoL, -1, "/usr/local/share/WindowMaker/Icons"); - addPathToList(panel->icoL, -1, "/usr/local/share/WindowMaker/Pixmaps"); - addPathToList(panel->icoL, -1, "/usr/share/WindowMaker/Icons"); + if (array) + wwarning(_("bad value in option IconPath. Using default path list")); + addPathToList(panel->icoL, -1, "~/pixmaps"); + addPathToList(panel->icoL, -1, "~/GNUstep/Library/Icons"); + addPathToList(panel->icoL, -1, "/usr/include/X11/pixmaps"); + addPathToList(panel->icoL, -1, "/usr/local/share/WindowMaker/Icons"); + addPathToList(panel->icoL, -1, "/usr/local/share/WindowMaker/Pixmaps"); + addPathToList(panel->icoL, -1, "/usr/share/WindowMaker/Icons"); } else { - for (i=0; iicoL, -1, WMGetFromPLString(val)); - } + for (i=0; iicoL, -1, WMGetFromPLString(val)); + } } array = GetObjectForKey("PixmapPath"); if (!array || !WMIsPLArray(array)) { - if (array) - wwarning(_("bad value in option PixmapPath. Using default path list")); - addPathToList(panel->pixL, -1, "~/pixmaps"); - addPathToList(panel->pixL, -1, "~/GNUstep/Library/WindowMaker/Pixmaps"); - addPathToList(panel->pixL, -1, "/usr/local/share/WindowMaker/Pixmaps"); + if (array) + wwarning(_("bad value in option PixmapPath. Using default path list")); + addPathToList(panel->pixL, -1, "~/pixmaps"); + addPathToList(panel->pixL, -1, "~/GNUstep/Library/WindowMaker/Pixmaps"); + addPathToList(panel->pixL, -1, "/usr/local/share/WindowMaker/Pixmaps"); } else { - for (i=0; ipixL, -1, WMGetFromPLString(val)); - } + for (i=0; ipixL, -1, WMGetFromPLString(val)); + } } } @@ -120,18 +120,18 @@ pushButton(WMWidget *w, void *data) /* icon paths */ if (w == panel->icorB) { - i = WMGetListSelectedItemRow(panel->icoL); + i = WMGetListSelectedItemRow(panel->icoL); - if (i>=0) - WMRemoveListItem(panel->icoL, i); + if (i>=0) + WMRemoveListItem(panel->icoL, i); } /* pixmap paths */ if (w == panel->pixrB) { - i = WMGetListSelectedItemRow(panel->pixL); + i = WMGetListSelectedItemRow(panel->pixL); - if (i>=0) - WMRemoveListItem(panel->pixL, i); + if (i>=0) + WMRemoveListItem(panel->pixL, i); } } @@ -197,9 +197,9 @@ paintItem(WMList *lPtr, int index, Drawable d, char *text, int state, WMRect *re XFillRectangle(dpy, d, WMColorGC(backColor), x, y, width, height); if (state & 1) { - WMDrawString(scr, d, panel->red, panel->font, x+4, y, text, strlen(text)); + WMDrawString(scr, d, panel->red, panel->font, x+4, y, text, strlen(text)); } else { - WMDrawString(scr, d, panel->black, panel->font, x+4, y, text, strlen(text)); + WMDrawString(scr, d, panel->black, panel->font, x+4, y, text, strlen(text)); } } @@ -212,20 +212,20 @@ storeData(_Panel *panel) WMPropList *tmp; int i; char *p; - + list = WMCreatePLArray(NULL, NULL); for (i=0; iicoL); i++) { - p = WMGetListItem(panel->icoL, i)->text; - tmp = WMCreatePLString(p); - WMAddToPLArray(list, tmp); + p = WMGetListItem(panel->icoL, i)->text; + tmp = WMCreatePLString(p); + WMAddToPLArray(list, tmp); } SetObjectForKey(list, "IconPath"); - + list = WMCreatePLArray(NULL, NULL); for (i=0; ipixL); i++) { - p = WMGetListItem(panel->pixL, i)->text; - tmp = WMCreatePLString(p); - WMAddToPLArray(list, tmp); + p = WMGetListItem(panel->pixL, i)->text; + tmp = WMCreatePLString(p); + WMAddToPLArray(list, tmp); } SetObjectForKey(list, "PixmapPath"); } @@ -244,16 +244,16 @@ createPanel(Panel *p) panel->gray = WMGrayColor(scr); panel->red = WMCreateRGBColor(scr, 0xffff, 0, 0, True); panel->font = WMSystemFontOfSize(scr, 12); - + panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - - + + panel->tabv = WMCreateTabView(panel->box); WMMoveWidget(panel->tabv, 12, 10); WMResizeWidget(panel->tabv, 500, 215); - + /* icon path */ panel->icoF = WMCreateFrame(panel->box); @@ -264,13 +264,13 @@ createPanel(Panel *p) WMSetTabViewItemView(tab, WMWidgetView(panel->icoF)); WMAddItemInTabView(panel->tabv, tab); WMSetTabViewItemLabel(tab, _("Icon Search Paths")); - + panel->icoL = WMCreateList(panel->icoF); WMResizeWidget(panel->icoL, 480, 147); WMMoveWidget(panel->icoL, 10, 10); WMSetListUserDrawProc(panel->icoL, paintItem); WMHangData(panel->icoL, panel); - + panel->icoaB = WMCreateCommandButton(panel->icoF); WMResizeWidget(panel->icoaB, 95, 24); WMMoveWidget(panel->icoaB, 293, 165); @@ -290,25 +290,25 @@ createPanel(Panel *p) panel->pixF = WMCreateFrame(panel->box); WMSetFrameRelief(panel->pixF, WRFlat); WMResizeWidget(panel->pixF, 230, 210); - + tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(panel->pixF)); WMAddItemInTabView(panel->tabv, tab); WMSetTabViewItemLabel(tab, _("Pixmap Search Paths")); - + panel->pixL = WMCreateList(panel->pixF); WMResizeWidget(panel->pixL, 480, 147); WMMoveWidget(panel->pixL, 10, 10); WMSetListUserDrawProc(panel->pixL, paintItem); WMHangData(panel->pixL, panel); - + panel->pixaB = WMCreateCommandButton(panel->pixF); WMResizeWidget(panel->pixaB, 95, 24); WMMoveWidget(panel->pixaB, 293, 165); WMSetButtonText(panel->pixaB, _("Add")); WMSetButtonAction(panel->pixaB, browseForFile, panel); WMSetButtonImagePosition(panel->pixaB, WIPRight); - + panel->pixrB = WMCreateCommandButton(panel->pixF); WMResizeWidget(panel->pixrB, 95, 24); WMMoveWidget(panel->pixrB, 395, 165); @@ -317,10 +317,10 @@ createPanel(Panel *p) WMMapSubwidgets(panel->pixF); - + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); - + showData(panel); } @@ -337,14 +337,15 @@ InitPaths(WMScreen *scr, WMWidget *parent) panel->sectionName = _("Search Path Configuration"); panel->description = _("Search paths to use when looking for pixmaps\n" - "and icons."); + "and icons."); panel->parent = parent; panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeData; - + AddSection(panel, ICON_FILE); return panel; } + diff --git a/WPrefs.app/Preferences.c b/WPrefs.app/Preferences.c index 08659b96..fb400280 100644 --- a/WPrefs.app/Preferences.c +++ b/WPrefs.app/Preferences.c @@ -1,9 +1,9 @@ /* Preferences.c- misc personal preferences - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -31,12 +31,12 @@ typedef struct _Panel { char *description; CallbackRec callbacks; - + WMWidget *parent; WMFrame *sizeF; WMPopUpButton *sizeP; - + WMFrame *posiF; WMPopUpButton *posiP; @@ -72,15 +72,15 @@ borderCallback(WMWidget *w, void *data) i = WMGetSliderValue(panel->borderS); if (i == 0) - sprintf(buffer, _("OFF")); + sprintf(buffer, _("OFF")); else if (i == 1) - sprintf(buffer, _("1 pixel")); + sprintf(buffer, _("1 pixel")); else if (i <= 4) - /* 2-4 */ - sprintf(buffer, _("%i pixels"), i); + /* 2-4 */ + sprintf(buffer, _("%i pixels"), i); else - /* >4 */ - sprintf(buffer, _("%i pixels "), i); /* note space! */ + /* >4 */ + sprintf(buffer, _("%i pixels "), i); /* note space! */ WMSetLabelText(panel->borderL, buffer); } @@ -93,29 +93,29 @@ showData(_Panel *panel) str = GetStringForKey("ResizeDisplay"); if (!str) - str = "corner"; + str = "corner"; if (strcasecmp(str, "corner")==0) - WMSetPopUpButtonSelectedItem(panel->sizeP, 0); + WMSetPopUpButtonSelectedItem(panel->sizeP, 0); else if (strcasecmp(str, "center")==0) - WMSetPopUpButtonSelectedItem(panel->sizeP, 1); + WMSetPopUpButtonSelectedItem(panel->sizeP, 1); else if (strcasecmp(str, "floating")==0) - WMSetPopUpButtonSelectedItem(panel->sizeP, 2); + WMSetPopUpButtonSelectedItem(panel->sizeP, 2); else if (strcasecmp(str, "line")==0) - WMSetPopUpButtonSelectedItem(panel->sizeP, 3); + WMSetPopUpButtonSelectedItem(panel->sizeP, 3); else if (strcasecmp(str, "none")==0) - WMSetPopUpButtonSelectedItem(panel->sizeP, 4); - + WMSetPopUpButtonSelectedItem(panel->sizeP, 4); + str = GetStringForKey("MoveDisplay"); if (!str) - str = "corner"; + str = "corner"; if (strcasecmp(str, "corner")==0) - WMSetPopUpButtonSelectedItem(panel->posiP, 0); + WMSetPopUpButtonSelectedItem(panel->posiP, 0); else if (strcasecmp(str, "center")==0) - WMSetPopUpButtonSelectedItem(panel->posiP, 1); + WMSetPopUpButtonSelectedItem(panel->posiP, 1); else if (strcasecmp(str, "floating")==0) - WMSetPopUpButtonSelectedItem(panel->posiP, 2); + WMSetPopUpButtonSelectedItem(panel->posiP, 2); else if (strcasecmp(str, "none")==0) - WMSetPopUpButtonSelectedItem(panel->posiP, 3); + WMSetPopUpButtonSelectedItem(panel->posiP, 3); x = GetIntegerForKey("WorkspaceBorderSize"); x = x<0 ? 0 : x; @@ -154,37 +154,37 @@ storeData(_Panel *panel) Bool lr, tb; switch (WMGetPopUpButtonSelectedItem(panel->sizeP)) { - case 0: - str = "corner"; - break; - case 1: - str = "center"; - break; - case 2: - str = "floating"; - break; - case 4: - str = "none"; - break; - default: - str = "line"; - break; + case 0: + str = "corner"; + break; + case 1: + str = "center"; + break; + case 2: + str = "floating"; + break; + case 4: + str = "none"; + break; + default: + str = "line"; + break; } SetStringForKey(str, "ResizeDisplay"); - + switch (WMGetPopUpButtonSelectedItem(panel->posiP)) { - case 0: - str = "corner"; - break; - case 1: - str = "center"; - break; - case 3: - str = "none"; - break; - default: - str = "floating"; - break; + case 0: + str = "corner"; + break; + case 1: + str = "center"; + break; + case 3: + str = "none"; + break; + default: + str = "floating"; + break; } SetStringForKey(str, "MoveDisplay"); @@ -217,11 +217,11 @@ createPanel(Panel *p) { _Panel *panel = (_Panel*)p; int i; - + panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - - + + /***************** Size Display ****************/ panel->sizeF = WMCreateFrame(panel->box); WMResizeWidget(panel->sizeF, 240, 60); @@ -268,11 +268,11 @@ createPanel(Panel *p) WMResizeWidget(panel->ballF, 235, 125); WMMoveWidget(panel->ballF, 270, 10); WMSetFrameTitle(panel->ballF, _("Show balloon text for...")); - + for (i=0; i<4; i++) { - panel->ballB[i] = WMCreateSwitchButton(panel->ballF); - WMResizeWidget(panel->ballB[i], 205, 20); - WMMoveWidget(panel->ballB[i], 15, 20+i*25); + panel->ballB[i] = WMCreateSwitchButton(panel->ballF); + WMResizeWidget(panel->ballB[i], 205, 20); + WMMoveWidget(panel->ballB[i], 15, 20+i*25); } WMSetButtonText(panel->ballB[0], _("incomplete window titles")); WMSetButtonText(panel->ballB[1], _("miniwindow titles")); @@ -299,13 +299,13 @@ createPanel(Panel *p) #endif WMMapSubwidgets(panel->optF); - + /***************** Workspace border ****************/ panel->borderF = WMCreateFrame(panel->box); WMResizeWidget(panel->borderF, 240, 75); WMMoveWidget(panel->borderF, 20, 145); WMSetFrameTitle(panel->borderF, _("Workspace border")); - + panel->borderS = WMCreateSlider(panel->borderF); WMResizeWidget(panel->borderS, 80, 15); WMMoveWidget(panel->borderS, 20, 20); @@ -329,7 +329,7 @@ createPanel(Panel *p) WMMapSubwidgets(panel->borderF); - + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); @@ -348,10 +348,10 @@ InitPreferences(WMScreen *scr, WMWidget *parent) panel->sectionName = _("Miscellaneous Ergonomic Preferences"); panel->description = _("Various settings like balloon text, geometry\n" - "displays etc."); + "displays etc."); panel->parent = parent; - + panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeData; @@ -359,3 +359,4 @@ InitPreferences(WMScreen *scr, WMWidget *parent) return panel; } + diff --git a/WPrefs.app/TexturePanel.c b/WPrefs.app/TexturePanel.c index ba649cec..058db9aa 100644 --- a/WPrefs.app/TexturePanel.c +++ b/WPrefs.app/TexturePanel.c @@ -1,10 +1,10 @@ /* TexturePanel.c- texture editting panel - * + * * WPrefs - WindowMaker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima * Copyright (c) 1998 James Thompson - * + * * 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. * */ @@ -45,7 +45,7 @@ typedef struct _TexturePanel { /* texture name */ WMFrame *nameF; WMTextField *nameT; - + /* texture type */ WMPopUpButton *typeP; @@ -105,11 +105,11 @@ typedef struct _TexturePanel { WMButton *okB; WMButton *cancelB; - - + + WMCallback *okAction; void *okData; - + WMCallback *cancelAction; void *cancelData; @@ -118,7 +118,7 @@ typedef struct _TexturePanel { int currentType; - + WMPropList *pathList; } _TexturePanel; @@ -157,41 +157,41 @@ updateGradButtons(TexturePanel *panel) colorn = WMGetListNumberOfRows(panel->gcolL); if (colorn < 1) { - pixmap = NULL; + pixmap = NULL; } else { - int i; - WMListItem *item; - - colors = wmalloc(sizeof(RColor*)*(colorn+1)); - - for (i = 0; i < colorn; i++) { - item = WMGetListItem(panel->gcolL, i); - colors[i] = (RColor*)item->clientData; - } - colors[i] = NULL; - - image = RRenderMultiGradient(80, 30, colors, RHorizontalGradient); - pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->gcolL), - image, 128); - RReleaseImage(image); - WMSetButtonImage(panel->dirhB, pixmap); - WMReleasePixmap(pixmap); - - image = RRenderMultiGradient(80, 30, colors, RVerticalGradient); - pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->gcolL), - image, 128); - RReleaseImage(image); - WMSetButtonImage(panel->dirvB, pixmap); - WMReleasePixmap(pixmap); - - image = RRenderMultiGradient(80, 30, colors, RDiagonalGradient); - pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->gcolL), - image, 128); - RReleaseImage(image); - WMSetButtonImage(panel->dirdB, pixmap); - WMReleasePixmap(pixmap); - - wfree(colors); + int i; + WMListItem *item; + + colors = wmalloc(sizeof(RColor*)*(colorn+1)); + + for (i = 0; i < colorn; i++) { + item = WMGetListItem(panel->gcolL, i); + colors[i] = (RColor*)item->clientData; + } + colors[i] = NULL; + + image = RRenderMultiGradient(80, 30, colors, RHorizontalGradient); + pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->gcolL), + image, 128); + RReleaseImage(image); + WMSetButtonImage(panel->dirhB, pixmap); + WMReleasePixmap(pixmap); + + image = RRenderMultiGradient(80, 30, colors, RVerticalGradient); + pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->gcolL), + image, 128); + RReleaseImage(image); + WMSetButtonImage(panel->dirvB, pixmap); + WMReleasePixmap(pixmap); + + image = RRenderMultiGradient(80, 30, colors, RDiagonalGradient); + pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->gcolL), + image, 128); + RReleaseImage(image); + WMSetButtonImage(panel->dirdB, pixmap); + WMReleasePixmap(pixmap); + + wfree(colors); } } @@ -207,8 +207,8 @@ updateTGradImage(TexturePanel *panel) WMColor *color; if (!panel->image) - return; - + return; + color = WMGetColorWellColor(panel->tcol1W); from.red = WMRedComponentOfColor(color)>>8; from.green = WMGreenComponentOfColor(color)>>8; @@ -220,27 +220,27 @@ updateTGradImage(TexturePanel *panel) to.blue = WMBlueComponentOfColor(color)>>8; if (panel->image->width < 141 || panel->image->height < 91) { - image = RMakeTiledImage(panel->image, 141, 91); + image = RMakeTiledImage(panel->image, 141, 91); } else { - image = RCloneImage(panel->image); + image = RCloneImage(panel->image); } if (WMGetButtonSelected(panel->dirhB)) { - gradient = RRenderGradient(image->width, image->height, &from, &to, - RHorizontalGradient); + gradient = RRenderGradient(image->width, image->height, &from, &to, + RHorizontalGradient); } else if (WMGetButtonSelected(panel->dirvB)) { - gradient = RRenderGradient(image->width, image->height, &from, &to, - RVerticalGradient); + gradient = RRenderGradient(image->width, image->height, &from, &to, + RVerticalGradient); } else { - gradient = RRenderGradient(image->width, image->height, &from, &to, - RDiagonalGradient); + gradient = RRenderGradient(image->width, image->height, &from, &to, + RDiagonalGradient); } RCombineImagesWithOpaqueness(image, gradient, - WMGetSliderValue(panel->topaS)); + WMGetSliderValue(panel->topaS)); RReleaseImage(gradient); pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->win), - image, 128); + image, 128); WMSetLabelImage(panel->imageL, pixmap); WMReleasePixmap(pixmap); @@ -270,21 +270,21 @@ updateSGradButtons(TexturePanel *panel) image = RRenderGradient(80, 30, &from, &to, RHorizontalGradient); pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->gcolL), - image, 128); + image, 128); RReleaseImage(image); WMSetButtonImage(panel->dirhB, pixmap); WMReleasePixmap(pixmap); - + image = RRenderGradient(80, 30, &from, &to, RVerticalGradient); pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->gcolL), - image, 128); + image, 128); RReleaseImage(image); WMSetButtonImage(panel->dirvB, pixmap); WMReleasePixmap(pixmap); - + image = RRenderGradient(80, 30, &from, &to, RDiagonalGradient); pixmap = WMCreatePixmapFromRImage(WMWidgetScreen(panel->gcolL), - image, 128); + image, 128); RReleaseImage(image); WMSetButtonImage(panel->dirdB, pixmap); WMReleasePixmap(pixmap); @@ -305,37 +305,37 @@ updateSVSlider(WMSlider *sPtr, Bool saturation, WMFont *font, RHSVColor *hsv) tmp = *hsv; if (saturation) { - tmp.saturation = 0; - RHSVtoRGB(&tmp, &from); - tmp.saturation = 255; - RHSVtoRGB(&tmp, &to); + tmp.saturation = 0; + RHSVtoRGB(&tmp, &from); + tmp.saturation = 255; + RHSVtoRGB(&tmp, &to); } else { - tmp.value = 0; - RHSVtoRGB(&tmp, &from); - tmp.value = 255; - RHSVtoRGB(&tmp, &to); + tmp.value = 0; + RHSVtoRGB(&tmp, &from); + tmp.value = 255; + RHSVtoRGB(&tmp, &to); } image = RRenderGradient(130, 16, &from, &to, RHorizontalGradient); pixmap = WMCreatePixmapFromRImage(scr, image, 128); RReleaseImage(image); if (saturation) - buffer = wstrdup(_("Saturation")); + buffer = wstrdup(_("Saturation")); else - buffer = wstrdup(_("Brightness")); - + buffer = wstrdup(_("Brightness")); + if (hsv->value < 128 || !saturation) { - WMColor *col = WMWhiteColor(scr); - - WMDrawString(scr, WMGetPixmapXID(pixmap), col, font, 2, - (16 - WMFontHeight(font))/2 - 1, buffer, strlen(buffer)); - WMReleaseColor(col); + WMColor *col = WMWhiteColor(scr); + + WMDrawString(scr, WMGetPixmapXID(pixmap), col, font, 2, + (16 - WMFontHeight(font))/2 - 1, buffer, strlen(buffer)); + WMReleaseColor(col); } else { - WMColor *col = WMBlackColor(scr); + WMColor *col = WMBlackColor(scr); - WMDrawString(scr, WMGetPixmapXID(pixmap), col, font, 2, - (16 - WMFontHeight(font))/2 - 1, buffer, strlen(buffer)); - WMReleaseColor(col); + WMDrawString(scr, WMGetPixmapXID(pixmap), col, font, 2, + (16 - WMFontHeight(font))/2 - 1, buffer, strlen(buffer)); + WMReleaseColor(col); } wfree(buffer); WMSetSliderImage(sPtr, pixmap); @@ -366,25 +366,25 @@ updateHueSlider(WMSlider *sPtr, WMFont *font, RHSVColor *hsv) RReleaseImage(image); if (hsv->value < 128) { - WMColor *col = WMWhiteColor(scr); + WMColor *col = WMWhiteColor(scr); - WMDrawString(scr, WMGetPixmapXID(pixmap), col, font, 2, - (16 - WMFontHeight(font))/2 - 1, - _("Hue"), strlen(_("Hue"))); - WMReleaseColor(col); + WMDrawString(scr, WMGetPixmapXID(pixmap), col, font, 2, + (16 - WMFontHeight(font))/2 - 1, + _("Hue"), strlen(_("Hue"))); + WMReleaseColor(col); } else { - WMColor *col = WMBlackColor(scr); + WMColor *col = WMBlackColor(scr); - WMDrawString(scr, WMGetPixmapXID(pixmap), col, font, 2, - (16 - WMFontHeight(font))/2 - 1, - _("Hue"), strlen(_("Hue"))); - WMReleaseColor(col); + WMDrawString(scr, WMGetPixmapXID(pixmap), col, font, 2, + (16 - WMFontHeight(font))/2 - 1, + _("Hue"), strlen(_("Hue"))); + WMReleaseColor(col); } WMSetSliderImage(sPtr, pixmap); WMReleasePixmap(pixmap); for (i = 0; i <= 6; i++) - wfree(colors[i]); + wfree(colors[i]); } @@ -407,47 +407,47 @@ sliderChangeCallback(WMWidget *w, void *data) row = WMGetListSelectedItemRow(panel->gcolL); if (row >= 0) { - RColor *rgb; + RColor *rgb; + + item = WMGetListItem(panel->gcolL, row); - item = WMGetListItem(panel->gcolL, row); + rgb = (RColor*)item->clientData; - rgb = (RColor*)item->clientData; + RHSVtoRGB(&hsv, rgb); - RHSVtoRGB(&hsv, rgb); - - sprintf(item->text, "%02x,%02x,%02x", rgb->red, rgb->green, rgb->blue); + sprintf(item->text, "%02x,%02x,%02x", rgb->red, rgb->green, rgb->blue); } if (w == panel->ghueS) { - updateSVSlider(panel->gsatS, True, panel->listFont, &hsv); - updateSVSlider(panel->gvalS, False, panel->listFont, &hsv); + updateSVSlider(panel->gsatS, True, panel->listFont, &hsv); + updateSVSlider(panel->gvalS, False, panel->listFont, &hsv); } else if (w == panel->gsatS) { - updateHueSlider(panel->ghueS, panel->listFont, &hsv); - updateSVSlider(panel->gvalS, False, panel->listFont, &hsv); + updateHueSlider(panel->ghueS, panel->listFont, &hsv); + updateSVSlider(panel->gvalS, False, panel->listFont, &hsv); } else { - updateHueSlider(panel->ghueS, panel->listFont, &hsv); - updateSVSlider(panel->gsatS, True, panel->listFont, &hsv); + updateHueSlider(panel->ghueS, panel->listFont, &hsv); + updateSVSlider(panel->gsatS, True, panel->listFont, &hsv); } rows = WMGetListNumberOfRows(panel->gcolL); if (rows == 0) - return; + return; colors = wmalloc(sizeof(RColor*)*(rows+1)); for (i = 0; i < rows; i++) { - item = WMGetListItem(panel->gcolL, i); + item = WMGetListItem(panel->gcolL, i); - colors[i] = (RColor*)item->clientData; + colors[i] = (RColor*)item->clientData; } colors[i] = NULL; if (panel->gimage != None) { - XFreePixmap(WMScreenDisplay(scr), panel->gimage); + XFreePixmap(WMScreenDisplay(scr), panel->gimage); } - image = RRenderMultiGradient(30, i*WMGetListItemHeight(panel->gcolL), - colors, RVerticalGradient); + image = RRenderMultiGradient(30, i*WMGetListItemHeight(panel->gcolL), + colors, RVerticalGradient); RConvertImage(WMScreenRContext(scr), image, &panel->gimage); RReleaseImage(image); @@ -460,8 +460,8 @@ sliderChangeCallback(WMWidget *w, void *data) static void -paintGradListItem(WMList *lPtr, int index, Drawable d, char *text, int state, - WMRect *rect) +paintGradListItem(WMList *lPtr, int index, Drawable d, char *text, int state, + WMRect *rect) { TexturePanel *panel = (TexturePanel*)WMGetHangedData(lPtr); WMScreen *scr = WMWidgetScreen(lPtr); @@ -487,8 +487,8 @@ paintGradListItem(WMList *lPtr, int index, Drawable d, char *text, int state, item = WMGetListItem(lPtr, index); if (panel->gimage) { - XCopyArea(WMScreenDisplay(scr), panel->gimage, d, WMColorGC(white), - 0, height*index, 30, height, x + 5, y); + XCopyArea(WMScreenDisplay(scr), panel->gimage, d, WMColorGC(white), + 0, height*index, 30, height, x + 5, y); } WMDrawString(scr, d, black, panel->listFont, x + 40, y + 1, text, strlen(text)); @@ -535,7 +535,7 @@ gradClickCallback(WMWidget *w, void *data) row = WMGetListSelectedItemRow(w); if (row < 0) - return; + return; item = WMGetListItem(panel->gcolL, row); RRGBtoHSV((RColor*)item->clientData, &hsv); @@ -558,7 +558,7 @@ gradDeleteCallback(WMWidget *w, void *data) row = WMGetListSelectedItemRow(panel->gcolL); if (row < 0) - return; + return; item = WMGetListItem(panel->gcolL, row); wfree(item->clientData); @@ -605,44 +605,44 @@ updateImage(TexturePanel *panel, char *path) WMSize size; if (path) { - image = RLoadImage(WMScreenRContext(scr), path, 0); - if (!image) { - char *message; - - message = wstrconcat(_("Could not load the selected file: "), - (char*)RMessageForError(RErrorCode)); + image = RLoadImage(WMScreenRContext(scr), path, 0); + if (!image) { + char *message; - WMRunAlertPanel(scr, panel->win, _("Error"), message, - _("OK"), NULL, NULL); + message = wstrconcat(_("Could not load the selected file: "), + (char*)RMessageForError(RErrorCode)); - if (!panel->image) - WMSetButtonEnabled(panel->okB, False); + WMRunAlertPanel(scr, panel->win, _("Error"), message, + _("OK"), NULL, NULL); + + if (!panel->image) + WMSetButtonEnabled(panel->okB, False); wfree(message); return; - } + } - WMSetButtonEnabled(panel->okB, True); + WMSetButtonEnabled(panel->okB, True); - if (panel->image) - RReleaseImage(panel->image); - panel->image = image; + if (panel->image) + RReleaseImage(panel->image); + panel->image = image; } else { - image = panel->image; + image = panel->image; } - + if (WMGetPopUpButtonSelectedItem(panel->typeP) == TYPE_PIXMAP) { - if (image) { - pixmap = WMCreatePixmapFromRImage(scr, image, 128); - - size = WMGetPixmapSize(pixmap); - WMSetLabelImage(panel->imageL, pixmap); - WMResizeWidget(panel->imageL, size.width, size.height); - - WMReleasePixmap(pixmap); - } + if (image) { + pixmap = WMCreatePixmapFromRImage(scr, image, 128); + + size = WMGetPixmapSize(pixmap); + WMSetLabelImage(panel->imageL, pixmap); + WMResizeWidget(panel->imageL, size.width, size.height); + + WMReleasePixmap(pixmap); + } } else { - updateTGradImage(panel); + updateTGradImage(panel); } } @@ -660,49 +660,49 @@ browseImageCallback(WMWidget *w, void *data) WMSetFilePanelCanChooseFiles(opanel, True); if (!ipath) - ipath = wstrdup(wgethomedir()); - + ipath = wstrdup(wgethomedir()); + if (WMRunModalFilePanelForDirectory(opanel, panel->win, ipath, - _("Open Image"), NULL)) { - char *path, *fullpath; - char *tmp, *tmp2; - - tmp = WMGetFilePanelFileName(opanel); - if (!tmp) - return; - fullpath = tmp; - - wfree(ipath); - ipath = fullpath; - - path = wstrdup(fullpath); - - tmp2 = strrchr(fullpath, '/'); - if (tmp2) - tmp2++; - - tmp = wfindfileinarray(panel->pathList, tmp2); - - if (tmp) { - if (strcmp(fullpath, tmp)==0) { - wfree(path); - path = tmp2; - } - wfree(tmp); - } - - if (!RGetImageFileFormat(fullpath)) { - WMRunAlertPanel(scr, panel->win, _("Error"), - _("The selected file does not contain a supported image."), - _("OK"), NULL, NULL); - wfree(path); - } else { - updateImage(panel, fullpath); - wfree(panel->imageFile); - panel->imageFile = path; - - WMSetTextFieldText(panel->imageT, path); - } + _("Open Image"), NULL)) { + char *path, *fullpath; + char *tmp, *tmp2; + + tmp = WMGetFilePanelFileName(opanel); + if (!tmp) + return; + fullpath = tmp; + + wfree(ipath); + ipath = fullpath; + + path = wstrdup(fullpath); + + tmp2 = strrchr(fullpath, '/'); + if (tmp2) + tmp2++; + + tmp = wfindfileinarray(panel->pathList, tmp2); + + if (tmp) { + if (strcmp(fullpath, tmp)==0) { + wfree(path); + path = tmp2; + } + wfree(tmp); + } + + if (!RGetImageFileFormat(fullpath)) { + WMRunAlertPanel(scr, panel->win, _("Error"), + _("The selected file does not contain a supported image."), + _("OK"), NULL, NULL); + wfree(path); + } else { + updateImage(panel, fullpath); + wfree(panel->imageFile); + panel->imageFile = path; + + WMSetTextFieldText(panel->imageT, path); + } } } @@ -712,11 +712,11 @@ static void buttonCallback(WMWidget *w, void *data) { TexturePanel *panel = (TexturePanel*)data; - + if (w == panel->okB) { - (*panel->okAction)(panel->okData); + (*panel->okAction)(panel->okData); } else { - (*panel->cancelAction)(panel->cancelData); + (*panel->cancelAction)(panel->cancelData); } } @@ -731,40 +731,40 @@ changeTypeCallback(WMWidget *w, void *data) newType = WMGetPopUpButtonSelectedItem(w); if (newType == panel->currentType) - return; + return; if (panel->currentType >= 0) { - for (i = 0; i < MAX_SECTION_PARTS; i++) { - if (panel->sectionParts[panel->currentType][i] == NULL) - break; - WMUnmapWidget(panel->sectionParts[panel->currentType][i]); - } + for (i = 0; i < MAX_SECTION_PARTS; i++) { + if (panel->sectionParts[panel->currentType][i] == NULL) + break; + WMUnmapWidget(panel->sectionParts[panel->currentType][i]); + } } for (i = 0; i < MAX_SECTION_PARTS; i++) { - if (panel->sectionParts[newType][i] == NULL) - break; - WMMapWidget(panel->sectionParts[newType][i]); + if (panel->sectionParts[newType][i] == NULL) + break; + WMMapWidget(panel->sectionParts[newType][i]); } panel->currentType = newType; switch (newType) { - case TYPE_SGRADIENT: - updateSGradButtons(panel); - WMSetButtonEnabled(panel->okB, True); - break; - case TYPE_GRADIENT: - updateGradButtons(panel); - WMSetButtonEnabled(panel->okB, WMGetListNumberOfRows(panel->gcolL)>1); - break; - case TYPE_TGRADIENT: - case TYPE_PIXMAP: - updateImage(panel, NULL); - WMSetButtonEnabled(panel->okB, panel->image!=NULL); - break; - default: - WMSetButtonEnabled(panel->okB, True); - break; + case TYPE_SGRADIENT: + updateSGradButtons(panel); + WMSetButtonEnabled(panel->okB, True); + break; + case TYPE_GRADIENT: + updateGradButtons(panel); + WMSetButtonEnabled(panel->okB, WMGetListNumberOfRows(panel->gcolL)>1); + break; + case TYPE_TGRADIENT: + case TYPE_PIXMAP: + updateImage(panel, NULL); + WMSetButtonEnabled(panel->okB, panel->image!=NULL); + break; + default: + WMSetButtonEnabled(panel->okB, True); + break; } } @@ -788,8 +788,8 @@ ShowTexturePanel(TexturePanel *panel) Screen *scr = DefaultScreenOfDisplay(dpy); WMSetWindowInitialPosition(panel->win, - (WidthOfScreen(scr)-WMWidgetWidth(panel->win))/2, - (HeightOfScreen(scr)-WMWidgetHeight(panel->win))/2); + (WidthOfScreen(scr)-WMWidgetWidth(panel->win))/2, + (HeightOfScreen(scr)-WMWidgetHeight(panel->win))/2); WMMapWidget(panel->win); } @@ -831,240 +831,240 @@ SetTexturePanelTexture(TexturePanel *panel, char *name, WMPropList *texture) WMSetTextFieldText(panel->nameT, name); if (!texture) - return; + return; p = WMGetFromPLArray(texture, 0); if (!p) { - goto bad_texture; + goto bad_texture; } type = WMGetFromPLString(p); /*...............................................*/ if (strcasecmp(type, "solid")==0) { - WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_SOLID); + WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_SOLID); - p = WMGetFromPLArray(texture, 1); - if (!p) { - str = "black"; - } else { - str = WMGetFromPLString(p); - } - color = WMCreateNamedColor(scr, str, False); + p = WMGetFromPLArray(texture, 1); + if (!p) { + str = "black"; + } else { + str = WMGetFromPLString(p); + } + color = WMCreateNamedColor(scr, str, False); - WMSetColorWellColor(panel->defcW, color); + WMSetColorWellColor(panel->defcW, color); - WMReleaseColor(color); - /*...............................................*/ + WMReleaseColor(color); + /*...............................................*/ } else if (strcasecmp(type, "hgradient")==0 - || strcasecmp(type, "vgradient")==0 - || strcasecmp(type, "dgradient")==0) { + || strcasecmp(type, "vgradient")==0 + || strcasecmp(type, "dgradient")==0) { - WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_SGRADIENT); + WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_SGRADIENT); - p = WMGetFromPLArray(texture, 1); - if (!p) { - str = "black"; - } else { - str = WMGetFromPLString(p); - } - color = WMCreateNamedColor(scr, str, False); + p = WMGetFromPLArray(texture, 1); + if (!p) { + str = "black"; + } else { + str = WMGetFromPLString(p); + } + color = WMCreateNamedColor(scr, str, False); - WMSetColorWellColor(panel->tcol1W, color); + WMSetColorWellColor(panel->tcol1W, color); - WMReleaseColor(color); + WMReleaseColor(color); - p = WMGetFromPLArray(texture, 2); - if (!p) { - str = "black"; - } else { - str = WMGetFromPLString(p); - } - color = WMCreateNamedColor(scr, str, False); + p = WMGetFromPLArray(texture, 2); + if (!p) { + str = "black"; + } else { + str = WMGetFromPLString(p); + } + color = WMCreateNamedColor(scr, str, False); - WMSetColorWellColor(panel->tcol2W, color); + WMSetColorWellColor(panel->tcol2W, color); - WMReleaseColor(color); + WMReleaseColor(color); - gradient = type[0]; - /*...............................................*/ + gradient = type[0]; + /*...............................................*/ } else if (strcasecmp(type, "thgradient")==0 - || strcasecmp(type, "tvgradient")==0 - || strcasecmp(type, "tdgradient")==0) { - int i; - - WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_TGRADIENT); - - gradient = type[1]; - - WMSetTextFieldText(panel->imageT, - WMGetFromPLString(WMGetFromPLArray(texture, 1))); - if (panel->imageFile) - wfree(panel->imageFile); - panel->imageFile = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 1))); - - - i = 180; - sscanf(WMGetFromPLString(WMGetFromPLArray(texture, 2)), "%i", &i); - WMSetSliderValue(panel->topaS, i); - - p = WMGetFromPLArray(texture, 3); - if (!p) { - str = "black"; - } else { - str = WMGetFromPLString(p); - } - color = WMCreateNamedColor(scr, str, False); - - WMSetColorWellColor(panel->tcol1W, color); - - WMReleaseColor(color); - - p = WMGetFromPLArray(texture, 4); - if (!p) { - str = "black"; - } else { - str = WMGetFromPLString(p); - } - color = WMCreateNamedColor(scr, str, False); - - WMSetColorWellColor(panel->tcol2W, color); - - WMReleaseColor(color); - - WMSetTextFieldText(panel->imageT, - WMGetFromPLString(WMGetFromPLArray(texture, 1))); - - if (panel->imageFile) - wfree(panel->imageFile); - if ((panel->imageFile = wfindfileinarray(panel->pathList, - WMGetFromPLString(WMGetFromPLArray(texture, 1)))) != NULL) { - - panel->image = RLoadImage(WMScreenRContext(scr), panel->imageFile, 0); - updateTGradImage(panel); + || strcasecmp(type, "tvgradient")==0 + || strcasecmp(type, "tdgradient")==0) { + int i; - updateSGradButtons(panel); - } else wwarning(_("could not load file '%s': %s"), panel->imageFile, - RMessageForError(RErrorCode)); + WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_TGRADIENT); - /*...............................................*/ - } else if (strcasecmp(type, "mhgradient")==0 - || strcasecmp(type, "mvgradient")==0 - || strcasecmp(type, "mdgradient")==0) { - WMListItem *item; + gradient = type[1]; - for (i = 0; i < WMGetListNumberOfRows(panel->gcolL); i++) { - item = WMGetListItem(panel->gcolL, i); - wfree(item->clientData); - } - WMClearList(panel->gcolL); + WMSetTextFieldText(panel->imageT, + WMGetFromPLString(WMGetFromPLArray(texture, 1))); + if (panel->imageFile) + wfree(panel->imageFile); + panel->imageFile = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 1))); - WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_GRADIENT); - p = WMGetFromPLArray(texture, 1); - if (!p) { - str = "black"; - } else { - str = WMGetFromPLString(p); - } - color = WMCreateNamedColor(scr, str, False); + i = 180; + sscanf(WMGetFromPLString(WMGetFromPLArray(texture, 2)), "%i", &i); + WMSetSliderValue(panel->topaS, i); - WMSetColorWellColor(panel->defcW, color); + p = WMGetFromPLArray(texture, 3); + if (!p) { + str = "black"; + } else { + str = WMGetFromPLString(p); + } + color = WMCreateNamedColor(scr, str, False); - WMReleaseColor(color); + WMSetColorWellColor(panel->tcol1W, color); - for (i = 2; i < WMGetPropListItemCount(texture); i++) { - RColor *rgb; - XColor xcolor; + WMReleaseColor(color); - p = WMGetFromPLArray(texture, i); - if (!p) { - str = "black"; - } else { - str = WMGetFromPLString(p); - } + p = WMGetFromPLArray(texture, 4); + if (!p) { + str = "black"; + } else { + str = WMGetFromPLString(p); + } + color = WMCreateNamedColor(scr, str, False); - XParseColor(WMScreenDisplay(scr), WMScreenRContext(scr)->cmap, - str, &xcolor); + WMSetColorWellColor(panel->tcol2W, color); - rgb = wmalloc(sizeof(RColor)); - rgb->red = xcolor.red >> 8; - rgb->green = xcolor.green >> 8; - rgb->blue = xcolor.blue >> 8; - sprintf(buffer, "%02x,%02x,%02x", rgb->red, rgb->green, rgb->blue); + WMReleaseColor(color); - item = WMAddListItem(panel->gcolL, buffer); - item->clientData = rgb; - } + WMSetTextFieldText(panel->imageT, + WMGetFromPLString(WMGetFromPLArray(texture, 1))); - sliderChangeCallback(panel->ghueS, panel); + if (panel->imageFile) + wfree(panel->imageFile); + if ((panel->imageFile = wfindfileinarray(panel->pathList, + WMGetFromPLString(WMGetFromPLArray(texture, 1)))) != NULL) { - gradient = type[1]; - /*...............................................*/ + panel->image = RLoadImage(WMScreenRContext(scr), panel->imageFile, 0); + updateTGradImage(panel); + + updateSGradButtons(panel); + } else wwarning(_("could not load file '%s': %s"), panel->imageFile, + RMessageForError(RErrorCode)); + + /*...............................................*/ + } else if (strcasecmp(type, "mhgradient")==0 + || strcasecmp(type, "mvgradient")==0 + || strcasecmp(type, "mdgradient")==0) { + WMListItem *item; + + for (i = 0; i < WMGetListNumberOfRows(panel->gcolL); i++) { + item = WMGetListItem(panel->gcolL, i); + wfree(item->clientData); + } + WMClearList(panel->gcolL); + + WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_GRADIENT); + + p = WMGetFromPLArray(texture, 1); + if (!p) { + str = "black"; + } else { + str = WMGetFromPLString(p); + } + color = WMCreateNamedColor(scr, str, False); + + WMSetColorWellColor(panel->defcW, color); + + WMReleaseColor(color); + + for (i = 2; i < WMGetPropListItemCount(texture); i++) { + RColor *rgb; + XColor xcolor; + + p = WMGetFromPLArray(texture, i); + if (!p) { + str = "black"; + } else { + str = WMGetFromPLString(p); + } + + XParseColor(WMScreenDisplay(scr), WMScreenRContext(scr)->cmap, + str, &xcolor); + + rgb = wmalloc(sizeof(RColor)); + rgb->red = xcolor.red >> 8; + rgb->green = xcolor.green >> 8; + rgb->blue = xcolor.blue >> 8; + sprintf(buffer, "%02x,%02x,%02x", rgb->red, rgb->green, rgb->blue); + + item = WMAddListItem(panel->gcolL, buffer); + item->clientData = rgb; + } + + sliderChangeCallback(panel->ghueS, panel); + + gradient = type[1]; + /*...............................................*/ } else if (strcasecmp(type, "cpixmap")==0 - || strcasecmp(type, "spixmap")==0 - || strcasecmp(type, "mpixmap")==0 - || strcasecmp(type, "tpixmap")==0) { - - WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_PIXMAP); - - switch (toupper(type[0])) { - case 'C': - WMSetPopUpButtonSelectedItem(panel->arrP, PTYPE_CENTER); - break; - case 'S': - WMSetPopUpButtonSelectedItem(panel->arrP, PTYPE_SCALE); - break; - case 'M': - WMSetPopUpButtonSelectedItem(panel->arrP, PTYPE_MAXIMIZE); - break; - default: - case 'T': - WMSetPopUpButtonSelectedItem(panel->arrP, PTYPE_TILE); - break; - } - - WMSetTextFieldText(panel->imageT, - WMGetFromPLString(WMGetFromPLArray(texture, 1))); - - if (panel->imageFile) - wfree(panel->imageFile); - panel->imageFile = wfindfileinarray(panel->pathList, - WMGetFromPLString(WMGetFromPLArray(texture, 1))); - - color = WMCreateNamedColor(scr, - WMGetFromPLString(WMGetFromPLArray(texture, 2)), False); - WMSetColorWellColor(panel->defcW, color); - WMReleaseColor(color); - - updateImage(panel, panel->imageFile); + || strcasecmp(type, "spixmap")==0 + || strcasecmp(type, "mpixmap")==0 + || strcasecmp(type, "tpixmap")==0) { + + WMSetPopUpButtonSelectedItem(panel->typeP, TYPE_PIXMAP); + + switch (toupper(type[0])) { + case 'C': + WMSetPopUpButtonSelectedItem(panel->arrP, PTYPE_CENTER); + break; + case 'S': + WMSetPopUpButtonSelectedItem(panel->arrP, PTYPE_SCALE); + break; + case 'M': + WMSetPopUpButtonSelectedItem(panel->arrP, PTYPE_MAXIMIZE); + break; + default: + case 'T': + WMSetPopUpButtonSelectedItem(panel->arrP, PTYPE_TILE); + break; + } + + WMSetTextFieldText(panel->imageT, + WMGetFromPLString(WMGetFromPLArray(texture, 1))); + + if (panel->imageFile) + wfree(panel->imageFile); + panel->imageFile = wfindfileinarray(panel->pathList, + WMGetFromPLString(WMGetFromPLArray(texture, 1))); + + color = WMCreateNamedColor(scr, + WMGetFromPLString(WMGetFromPLArray(texture, 2)), False); + WMSetColorWellColor(panel->defcW, color); + WMReleaseColor(color); + + updateImage(panel, panel->imageFile); } changeTypeCallback(panel->typeP, panel); if (gradient > 0) { - updateGradButtons(panel); - - switch (toupper(gradient)) { - case 'H': - WMPerformButtonClick(panel->dirhB); - break; - case 'V': - WMPerformButtonClick(panel->dirvB); - break; - default: - case 'D': - WMPerformButtonClick(panel->dirdB); - break; - } + updateGradButtons(panel); + + switch (toupper(gradient)) { + case 'H': + WMPerformButtonClick(panel->dirhB); + break; + case 'V': + WMPerformButtonClick(panel->dirvB); + break; + default: + case 'D': + WMPerformButtonClick(panel->dirdB); + break; + } } return; - bad_texture: - str = WMGetPropListDescription(texture, False); - wwarning(_("error creating texture %s"), str); - wfree(str); + bad_texture: + str = WMGetPropListDescription(texture, False); + wwarning(_("error creating texture %s"), str); + wfree(str); } @@ -1090,130 +1090,130 @@ GetTexturePanelTexture(TexturePanel *panel) switch (WMGetPopUpButtonSelectedItem(panel->typeP)) { - case TYPE_SOLID: - color = WMGetColorWellColor(panel->defcW); - str = WMGetColorRGBDescription(color); - prop = WMCreatePLArray(WMCreatePLString("solid"), - WMCreatePLString(str), NULL); - wfree(str); - - break; - - case TYPE_PIXMAP: - color = WMGetColorWellColor(panel->defcW); - str = WMGetColorRGBDescription(color); - - switch (WMGetPopUpButtonSelectedItem(panel->arrP)) { - case PTYPE_SCALE: - prop = WMCreatePLArray(WMCreatePLString("spixmap"), - WMCreatePLString(panel->imageFile), - WMCreatePLString(str), NULL); - break; - case PTYPE_MAXIMIZE: - prop = WMCreatePLArray(WMCreatePLString("mpixmap"), - WMCreatePLString(panel->imageFile), - WMCreatePLString(str), NULL); - break; - case PTYPE_CENTER: - prop = WMCreatePLArray(WMCreatePLString("cpixmap"), - WMCreatePLString(panel->imageFile), - WMCreatePLString(str), NULL); - break; - case PTYPE_TILE: - prop = WMCreatePLArray(WMCreatePLString("tpixmap"), - WMCreatePLString(panel->imageFile), - WMCreatePLString(str), NULL); - break; - } - wfree(str); - break; - - case TYPE_TGRADIENT: - color = WMGetColorWellColor(panel->tcol1W); - str = WMGetColorRGBDescription(color); - - color = WMGetColorWellColor(panel->tcol2W); - str2 = WMGetColorRGBDescription(color); - - sprintf(buff, "%i", WMGetSliderValue(panel->topaS)); - - if (WMGetButtonSelected(panel->dirdB)) { - prop = WMCreatePLArray(WMCreatePLString("tdgradient"), - WMCreatePLString(panel->imageFile), - WMCreatePLString(buff), - WMCreatePLString(str), - WMCreatePLString(str2), NULL); - } else if (WMGetButtonSelected(panel->dirvB)) { - prop = WMCreatePLArray(WMCreatePLString("tvgradient"), - WMCreatePLString(panel->imageFile), - WMCreatePLString(buff), - WMCreatePLString(str), - WMCreatePLString(str2), NULL); - } else { - prop = WMCreatePLArray(WMCreatePLString("thgradient"), - WMCreatePLString(panel->imageFile), - WMCreatePLString(buff), - WMCreatePLString(str), - WMCreatePLString(str2), NULL); - } - wfree(str); - wfree(str2); - break; - - - case TYPE_SGRADIENT: - color = WMGetColorWellColor(panel->tcol1W); - str = WMGetColorRGBDescription(color); - - color = WMGetColorWellColor(panel->tcol2W); - str2 = WMGetColorRGBDescription(color); - - if (WMGetButtonSelected(panel->dirdB)) { - prop = WMCreatePLArray(WMCreatePLString("dgradient"), - WMCreatePLString(str), - WMCreatePLString(str2), NULL); - } else if (WMGetButtonSelected(panel->dirvB)) { - prop = WMCreatePLArray(WMCreatePLString("vgradient"), - WMCreatePLString(str), - WMCreatePLString(str2), NULL); - } else { - prop = WMCreatePLArray(WMCreatePLString("hgradient"), - WMCreatePLString(str), - WMCreatePLString(str2), NULL); - } - wfree(str); - wfree(str2); - break; - - case TYPE_GRADIENT: - color = WMGetColorWellColor(panel->defcW); - str = WMGetColorRGBDescription(color); - - if (WMGetButtonSelected(panel->dirdB)) { - prop = WMCreatePLArray(WMCreatePLString("mdgradient"), - WMCreatePLString(str), NULL); - } else if (WMGetButtonSelected(panel->dirvB)) { - prop = WMCreatePLArray(WMCreatePLString("mvgradient"), - WMCreatePLString(str), NULL); - } else { - prop = WMCreatePLArray(WMCreatePLString("mhgradient"), - WMCreatePLString(str), NULL); - } - wfree(str); - - for (i = 0; i < WMGetListNumberOfRows(panel->gcolL); i++) { - RColor *rgb; - WMListItem *item; - - item = WMGetListItem(panel->gcolL, i); - - rgb = (RColor*)item->clientData; - - sprintf(buff, "#%02x%02x%02x", rgb->red, rgb->green, rgb->blue); - - WMAddToPLArray(prop, WMCreatePLString(buff)); - } - break; + case TYPE_SOLID: + color = WMGetColorWellColor(panel->defcW); + str = WMGetColorRGBDescription(color); + prop = WMCreatePLArray(WMCreatePLString("solid"), + WMCreatePLString(str), NULL); + wfree(str); + + break; + + case TYPE_PIXMAP: + color = WMGetColorWellColor(panel->defcW); + str = WMGetColorRGBDescription(color); + + switch (WMGetPopUpButtonSelectedItem(panel->arrP)) { + case PTYPE_SCALE: + prop = WMCreatePLArray(WMCreatePLString("spixmap"), + WMCreatePLString(panel->imageFile), + WMCreatePLString(str), NULL); + break; + case PTYPE_MAXIMIZE: + prop = WMCreatePLArray(WMCreatePLString("mpixmap"), + WMCreatePLString(panel->imageFile), + WMCreatePLString(str), NULL); + break; + case PTYPE_CENTER: + prop = WMCreatePLArray(WMCreatePLString("cpixmap"), + WMCreatePLString(panel->imageFile), + WMCreatePLString(str), NULL); + break; + case PTYPE_TILE: + prop = WMCreatePLArray(WMCreatePLString("tpixmap"), + WMCreatePLString(panel->imageFile), + WMCreatePLString(str), NULL); + break; + } + wfree(str); + break; + + case TYPE_TGRADIENT: + color = WMGetColorWellColor(panel->tcol1W); + str = WMGetColorRGBDescription(color); + + color = WMGetColorWellColor(panel->tcol2W); + str2 = WMGetColorRGBDescription(color); + + sprintf(buff, "%i", WMGetSliderValue(panel->topaS)); + + if (WMGetButtonSelected(panel->dirdB)) { + prop = WMCreatePLArray(WMCreatePLString("tdgradient"), + WMCreatePLString(panel->imageFile), + WMCreatePLString(buff), + WMCreatePLString(str), + WMCreatePLString(str2), NULL); + } else if (WMGetButtonSelected(panel->dirvB)) { + prop = WMCreatePLArray(WMCreatePLString("tvgradient"), + WMCreatePLString(panel->imageFile), + WMCreatePLString(buff), + WMCreatePLString(str), + WMCreatePLString(str2), NULL); + } else { + prop = WMCreatePLArray(WMCreatePLString("thgradient"), + WMCreatePLString(panel->imageFile), + WMCreatePLString(buff), + WMCreatePLString(str), + WMCreatePLString(str2), NULL); + } + wfree(str); + wfree(str2); + break; + + + case TYPE_SGRADIENT: + color = WMGetColorWellColor(panel->tcol1W); + str = WMGetColorRGBDescription(color); + + color = WMGetColorWellColor(panel->tcol2W); + str2 = WMGetColorRGBDescription(color); + + if (WMGetButtonSelected(panel->dirdB)) { + prop = WMCreatePLArray(WMCreatePLString("dgradient"), + WMCreatePLString(str), + WMCreatePLString(str2), NULL); + } else if (WMGetButtonSelected(panel->dirvB)) { + prop = WMCreatePLArray(WMCreatePLString("vgradient"), + WMCreatePLString(str), + WMCreatePLString(str2), NULL); + } else { + prop = WMCreatePLArray(WMCreatePLString("hgradient"), + WMCreatePLString(str), + WMCreatePLString(str2), NULL); + } + wfree(str); + wfree(str2); + break; + + case TYPE_GRADIENT: + color = WMGetColorWellColor(panel->defcW); + str = WMGetColorRGBDescription(color); + + if (WMGetButtonSelected(panel->dirdB)) { + prop = WMCreatePLArray(WMCreatePLString("mdgradient"), + WMCreatePLString(str), NULL); + } else if (WMGetButtonSelected(panel->dirvB)) { + prop = WMCreatePLArray(WMCreatePLString("mvgradient"), + WMCreatePLString(str), NULL); + } else { + prop = WMCreatePLArray(WMCreatePLString("mhgradient"), + WMCreatePLString(str), NULL); + } + wfree(str); + + for (i = 0; i < WMGetListNumberOfRows(panel->gcolL); i++) { + RColor *rgb; + WMListItem *item; + + item = WMGetListItem(panel->gcolL, i); + + rgb = (RColor*)item->clientData; + + sprintf(buff, "#%02x%02x%02x", rgb->red, rgb->green, rgb->blue); + + WMAddToPLArray(prop, WMCreatePLString(buff)); + } + break; } @@ -1244,13 +1244,13 @@ CreateTexturePanel(WMWindow *keyWindow) panel->win = WMCreatePanelWithStyleForWindow(keyWindow, "texturePanel", - WMTitledWindowMask - |WMClosableWindowMask); - /* - panel->win = WMCreateWindowWithStyle(scr, "texturePanel", - WMTitledWindowMask - |WMClosableWindowMask); - */ + WMTitledWindowMask + |WMClosableWindowMask); + /* + panel->win = WMCreateWindowWithStyle(scr, "texturePanel", + WMTitledWindowMask + |WMClosableWindowMask); + */ WMResizeWidget(panel->win, 325, 423); WMSetWindowTitle(panel->win, _("Texture Panel")); @@ -1311,7 +1311,7 @@ CreateTexturePanel(WMWindow *keyWindow) WMMoveWidget(panel->gcolaB, 10, 170); WMSetButtonText(panel->gcolaB, _("Add")); WMSetButtonAction(panel->gcolaB, gradAddCallback, panel); - + panel->gcoldB = WMCreateCommandButton(panel->gcolF); WMResizeWidget(panel->gcoldB, 64, 24); WMMoveWidget(panel->gcoldB, 75, 170); @@ -1326,21 +1326,21 @@ CreateTexturePanel(WMWindow *keyWindow) WMSetSliderMaxValue(panel->gbriS, 100); WMSetSliderAction(panel->gbriS, sliderChangeCallback, panel); { - WMPixmap *pixmap; - WMColor *color; - - pixmap = WMCreatePixmap(scr, 130, 16, WMScreenDepth(scr), False); - color = WMDarkGrayColor(scr); - XFillRectangle(WMScreenDisplay(scr), WMGetPixmapXID(pixmap), - WMColorGC(color), 0, 0, 130, 16); - WMReleaseColor(color); - color = WMWhiteColor(color); - WMDrawString(scr, WMGetPixmapXID(pixmap), color, - panel->listFont, 2, - (16 - WMFontHeight(panel->listFont))/2 - 1, - "Brightness", 10); - WMSetSliderImage(panel->gbriS, pixmap); - WMReleasePixmap(pixmap); + WMPixmap *pixmap; + WMColor *color; + + pixmap = WMCreatePixmap(scr, 130, 16, WMScreenDepth(scr), False); + color = WMDarkGrayColor(scr); + XFillRectangle(WMScreenDisplay(scr), WMGetPixmapXID(pixmap), + WMColorGC(color), 0, 0, 130, 16); + WMReleaseColor(color); + color = WMWhiteColor(color); + WMDrawString(scr, WMGetPixmapXID(pixmap), color, + panel->listFont, 2, + (16 - WMFontHeight(panel->listFont))/2 - 1, + "Brightness", 10); + WMSetSliderImage(panel->gbriS, pixmap); + WMReleasePixmap(pixmap); } panel->gconS = WMCreateSlider(panel->gcolF); @@ -1350,21 +1350,21 @@ CreateTexturePanel(WMWindow *keyWindow) WMSetSliderMaxValue(panel->gconS, 100); WMSetSliderAction(panel->gconS, sliderChangeCallback, panel); { - WMPixmap *pixmap; - WMColor *color; - - pixmap = WMCreatePixmap(scr, 130, 16, WMScreenDepth(scr), False); - color = WMDarkGrayColor(scr); - XFillRectangle(WMScreenDisplay(scr), WMGetPixmapXID(pixmap), - WMColorGC(color), 0, 0, 130, 16); - WMReleaseColor(color); - color = WMWhiteColor(scr); - WMDrawString(scr, WMGetPixmapXID(pixmap), color, - panel->listFont, 2, - (16 - WMFontHeight(panel->listFont))/2 - 1, - "Contrast", 8); - WMSetSliderImage(panel->gconS, pixmap); - WMReleasePixmap(pixmap); + WMPixmap *pixmap; + WMColor *color; + + pixmap = WMCreatePixmap(scr, 130, 16, WMScreenDepth(scr), False); + color = WMDarkGrayColor(scr); + XFillRectangle(WMScreenDisplay(scr), WMGetPixmapXID(pixmap), + WMColorGC(color), 0, 0, 130, 16); + WMReleaseColor(color); + color = WMWhiteColor(scr); + WMDrawString(scr, WMGetPixmapXID(pixmap), color, + panel->listFont, 2, + (16 - WMFontHeight(panel->listFont))/2 - 1, + "Contrast", 8); + WMSetSliderImage(panel->gconS, pixmap); + WMReleasePixmap(pixmap); } #endif panel->ghueS = WMCreateSlider(panel->gcolF); @@ -1427,13 +1427,13 @@ CreateTexturePanel(WMWindow *keyWindow) WMResizeWidget(panel->tcol1W, 60, 45); WMMoveWidget(panel->tcol1W, 20, 25); WMAddNotificationObserver(colorWellObserver, panel, - WMColorWellDidChangeNotification, panel->tcol1W); + WMColorWellDidChangeNotification, panel->tcol1W); panel->tcol2W = WMCreateColorWell(panel->tcolF); WMResizeWidget(panel->tcol2W, 60, 45); WMMoveWidget(panel->tcol2W, 20, 75); WMAddNotificationObserver(colorWellObserver, panel, - WMColorWellDidChangeNotification, panel->tcol2W); + WMColorWellDidChangeNotification, panel->tcol2W); /** Opacity */ panel->topaF = WMCreateFrame(panel->win); @@ -1448,31 +1448,31 @@ CreateTexturePanel(WMWindow *keyWindow) WMSetSliderValue(panel->topaS, 200); WMSetSliderContinuous(panel->topaS, False); WMSetSliderAction(panel->topaS, opaqChangeCallback, panel); - + WMMapSubwidgets(panel->topaF); { - WMPixmap *pixmap; - Pixmap p; - WMColor *color; - - pixmap = WMCreatePixmap(scr, 155, 18, WMScreenDepth(scr), False); - p = WMGetPixmapXID(pixmap); - - color = WMDarkGrayColor(scr); - XFillRectangle(WMScreenDisplay(scr), p, WMColorGC(color), - 0, 0, 155, 18); - WMReleaseColor(color); - - color = WMWhiteColor(scr); - WMDrawString(scr, p, color, panel->listFont, 2, 1, "0%", 2); - WMDrawString(scr, p, color, panel->listFont, - 153 - WMWidthOfString(panel->listFont, "100%", 4), 1, - "100%", 4); - WMReleaseColor(color); - - WMSetSliderImage(panel->topaS, pixmap); - WMReleasePixmap(pixmap); + WMPixmap *pixmap; + Pixmap p; + WMColor *color; + + pixmap = WMCreatePixmap(scr, 155, 18, WMScreenDepth(scr), False); + p = WMGetPixmapXID(pixmap); + + color = WMDarkGrayColor(scr); + XFillRectangle(WMScreenDisplay(scr), p, WMColorGC(color), + 0, 0, 155, 18); + WMReleaseColor(color); + + color = WMWhiteColor(scr); + WMDrawString(scr, p, color, panel->listFont, 2, 1, "0%", 2); + WMDrawString(scr, p, color, panel->listFont, + 153 - WMWidthOfString(panel->listFont, "100%", 4), 1, + "100%", 4); + WMReleaseColor(color); + + WMSetSliderImage(panel->topaS, pixmap); + WMReleasePixmap(pixmap); } WMMapSubwidgets(panel->tcolF); @@ -1504,11 +1504,11 @@ CreateTexturePanel(WMWindow *keyWindow) WMSetButtonText(panel->browB, _("Browse...")); WMSetButtonAction(panel->browB, browseImageCallback, panel); -/* panel->dispB = WMCreateCommandButton(panel->imageF); - WMResizeWidget(panel->dispB, 90, 24); - WMMoveWidget(panel->dispB, 190, 80); - WMSetButtonText(panel->dispB, _("Show")); - */ + /* panel->dispB = WMCreateCommandButton(panel->imageF); + WMResizeWidget(panel->dispB, 90, 24); + WMMoveWidget(panel->dispB, 190, 80); + WMSetButtonText(panel->dispB, _("Show")); + */ panel->arrP = WMCreatePopUpButton(panel->imageF); WMResizeWidget(panel->arrP, 90, 20); @@ -1528,7 +1528,7 @@ CreateTexturePanel(WMWindow *keyWindow) WMMoveWidget(panel->okB, 225, 390); WMSetButtonText(panel->okB, _("OK")); WMSetButtonAction(panel->okB, buttonCallback, panel); - + panel->cancelB = WMCreateCommandButton(panel->win); WMResizeWidget(panel->cancelB, 84, 24); WMMoveWidget(panel->cancelB, 130, 390); @@ -1596,55 +1596,59 @@ testOKButton(WMWidget *self, void *data) Window win; Pixmap pix; RImage *image; - + TexturePanel *panel = (TexturePanel*)data; /* test = GetTexturePanelTextureString(panel); */ - + wwarning(test); - + dpy = WMScreenDisplay(WMWidgetScreen(panel->okB)); win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 250, 250, - 0, 0, 0); + 0, 0, 0); XMapRaised(dpy, win); XFlush(dpy); - + /* image = RenderTexturePanelTexture(panel, 250, 250); */ - + RConvertImage(WMScreenRContext(WMWidgetScreen(panel->okB)), image, &pix); - - XCopyArea(dpy, pix, win, (WMScreenRContext(WMWidgetScreen(panel->okB)))->copy_gc, 0, 0, image->width, image->height, - 0, 0); - + + XCopyArea(dpy, pix, win, (WMScreenRContext(WMWidgetScreen(panel->okB)))->copy_gc, 0, 0, image->width, image->height, + 0, 0); + wfree (test); - + } -void testCancelButton(WMWidget *self, void *data){ +void +testCancelButton(WMWidget *self, void *data) +{ wwarning("Exiting test...."); exit(0); } -void wAbort() +void +wAbort() { exit(1); } -int main(int argc, char **argv) +int +main(int argc, char **argv) { TexturePanel *panel; - + Display *dpy = XOpenDisplay(""); WMScreen *scr; - + /* char *test; */ - + WMInitializeApplication("Test", &argc, argv); - + if (!dpy) { wfatal("could not open display"); exit(1); } - + scr = WMCreateSimpleApplicationScreen(dpy); panel = CreateTexturePanel(scr); @@ -1653,7 +1657,7 @@ int main(int argc, char **argv) SetTexturePanelCancelAction(panel,(WMAction*)testCancelButton,panel); SetTexturePanelTexture(panel, "pinky", - WMCreatePropListFromDescription("(mdgradient, pink, red, blue, yellow)")); + WMCreatePropListFromDescription("(mdgradient, pink, red, blue, yellow)")); ShowTexturePanel(panel); @@ -1661,3 +1665,4 @@ int main(int argc, char **argv) return 0; } #endif + diff --git a/WPrefs.app/TexturePanel.h b/WPrefs.app/TexturePanel.h index 30b2e599..a7c3cb3f 100644 --- a/WPrefs.app/TexturePanel.h +++ b/WPrefs.app/TexturePanel.h @@ -1,9 +1,9 @@ /* TexturePanel.h- texture editting panel - * + * * WPrefs - WindowMaker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -36,22 +36,22 @@ void ShowTexturePanel(TexturePanel *panel); void HideTexturePanel(TexturePanel *panel); -void SetTexturePanelTexture(TexturePanel *panel, char *name, - WMPropList *texture); +void SetTexturePanelTexture(TexturePanel *panel, char *name, + WMPropList *texture); char *GetTexturePanelTextureName(TexturePanel *panel); WMPropList *GetTexturePanelTexture(TexturePanel *panel); -RImage *RenderTexturePanelTexture(TexturePanel *panel, unsigned width, - unsigned height); +RImage *RenderTexturePanelTexture(TexturePanel *panel, unsigned width, + unsigned height); void SetTexturePanelOkAction(TexturePanel *panel, WMCallback *action, - void *clientData); + void *clientData); void SetTexturePanelCancelAction(TexturePanel *panel, WMCallback *action, - void *clientData); + void *clientData); void SetTexturePanelPixmapPath(TexturePanel *panel, WMPropList *array); diff --git a/WPrefs.app/Themes.c b/WPrefs.app/Themes.c index 8c325f17..d09509f5 100644 --- a/WPrefs.app/Themes.c +++ b/WPrefs.app/Themes.c @@ -1,9 +1,9 @@ /* Themes.c- Theme stuff - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -31,18 +31,18 @@ typedef struct _Panel { char *sectionName; CallbackRec callbacks; - + WMWidget *parent; WMButton *saveB; WMList *list; WMButton *loadB; WMButton *instB; - + WMFrame *totF; WMButton *totB; WMLabel *totL; - + WMFrame *botF; WMButton *botB; WMLabel *botL; @@ -88,23 +88,23 @@ static pid_t downloadFile(WMScreen *scr, _Panel *panel, char *file) { pid_t pid; - + pid = fork(); if (pid < 0) { - wsyserror("could not fork() process"); + wsyserror("could not fork() process"); - WMRunAlertPanel(scr, GetWindow(panel), _("Error"), - "Could not start download. fork() failed", - _("OK"), NULL, NULL); - return -1; + WMRunAlertPanel(scr, GetWindow(panel), _("Error"), + "Could not start download. fork() failed", + _("OK"), NULL, NULL); + return -1; } if (pid != 0) { - return pid; + return pid; } close(ConnectionNumber(WMScreenDisplay(scr))); - + exit(1); } @@ -119,28 +119,28 @@ downloadCallback(WMWidget *w, void *data) pid_t *pid; if (button == panel->totB) { - pid = &panel->tilePID; + pid = &panel->tilePID; } else { - pid = &panel->barPID; + pid = &panel->barPID; } - + if (*pid == 0) { - newPid = downloadFile(WMWidgetScreen(w), panel, NULL); - if (newPid < 0) { - return; - } - WMSetButtonText(button, _("Stop")); - - if (button == panel->totB) { - AddDeadChildHandler(newPid, finishedTileDownload, data); - } else { - AddDeadChildHandler(newPid, finishedBarDownload, data); - } - *pid = newPid; + newPid = downloadFile(WMWidgetScreen(w), panel, NULL); + if (newPid < 0) { + return; + } + WMSetButtonText(button, _("Stop")); + + if (button == panel->totB) { + AddDeadChildHandler(newPid, finishedTileDownload, data); + } else { + AddDeadChildHandler(newPid, finishedBarDownload, data); + } + *pid = newPid; } else { - *pid = 0; + *pid = 0; - WMSetButtonText(button, _("Download")); + WMSetButtonText(button, _("Download")); } } @@ -151,8 +151,8 @@ updateThemeList(_Panel *panel) { WMClearList(panel->list); - - + + } @@ -184,9 +184,9 @@ createPanel(Panel *p) WMMoveWidget(panel->instB, 95, 200); WMSetButtonText(panel->instB, _("Install")); - + /**************** Tile of the day ****************/ - + panel->totF = WMCreateFrame(panel->box); WMResizeWidget(panel->totF, 210, 105); WMMoveWidget(panel->totF, 240, 10); @@ -204,7 +204,7 @@ createPanel(Panel *p) WMSetButtonAction(panel->totB, downloadCallback, panel); WMMapSubwidgets(panel->totF); - + /**************** Bar of the day ****************/ panel->botF = WMCreateFrame(panel->box); @@ -227,7 +227,7 @@ createPanel(Panel *p) WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); - + showData(panel); } @@ -248,9 +248,9 @@ InitThemes(WMScreen *scr, WMWidget *parent) memset(panel, 0, sizeof(_Panel)); panel->sectionName = _("Themes"); - + panel->parent = parent; - + panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeData; @@ -258,3 +258,4 @@ InitThemes(WMScreen *scr, WMWidget *parent) return panel; } + diff --git a/WPrefs.app/WPrefs.c b/WPrefs.app/WPrefs.c index fa06a73e..b6ced7d4 100644 --- a/WPrefs.app/WPrefs.c +++ b/WPrefs.app/WPrefs.c @@ -1,9 +1,9 @@ /* WPrefs.c- main window and other basic stuff - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -67,13 +67,13 @@ extern Panel *InitAppearance(WMScreen *scr, WMWidget *parent); #define MAX_SECTIONS 16 -typedef struct _WPrefs { +typedef struct _WPrefs { WMWindow *win; WMScrollView *scrollV; WMFrame *buttonF; WMButton *sectionB[MAX_SECTIONS]; - + int sectionCount; WMButton *saveBtn; @@ -88,7 +88,7 @@ typedef struct _WPrefs { WMLabel *versionL; WMLabel *creditsL; WMLabel *statusL; - + Panel *currentPanel; } _WPrefs; @@ -136,53 +136,53 @@ save(WMWidget *w, void *data) XEvent ev; -/* puts("gathering data");*/ + /* puts("gathering data");*/ for (i=0; icallbacks.flags & INITIALIZED_PANEL)) - savePanelData((Panel*)rec); + PanelRec *rec = WMGetHangedData(WPrefs.sectionB[i]); + if ((rec->callbacks.flags & INITIALIZED_PANEL)) + savePanelData((Panel*)rec); } -/* puts("compressing data");*/ + /* puts("compressing data");*/ /* compare the user dictionary with the global and remove redundant data */ keyList = WMGetPLDictionaryKeys(GlobalDB); -/* puts(WMGetPropListDescription(WindowMakerDB, False));*/ + /* puts(WMGetPropListDescription(WindowMakerDB, False));*/ for (i=0; icallbacks.undoChanges - && (rec->callbacks.flags & INITIALIZED_PANEL)) { - (*rec->callbacks.undoChanges)(WPrefs.currentPanel); + if (rec->callbacks.undoChanges + && (rec->callbacks.flags & INITIALIZED_PANEL)) { + (*rec->callbacks.undoChanges)(WPrefs.currentPanel); } } @@ -207,13 +207,13 @@ static void undoAll(WMWidget *w, void *data) { int i; - + for (i=0; icallbacks.undoChanges - && (rec->callbacks.flags & INITIALIZED_PANEL)) - (*rec->callbacks.undoChanges)((Panel*)rec); + if (rec->callbacks.undoChanges + && (rec->callbacks.flags & INITIALIZED_PANEL)) + (*rec->callbacks.undoChanges)((Panel*)rec); } } @@ -225,11 +225,11 @@ prepareForClose() int i; for (i=0; icallbacks.prepareForClose - && (rec->callbacks.flags & INITIALIZED_PANEL)) - (*rec->callbacks.prepareForClose)((Panel*)rec); + if (rec->callbacks.prepareForClose + && (rec->callbacks.flags & INITIALIZED_PANEL)) + (*rec->callbacks.prepareForClose)((Panel*)rec); } } @@ -263,7 +263,7 @@ createMainWindow(WMScreen *scr) WMSetWindowMinSize(WPrefs.win, 520, 390); WMSetWindowMiniwindowTitle(WPrefs.win, "Preferences"); WMSetWindowMiniwindowPixmap(WPrefs.win, WMGetApplicationIconPixmap(scr)); - + WPrefs.scrollV = WMCreateScrollView(WPrefs.win); WMResizeWidget(WPrefs.scrollV, 500, 87); WMMoveWidget(WPrefs.scrollV, 10, 10); @@ -283,7 +283,7 @@ createMainWindow(WMScreen *scr) WMMoveWidget(WPrefs.undosBtn, 135, 350); WMSetButtonText(WPrefs.undosBtn, _("Revert Page")); WMSetButtonAction(WPrefs.undosBtn, undo, NULL); - + WPrefs.undoBtn = WMCreateCommandButton(WPrefs.win); WMResizeWidget(WPrefs.undoBtn, 90, 28); WMMoveWidget(WPrefs.undoBtn, 235, 350); @@ -295,7 +295,7 @@ createMainWindow(WMScreen *scr) WMMoveWidget(WPrefs.saveBtn, 335, 350); WMSetButtonText(WPrefs.saveBtn, _("Save")); WMSetButtonAction(WPrefs.saveBtn, save, NULL); - + WPrefs.closeBtn = WMCreateCommandButton(WPrefs.win); WMResizeWidget(WPrefs.closeBtn, 80, 28); WMMoveWidget(WPrefs.closeBtn, 425, 350); @@ -309,11 +309,11 @@ createMainWindow(WMScreen *scr) WMSetButtonText(WPrefs.balloonBtn, _("Balloon Help")); WMSetButtonAction(WPrefs.balloonBtn, toggleBalloons, NULL); { - WMUserDefaults *udb = WMGetStandardUserDefaults(); - Bool flag = WMGetUDBoolForKey(udb, "BalloonHelp"); + WMUserDefaults *udb = WMGetStandardUserDefaults(); + Bool flag = WMGetUDBoolForKey(udb, "BalloonHelp"); - WMSetButtonSelected(WPrefs.balloonBtn, flag); - WMSetBalloonEnabled(scr, flag); + WMSetButtonSelected(WPrefs.balloonBtn, flag); + WMSetBalloonEnabled(scr, flag); } /* banner */ @@ -323,9 +323,9 @@ createMainWindow(WMScreen *scr) WMSetFrameRelief(WPrefs.banner, WRFlat); font = WMCreateFont(scr, "-*-times-bold-r-*-*-24-*-*-*-*-*-*-*," - "-*-fixed-medium-r-normal-*-24-*"); + "-*-fixed-medium-r-normal-*-24-*"); if (!font) - font = WMBoldSystemFontOfSize(scr, 24); + font = WMBoldSystemFontOfSize(scr, 24); WPrefs.nameL = WMCreateLabel(WPrefs.banner); WMSetLabelTextAlignment(WPrefs.nameL, WACenter); WMResizeWidget(WPrefs.nameL, FRAME_WIDTH-20, 30); @@ -339,7 +339,7 @@ createMainWindow(WMScreen *scr) WMMoveWidget(WPrefs.versionL, 10, 65); WMSetLabelTextAlignment(WPrefs.versionL, WACenter); sprintf(buffer, _("Version %s for Window Maker %s or newer"), WVERSION, - WMVERSION); + WMVERSION); WMSetLabelText(WPrefs.versionL, buffer); WPrefs.statusL = WMCreateLabel(WPrefs.banner); @@ -347,18 +347,18 @@ createMainWindow(WMScreen *scr) WMMoveWidget(WPrefs.statusL, 10, 100); WMSetLabelTextAlignment(WPrefs.statusL, WACenter); WMSetLabelText(WPrefs.statusL, _("Starting...")); - + WPrefs.creditsL = WMCreateLabel(WPrefs.banner); WMResizeWidget(WPrefs.creditsL, FRAME_WIDTH-20, 60); WMMoveWidget(WPrefs.creditsL, 10, FRAME_HEIGHT-60); WMSetLabelTextAlignment(WPrefs.creditsL, WACenter); WMSetLabelText(WPrefs.creditsL, _("Programming/Design: Alfredo K. Kojima\n" - "Artwork: Marco van Hylckama Vlieg, Largo et al\n" - "More Programming: James Thompson et al")); - - + "Artwork: Marco van Hylckama Vlieg, Largo et al\n" + "More Programming: James Thompson et al")); + + WMMapSubwidgets(WPrefs.win); - + WMUnmapWidget(WPrefs.undosBtn); WMUnmapWidget(WPrefs.undoBtn); WMUnmapWidget(WPrefs.saveBtn); @@ -369,16 +369,16 @@ static void showPanel(Panel *panel) { PanelRec *rec = (PanelRec*)panel; - + if (!(rec->callbacks.flags & INITIALIZED_PANEL)) { - (*rec->callbacks.createWidgets)(panel); - rec->callbacks.flags |= INITIALIZED_PANEL; + (*rec->callbacks.createWidgets)(panel); + rec->callbacks.flags |= INITIALIZED_PANEL; } WMSetWindowTitle(WPrefs.win, rec->sectionName); - + if (rec->callbacks.showPanel) - (*rec->callbacks.showPanel)(panel); + (*rec->callbacks.showPanel)(panel); WMMapWidget(rec->box); } @@ -388,50 +388,50 @@ showPanel(Panel *panel) static void hidePanel(Panel *panel) { - PanelRec *rec = (PanelRec*)panel; - + PanelRec *rec = (PanelRec*)panel; + WMUnmapWidget(rec->box); - + if (rec->callbacks.hidePanel) - (*rec->callbacks.hidePanel)(panel); + (*rec->callbacks.hidePanel)(panel); } static void savePanelData(Panel *panel) { - PanelRec *rec = (PanelRec*)panel; + PanelRec *rec = (PanelRec*)panel; if (rec->callbacks.updateDomain) { - (*rec->callbacks.updateDomain)(panel); + (*rec->callbacks.updateDomain)(panel); } } -static void +static void changeSection(WMWidget *self, void *data) { if (WPrefs.currentPanel == data) - return; - + return; + if (WPrefs.currentPanel == NULL) { - WMDestroyWidget(WPrefs.nameL); - WMDestroyWidget(WPrefs.creditsL); - WMDestroyWidget(WPrefs.versionL); - WMDestroyWidget(WPrefs.statusL); + WMDestroyWidget(WPrefs.nameL); + WMDestroyWidget(WPrefs.creditsL); + WMDestroyWidget(WPrefs.versionL); + WMDestroyWidget(WPrefs.statusL); - WMSetFrameRelief(WPrefs.banner, WRGroove); + WMSetFrameRelief(WPrefs.banner, WRGroove); -/* WMMapWidget(WPrefs.undosBtn); - WMMapWidget(WPrefs.undoBtn); - */ - WMMapWidget(WPrefs.saveBtn); + /* WMMapWidget(WPrefs.undosBtn); + WMMapWidget(WPrefs.undoBtn); + */ + WMMapWidget(WPrefs.saveBtn); } showPanel(data); if (WPrefs.currentPanel) - hidePanel(WPrefs.currentPanel); + hidePanel(WPrefs.currentPanel); WPrefs.currentPanel = data; } @@ -442,19 +442,19 @@ LocateImage(char *name) { char *path; char *tmp = wmalloc(strlen(name)+8); - + if (TIFFOK) { - sprintf(tmp, "%s.tiff", name); - path = WMPathForResourceOfType(tmp, "tiff"); + sprintf(tmp, "%s.tiff", name); + path = WMPathForResourceOfType(tmp, "tiff"); } else { - sprintf(tmp, "%s.xpm", name); - path = WMPathForResourceOfType(tmp, "xpm"); + sprintf(tmp, "%s.xpm", name); + path = WMPathForResourceOfType(tmp, "xpm"); } wfree(tmp); if (!path) { - wwarning(_("could not locate image file %s\n"), name); + wwarning(_("could not locate image file %s\n"), name); } - + return path; } @@ -464,7 +464,7 @@ static WMPixmap* makeTitledIcon(WMScreen *scr, WMPixmap *icon, char *title1, char *title2) { return WMRetainPixmap(icon); - + #if 0 static GC gc = NULL; static XFontStruct *hfont = NULL; @@ -476,60 +476,60 @@ makeTitledIcon(WMScreen *scr, WMPixmap *icon, char *title1, char *title2) GC fgc; WMSize size = WMGetPixmapSize(icon); - + tmp = WMCreatePixmap(scr, 60, 60, WMScreenDepth(scr), True); pix = WMGetPixmapXID(tmp); mask = WMGetPixmapMaskXID(tmp); if (gc == NULL) { - gc = XCreateGC(dpy, mask, 0, NULL); + gc = XCreateGC(dpy, mask, 0, NULL); - hfont = XLoadQueryFont(dpy, ICON_TITLE_FONT); - vfont = XLoadQueryFont(dpy, ICON_TITLE_VFONT); + hfont = XLoadQueryFont(dpy, ICON_TITLE_FONT); + vfont = XLoadQueryFont(dpy, ICON_TITLE_VFONT); } - + if (hfont == NULL) { - return WMRetainPixmap(icon); + return WMRetainPixmap(icon); } - + XSetForeground(dpy, gc, 0); XFillRectangle(dpy, mask, gc, 0, 0, 60, 60); - + fgc = WMColorGC(black); - + XSetForeground(dpy, gc, 1); - + XCopyArea(dpy, WMGetPixmapXID(icon), pix, fgc, 0, 0, - size.width, size.height, 12, 12); - + size.width, size.height, 12, 12); + if (WMGetPixmapMaskXID(icon) != None) - XCopyPlane(dpy, WMGetPixmapMaskXID(icon), mask, gc, 0, 0, - size.width, size.height, 12, 12, 1); + XCopyPlane(dpy, WMGetPixmapMaskXID(icon), mask, gc, 0, 0, + size.width, size.height, 12, 12, 1); else - XFillRectangle(dpy, mask, gc, 12, 12, 48, 48); + XFillRectangle(dpy, mask, gc, 12, 12, 48, 48); if (title1) { - XSetFont(dpy, fgc, vfont->fid); - XSetFont(dpy, gc, vfont->fid); - - XDrawString(dpy, pix, fgc, 0, vfont->ascent, - title1, strlen(title1)); - - XDrawString(dpy, mask, gc, 0, vfont->ascent, - title1, strlen(title1)); + XSetFont(dpy, fgc, vfont->fid); + XSetFont(dpy, gc, vfont->fid); + + XDrawString(dpy, pix, fgc, 0, vfont->ascent, + title1, strlen(title1)); + + XDrawString(dpy, mask, gc, 0, vfont->ascent, + title1, strlen(title1)); } if (title2) { - XSetFont(dpy, fgc, hfont->fid); - XSetFont(dpy, gc, hfont->fid); - - XDrawString(dpy, pix, fgc, (title1 ? 12 : 0), hfont->ascent, - title2, strlen(title2)); - - XDrawString(dpy, mask, gc, (title1 ? 12 : 0), hfont->ascent, - title2, strlen(title2)); + XSetFont(dpy, fgc, hfont->fid); + XSetFont(dpy, gc, hfont->fid); + + XDrawString(dpy, pix, fgc, (title1 ? 12 : 0), hfont->ascent, + title2, strlen(title2)); + + XDrawString(dpy, mask, gc, (title1 ? 12 : 0), hfont->ascent, + title2, strlen(title2)); } return tmp; @@ -539,7 +539,7 @@ makeTitledIcon(WMScreen *scr, WMPixmap *icon, char *title1, char *title2) void SetButtonAlphaImage(WMScreen *scr, WMButton *bPtr, char *file, - char *title1, char *title2) + char *title1, char *title2) { WMPixmap *icon; WMPixmap *icon2; @@ -553,45 +553,45 @@ SetButtonAlphaImage(WMScreen *scr, WMButton *bPtr, char *file, color.blue = 0xae; color.alpha = 0; if (iconPath) { - icon = WMCreateBlendedPixmapFromFile(scr, iconPath, &color); - if (!icon) - wwarning(_("could not load icon file %s"), iconPath); + icon = WMCreateBlendedPixmapFromFile(scr, iconPath, &color); + if (!icon) + wwarning(_("could not load icon file %s"), iconPath); } else { - icon = NULL; + icon = NULL; } - + if (icon) { - icon2 = makeTitledIcon(scr, icon, title1, title2); - if (icon) - WMReleasePixmap(icon); + icon2 = makeTitledIcon(scr, icon, title1, title2); + if (icon) + WMReleasePixmap(icon); } else { - icon2 = NULL; + icon2 = NULL; } - + WMSetButtonImage(bPtr, icon2); if (icon2) - WMReleasePixmap(icon2); + WMReleasePixmap(icon2); color.red = 0xff; color.green = 0xff; color.blue = 0xff; color.alpha = 0; if (iconPath) { - icon = WMCreateBlendedPixmapFromFile(scr, iconPath, &color); - if (!icon) - wwarning(_("could not load icon file %s"), iconPath); + icon = WMCreateBlendedPixmapFromFile(scr, iconPath, &color); + if (!icon) + wwarning(_("could not load icon file %s"), iconPath); } else { - icon = NULL; + icon = NULL; } WMSetButtonAltImage(bPtr, icon); if (icon) - WMReleasePixmap(icon); + WMReleasePixmap(icon); if (iconPath) - wfree(iconPath); + wfree(iconPath); } @@ -601,38 +601,38 @@ AddSection(Panel *panel, char *iconFile) WMButton *bPtr; assert(WPrefs.sectionCount < MAX_SECTIONS); - + bPtr = WMCreateCustomButton(WPrefs.buttonF, WBBStateLightMask - |WBBStateChangeMask); + |WBBStateChangeMask); WMResizeWidget(bPtr, 64, 64); WMMoveWidget(bPtr, WPrefs.sectionCount*64, 0); WMSetButtonImagePosition(bPtr, WIPImageOnly); WMSetButtonAction(bPtr, changeSection, panel); WMHangData(bPtr, panel); - WMSetBalloonTextForView(((PanelRec*)panel)->description, - WMWidgetView(bPtr)); + WMSetBalloonTextForView(((PanelRec*)panel)->description, + WMWidgetView(bPtr)); { - char *t1, *t2; - - t1 = wstrdup(((PanelRec*)panel)->sectionName); - t2 = strchr(t1, ' '); - if (t2) { - *t2 = 0; - t2++; - } - SetButtonAlphaImage(WMWidgetScreen(bPtr), bPtr, iconFile, - t1, t2); - wfree(t1); + char *t1, *t2; + + t1 = wstrdup(((PanelRec*)panel)->sectionName); + t2 = strchr(t1, ' '); + if (t2) { + *t2 = 0; + t2++; + } + SetButtonAlphaImage(WMWidgetScreen(bPtr), bPtr, iconFile, + t1, t2); + wfree(t1); } WMMapWidget(bPtr); WPrefs.sectionB[WPrefs.sectionCount] = bPtr; if (WPrefs.sectionCount > 0) { - WMGroupButtons(WPrefs.sectionB[0], bPtr); + WMGroupButtons(WPrefs.sectionB[0], bPtr); } WPrefs.sectionCount++; @@ -648,38 +648,38 @@ Initialize(WMScreen *scr) int i; char *path; WMPixmap *icon; - - + + list = RSupportedFileFormats(); for (i=0; list[i]!=NULL; i++) { - if (strcmp(list[i], "TIFF")==0) { - TIFFOK = True; - break; - } + if (strcmp(list[i], "TIFF")==0) { + TIFFOK = True; + break; + } } - + if (TIFFOK) - path = WMPathForResourceOfType("WPrefs.tiff", NULL); + path = WMPathForResourceOfType("WPrefs.tiff", NULL); else - path = WMPathForResourceOfType("WPrefs.xpm", NULL); + path = WMPathForResourceOfType("WPrefs.xpm", NULL); if (path) { - RImage *tmp; - - tmp = RLoadImage(WMScreenRContext(scr), path, 0); - if (!tmp) { - wwarning(_("could not load image file %s:%s"), path, - RMessageForError(RErrorCode)); - } else { - icon = WMCreatePixmapFromRImage(scr, tmp, 0); - RReleaseImage(tmp); - if (icon) { - WMSetApplicationIconPixmap(scr, icon); - WMReleasePixmap(icon); - } - } - wfree(path); + RImage *tmp; + + tmp = RLoadImage(WMScreenRContext(scr), path, 0); + if (!tmp) { + wwarning(_("could not load image file %s:%s"), path, + RMessageForError(RErrorCode)); + } else { + icon = WMCreatePixmapFromRImage(scr, tmp, 0); + RReleaseImage(tmp); + if (icon) { + WMSetApplicationIconPixmap(scr, icon); + WMReleasePixmap(icon); + } + } + wfree(path); } - + memset(&WPrefs, 0, sizeof(_WPrefs)); createMainWindow(scr); @@ -699,7 +699,7 @@ Initialize(WMScreen *scr) InitIcons(scr, WPrefs.banner); InitPreferences(scr, WPrefs.banner); - InitPaths(scr, WPrefs.banner); + InitPaths(scr, WPrefs.banner); InitWorkspace(scr, WPrefs.banner); InitConfigurations(scr, WPrefs.banner); @@ -715,7 +715,7 @@ Initialize(WMScreen *scr) #ifdef finished_checking InitFont(scr, WPrefs.banner); -#endif +#endif #ifdef not_yet_fully_implemented InitThemes(scr, WPrefs.banner); @@ -724,9 +724,9 @@ Initialize(WMScreen *scr) WMRealizeWidget(WPrefs.scrollV); - WMSetLabelText(WPrefs.statusL, - _("WPrefs is free software and is distributed WITHOUT ANY\n" - "WARRANTY under the terms of the GNU General Public License.")); + WMSetLabelText(WPrefs.statusL, + _("WPrefs is free software and is distributed WITHOUT ANY\n" + "WARRANTY under the terms of the GNU General Public License.")); } @@ -746,109 +746,109 @@ loadConfigurations(WMScreen *scr, WMWindow *mainw) char buffer[1024]; char mbuf[1024]; int v1, v2, v3; - + path = wdefaultspathfordomain("WindowMaker"); WindowMakerDBPath = path; - + db = WMReadPropListFromFile(path); if (db) { - if (!WMIsPLDictionary(db)) { - WMReleasePropList(db); - db = NULL; - sprintf(mbuf, _("Window Maker domain (%s) is corrupted!"), path); - WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); - } + if (!WMIsPLDictionary(db)) { + WMReleasePropList(db); + db = NULL; + sprintf(mbuf, _("Window Maker domain (%s) is corrupted!"), path); + WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); + } } else { - sprintf(mbuf, _("Could not load Window Maker domain (%s) from defaults database."), - path); - WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); + sprintf(mbuf, _("Could not load Window Maker domain (%s) from defaults database."), + path); + WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); } path = getenv("WMAKER_BIN_NAME"); if (!path) - path = "wmaker"; + path = "wmaker"; { - char *command; + char *command; - command = wstrconcat(path, " --version"); - file = popen(command, "r"); - wfree(command); + command = wstrconcat(path, " --version"); + file = popen(command, "r"); + wfree(command); } if (!file || !fgets(buffer, 1023, file)) { - wsyserror(_("could not extract version information from Window Maker")); - wfatal(_("Make sure wmaker is in your search path.")); - - WMRunAlertPanel(scr, mainw, _("Error"), - _("Could not extract version from Window Maker. Make sure it is correctly installed and is in your PATH environment variable."), - _("OK"), NULL, NULL); - exit(1); + wsyserror(_("could not extract version information from Window Maker")); + wfatal(_("Make sure wmaker is in your search path.")); + + WMRunAlertPanel(scr, mainw, _("Error"), + _("Could not extract version from Window Maker. Make sure it is correctly installed and is in your PATH environment variable."), + _("OK"), NULL, NULL); + exit(1); } if (file) - pclose(file); - + pclose(file); + if (sscanf(buffer, "Window Maker %i.%i.%i",&v1,&v2,&v3)!=3 - && sscanf(buffer, "WindowMaker %i.%i.%i",&v1,&v2,&v3)!=3) { - WMRunAlertPanel(scr, mainw, _("Error"), - _("Could not extract version from Window Maker. " - "Make sure it is correctly installed and the path " - "where it installed is in the PATH environment " - "variable."), _("OK"), NULL, NULL); - exit(1); + && sscanf(buffer, "WindowMaker %i.%i.%i",&v1,&v2,&v3)!=3) { + WMRunAlertPanel(scr, mainw, _("Error"), + _("Could not extract version from Window Maker. " + "Make sure it is correctly installed and the path " + "where it installed is in the PATH environment " + "variable."), _("OK"), NULL, NULL); + exit(1); } if (v1 == 0 && (v2 < 18 || v3 < 0)) { - sprintf(mbuf, _("WPrefs only supports Window Maker 0.18.0 or newer.\n" - "The version installed is %i.%i.%i\n"), v1, v2, v3); - WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); - exit(1); + sprintf(mbuf, _("WPrefs only supports Window Maker 0.18.0 or newer.\n" + "The version installed is %i.%i.%i\n"), v1, v2, v3); + WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); + exit(1); } if (v1 > 1 || (v1 == 1 && (v2 > 0))) { - sprintf(mbuf, _("Window Maker %i.%i.%i, which is installed in your system, is not fully supported by this version of WPrefs."), - v1, v2, v3); - WMRunAlertPanel(scr, mainw, _("Warning"), mbuf, _("OK"), NULL, NULL); + sprintf(mbuf, _("Window Maker %i.%i.%i, which is installed in your system, is not fully supported by this version of WPrefs."), + v1, v2, v3); + WMRunAlertPanel(scr, mainw, _("Warning"), mbuf, _("OK"), NULL, NULL); } { - char *command; - - command = wstrconcat(path, " --global_defaults_path"); - file = popen(command, "r"); - wfree(command); + char *command; + + command = wstrconcat(path, " --global_defaults_path"); + file = popen(command, "r"); + wfree(command); } if (!file || !fgets(buffer, 1023, file)) { - wsyserror(_("could not run \"%s --global_defaults_path\"."), path); - exit(1); + wsyserror(_("could not run \"%s --global_defaults_path\"."), path); + exit(1); } else { - char *ptr; - ptr = strchr(buffer, '\n'); - if (ptr) - *ptr = 0; - strcat(buffer, "/WindowMaker"); + char *ptr; + ptr = strchr(buffer, '\n'); + if (ptr) + *ptr = 0; + strcat(buffer, "/WindowMaker"); } if (file) - pclose(file); + pclose(file); gdb = WMReadPropListFromFile(buffer); if (gdb) { - if (!WMIsPLDictionary(gdb)) { - WMReleasePropList(gdb); - gdb = NULL; - sprintf(mbuf, _("Window Maker domain (%s) is corrupted!"), buffer); - WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); - } + if (!WMIsPLDictionary(gdb)) { + WMReleasePropList(gdb); + gdb = NULL; + sprintf(mbuf, _("Window Maker domain (%s) is corrupted!"), buffer); + WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); + } } else { - sprintf(mbuf, _("Could not load global Window Maker domain (%s)."), - buffer); - WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); + sprintf(mbuf, _("Could not load global Window Maker domain (%s)."), + buffer); + WMRunAlertPanel(scr, mainw, _("Error"), mbuf, _("OK"), NULL, NULL); } if (!db) { - db = WMCreatePLDictionary(NULL, NULL); + db = WMCreatePLDictionary(NULL, NULL); } if (!gdb) { - gdb = WMCreatePLDictionary(NULL, NULL); + gdb = WMCreatePLDictionary(NULL, NULL); } GlobalDB = gdb; @@ -865,7 +865,7 @@ GetObjectForKey(char *defaultName) object = WMGetFromPLDictionary(WindowMakerDB, key); if (!object) - object = WMGetFromPLDictionary(GlobalDB, key); + object = WMGetFromPLDictionary(GlobalDB, key); WMReleasePropList(key); @@ -887,9 +887,9 @@ void RemoveObjectForKey(char *defaultName) { WMPropList *key = WMCreatePLString(defaultName); - + WMRemoveFromPLDictionary(WindowMakerDB, key); - + WMReleasePropList(key); } @@ -898,14 +898,14 @@ char* GetStringForKey(char *defaultName) { WMPropList *val; - + val = GetObjectForKey(defaultName); if (!val) - return NULL; + return NULL; if (!WMIsPLString(val)) - return NULL; + return NULL; return WMGetFromPLString(val); } @@ -916,14 +916,14 @@ WMPropList* GetArrayForKey(char *defaultName) { WMPropList *val; - + val = GetObjectForKey(defaultName); - + if (!val) - return NULL; + return NULL; if (!WMIsPLArray(val)) - return NULL; + return NULL; return val; } @@ -935,12 +935,12 @@ GetDictionaryForKey(char *defaultName) WMPropList *val; val = GetObjectForKey(defaultName); - + if (!val) - return NULL; + return NULL; if (!WMIsPLDictionary(val)) - return NULL; + return NULL; return val; } @@ -954,19 +954,19 @@ GetIntegerForKey(char *defaultName) int value; val = GetObjectForKey(defaultName); - + if (!val) - return 0; + return 0; if (!WMIsPLString(val)) - return 0; - + return 0; + str = WMGetFromPLString(val); if (!str) - return 0; - + return 0; + if (sscanf(str, "%i", &value)!=1) - return 0; + return 0; return value; } @@ -979,18 +979,18 @@ GetBoolForKey(char *defaultName) char *str; str = GetStringForKey(defaultName); - + if (!str) - return False; - + return False; + if (sscanf(str, "%i", &value)==1 && value!=0) - return True; + return True; if (strcasecmp(str, "YES")==0) - return True; - + return True; + if (strcasecmp(str, "Y")==0) - return True; + return True; return False; } @@ -1004,7 +1004,7 @@ SetIntegerForKey(int value, char *defaultName) sprintf(buffer, "%i", value); object = WMCreatePLString(buffer); - + SetObjectForKey(object, defaultName); WMReleasePropList(object); } @@ -1017,7 +1017,7 @@ SetStringForKey(char *value, char *defaultName) WMPropList *object; object = WMCreatePLString(value); - + SetObjectForKey(object, defaultName); WMReleasePropList(object); } @@ -1029,8 +1029,8 @@ SetBoolForKey(Bool value, char *defaultName) static WMPropList *yes = NULL, *no = NULL; if (!yes) { - yes = WMCreatePLString("YES"); - no = WMCreatePLString("NO"); + yes = WMCreatePLString("YES"); + no = WMCreatePLString("NO"); } SetObjectForKey(value ? yes : no, defaultName); @@ -1041,29 +1041,29 @@ void SetSpeedForKey(int speed, char *defaultName) { char *str; - + switch (speed) { - case 0: - str = "ultraslow"; - break; - case 1: - str = "slow"; - break; - case 2: - str = "medium"; - break; - case 3: - str = "fast"; - break; - case 4: - str = "ultrafast"; - break; - default: - str = NULL; + case 0: + str = "ultraslow"; + break; + case 1: + str = "slow"; + break; + case 2: + str = "medium"; + break; + case 3: + str = "fast"; + break; + case 4: + str = "ultrafast"; + break; + default: + str = NULL; } - + if (str) - SetStringForKey(str, defaultName); + SetStringForKey(str, defaultName); } @@ -1072,25 +1072,25 @@ GetSpeedForKey(char *defaultName) { char *str; int i; - + str = GetStringForKey(defaultName); if (!str) - return 2; + return 2; if (strcasecmp(str, "ultraslow")==0) - i = 0; + i = 0; else if (strcasecmp(str, "slow")==0) - i = 1; + i = 1; else if (strcasecmp(str, "medium")==0) - i = 2; + i = 2; else if (strcasecmp(str, "fast")==0) - i = 3; + i = 3; else if (strcasecmp(str, "ultrafast")==0) - i = 4; + i = 4; else { - wwarning(_("bad speed value for option %s\n. Using default Medium"), - defaultName); - i = 2; + wwarning(_("bad speed value for option %s\n. Using default Medium"), + defaultName); + i = 2; } return i; } diff --git a/WPrefs.app/WPrefs.h b/WPrefs.app/WPrefs.h index e936e340..07dda522 100644 --- a/WPrefs.app/WPrefs.h +++ b/WPrefs.app/WPrefs.h @@ -1,9 +1,9 @@ /* WPrefs.h- general definitions - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -48,7 +48,7 @@ typedef struct _Panel Panel; typedef struct { unsigned flags; /* reserved for WPrefs.c Don't access it */ - + void (*createWidgets)(Panel*); /* called when showing for first time */ void (*updateDomain)(Panel*); /* save the changes to the dictionary */ Bool (*requiresRestart)(Panel*); /* return True if some static option was changed */ diff --git a/WPrefs.app/WindowHandling.c b/WPrefs.app/WindowHandling.c index 7965a015..730d38a2 100644 --- a/WPrefs.app/WindowHandling.c +++ b/WPrefs.app/WindowHandling.c @@ -1,9 +1,9 @@ /* WindowHandling.c- options for handling windows - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -31,16 +31,16 @@ typedef struct _Panel { char *description; CallbackRec callbacks; - + WMWidget *parent; - + WMFrame *placF; WMPopUpButton *placP; WMLabel *porigL; WMLabel *porigvL; WMFrame *porigF; WMLabel *porigW; - + WMSlider *vsli; WMSlider *hsli; @@ -53,7 +53,7 @@ typedef struct _Panel { WMFrame *maxiF; WMButton *miconB; WMButton *mdockB; - + WMFrame *opaqF; WMButton *opaqB; @@ -74,10 +74,10 @@ typedef struct _Panel { static char *placements[] = { "auto", - "random", - "manual", - "cascade", - "smart" + "random", + "manual", + "cascade", + "smart" }; @@ -92,11 +92,11 @@ sliderCallback(WMWidget *w, void *data) x = WMGetSliderValue(panel->hsli); y = WMGetSliderValue(panel->vsli); - + rx = x*(WMWidgetWidth(panel->porigF)-3)/swidth+2; ry = y*(WMWidgetHeight(panel->porigF)-3)/sheight+2; WMMoveWidget(panel->porigW, rx, ry); - + sprintf(buffer, "(%i,%i)", x, y); WMSetLabelText(panel->porigvL, buffer); } @@ -113,33 +113,33 @@ resistanceCallback(WMWidget *w, void *data) i = WMGetSliderValue(panel->resS); if (i == 0) - WMSetLabelText(panel->resL, "OFF"); + WMSetLabelText(panel->resL, "OFF"); else { - sprintf(buffer, "%i", i); - WMSetLabelText(panel->resL, buffer); + sprintf(buffer, "%i", i); + WMSetLabelText(panel->resL, buffer); } } static int -getPlacement(char *str) +getPlacement(char *str) { if (!str) - return 0; + return 0; if (strcasecmp(str, "auto")==0) - return 0; + return 0; else if (strcasecmp(str, "random")==0) - return 1; + return 1; else if (strcasecmp(str, "manual")==0) - return 2; + return 2; else if (strcasecmp(str, "cascade")==0) - return 3; + return 3; else if (strcasecmp(str, "smart")==0) return 4; else - wwarning(_("bad option value %s in WindowPlacement. Using default value"), - str); + wwarning(_("bad option value %s in WindowPlacement. Using default value"), + str); return 0; } @@ -157,15 +157,15 @@ showData(_Panel *panel) arr = GetObjectForKey("WindowPlaceOrigin"); - x = 0; + x = 0; y = 0; if (arr && (!WMIsPLArray(arr) || WMGetPropListItemCount(arr)!=2)) { - wwarning(_("invalid data in option WindowPlaceOrigin. Using default (0,0)")); + wwarning(_("invalid data in option WindowPlaceOrigin. Using default (0,0)")); } else { - if (arr) { - x = atoi(WMGetFromPLString(WMGetFromPLArray(arr, 0))); - y = atoi(WMGetFromPLString(WMGetFromPLArray(arr, 1))); - } + if (arr) { + x = atoi(WMGetFromPLString(WMGetFromPLArray(arr, 0))); + y = atoi(WMGetFromPLString(WMGetFromPLArray(arr, 1))); + } } WMSetSliderValue(panel->hsli, x); @@ -178,16 +178,16 @@ showData(_Panel *panel) resistanceCallback(NULL, panel); WMSetButtonSelected(panel->tranB, GetBoolForKey("OpenTransientOnOwnerWorkspace")); - + WMSetButtonSelected(panel->opaqB, GetBoolForKey("OpaqueMove")); - + WMSetButtonSelected(panel->miconB, GetBoolForKey("NoWindowOverIcons")); WMSetButtonSelected(panel->mdockB, GetBoolForKey("NoWindowOverDock")); if (GetBoolForKey("Attraction")) WMPerformButtonClick(panel->resrB); - else + else WMPerformButtonClick(panel->resaB); } @@ -197,13 +197,13 @@ storeData(_Panel *panel) { WMPropList *arr; char x[16], y[16]; - + SetBoolForKey(WMGetButtonSelected(panel->miconB), "NoWindowOverIcons"); SetBoolForKey(WMGetButtonSelected(panel->mdockB), "NoWindowOverDock"); SetBoolForKey(WMGetButtonSelected(panel->opaqB), "OpaqueMove"); SetBoolForKey(WMGetButtonSelected(panel->tranB), "OpenTransientOnOwnerWorkspace"); SetStringForKey(placements[WMGetPopUpButtonSelectedItem(panel->placP)], - "WindowPlacement"); + "WindowPlacement"); sprintf(x, "%i", WMGetSliderValue(panel->hsli)); sprintf(y, "%i", WMGetSliderValue(panel->vsli)); arr = WMCreatePLArray(WMCreatePLString(x), WMCreatePLString(y), NULL); @@ -225,16 +225,16 @@ createPanel(Panel *p) int swidth, sheight; char *path; WMBox *hbox; - + panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); WMSetBoxHorizontal(panel->box, False); WMSetBoxBorderWidth(panel->box, 8); - + hbox = WMCreateBox(panel->box); WMSetBoxHorizontal(hbox, True); WMAddBoxSubview(panel->box, WMWidgetView(hbox), False, True, 110, 0, 10); - + /************** Window Placement ***************/ panel->placF = WMCreateFrame(hbox); WMMapWidget(panel->placF); @@ -242,7 +242,7 @@ createPanel(Panel *p) WMSetFrameTitle(panel->placF, _("Window Placement")); WMSetBalloonTextForView(_("How to place windows when they are first put\n" - "on screen."), WMWidgetView(panel->placF)); + "on screen."), WMWidgetView(panel->placF)); panel->placP = WMCreatePopUpButton(panel->placF); WMResizeWidget(panel->placP, 105, 20); @@ -252,39 +252,39 @@ createPanel(Panel *p) WMAddPopUpButtonItem(panel->placP, _("Manual")); WMAddPopUpButtonItem(panel->placP, _("Cascade")); WMAddPopUpButtonItem(panel->placP, _("Smart")); - + panel->porigL = WMCreateLabel(panel->placF); WMResizeWidget(panel->porigL, 120, 32); WMMoveWidget(panel->porigL, 5, 45); WMSetLabelTextAlignment(panel->porigL, WACenter); WMSetLabelText(panel->porigL, _("Placement Origin")); - + panel->porigvL = WMCreateLabel(panel->placF); WMResizeWidget(panel->porigvL, 80, 20); WMMoveWidget(panel->porigvL, 30, 75); - WMSetLabelTextAlignment(panel->porigvL, WACenter); + WMSetLabelTextAlignment(panel->porigvL, WACenter); color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); panel->porigF = WMCreateFrame(panel->placF); WMSetWidgetBackgroundColor(panel->porigF, color); WMReleaseColor(color); WMSetFrameRelief(panel->porigF, WRSunken); - + swidth = WidthOfScreen(DefaultScreenOfDisplay(WMScreenDisplay(scr))); sheight = HeightOfScreen(DefaultScreenOfDisplay(WMScreenDisplay(scr))); - + if (sheight > swidth) { - height = 70; - width = 70*swidth/sheight; - if (width > 240) - width = 240; - height = 240*sheight/swidth; + height = 70; + width = 70*swidth/sheight; + if (width > 240) + width = 240; + height = 240*sheight/swidth; } else { - width = 240; - height = 240*sheight/swidth; - if (height > 70) - height = 70; - width = 70*swidth/sheight; + width = 240; + height = 240*sheight/swidth; + if (height > 70) + height = 70; + width = 70*swidth/sheight; } WMResizeWidget(panel->porigF, width, height); WMMoveWidget(panel->porigF, 130+(240-width)/2, 20+(70-height)/2); @@ -294,7 +294,7 @@ createPanel(Panel *p) WMMoveWidget(panel->porigW, 2, 2); WMSetLabelRelief(panel->porigW, WRRaised); - + panel->hsli = WMCreateSlider(panel->placF); WMResizeWidget(panel->hsli, width, 12); WMMoveWidget(panel->hsli, 130+(240-width)/2, 20+(70-height)/2+height+2); @@ -317,12 +317,12 @@ createPanel(Panel *p) panel->opaqF = WMCreateFrame(hbox); WMMapWidget(panel->opaqF); WMAddBoxSubview(hbox, WMWidgetView(panel->opaqF), False, True, 110, 0, 0); - + WMSetFrameTitle(panel->opaqF, _("Opaque Move")); WMSetBalloonTextForView(_("Whether the window contents should be moved\n" - "when dragging windows aroung or if only a\n" - "frame should be displayed.\n"), - WMWidgetView(panel->opaqF)); + "when dragging windows aroung or if only a\n" + "frame should be displayed.\n"), + WMWidgetView(panel->opaqF)); panel->opaqB = WMCreateButton(panel->opaqF, WBTToggle); WMResizeWidget(panel->opaqB, 64, 64); @@ -331,35 +331,35 @@ createPanel(Panel *p) path = LocateImage(NON_OPAQUE_MOVE_PIXMAP); if (path) { - pixmap = WMCreatePixmapFromFile(scr, path); - if (pixmap) { - WMSetButtonImage(panel->opaqB, pixmap); - WMReleasePixmap(pixmap); - } else { - wwarning(_("could not load icon %s"), path); - } - wfree(path); + pixmap = WMCreatePixmapFromFile(scr, path); + if (pixmap) { + WMSetButtonImage(panel->opaqB, pixmap); + WMReleasePixmap(pixmap); + } else { + wwarning(_("could not load icon %s"), path); + } + wfree(path); } - + path = LocateImage(OPAQUE_MOVE_PIXMAP); if (path) { - pixmap = WMCreatePixmapFromFile(scr, path); - if (pixmap) { - WMSetButtonAltImage(panel->opaqB, pixmap); - WMReleasePixmap(pixmap); - } else { - wwarning(_("could not load icon %s"), path); - } - wfree(path); + pixmap = WMCreatePixmapFromFile(scr, path); + if (pixmap) { + WMSetButtonAltImage(panel->opaqB, pixmap); + WMReleasePixmap(pixmap); + } else { + wwarning(_("could not load icon %s"), path); + } + wfree(path); } WMMapSubwidgets(panel->opaqF); - + /**************** Account for Icon/Dock ***************/ panel->maxiF = WMCreateFrame(panel->box); WMResizeWidget(panel->maxiF, 205, 95); WMMoveWidget(panel->maxiF, 305, 125); WMSetFrameTitle(panel->maxiF, _("When maximizing...")); - + panel->miconB = WMCreateSwitchButton(panel->maxiF); WMResizeWidget(panel->miconB, 190, 30); WMMoveWidget(panel->miconB, 10, 18); @@ -381,9 +381,9 @@ createPanel(Panel *p) WMSetFrameTitle(panel->resF, _("Edge Resistance")); WMSetBalloonTextForView(_("Edge resistance will make windows `resist'\n" - "being moved further for the defined threshold\n" - "when moved against other windows or the edges\n" - "of the screen."), WMWidgetView(panel->resF)); + "being moved further for the defined threshold\n" + "when moved against other windows or the edges\n" + "of the screen."), WMWidgetView(panel->resF)); panel->resS = WMCreateSlider(panel->resF); WMResizeWidget(panel->resS, 80, 15); @@ -410,21 +410,21 @@ createPanel(Panel *p) WMMapSubwidgets(panel->resF); /**************** Transients on Parent Workspace ****************/ - + panel->tranF = WMCreateFrame(panel->box); WMResizeWidget(panel->tranF, 285, 40); WMMoveWidget(panel->tranF, 8, 180); - + panel->tranB = WMCreateSwitchButton(panel->tranF); WMMoveWidget(panel->tranB, 10, 5); WMResizeWidget(panel->tranB, 250, 30); WMSetButtonText(panel->tranB, _("Open dialogs in the same workspace\nas their owners")); - + WMMapSubwidgets(panel->tranF); - + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); - + /* show the config data */ showData(panel); } @@ -448,15 +448,16 @@ InitWindowHandling(WMScreen *scr, WMWidget *parent) panel->sectionName = _("Window Handling Preferences"); panel->description = _("Window handling options. Initial placement style\n" - "edge resistance, opaque move etc."); + "edge resistance, opaque move etc."); panel->parent = parent; - + panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeData; panel->callbacks.undoChanges = undo; - + AddSection(panel, ICON_FILE); - + return panel; } + diff --git a/WPrefs.app/Workspace.c b/WPrefs.app/Workspace.c index 2c1c9421..35b16569 100644 --- a/WPrefs.app/Workspace.c +++ b/WPrefs.app/Workspace.c @@ -1,9 +1,9 @@ /* Workspace.c- workspace options - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -68,47 +68,47 @@ typedef struct _Panel { static char *WSNamePositions[] = { "none", - "center", - "top", - "bottom", - "topleft", - "topright", - "bottomleft", - "bottomright" + "center", + "top", + "bottom", + "topleft", + "topright", + "bottomleft", + "bottomright" }; static void -createImages(WMScreen *scr, RContext *rc, RImage *xis, char *file, - WMPixmap **icon1, WMPixmap **icon2) +createImages(WMScreen *scr, RContext *rc, RImage *xis, char *file, + WMPixmap **icon1, WMPixmap **icon2) { RImage *icon; RColor gray = {0xae,0xaa,0xae}; - + *icon1 = WMCreatePixmapFromFile(scr, file); if (!*icon1) { - wwarning(_("could not load icon %s"), file); - if (icon2) - *icon2 = NULL; - return; + wwarning(_("could not load icon %s"), file); + if (icon2) + *icon2 = NULL; + return; } if (!icon2) - return; - + return; + icon = RLoadImage(rc, file, 0); if (!icon) { - wwarning(_("could not load icon %s"), file); - *icon2 = NULL; - return; + wwarning(_("could not load icon %s"), file); + *icon2 = NULL; + return; } RCombineImageWithColor(icon, &gray); if (xis) { - RCombineImagesWithOpaqueness(icon, xis, 180); - if (!(*icon2 = WMCreatePixmapFromRImage(scr, icon, 127))) { - wwarning(_("could not process icon %s:"), file, RMessageForError(RErrorCode)); - *icon2 = NULL; - } + RCombineImagesWithOpaqueness(icon, xis, 180); + if (!(*icon2 = WMCreatePixmapFromRImage(scr, icon, 127))) { + wwarning(_("could not process icon %s:"), file, RMessageForError(RErrorCode)); + *icon2 = NULL; + } } RReleaseImage(icon); } @@ -122,25 +122,25 @@ showData(_Panel *panel) char *str; WMSetButtonSelected(panel->linkB, !GetBoolForKey("DontLinkWorkspaces")); - + WMSetButtonSelected(panel->cyclB, GetBoolForKey("CycleWorkspaces")); - + WMSetButtonSelected(panel->newB, GetBoolForKey("AdvanceToNewWorkspace")); - + WMSetButtonSelected(panel->dockB, !GetBoolForKey("DisableDock")); - + WMSetButtonSelected(panel->clipB, !GetBoolForKey("DisableClip")); str = GetStringForKey("WorkspaceNameDisplayPosition"); if (!str) - str = "center"; + str = "center"; idx = 1; /* center */ for (i = 0; i < sizeof(WSNamePositions)/sizeof(char*); i++) { - if (strcasecmp(WSNamePositions[i], str) == 0) { - idx = i; - break; - } + if (strcasecmp(WSNamePositions[i], str) == 0) { + idx = i; + break; + } } WMSetPopUpButtonSelectedItem(panel->posP, idx); } @@ -156,31 +156,31 @@ createPanel(Panel *p) RImage *xis = NULL; RContext *rc = WMScreenRContext(scr); char *path; - + path = LocateImage(ARQUIVO_XIS); if (path) { - xis = RLoadImage(rc, path, 0); - if (!xis) { - wwarning(_("could not load image file %s"), path); - } - wfree(path); + xis = RLoadImage(rc, path, 0); + if (!xis) { + wwarning(_("could not load image file %s"), path); + } + wfree(path); } panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - + /***************** Workspace Navigation *****************/ panel->navF = WMCreateFrame(panel->box); WMResizeWidget(panel->navF, 365, 210); WMMoveWidget(panel->navF, 15, 10); WMSetFrameTitle(panel->navF, _("Workspace Navigation")); - + panel->cyclB = WMCreateSwitchButton(panel->navF); WMResizeWidget(panel->cyclB, 280, 34); WMMoveWidget(panel->cyclB, 75, 30); WMSetButtonText(panel->cyclB, - _("Wrap to the first workspace from the last workspace.")); + _("Wrap to the first workspace from the last workspace.")); panel->cyclL = WMCreateLabel(panel->navF); WMResizeWidget(panel->cyclL, 60, 60); @@ -188,12 +188,12 @@ createPanel(Panel *p) WMSetLabelImagePosition(panel->cyclL, WIPImageOnly); path = LocateImage(CYCLE_FILE); if (path) { - createImages(scr, rc, xis, path, &icon1, NULL); - if (icon1) { - WMSetLabelImage(panel->cyclL, icon1); - WMReleasePixmap(icon1); - } - wfree(path); + createImages(scr, rc, xis, path, &icon1, NULL); + if (icon1) { + WMSetLabelImage(panel->cyclL, icon1); + WMReleasePixmap(icon1); + } + wfree(path); } /**/ @@ -202,7 +202,7 @@ createPanel(Panel *p) WMResizeWidget(panel->linkB, 280, 34); WMMoveWidget(panel->linkB, 75, 75); WMSetButtonText(panel->linkB, - _("Switch workspaces while dragging windows.")); + _("Switch workspaces while dragging windows.")); panel->linkL = WMCreateLabel(panel->navF); WMResizeWidget(panel->linkL, 60, 40); @@ -210,21 +210,21 @@ createPanel(Panel *p) WMSetLabelImagePosition(panel->linkL, WIPImageOnly); path = LocateImage(DONT_LINK_FILE); if (path) { - createImages(scr, rc, xis, path, &icon1, NULL); - if (icon1) { - WMSetLabelImage(panel->linkL, icon1); - WMReleasePixmap(icon1); - } - wfree(path); + createImages(scr, rc, xis, path, &icon1, NULL); + if (icon1) { + WMSetLabelImage(panel->linkL, icon1); + WMReleasePixmap(icon1); + } + wfree(path); } /**/ - + panel->newB = WMCreateSwitchButton(panel->navF); WMResizeWidget(panel->newB, 280, 34); WMMoveWidget(panel->newB, 75, 120); WMSetButtonText(panel->newB, - _("Automatically create new workspaces.")); + _("Automatically create new workspaces.")); panel->newL = WMCreateLabel(panel->navF); WMResizeWidget(panel->newL, 60, 20); @@ -232,37 +232,37 @@ createPanel(Panel *p) WMSetLabelImagePosition(panel->newL, WIPImageOnly); path = LocateImage(ADVANCE_FILE); if (path) { - createImages(scr, rc, xis, path, &icon1, NULL); - if (icon1) { - WMSetLabelImage(panel->newL, icon1); - WMReleasePixmap(icon1); - } - wfree(path); + createImages(scr, rc, xis, path, &icon1, NULL); + if (icon1) { + WMSetLabelImage(panel->newL, icon1); + WMReleasePixmap(icon1); + } + wfree(path); } /**/ - + panel->posL = WMCreateLabel(panel->navF); WMResizeWidget(panel->posL, 140, 30); WMMoveWidget(panel->posL, 75, 165); WMSetLabelTextAlignment(panel->posL, WARight); - WMSetLabelText(panel->posL, - _("Position of workspace\nname display")); - + WMSetLabelText(panel->posL, + _("Position of workspace\nname display")); + panel->posiL = WMCreateLabel(panel->navF); WMResizeWidget(panel->posiL, 60, 40); WMMoveWidget(panel->posiL, 10, 160); WMSetLabelImagePosition(panel->posiL, WIPImageOnly); path = LocateImage(WSNAME_FILE); if (path) { - createImages(scr, rc, xis, path, &icon1, NULL); - if (icon1) { - WMSetLabelImage(panel->posiL, icon1); - WMReleasePixmap(icon1); - } - wfree(path); + createImages(scr, rc, xis, path, &icon1, NULL); + if (icon1) { + WMSetLabelImage(panel->posiL, icon1); + WMReleasePixmap(icon1); + } + wfree(path); } - + panel->posP = WMCreatePopUpButton(panel->navF); WMResizeWidget(panel->posP, 125, 20); WMMoveWidget(panel->posP, 225, 175); @@ -274,7 +274,7 @@ createPanel(Panel *p) WMAddPopUpButtonItem(panel->posP, _("Top/Right")); WMAddPopUpButtonItem(panel->posP, _("Bottom/Left")); WMAddPopUpButtonItem(panel->posP, _("Bottom/Right")); - + WMMapSubwidgets(panel->navF); /***************** Dock/Clip *****************/ @@ -289,20 +289,20 @@ createPanel(Panel *p) WMSetButtonImagePosition(panel->dockB, WIPImageOnly); path = LocateImage(DOCK_FILE); if (path) { - createImages(scr, rc, xis, path, &icon1, &icon2); - if (icon2) { - WMSetButtonImage(panel->dockB, icon2); - WMReleasePixmap(icon2); - } - if (icon1) { - WMSetButtonAltImage(panel->dockB, icon1); - WMReleasePixmap(icon1); - } - wfree(path); + createImages(scr, rc, xis, path, &icon1, &icon2); + if (icon2) { + WMSetButtonImage(panel->dockB, icon2); + WMReleasePixmap(icon2); + } + if (icon1) { + WMSetButtonAltImage(panel->dockB, icon1); + WMReleasePixmap(icon1); + } + wfree(path); } WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n" - "vertical icon bar in the side of the screen)."), - WMWidgetView(panel->dockB)); + "vertical icon bar in the side of the screen)."), + WMWidgetView(panel->dockB)); panel->clipB = WMCreateButton(panel->dockF, WBTToggle); WMResizeWidget(panel->clipB, 64, 64); @@ -310,26 +310,26 @@ createPanel(Panel *p) WMSetButtonImagePosition(panel->clipB, WIPImageOnly); path = LocateImage(CLIP_FILE); if (path) { - createImages(scr, rc, xis, path, &icon1, &icon2); - if (icon2) { - WMSetButtonImage(panel->clipB, icon2); - WMReleasePixmap(icon2); - } - if (icon1) { - WMSetButtonAltImage(panel->clipB, icon1); - WMReleasePixmap(icon1); - } - wfree(path); + createImages(scr, rc, xis, path, &icon1, &icon2); + if (icon2) { + WMSetButtonImage(panel->clipB, icon2); + WMReleasePixmap(icon2); + } + if (icon1) { + WMSetButtonAltImage(panel->clipB, icon1); + WMReleasePixmap(icon1); + } + wfree(path); } WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n" - "a paper clip icon)."), - WMWidgetView(panel->clipB)); + "a paper clip icon)."), + WMWidgetView(panel->clipB)); WMMapSubwidgets(panel->dockF); if (xis) - RReleaseImage(xis); - + RReleaseImage(xis); + WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); @@ -343,12 +343,12 @@ storeData(_Panel *panel) SetBoolForKey(!WMGetButtonSelected(panel->linkB), "DontLinkWorkspaces"); SetBoolForKey(WMGetButtonSelected(panel->cyclB), "CycleWorkspaces"); SetBoolForKey(WMGetButtonSelected(panel->newB), "AdvanceToNewWorkspace"); - + SetBoolForKey(!WMGetButtonSelected(panel->dockB), "DisableDock"); SetBoolForKey(!WMGetButtonSelected(panel->clipB), "DisableClip"); - + SetStringForKey(WSNamePositions[WMGetPopUpButtonSelectedItem(panel->posP)], - "WorkspaceNameDisplayPosition"); + "WorkspaceNameDisplayPosition"); } @@ -364,10 +364,10 @@ InitWorkspace(WMScreen *scr, WMWidget *parent) panel->sectionName = _("Workspace Preferences"); panel->description = _("Workspace navigation features.\n" - "You can also enable/disable the Dock and Clip here."); + "You can also enable/disable the Dock and Clip here."); panel->parent = parent; - + panel->callbacks.createWidgets = createPanel; panel->callbacks.updateDomain = storeData; @@ -375,3 +375,4 @@ InitWorkspace(WMScreen *scr, WMWidget *parent) return panel; } + diff --git a/WPrefs.app/double.c b/WPrefs.app/double.c index 98d81256..ce628d2a 100644 --- a/WPrefs.app/double.c +++ b/WPrefs.app/double.c @@ -1,7 +1,7 @@ /* * Widget for testing double-clicks - * + * */ #include @@ -46,7 +46,7 @@ InitDoubleTest(WMScreen *scr) { /* register our widget with WINGs and get our widget class ID */ if (!DoubleTestClass) { - DoubleTestClass = W_RegisterUserWidget(); + DoubleTestClass = W_RegisterUserWidget(); } return DoubleTestClass; @@ -62,8 +62,8 @@ CreateDoubleTest(WMWidget *parent, char *text) DoubleTest *dPtr; if (!DoubleTestClass) - InitDoubleTest(WMWidgetScreen(parent)); - + InitDoubleTest(WMWidgetScreen(parent)); + /* allocate some storage for our new widget instance */ dPtr = wmalloc(sizeof(DoubleTest)); /* initialize it */ @@ -71,20 +71,20 @@ CreateDoubleTest(WMWidget *parent, char *text) /* set the class ID */ dPtr->widgetClass = DoubleTestClass; - + dPtr->view = W_CreateView(W_VIEW(parent)); if (!dPtr->view) { - wfree(dPtr); - return NULL; + wfree(dPtr); + return NULL; } /* always do this */ dPtr->view->self = dPtr; - + dPtr->text = wstrdup(text); WMCreateEventHandler(dPtr->view, ExposureMask /* this allows us to know when we should paint */ - |StructureNotifyMask, /* this allows us to know things like when we are destroyed */ - handleEvents, dPtr); + |StructureNotifyMask, /* this allows us to know things like when we are destroyed */ + handleEvents, dPtr); WMCreateEventHandler(dPtr->view, ButtonPressMask,handleActionEvents, dPtr); @@ -99,21 +99,21 @@ paintDoubleTest(_DoubleTest *dPtr) W_Screen *scr = dPtr->view->screen; if (dPtr->active) { - XFillRectangle(scr->display, dPtr->view->window, WMColorGC(scr->white), - 0, 0, dPtr->view->size.width, dPtr->view->size.height); + XFillRectangle(scr->display, dPtr->view->window, WMColorGC(scr->white), + 0, 0, dPtr->view->size.width, dPtr->view->size.height); } else { - XClearWindow(scr->display, dPtr->view->window); + XClearWindow(scr->display, dPtr->view->window); } - + W_DrawRelief(scr, dPtr->view->window, 0, 0, dPtr->view->size.width, - dPtr->view->size.height, dPtr->on ? WRSunken : WRRaised); + dPtr->view->size.height, dPtr->on ? WRSunken : WRRaised); if (dPtr->text) { - int y; - y = (dPtr->view->size.height-scr->normalFont->height)/2; - W_PaintText(dPtr->view, dPtr->view->window, scr->normalFont, - dPtr->on, dPtr->on+y, dPtr->view->size.width, WACenter, - scr->black, False, dPtr->text, strlen(dPtr->text)); + int y; + y = (dPtr->view->size.height-scr->normalFont->height)/2; + W_PaintText(dPtr->view, dPtr->view->window, scr->normalFont, + dPtr->on, dPtr->on+y, dPtr->view->size.width, WACenter, + scr->black, False, dPtr->text, strlen(dPtr->text)); } } @@ -125,17 +125,17 @@ handleEvents(XEvent *event, void *data) _DoubleTest *dPtr = (_DoubleTest*)data; - switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintDoubleTest(dPtr); - break; - - case DestroyNotify: - destroyDoubleTest(dPtr); - break; - + switch (event->type) { + case Expose: + if (event->xexpose.count!=0) + break; + paintDoubleTest(dPtr); + break; + + case DestroyNotify: + destroyDoubleTest(dPtr); + break; + } } @@ -143,12 +143,12 @@ handleEvents(XEvent *event, void *data) static void deactivate(void *data) { - _DoubleTest *dPtr = (_DoubleTest*)data; - + _DoubleTest *dPtr = (_DoubleTest*)data; + if (dPtr->active) - dPtr->active = 0; + dPtr->active = 0; paintDoubleTest(dPtr); - + dPtr->timer = NULL; } @@ -160,21 +160,21 @@ handleActionEvents(XEvent *event, void *data) extern _WINGsConfiguration WINGsConfiguration; switch (event->type) { - case ButtonPress: - if (WMIsDoubleClick(event)) { - if (dPtr->timer) - WMDeleteTimerHandler(dPtr->timer); - dPtr->timer = NULL; - dPtr->on = !dPtr->on; - dPtr->active = 0; - paintDoubleTest(dPtr); - } else { - dPtr->timer=WMAddTimerHandler(WINGsConfiguration.doubleClickDelay, - deactivate, dPtr); - dPtr->active = 1; - paintDoubleTest(dPtr); - } - break; + case ButtonPress: + if (WMIsDoubleClick(event)) { + if (dPtr->timer) + WMDeleteTimerHandler(dPtr->timer); + dPtr->timer = NULL; + dPtr->on = !dPtr->on; + dPtr->active = 0; + paintDoubleTest(dPtr); + } else { + dPtr->timer=WMAddTimerHandler(WINGsConfiguration.doubleClickDelay, + deactivate, dPtr); + dPtr->active = 1; + paintDoubleTest(dPtr); + } + break; } } @@ -184,10 +184,10 @@ static void destroyDoubleTest(_DoubleTest *dPtr) { if (dPtr->timer) - WMDeleteTimerHandler(dPtr->timer); + WMDeleteTimerHandler(dPtr->timer); if (dPtr->text) - wfree(dPtr->text); - + wfree(dPtr->text); + wfree(dPtr); } diff --git a/WPrefs.app/double.h b/WPrefs.app/double.h index f31ba9ce..3d0b8132 100644 --- a/WPrefs.app/double.h +++ b/WPrefs.app/double.h @@ -3,3 +3,4 @@ typedef struct W_DoubleTest DoubleTest; DoubleTest *CreateDoubleTest(WMWidget *parent, char *text); + diff --git a/WPrefs.app/editmenu.c b/WPrefs.app/editmenu.c index 4be180fd..470d6741 100644 --- a/WPrefs.app/editmenu.c +++ b/WPrefs.app/editmenu.c @@ -1,9 +1,9 @@ /* editmenu.c - editable menus - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 2000-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -42,10 +42,10 @@ typedef struct W_EditMenuItem { WMCallback *destroyData; struct W_EditMenu *submenu; /* if it's a cascade, NULL otherwise */ - + struct { - unsigned isTitle:1; - unsigned isHighlighted:1; + unsigned isTitle:1; + unsigned isHighlighted:1; } flags; } EditMenuItem; @@ -57,16 +57,16 @@ typedef struct W_EditMenu { struct W_EditMenu *parent; WMArray *items; /* EditMenuItem */ - + EditMenuItem *selectedItem; - + WMTextField *tfield; WMButton *closeB; int titleHeight; int itemHeight; - + WEditMenuDelegate *delegate; WMTextFieldDelegate *tdelegate; @@ -74,26 +74,26 @@ typedef struct W_EditMenu { /* item dragging */ int draggedItem; int dragX, dragY; - + /* only for non-standalone menu */ WMSize maxSize; WMSize minSize; - + struct { - unsigned standalone:1; - unsigned isTitled:1; - - unsigned acceptsDrop:1; - unsigned isFactory:1; - unsigned isSelectable:1; - unsigned isEditable:1; - - unsigned isTornOff:1; - - unsigned isDragging:1; - unsigned isEditing:1; - - unsigned wasMapped:1; + unsigned standalone:1; + unsigned isTitled:1; + + unsigned acceptsDrop:1; + unsigned isFactory:1; + unsigned isSelectable:1; + unsigned isEditable:1; + + unsigned isTornOff:1; + + unsigned isDragging:1; + unsigned isEditing:1; + + unsigned wasMapped:1; } flags; } EditMenu; @@ -116,7 +116,7 @@ InitEditMenuItem(WMScreen *scr) { /* register our widget with WINGs and get our widget class ID */ if (!EditMenuItemClass) { - EditMenuItemClass = W_RegisterUserWidget(); + EditMenuItemClass = W_RegisterUserWidget(); } return EditMenuItemClass; @@ -130,7 +130,7 @@ WCreateEditMenuItem(WMWidget *parent, char *title, Bool isTitle) WMScreen *scr = WMWidgetScreen(parent); if (!EditMenuItemClass) - InitEditMenuItem(scr); + InitEditMenuItem(scr); iPtr = wmalloc(sizeof(WEditMenuItem)); @@ -138,29 +138,29 @@ WCreateEditMenuItem(WMWidget *parent, char *title, Bool isTitle) memset(iPtr, 0, sizeof(WEditMenuItem)); iPtr->widgetClass = EditMenuItemClass; - + iPtr->view = W_CreateView(W_VIEW(parent)); if (!iPtr->view) { - wfree(iPtr); - return NULL; + wfree(iPtr); + return NULL; } iPtr->view->self = iPtr; iPtr->parent = parent; - + iPtr->label = wstrdup(title); - + iPtr->flags.isTitle = isTitle; - + if (isTitle) { - WMSetWidgetBackgroundColor(iPtr, WMBlackColor(scr)); + WMSetWidgetBackgroundColor(iPtr, WMBlackColor(scr)); } - + WMCreateEventHandler(iPtr->view, ExposureMask|StructureNotifyMask, - handleItemEvents, iPtr); - + handleItemEvents, iPtr); + WMCreateEventHandler(iPtr->view, ButtonPressMask|ButtonReleaseMask - |ButtonMotionMask, handleItemClick, iPtr); + |ButtonMotionMask, handleItemClick, iPtr); return iPtr; @@ -191,7 +191,7 @@ void WSetEditMenuItemImage(WEditMenuItem *item, WMPixmap *pixmap) { if (item->pixmap) - WMReleasePixmap(item->pixmap); + WMReleasePixmap(item->pixmap); item->pixmap = WMRetainPixmap(pixmap); } @@ -207,11 +207,11 @@ paintEditMenuItem(WEditMenuItem *iPtr) WMFont *font = (iPtr->flags.isTitle ? scr->boldFont : scr->normalFont); if (!iPtr->view->flags.realized) - return; + return; color = scr->black; if (iPtr->flags.isTitle && !iPtr->flags.isHighlighted) { - color = scr->white; + color = scr->white; } @@ -222,40 +222,40 @@ paintEditMenuItem(WEditMenuItem *iPtr) WMDrawString(scr, win, color, font, 5, 3, iPtr->label, strlen(iPtr->label)); if (iPtr->pixmap) { - WMSize size = WMGetPixmapSize(iPtr->pixmap); - - WMDrawPixmap(iPtr->pixmap, win, w - size.width - 5, - (h - size.height)/2); + WMSize size = WMGetPixmapSize(iPtr->pixmap); + + WMDrawPixmap(iPtr->pixmap, win, w - size.width - 5, + (h - size.height)/2); } else if (iPtr->submenu) { - /* draw the cascade indicator */ - XDrawLine(scr->display,win,WMColorGC(scr->darkGray), - w-11, 6, w-6, h/2-1); - XDrawLine(scr->display,win,WMColorGC(scr->white), - w-11, h-8, w-6, h/2-1); - XDrawLine(scr->display,win,WMColorGC(scr->black), - w-12, 6, w-12, h-8); + /* draw the cascade indicator */ + XDrawLine(scr->display,win,WMColorGC(scr->darkGray), + w-11, 6, w-6, h/2-1); + XDrawLine(scr->display,win,WMColorGC(scr->white), + w-11, h-8, w-6, h/2-1); + XDrawLine(scr->display,win,WMColorGC(scr->black), + w-12, 6, w-12, h-8); } } static void highlightItem(WEditMenuItem *iPtr, Bool high) -{ +{ if (iPtr->flags.isTitle) - return; - + return; + iPtr->flags.isHighlighted = high; if (high) { - WMSetWidgetBackgroundColor(iPtr, WMWhiteColor(WMWidgetScreen(iPtr))); + WMSetWidgetBackgroundColor(iPtr, WMWhiteColor(WMWidgetScreen(iPtr))); } else { - if (!iPtr->flags.isTitle) { - WMSetWidgetBackgroundColor(iPtr, - WMGrayColor(WMWidgetScreen(iPtr))); - } else { - WMSetWidgetBackgroundColor(iPtr, - WMBlackColor(WMWidgetScreen(iPtr))); - } + if (!iPtr->flags.isTitle) { + WMSetWidgetBackgroundColor(iPtr, + WMGrayColor(WMWidgetScreen(iPtr))); + } else { + WMSetWidgetBackgroundColor(iPtr, + WMBlackColor(WMWidgetScreen(iPtr))); + } } } @@ -264,13 +264,13 @@ static int getItemTextWidth(WEditMenuItem *iPtr) { WMScreen *scr = WMWidgetScreen(iPtr); - + if (iPtr->flags.isTitle) { - return WMWidthOfString(scr->boldFont, iPtr->label, - strlen(iPtr->label)); + return WMWidthOfString(scr->boldFont, iPtr->label, + strlen(iPtr->label)); } else { - return WMWidthOfString(scr->normalFont, iPtr->label, - strlen(iPtr->label)); + return WMWidthOfString(scr->normalFont, iPtr->label, + strlen(iPtr->label)); } } @@ -281,16 +281,16 @@ handleItemEvents(XEvent *event, void *data) { WEditMenuItem *iPtr = (WEditMenuItem*)data; - switch (event->type) { - case Expose: - if (event->xexpose.count!=0) - break; - paintEditMenuItem(iPtr); - break; - - case DestroyNotify: - destroyEditMenuItem(iPtr); - break; + switch (event->type) { + case Expose: + if (event->xexpose.count!=0) + break; + paintEditMenuItem(iPtr); + break; + + case DestroyNotify: + destroyEditMenuItem(iPtr); + break; } } @@ -299,11 +299,11 @@ static void destroyEditMenuItem(WEditMenuItem *iPtr) { if (iPtr->label) - wfree(iPtr->label); + wfree(iPtr->label); if (iPtr->data && iPtr->destroyData) - (*iPtr->destroyData)(iPtr->data); + (*iPtr->destroyData)(iPtr->data); if (iPtr->submenu) - WMDestroyWidget(iPtr->submenu); + WMDestroyWidget(iPtr->submenu); wfree(iPtr); } @@ -334,7 +334,7 @@ InitEditMenu(WMScreen *scr) /* register our widget with WINGs and get our widget class ID */ if (!EditMenuClass) { - EditMenuClass = W_RegisterUserWidget(); + EditMenuClass = W_RegisterUserWidget(); } return EditMenuClass; @@ -363,7 +363,7 @@ static void writeGNUstepWMAttr(WMScreen *scr, Window window, GNUstepWMAttributes *attr) { unsigned long data[9]; - + /* handle idiot compilers where array of CARD32 != struct of CARD32 */ data[0] = attr->flags; data[1] = attr->window_style; @@ -403,16 +403,16 @@ itemSelectObserver(void *self, WMNotification *notif) rmenu = (WEditMenu*)WMGetNotificationObject(notif); /* check whether rmenu is from the same hierarchy of menu? */ - + if (rmenu == menu) { - return; + return; } if (menu->selectedItem) { - if (!menu->selectedItem->submenu) - deselectItem(menu); - if (menu->flags.isEditing) - stopEditItem(menu, False); + if (!menu->selectedItem->submenu) + deselectItem(menu); + if (menu->flags.isEditing) + stopEditItem(menu, False); } } @@ -424,7 +424,7 @@ makeEditMenu(WMScreen *scr, WMWidget *parent, char *title) WEditMenuItem *item; if (!EditMenuClass) - InitEditMenu(scr); + InitEditMenu(scr); mPtr = wmalloc(sizeof(WEditMenu)); @@ -433,15 +433,15 @@ makeEditMenu(WMScreen *scr, WMWidget *parent, char *title) mPtr->widgetClass = EditMenuClass; if (parent) { - mPtr->view = W_CreateView(W_VIEW(parent)); - mPtr->flags.standalone = 0; + mPtr->view = W_CreateView(W_VIEW(parent)); + mPtr->flags.standalone = 0; } else { - mPtr->view = W_CreateTopView(scr); - mPtr->flags.standalone = 1; + mPtr->view = W_CreateTopView(scr); + mPtr->flags.standalone = 1; } if (!mPtr->view) { - wfree(mPtr); - return NULL; + wfree(mPtr); + return NULL; } mPtr->view->self = mPtr; @@ -459,23 +459,23 @@ makeEditMenu(WMScreen *scr, WMWidget *parent, char *title) mPtr->items = WMCreateArray(4); WMCreateEventHandler(mPtr->view, ExposureMask|StructureNotifyMask, - handleEvents, mPtr); - + handleEvents, mPtr); + if (title != NULL) { - item = WCreateEditMenuItem(mPtr, title, True); + item = WCreateEditMenuItem(mPtr, title, True); - WMMapWidget(item); - WMAddToArray(mPtr->items, item); + WMMapWidget(item); + WMAddToArray(mPtr->items, item); - mPtr->flags.isTitled = 1; + mPtr->flags.isTitled = 1; } mPtr->itemHeight = WMFontHeight(scr->normalFont) + 6; mPtr->titleHeight = WMFontHeight(scr->boldFont) + 8; updateMenuContents(mPtr); - + return mPtr; } @@ -511,13 +511,13 @@ WInsertMenuItemWithTitle(WEditMenu *mPtr, int index, char *title) WMMapWidget(item); if (index >= WMGetArrayItemCount(mPtr->items)) { - WMAddToArray(mPtr->items, item); + WMAddToArray(mPtr->items, item); } else { - if (index < 0) - index = 0; - if (mPtr->flags.isTitled) - index++; - WMInsertInArray(mPtr->items, index, item); + if (index < 0) + index = 0; + if (mPtr->flags.isTitled) + index++; + WMInsertInArray(mPtr->items, index, item); } updateMenuContents(mPtr); @@ -530,7 +530,7 @@ WEditMenuItem* WGetEditMenuItem(WEditMenu *mPtr, int index) { if (index >= WMGetArrayItemCount(mPtr->items)) - return NULL; + return NULL; return WMGetFromArray(mPtr->items, index + (mPtr->flags.isTitled ? 1 : 0)); } @@ -540,7 +540,7 @@ WEditMenuItem* WAddMenuItemWithTitle(WEditMenu *mPtr, char *title) { return WInsertMenuItemWithTitle(mPtr, WMGetArrayItemCount(mPtr->items), - title); + title); } @@ -651,20 +651,20 @@ WGetEditMenuLocationForSubmenu(WEditMenu *mPtr, WEditMenu *submenu) int y; if (mPtr->flags.isTitled) - y = -mPtr->titleHeight; + y = -mPtr->titleHeight; else - y = 0; + y = 0; WM_ITERATE_ARRAY(mPtr->items, item, iter) { - if (item->submenu == submenu) { - WMPoint pt = WMGetViewScreenPosition(mPtr->view); + if (item->submenu == submenu) { + WMPoint pt = WMGetViewScreenPosition(mPtr->view); - return wmkpoint(pt.x + mPtr->view->size.width, pt.y + y); - } - y += W_VIEW_HEIGHT(item->view); + return wmkpoint(pt.x + mPtr->view->size.width, pt.y + y); + } + y += W_VIEW_HEIGHT(item->view); } puts("invalid submenu passed to WGetEditMenuLocationForSubmenu()"); - + return wmkpoint(0,0); } @@ -686,11 +686,11 @@ void WTearOffEditMenu(WEditMenu *menu, WEditMenu *submenu) { WEditMenuItem *item; - + submenu->flags.isTornOff = 1; - + item = (WEditMenuItem*)WMGetFromArray(submenu->items, 0); - + submenu->closeB = WMCreateCommandButton(item); WMResizeWidget(submenu->closeB, 15, 15); WMMoveWidget(submenu->closeB, W_VIEW(submenu)->size.width - 20, 3); @@ -700,9 +700,9 @@ WTearOffEditMenu(WEditMenu *menu, WEditMenu *submenu) WMMapWidget(submenu->closeB); if (menu->selectedItem && menu->selectedItem->submenu == submenu) - deselectItem(menu); + deselectItem(menu); } - + Bool @@ -720,18 +720,18 @@ WEditMenuHide(WEditMenu *mPtr) int i = 0; if (WMWidgetIsMapped(mPtr)) { - WMUnmapWidget(mPtr); - mPtr->flags.wasMapped = 1; + WMUnmapWidget(mPtr); + mPtr->flags.wasMapped = 1; } else { - mPtr->flags.wasMapped = 0; + mPtr->flags.wasMapped = 0; } while ((item = WGetEditMenuItem(mPtr, i++))) { - WEditMenu *submenu; + WEditMenu *submenu; - submenu = WGetEditMenuSubmenu(mPtr, item); - if (submenu) { - WEditMenuHide(submenu); - } + submenu = WGetEditMenuSubmenu(mPtr, item); + if (submenu) { + WEditMenuHide(submenu); + } } } @@ -744,15 +744,15 @@ WEditMenuUnhide(WEditMenu *mPtr) int i = 0; if (mPtr->flags.wasMapped) { - WMMapWidget(mPtr); + WMMapWidget(mPtr); } while ((item = WGetEditMenuItem(mPtr, i++))) { - WEditMenu *submenu; + WEditMenu *submenu; - submenu = WGetEditMenuSubmenu(mPtr, item); - if (submenu) { - WEditMenuUnhide(submenu); - } + submenu = WGetEditMenuSubmenu(mPtr, item); + if (submenu) { + WEditMenuUnhide(submenu); + } } } @@ -770,8 +770,8 @@ WEditMenuShowAt(WEditMenu *menu, int x, int y) WMMoveWidget(menu, x, y); XSetWMNormalHints(W_VIEW_DISPLAY(menu->view), - W_VIEW_DRAWABLE(menu->view), - hints); + W_VIEW_DRAWABLE(menu->view), + hints); XFree(hints); WMMapWidget(menu); @@ -793,51 +793,51 @@ updateMenuContents(WEditMenu *mPtr) newH = offs; i = 0; - WM_ITERATE_ARRAY(mPtr->items, item, iter) { - w = getItemTextWidth(item); - - newW = WMAX(w, newW); - - WMMoveWidget(item, offs, newH); - if (i == 0 && mPtr->flags.isTitled) { - newH += mPtr->titleHeight; - } else { - newH += iheight; - } - i = 1; + WM_ITERATE_ARRAY(mPtr->items, item, iter) { + w = getItemTextWidth(item); + + newW = WMAX(w, newW); + + WMMoveWidget(item, offs, newH); + if (i == 0 && mPtr->flags.isTitled) { + newH += mPtr->titleHeight; + } else { + newH += iheight; + } + i = 1; } newW += iheight + 10; newH--; - + if (mPtr->minSize.width) - newW = WMAX(newW, mPtr->minSize.width); + newW = WMAX(newW, mPtr->minSize.width); if (mPtr->maxSize.width) - newW = WMIN(newW, mPtr->maxSize.width); - + newW = WMIN(newW, mPtr->maxSize.width); + if (mPtr->minSize.height) - newH = WMAX(newH, mPtr->minSize.height); + newH = WMAX(newH, mPtr->minSize.height); if (mPtr->maxSize.height) - newH = WMIN(newH, mPtr->maxSize.height); - + newH = WMIN(newH, mPtr->maxSize.height); + if (W_VIEW(mPtr)->size.width == newW && mPtr->view->size.height == newH+1) - return; + return; W_ResizeView(mPtr->view, newW, newH+1); if (mPtr->closeB) - WMMoveWidget(mPtr->closeB, newW - 20, 3); + WMMoveWidget(mPtr->closeB, newW - 20, 3); newW -= 2*offs; - + i = 0; WM_ITERATE_ARRAY(mPtr->items, item, iter) { - if (i == 0 && mPtr->flags.isTitled) { - WMResizeWidget(item, newW, mPtr->titleHeight); - } else { - WMResizeWidget(item, newW, iheight); - } - i = 1; + if (i == 0 && mPtr->flags.isTitled) { + WMResizeWidget(item, newW, mPtr->titleHeight); + } else { + WMResizeWidget(item, newW, iheight); + } + i = 1; } } @@ -847,18 +847,18 @@ deselectItem(WEditMenu *menu) { WEditMenu *submenu; WEditMenuItem *item = menu->selectedItem; - + highlightItem(item, False); - + if (menu->delegate && menu->delegate->itemDeselected) { - (*menu->delegate->itemDeselected)(menu->delegate, menu, item); + (*menu->delegate->itemDeselected)(menu->delegate, menu, item); } submenu = item->submenu; if (submenu && !WEditMenuIsTornOff(submenu)) { - WEditMenuHide(submenu); + WEditMenuHide(submenu); } - + menu->selectedItem = NULL; } @@ -867,34 +867,34 @@ static void selectItem(WEditMenu *menu, WEditMenuItem *item) { if (!menu->flags.isSelectable || menu->selectedItem == item) { - return; + return; } if (menu->selectedItem) { - deselectItem(menu); + deselectItem(menu); } if (menu->flags.isEditing) { - stopEditItem(menu, False); + stopEditItem(menu, False); } if (item && !item->flags.isTitle) { - highlightItem(item, True); + highlightItem(item, True); + + if (item->submenu && !W_VIEW_MAPPED(item->submenu->view)) { + WMPoint pt; - if (item->submenu && !W_VIEW_MAPPED(item->submenu->view)) { - WMPoint pt; + pt = WGetEditMenuLocationForSubmenu(menu, item->submenu); - pt = WGetEditMenuLocationForSubmenu(menu, item->submenu); - - WEditMenuShowAt(item->submenu, pt.x, pt.y); - - item->submenu->flags.isTornOff = 0; - } + WEditMenuShowAt(item->submenu, pt.x, pt.y); - WMPostNotificationName("EditMenuItemSelected", menu, NULL); + item->submenu->flags.isTornOff = 0; + } - if (menu->delegate && menu->delegate->itemSelected) { - (*menu->delegate->itemSelected)(menu->delegate, menu, item); - } + WMPostNotificationName("EditMenuItemSelected", menu, NULL); + + if (menu->delegate && menu->delegate->itemSelected) { + (*menu->delegate->itemSelected)(menu->delegate, menu, item); + } } menu->selectedItem = item; @@ -905,9 +905,9 @@ static void paintMenu(WEditMenu *mPtr) { W_View *view = mPtr->view; - + W_DrawRelief(W_VIEW_SCREEN(view), W_VIEW_DRAWABLE(view), 0, 0, - W_VIEW_WIDTH(view), W_VIEW_HEIGHT(view), WRSimple); + W_VIEW_WIDTH(view), W_VIEW_HEIGHT(view), WRSimple); } @@ -916,15 +916,15 @@ handleEvents(XEvent *event, void *data) { WEditMenu *mPtr = (WEditMenu*)data; - switch (event->type) { - case DestroyNotify: - destroyEditMenu(mPtr); - break; - - case Expose: - if (event->xexpose.count == 0) - paintMenu(mPtr); - break; + switch (event->type) { + case DestroyNotify: + destroyEditMenu(mPtr); + break; + + case Expose: + if (event->xexpose.count == 0) + paintMenu(mPtr); + break; } } @@ -938,21 +938,21 @@ static void stopEditItem(WEditMenu *menu, Bool apply) { char *text; - + if (apply) { - text = WMGetTextFieldText(menu->tfield); - - wfree(menu->selectedItem->label); - menu->selectedItem->label = wstrdup(text); + text = WMGetTextFieldText(menu->tfield); + + wfree(menu->selectedItem->label); + menu->selectedItem->label = wstrdup(text); - updateMenuContents(menu); + updateMenuContents(menu); - if (menu->delegate && menu->delegate->itemEdited) { - (*menu->delegate->itemEdited)(menu->delegate, menu, - menu->selectedItem); - } + if (menu->delegate && menu->delegate->itemEdited) { + (*menu->delegate->itemEdited)(menu->delegate, menu, + menu->selectedItem); + } - } + } WMUnmapWidget(menu->tfield); menu->flags.isEditing = 0; } @@ -965,42 +965,42 @@ textEndedEditing(struct WMTextFieldDelegate *self, WMNotification *notif) int reason; int i; WEditMenuItem *item; - + if (!menu->flags.isEditing) - return; + return; reason = (int)WMGetNotificationClientData(notif); - - switch (reason) { - case WMEscapeTextMovement: - stopEditItem(menu, False); - break; - - case WMReturnTextMovement: - stopEditItem(menu, True); - break; - - case WMTabTextMovement: - stopEditItem(menu, True); - - i = WMGetFirstInArray(menu->items, menu->selectedItem); - item = WMGetFromArray(menu->items, i+1); - if (item != NULL) { - selectItem(menu, item); - editItemLabel(item); - } - break; - - case WMBacktabTextMovement: - stopEditItem(menu, True); - - i = WMGetFirstInArray(menu->items, menu->selectedItem); - item = WMGetFromArray(menu->items, i-1); - if (item != NULL) { - selectItem(menu, item); - editItemLabel(item); - } - break; + + switch (reason) { + case WMEscapeTextMovement: + stopEditItem(menu, False); + break; + + case WMReturnTextMovement: + stopEditItem(menu, True); + break; + + case WMTabTextMovement: + stopEditItem(menu, True); + + i = WMGetFirstInArray(menu->items, menu->selectedItem); + item = WMGetFromArray(menu->items, i+1); + if (item != NULL) { + selectItem(menu, item); + editItemLabel(item); + } + break; + + case WMBacktabTextMovement: + stopEditItem(menu, True); + + i = WMGetFirstInArray(menu->items, menu->selectedItem); + item = WMGetFromArray(menu->items, i-1); + if (item != NULL) { + selectItem(menu, item); + editItemLabel(item); + } + break; } } @@ -1008,11 +1008,11 @@ textEndedEditing(struct WMTextFieldDelegate *self, WMNotification *notif) static WMTextFieldDelegate textFieldDelegate = { NULL, - NULL, - NULL, - textEndedEditing, - NULL, - NULL + NULL, + NULL, + textEndedEditing, + NULL, + NULL }; @@ -1021,23 +1021,23 @@ editItemLabel(WEditMenuItem *item) { WEditMenu *mPtr = item->parent; WMTextField *tf; - + if (!mPtr->flags.isEditable) { - return; + return; } if (!mPtr->tfield) { - mPtr->tfield = WMCreateTextField(mPtr); - WMSetTextFieldBeveled(mPtr->tfield, False); - WMRealizeWidget(mPtr->tfield); + mPtr->tfield = WMCreateTextField(mPtr); + WMSetTextFieldBeveled(mPtr->tfield, False); + WMRealizeWidget(mPtr->tfield); - mPtr->tdelegate = wmalloc(sizeof(WMTextFieldDelegate)); - memcpy(mPtr->tdelegate, &textFieldDelegate, - sizeof(WMTextFieldDelegate)); - - mPtr->tdelegate->data = mPtr; + mPtr->tdelegate = wmalloc(sizeof(WMTextFieldDelegate)); + memcpy(mPtr->tdelegate, &textFieldDelegate, + sizeof(WMTextFieldDelegate)); - WMSetTextFieldDelegate(mPtr->tfield, mPtr->tdelegate); + mPtr->tdelegate->data = mPtr; + + WMSetTextFieldDelegate(mPtr->tfield, mPtr->tdelegate); } tf = mPtr->tfield; @@ -1064,19 +1064,19 @@ slideWindow(Display *dpy, Window win, int srcX, int srcY, int dstX, int dstY) int iterations; iterations = WMIN(25, WMAX(abs(dstX-srcX), abs(dstY-srcY))); - + x = srcX; y = srcY; - + dx = (double)(dstX-srcX)/iterations; dy = (double)(dstY-srcY)/iterations; for (i = 0; i <= iterations; i++) { - XMoveWindow(dpy, win, x, y); + XMoveWindow(dpy, win, x, y); XFlush(dpy); - - wusleep(800); - + + wusleep(800); + x += dx; y += dy; } @@ -1101,42 +1101,42 @@ findMenuInWindow(Display *dpy, Window toplevel, int x, int y) WEditMenu *menu; WMView *view; int (*oldHandler)(Display *, XErrorEvent *); - + view = W_GetViewForXWindow(dpy, toplevel); if (view && view->self && WMWidgetClass(view->self) == EditMenuClass) { - menu = (WEditMenu*)view->self; - if (menu->flags.acceptsDrop) { - return menu; - } + menu = (WEditMenu*)view->self; + if (menu->flags.acceptsDrop) { + return menu; + } } - + if (!XQueryTree(dpy, toplevel, &foo, &bar, - &children, &nchildren) || children == NULL) { - return NULL; + &children, &nchildren) || children == NULL) { + return NULL; } - + oldHandler = XSetErrorHandler(errorHandler); - + /* first window that contains the point is the one */ for (i = nchildren-1; i >= 0; i--) { - XWindowAttributes attr; - - if (XGetWindowAttributes(dpy, children[i], &attr) - && attr.map_state == IsViewable - && x >= attr.x && y >= attr.y - && x < attr.x + attr.width && y < attr.y + attr.height) { - Window tmp; - - tmp = children[i]; - - menu = findMenuInWindow(dpy, tmp, x - attr.x, y - attr.y); - if (menu) { - XFree(children); - return menu; - } - } + XWindowAttributes attr; + + if (XGetWindowAttributes(dpy, children[i], &attr) + && attr.map_state == IsViewable + && x >= attr.x && y >= attr.y + && x < attr.x + attr.width && y < attr.y + attr.height) { + Window tmp; + + tmp = children[i]; + + menu = findMenuInWindow(dpy, tmp, x - attr.x, y - attr.y); + if (menu) { + XFree(children); + return menu; + } + } } - + XSetErrorHandler(oldHandler); XFree(children); @@ -1145,8 +1145,8 @@ findMenuInWindow(Display *dpy, Window toplevel, int x, int y) static void -handleDragOver(WEditMenu *menu, WMView *view, WEditMenuItem *item, - int x, int y) +handleDragOver(WEditMenu *menu, WMView *view, WEditMenuItem *item, + int x, int y) { WMScreen *scr = W_VIEW_SCREEN(menu->view); Window blaw; @@ -1154,54 +1154,54 @@ handleDragOver(WEditMenu *menu, WMView *view, WEditMenuItem *item, int offs; XTranslateCoordinates(scr->display, W_VIEW_DRAWABLE(menu->view), - scr->rootWin, 0, 0, &mx, &my, &blaw); - + scr->rootWin, 0, 0, &mx, &my, &blaw); + offs = menu->flags.standalone ? 0 : 1; - + W_MoveView(view, mx + offs, y); if (view->size.width != menu->view->size.width) { - W_ResizeView(view, menu->view->size.width - 2*offs, - menu->itemHeight); - W_ResizeView(item->view, menu->view->size.width - 2*offs, - menu->itemHeight); + W_ResizeView(view, menu->view->size.width - 2*offs, + menu->itemHeight); + W_ResizeView(item->view, menu->view->size.width - 2*offs, + menu->itemHeight); } } static void handleItemDrop(WEditMenu *menu, WEditMenuItem *item, int x, int y) -{ +{ WMScreen *scr = W_VIEW_SCREEN(menu->view); Window blaw; int mx, my; int index; XTranslateCoordinates(scr->display, W_VIEW_DRAWABLE(menu->view), - scr->rootWin, 0, 0, &mx, &my, &blaw); + scr->rootWin, 0, 0, &mx, &my, &blaw); index = y - my; if (menu->flags.isTitled) { - index -= menu->titleHeight; + index -= menu->titleHeight; } index = (index + menu->itemHeight/2) / menu->itemHeight; if (index < 0) - index = 0; + index = 0; if (menu->flags.isTitled) { - index++; + index++; } - + if (index > WMGetArrayItemCount(menu->items)) { - WMAddToArray(menu->items, item); + WMAddToArray(menu->items, item); } else { - WMInsertInArray(menu->items, index, item); + WMInsertInArray(menu->items, index, item); } W_ReparentView(item->view, menu->view, 0, index*menu->itemHeight); - + item->parent = menu; if (item->submenu) { - item->submenu->parent = menu; + item->submenu->parent = menu; } updateMenuContents(menu); @@ -1217,43 +1217,43 @@ dragMenu(WEditMenu *menu) int dx, dy; unsigned blau; Window blaw; - + XGetGeometry(scr->display, W_VIEW_DRAWABLE(menu->view), &blaw, &dx, &dy, - &blau, &blau, &blau, &blau); + &blau, &blau, &blau, &blau); XTranslateCoordinates(scr->display, W_VIEW_DRAWABLE(menu->view), - scr->rootWin, dx, dy, &dx, &dy, &blaw); + scr->rootWin, dx, dy, &dx, &dy, &blaw); dx = menu->dragX - dx; dy = menu->dragY - dy; - + XGrabPointer(scr->display, scr->rootWin, False, - ButtonReleaseMask|ButtonMotionMask, - GrabModeAsync, GrabModeAsync, None, scr->defaultCursor, - CurrentTime); - + ButtonReleaseMask|ButtonMotionMask, + GrabModeAsync, GrabModeAsync, None, scr->defaultCursor, + CurrentTime); + if (menu->parent) - WTearOffEditMenu(menu->parent, menu); + WTearOffEditMenu(menu->parent, menu); while (!done) { - WMNextEvent(scr->display, &ev); - - switch (ev.type) { - case ButtonRelease: - done = True; - break; - - case MotionNotify: - while (XCheckMaskEvent(scr->display, ButtonMotionMask, &ev)) ; - - WMMoveWidget(menu, ev.xmotion.x_root - dx, - ev.xmotion.y_root - dy); - break; - - default: - WMHandleEvent(&ev); - break; - } + WMNextEvent(scr->display, &ev); + + switch (ev.type) { + case ButtonRelease: + done = True; + break; + + case MotionNotify: + while (XCheckMaskEvent(scr->display, ButtonMotionMask, &ev)) ; + + WMMoveWidget(menu, ev.xmotion.x_root - dx, + ev.xmotion.y_root - dy); + break; + + default: + WMHandleEvent(&ev); + break; + } } XUngrabPointer(scr->display, CurrentTime); @@ -1265,10 +1265,10 @@ static WEditMenuItem* duplicateItem(WEditMenuItem *item) { WEditMenuItem *nitem; - + nitem = WCreateEditMenuItem(item->parent, item->label, False); if (item->pixmap) - nitem->pixmap = WMRetainPixmap(item->pixmap); + nitem->pixmap = WMRetainPixmap(item->pixmap); return nitem; } @@ -1288,23 +1288,23 @@ duplicateMenu(WEditMenu *menu) memcpy(&nmenu->flags, &menu->flags, sizeof(menu->flags)); nmenu->delegate = menu->delegate; - + WM_ITERATE_ARRAY(menu->items, item, iter) { - WEditMenuItem *nitem; - - if (first) { - first = False; - continue; - } - - nitem = WAddMenuItemWithTitle(nmenu, item->label); - if (item->pixmap) - WSetEditMenuItemImage(nitem, item->pixmap); - - if (menu->delegate && menu->delegate->itemCloned) { - (*menu->delegate->itemCloned)(menu->delegate, menu, - item, nitem); - } + WEditMenuItem *nitem; + + if (first) { + first = False; + continue; + } + + nitem = WAddMenuItemWithTitle(nmenu, item->label); + if (item->pixmap) + WSetEditMenuItemImage(nitem, item->pixmap); + + if (menu->delegate && menu->delegate->itemCloned) { + (*menu->delegate->itemCloned)(menu->delegate, menu, + item, nitem); + } } WMRealizeWidget(nmenu); @@ -1338,137 +1338,137 @@ dragItem(WEditMenu *menu, WEditMenuItem *item, Bool copy) if (item->flags.isTitle) { - WMRaiseWidget(menu); + WMRaiseWidget(menu); - dragMenu(menu); + dragMenu(menu); - return; + return; } - + selectItem(menu, NULL); win = scr->rootWin; - + XTranslateCoordinates(dpy, W_VIEW_DRAWABLE(item->view), win, - 0, 0, &orix, &oriy, &blaw); + 0, 0, &orix, &oriy, &blaw); dview = W_CreateUnmanagedTopView(scr); W_SetViewBackgroundColor(dview, scr->black); W_ResizeView(dview, W_VIEW_WIDTH(item->view), W_VIEW_HEIGHT(item->view)); W_MoveView(dview, orix, oriy); W_RealizeView(dview); - + if (menu->flags.isFactory || copy) { - dritem = duplicateItem(item); + dritem = duplicateItem(item); - W_ReparentView(dritem->view, dview, 0, 0); - WMResizeWidget(dritem, oldSize.width, oldSize.height); - WMRealizeWidget(dritem); - WMMapWidget(dritem); + W_ReparentView(dritem->view, dview, 0, 0); + WMResizeWidget(dritem, oldSize.width, oldSize.height); + WMRealizeWidget(dritem); + WMMapWidget(dritem); } else { - W_ReparentView(item->view, dview, 0, 0); + W_ReparentView(item->view, dview, 0, 0); } W_MapView(dview); dx = menu->dragX - orix; dy = menu->dragY - oriy; - + XGrabPointer(dpy, scr->rootWin, False, - ButtonPressMask|ButtonReleaseMask|ButtonMotionMask, - GrabModeAsync, GrabModeAsync, None, scr->defaultCursor, - CurrentTime); + ButtonPressMask|ButtonReleaseMask|ButtonMotionMask, + GrabModeAsync, GrabModeAsync, None, scr->defaultCursor, + CurrentTime); if (menu->flags.acceptsDrop) - XRecolorCursor(dpy, scr->defaultCursor, &green, &back); + XRecolorCursor(dpy, scr->defaultCursor, &green, &back); while (!done) { - XEvent ev; - - WMNextEvent(dpy, &ev); - - switch (ev.type) { - case MotionNotify: - while (XCheckMaskEvent(dpy, ButtonMotionMask, &ev)) ; - - XQueryPointer(dpy, win, &blaw, &blaw, &blai, &blai, &x, &y, &blau); - - dmenu = findMenuInWindow(dpy, win, x, y); - - if (dmenu) { - handleDragOver(dmenu, dview, dritem, x - dx, y - dy); - if (!enteredMenu) { - enteredMenu = True; - XRecolorCursor(dpy, scr->defaultCursor, &green, &back); - } - } else { - if (enteredMenu) { - W_ResizeView(dview, oldSize.width, oldSize.height); - W_ResizeView(dritem->view, oldSize.width, oldSize.height); - enteredMenu = False; - XRecolorCursor(dpy, scr->defaultCursor, &black, &back); - } - W_MoveView(dview, x - dx, y - dy); - } - - break; - - case ButtonRelease: - done = True; - break; - - default: - WMHandleEvent(&ev); - break; - } + XEvent ev; + + WMNextEvent(dpy, &ev); + + switch (ev.type) { + case MotionNotify: + while (XCheckMaskEvent(dpy, ButtonMotionMask, &ev)) ; + + XQueryPointer(dpy, win, &blaw, &blaw, &blai, &blai, &x, &y, &blau); + + dmenu = findMenuInWindow(dpy, win, x, y); + + if (dmenu) { + handleDragOver(dmenu, dview, dritem, x - dx, y - dy); + if (!enteredMenu) { + enteredMenu = True; + XRecolorCursor(dpy, scr->defaultCursor, &green, &back); + } + } else { + if (enteredMenu) { + W_ResizeView(dview, oldSize.width, oldSize.height); + W_ResizeView(dritem->view, oldSize.width, oldSize.height); + enteredMenu = False; + XRecolorCursor(dpy, scr->defaultCursor, &black, &back); + } + W_MoveView(dview, x - dx, y - dy); + } + + break; + + case ButtonRelease: + done = True; + break; + + default: + WMHandleEvent(&ev); + break; + } } XRecolorCursor(dpy, scr->defaultCursor, &black, &back); XUngrabPointer(dpy, CurrentTime); - + if (!enteredMenu) { - Bool rem = True; - - if (!menu->flags.isFactory && !copy) { - W_UnmapView(dview); - if (menu->delegate && menu->delegate->shouldRemoveItem) { - rem = (*menu->delegate->shouldRemoveItem)(menu->delegate, - menu, item); - } - W_MapView(dview); - } - - if (!rem || menu->flags.isFactory || copy) { - slideWindow(dpy, W_VIEW_DRAWABLE(dview), x-dx, y-dy, orix, oriy); - - if (!menu->flags.isFactory && !copy) { - WRemoveEditMenuItem(menu, dritem); - handleItemDrop(dmenu ? dmenu : menu, dritem, orix, oriy); - } - } else { - WRemoveEditMenuItem(menu, dritem); - } + Bool rem = True; + + if (!menu->flags.isFactory && !copy) { + W_UnmapView(dview); + if (menu->delegate && menu->delegate->shouldRemoveItem) { + rem = (*menu->delegate->shouldRemoveItem)(menu->delegate, + menu, item); + } + W_MapView(dview); + } + + if (!rem || menu->flags.isFactory || copy) { + slideWindow(dpy, W_VIEW_DRAWABLE(dview), x-dx, y-dy, orix, oriy); + + if (!menu->flags.isFactory && !copy) { + WRemoveEditMenuItem(menu, dritem); + handleItemDrop(dmenu ? dmenu : menu, dritem, orix, oriy); + } + } else { + WRemoveEditMenuItem(menu, dritem); + } } else { - WRemoveEditMenuItem(menu, dritem); - - if (menu->delegate && menu->delegate->itemCloned - && (menu->flags.isFactory || copy)) { - (*menu->delegate->itemCloned)(menu->delegate, menu, - item, dritem); - } - - handleItemDrop(dmenu, dritem, x-dy, y-dy); - - if (item->submenu && (menu->flags.isFactory || copy)) { - WEditMenu *submenu; - - submenu = duplicateMenu(item->submenu); - WSetEditMenuSubmenu(dmenu, dritem, submenu); - } + WRemoveEditMenuItem(menu, dritem); + + if (menu->delegate && menu->delegate->itemCloned + && (menu->flags.isFactory || copy)) { + (*menu->delegate->itemCloned)(menu->delegate, menu, + item, dritem); + } + + handleItemDrop(dmenu, dritem, x-dy, y-dy); + + if (item->submenu && (menu->flags.isFactory || copy)) { + WEditMenu *submenu; + + submenu = duplicateMenu(item->submenu); + WSetEditMenuSubmenu(dmenu, dritem, submenu); + } } - /* can't destroy now because we're being called from + /* can't destroy now because we're being called from * the event handler of the item. and destroying now, * would mean destroying the item too in some cases. */ @@ -1484,31 +1484,31 @@ handleItemClick(XEvent *event, void *data) WEditMenu *menu = item->parent; switch (event->type) { - case ButtonPress: - selectItem(menu, item); - - if (WMIsDoubleClick(event)) { - editItemLabel(item); - } - - menu->flags.isDragging = 1; - menu->dragX = event->xbutton.x_root; - menu->dragY = event->xbutton.y_root; - break; - - case ButtonRelease: - menu->flags.isDragging = 0; - break; - - case MotionNotify: - if (menu->flags.isDragging) { - if (abs(event->xbutton.x_root - menu->dragX) > 5 - || abs(event->xbutton.y_root - menu->dragY) > 5) { - menu->flags.isDragging = 0; - dragItem(menu, item, event->xbutton.state & ControlMask); - } - } - break; + case ButtonPress: + selectItem(menu, item); + + if (WMIsDoubleClick(event)) { + editItemLabel(item); + } + + menu->flags.isDragging = 1; + menu->dragX = event->xbutton.x_root; + menu->dragY = event->xbutton.y_root; + break; + + case ButtonRelease: + menu->flags.isDragging = 0; + break; + + case MotionNotify: + if (menu->flags.isDragging) { + if (abs(event->xbutton.x_root - menu->dragX) > 5 + || abs(event->xbutton.y_root - menu->dragY) > 5) { + menu->flags.isDragging = 0; + dragItem(menu, item, event->xbutton.state & ControlMask); + } + } + break; } } @@ -1522,15 +1522,15 @@ destroyEditMenu(WEditMenu *mPtr) WMRemoveNotificationObserver(mPtr); WM_ITERATE_ARRAY(mPtr->items, item, iter) { - if (item->submenu) { - WMDestroyWidget(item->submenu); - } + if (item->submenu) { + WMDestroyWidget(item->submenu); + } } - + WMFreeArray(mPtr->items); - + wfree(mPtr->tdelegate); - + wfree(mPtr); } diff --git a/WPrefs.app/editmenu.h b/WPrefs.app/editmenu.h index 529f1d0f..9838eb81 100644 --- a/WPrefs.app/editmenu.h +++ b/WPrefs.app/editmenu.h @@ -1,9 +1,9 @@ /* editmenu.h - editable menus - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 2000-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -32,30 +32,30 @@ typedef struct WEditMenuDelegate { void *data; void (*itemCloned)(struct WEditMenuDelegate*, WEditMenu*, - WEditMenuItem*, WEditMenuItem *); + WEditMenuItem*, WEditMenuItem *); void (*itemEdited)(struct WEditMenuDelegate*, WEditMenu*, - WEditMenuItem*); + WEditMenuItem*); void (*itemSelected)(struct WEditMenuDelegate*, WEditMenu*, - WEditMenuItem*); + WEditMenuItem*); void (*itemDeselected)(struct WEditMenuDelegate*, WEditMenu*, - WEditMenuItem*); + WEditMenuItem*); Bool (*shouldRemoveItem)(struct WEditMenuDelegate*, WEditMenu*, - WEditMenuItem*); + WEditMenuItem*); } WEditMenuDelegate; -WEditMenuItem *WCreateEditMenuItem(WMWidget *parent, char *title, - Bool isTitle); +WEditMenuItem *WCreateEditMenuItem(WMWidget *parent, char *title, + Bool isTitle); char *WGetEditMenuItemTitle(WEditMenuItem *item); void *WGetEditMenuItemData(WEditMenuItem *item); -void WSetEditMenuItemData(WEditMenuItem *item, void *data, - WMCallback *destroyer); +void WSetEditMenuItemData(WEditMenuItem *item, void *data, + WMCallback *destroyer); void WSetEditMenuItemImage(WEditMenuItem *item, WMPixmap *pixmap); @@ -65,8 +65,8 @@ WEditMenu *WCreateEditMenuPad(WMWidget *parent); void WSetEditMenuDelegate(WEditMenu *mPtr, WEditMenuDelegate *delegate); -WEditMenuItem *WInsertMenuItemWithTitle(WEditMenu *mPtr, int index, - char *title); +WEditMenuItem *WInsertMenuItemWithTitle(WEditMenu *mPtr, int index, + char *title); WEditMenuItem *WAddMenuItemWithTitle(WEditMenu *mPtr, char *title); @@ -79,7 +79,7 @@ char *WGetEditMenuTitle(WEditMenu *mPtr); void WSetEditMenuAcceptsDrop(WEditMenu *mPtr, Bool flag); void WSetEditMenuSubmenu(WEditMenu *mPtr, WEditMenuItem *item, - WEditMenu *submenu); + WEditMenu *submenu); WEditMenu *WGetEditMenuSubmenu(WEditMenu *mPtr, WEditMenuItem *item); diff --git a/WPrefs.app/imagebrowser.c b/WPrefs.app/imagebrowser.c index b5429763..62112c7a 100644 --- a/WPrefs.app/imagebrowser.c +++ b/WPrefs.app/imagebrowser.c @@ -1,9 +1,9 @@ /* imagebrowser.c- image browser widget - * + * * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 2000-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -42,22 +42,22 @@ struct _ImageBrowser { WMWindow *win; WMPopUpButton *pathP; - + WMScrollView *sview; WMFrame *frame; - + WMWidget *auxWidget; - - + + WMButton *viewBtn; WMButton *okBtn; WMButton *cancelBtn; WMSize maxPreviewSize; - + ImageBrowserDelegate *delegate; - + WMArray *previews; }; @@ -71,26 +71,26 @@ struct _ImageBrowser { ImageBrowser* CreateImageBrowser(WMScreen *scr, char *title, char **paths, int pathN, - WMSize *maxSize, WMWidget *auxWidget) + WMSize *maxSize, WMWidget *auxWidget) { ImageBrowser *br; int i; int h; - + br = wmalloc(sizeof(ImageBrowser)); - + br->win = WMCreateWindow(scr, "imageBrowser"); WMResizeWidget(br->win, DEFAULT_WIDTH, DEFAULT_HEIGHT); br->pathP = WMCreatePopUpButton(br->win); WMMoveWidget(br->pathP, (DEFAULT_WIDTH - 80)/2, 10); WMResizeWidget(br->pathP, DEFAULT_WIDTH - 80, 20); - + for (i = 0; i < pathN; i++) { - WMAddPopUpButtonItem(br->pathP, paths[i]); + WMAddPopUpButtonItem(br->pathP, paths[i]); } - + br->viewBtn = WMCreateCommandButton(br->win); WMSetButtonText(br->viewBtn, _("View")); WMResizeWidget(br->viewBtn, 80, 24); @@ -106,32 +106,32 @@ CreateImageBrowser(WMScreen *scr, char *title, char **paths, int pathN, WMResizeWidget(br->okBtn, 80, 24); WMMoveWidget(br->okBtn, DEFAULT_WIDTH - 10 - 160 - 5, DEFAULT_HEIGHT - 29); - - + + br->auxWidget = auxWidget; - - - h = DEFAULT_HEIGHT - - 20 /* top and bottom spacing */ - - 25 /* popup menu and spacing */ - - 29; /* button row and spacing */ - + + + h = DEFAULT_HEIGHT + - 20 /* top and bottom spacing */ + - 25 /* popup menu and spacing */ + - 29; /* button row and spacing */ + if (auxWidget != NULL) { - h -= WMWidgetHeight(auxWidget) + 5; - - W_ReparentView(WMWidgetView(auxWidget), - WMWidgetView(br->win), - 10, 10 + 25 + h + 5); + h -= WMWidgetHeight(auxWidget) + 5; + + W_ReparentView(WMWidgetView(auxWidget), + WMWidgetView(br->win), + 10, 10 + 25 + h + 5); } br->sview = WMCreateScrollView(br->win); WMResizeWidget(br->sview, DEFAULT_WIDTH-20, h); WMMoveWidget(br->sview, 10, 5 + 20 + 5); - - - + + + WMMapSubwidgets(br->win); - + return br; } @@ -142,24 +142,24 @@ ShowImageBrowser(ImageBrowser *browser) WMMapWidget(browser->win); } -void +void CloseImageBrowser(ImageBrowser *browser) { WMUnmapWidget(browser->win); } -void +void SetImageBrowserPathList(ImageBrowser *browser, char **paths, int pathN) { } void -SetImageBrowserDelegate(ImageBrowser *browser, - ImageBrowserDelegate *delegate) +SetImageBrowserDelegate(ImageBrowser *browser, + ImageBrowserDelegate *delegate) { - + } @@ -170,9 +170,9 @@ void DestroyImageBrowser(ImageBrowser *browser) { WMDestroyWidget(browser->win); - + /**/ - + wfree(browser); } diff --git a/WPrefs.app/imagebrowser.h b/WPrefs.app/imagebrowser.h index 4c682fe3..fa4b9f11 100644 --- a/WPrefs.app/imagebrowser.h +++ b/WPrefs.app/imagebrowser.h @@ -11,18 +11,18 @@ struct _ImageBrowserDelegate { void *data; void (*selected)(ImageBrowserDelegate *self, - ImageBrowser *browser, - char *path); - + ImageBrowser *browser, + char *path); + void (*closed)(ImageBrowserDelegate *self, - ImageBrowser *browser, - Bool canceled); - + ImageBrowser *browser, + Bool canceled); + }; ImageBrowser *CreateImageBrowser(WMScreen *scr, char *title, char **paths, - int pathN, WMSize *maxSize, - WMWidget *auxWidget); + int pathN, WMSize *maxSize, + WMWidget *auxWidget); diff --git a/WPrefs.app/main.c b/WPrefs.app/main.c index c59716cb..8313f508 100644 --- a/WPrefs.app/main.c +++ b/WPrefs.app/main.c @@ -1,8 +1,8 @@ /* * WPrefs - Window Maker Preferences Program - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -70,10 +70,10 @@ handleDeadChild(int sig) { pid_t pid; int status; - + pid = waitpid(-1, &status, WNOHANG); if (pid > 0) { - DeadChildren[DeadChildrenCount++] = pid; + DeadChildren[DeadChildrenCount++] = pid; } } #endif @@ -84,18 +84,18 @@ AddDeadChildHandler(pid_t pid, void (*handler)(void*), void *data) int i; for (i = 0; i < MAX_DEATHS; i++) { - if (DeadHandlers[i].pid == 0) { - DeadHandlers[i].pid = pid; - DeadHandlers[i].handler = handler; - DeadHandlers[i].data = data; - break; - } + if (DeadHandlers[i].pid == 0) { + DeadHandlers[i].pid = pid; + DeadHandlers[i].handler = handler; + DeadHandlers[i].data = data; + break; + } } assert(i!=MAX_DEATHS); } -int +int main(int argc, char **argv) { Display *dpy; @@ -105,29 +105,29 @@ main(int argc, char **argv) char *display_name=""; wsetabort(wAbort); - + memset(DeadHandlers, 0, sizeof(DeadHandlers)); - + WMInitializeApplication("WPrefs", &argc, argv); - + if (argc>1) { - for (i=1; i=argc) { - wwarning(_("too few arguments for %s"), argv[i-1]); - exit(0); - } - display_name = argv[i]; - } else { - print_help(argv[0]); - exit(0); - } - } + for (i=1; i=argc) { + wwarning(_("too few arguments for %s"), argv[i-1]); + exit(0); + } + display_name = argv[i]; + } else { + print_help(argv[0]); + exit(0); + } + } } locale = getenv("LANG"); @@ -135,31 +135,31 @@ main(int argc, char **argv) #ifdef I18N if (getenv("NLSPATH")) - bindtextdomain("WPrefs", getenv("NLSPATH")); + bindtextdomain("WPrefs", getenv("NLSPATH")); else - bindtextdomain("WPrefs", LOCALEDIR); + bindtextdomain("WPrefs", LOCALEDIR); textdomain("WPrefs"); if (!XSupportsLocale()) { - wwarning(_("X server does not support locale")); + wwarning(_("X server does not support locale")); } if (XSetLocaleModifiers("") == NULL) { - wwarning(_("cannot set locale modifiers")); + wwarning(_("cannot set locale modifiers")); } #endif dpy = XOpenDisplay(display_name); if (!dpy) { - wfatal(_("could not open display %s"), XDisplayName(display_name)); - exit(0); + wfatal(_("could not open display %s"), XDisplayName(display_name)); + exit(0); } #if 0 XSynchronize(dpy, 1); #endif scr = WMCreateScreen(dpy, DefaultScreen(dpy)); if (!scr) { - wfatal(_("could not initialize application")); - exit(0); + wfatal(_("could not initialize application")); + exit(0); } WMPLSetCaseSensitive(False); @@ -167,21 +167,22 @@ main(int argc, char **argv) Initialize(scr); while (1) { - XEvent event; - - WMNextEvent(dpy, &event); - - while (DeadChildrenCount-- > 0) { - int i; - - for (i=0; i 0) { + int i; + + for (i=0; i, Sept. 1997. */ - -/* - * More changes for WPrefs by Alfredo Kojima, Aug 1998 - */ - -/* The event_stream interface for X11 with Xt, and/or tty frames. - Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. - Copyright (C) 1995 Sun Microsystems, Inc. - Copyright (C) 1996 Ben Wing. - -This file is part of XEmacs. - -XEmacs 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, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include -#include -#include - -#include - - - -/************************************************************************/ -/* keymap handling */ -/************************************************************************/ - -/* X bogusly doesn't define the interpretations of any bits besides - ModControl, ModShift, and ModLock; so the Interclient Communication - Conventions Manual says that we have to bend over backwards to figure - out what the other modifier bits mean. According to ICCCM: - - - Any keycode which is assigned ModControl is a "control" key. - - - Any modifier bit which is assigned to a keycode which generates Meta_L - or Meta_R is the modifier bit meaning "meta". Likewise for Super, Hyper, - etc. - - - Any keypress event which contains ModControl in its state should be - interpreted as a "control" character. - - - Any keypress event which contains a modifier bit in its state which is - generated by a keycode whose corresponding keysym is Meta_L or Meta_R - should be interpreted as a "meta" character. Likewise for Super, Hyper, - etc. - - - It is illegal for a keysym to be associated with more than one modifier - bit. - - This means that the only thing that emacs can reasonably interpret as a - "meta" key is a key whose keysym is Meta_L or Meta_R, and which generates - one of the modifier bits Mod1-Mod5. - - Unfortunately, many keyboards don't have Meta keys in their default - configuration. So, if there are no Meta keys, but there are "Alt" keys, - emacs will interpret Alt as Meta. If there are both Meta and Alt keys, - then the Meta keys mean "Meta", and the Alt keys mean "Alt" (it used to - mean "Symbol," but that just confused the hell out of way too many people). - - This works with the default configurations of the 19 keyboard-types I've - checked. - - Emacs detects keyboard configurations which violate the above rules, and - prints an error message on the standard-error-output. (Perhaps it should - use a pop-up-window instead.) - */ - -static int MetaIndex, HyperIndex, SuperIndex, AltIndex, ModeIndex; - -static const char * -index_to_name (int indice) -{ - switch (indice) - { - case ShiftMapIndex: return "ModShift"; - case LockMapIndex: return "ModLock"; - case ControlMapIndex: return "ModControl"; - case Mod1MapIndex: return "Mod1"; - case Mod2MapIndex: return "Mod2"; - case Mod3MapIndex: return "Mod3"; - case Mod4MapIndex: return "Mod4"; - case Mod5MapIndex: return "Mod5"; - default: return "???"; - } -} - -static void -x_reset_modifier_mapping (Display *display) -{ - int modifier_index, modifier_key, column, mkpm; - int warned_about_overlapping_modifiers = 0; - int warned_about_predefined_modifiers = 0; - int warned_about_duplicate_modifiers = 0; - int meta_bit = 0; - int hyper_bit = 0; - int super_bit = 0; - int alt_bit = 0; - int mode_bit = 0; - XModifierKeymap *x_modifier_keymap = XGetModifierMapping (display); - -#define modwarn(name,old,other) \ - wwarning ("%s (0x%x) generates %s, which is generated by %s.\n\n", \ - name, code, index_to_name (old), other), \ - warned_about_overlapping_modifiers = 1 - -#define modbarf(name,other) \ - wwarning ("%s (0x%x) generates %s, which is nonsensical.\n\n", \ - name, code, other), \ - warned_about_predefined_modifiers = 1 - -#define check_modifier(name,mask) \ - if ((1<max_keypermod; - for (modifier_index = 0; modifier_index < 8; modifier_index++) - for (modifier_key = 0; modifier_key < mkpm; modifier_key++) { - KeySym last_sym = 0; - for (column = 0; column < 4; column += 2) { - KeyCode code = x_modifier_keymap->modifiermap[modifier_index * mkpm - + modifier_key]; - KeySym sym = (code ? XKeycodeToKeysym (display, code, column) : 0); - if (sym == last_sym) continue; - last_sym = sym; - switch (sym) { - case XK_Mode_switch:store_modifier ("Mode_switch", mode_bit); break; - case XK_Meta_L: store_modifier ("Meta_L", meta_bit); break; - case XK_Meta_R: store_modifier ("Meta_R", meta_bit); break; - case XK_Super_L: store_modifier ("Super_L", super_bit); break; - case XK_Super_R: store_modifier ("Super_R", super_bit); break; - case XK_Hyper_L: store_modifier ("Hyper_L", hyper_bit); break; - case XK_Hyper_R: store_modifier ("Hyper_R", hyper_bit); break; - case XK_Alt_L: store_modifier ("Alt_L", alt_bit); break; - case XK_Alt_R: store_modifier ("Alt_R", alt_bit); break; - case XK_Control_L: check_modifier ("Control_L", ControlMask); break; - case XK_Control_R: check_modifier ("Control_R", ControlMask); break; - case XK_Shift_L: check_modifier ("Shift_L", ShiftMask); break; - case XK_Shift_R: check_modifier ("Shift_R", ShiftMask); break; - case XK_Shift_Lock: check_modifier ("Shift_Lock", LockMask); break; - case XK_Caps_Lock: check_modifier ("Caps_Lock", LockMask); break; - - /* It probably doesn't make any sense for a modifier bit to be - assigned to a key that is not one of the above, but OpenWindows - assigns modifier bits to a couple of random function keys for - no reason that I can discern, so printing a warning here would - be annoying. */ - } - } - } -#undef store_modifier -#undef check_modifier -#undef modwarn -#undef modbarf - - /* If there was no Meta key, then try using the Alt key instead. - If there is both a Meta key and an Alt key, then the Alt key - is not disturbed and remains an Alt key. */ - if (! meta_bit && alt_bit) - meta_bit = alt_bit, alt_bit = 0; - - /* mode_bit overrides everything, since it's processed down inside of - XLookupString() instead of by us. If Meta and Mode_switch both - generate the same modifier bit (which is an error), then we don't - interpret that bit as Meta, because we can't make XLookupString() - not interpret it as Mode_switch; and interpreting it as both would - be totally wrong. */ - if (mode_bit) - { - const char *warn = 0; - if (mode_bit == meta_bit) warn = "Meta", meta_bit = 0; - else if (mode_bit == hyper_bit) warn = "Hyper", hyper_bit = 0; - else if (mode_bit == super_bit) warn = "Super", super_bit = 0; - else if (mode_bit == alt_bit) warn = "Alt", alt_bit = 0; - if (warn) - { - wwarning - ("%s is being used for both Mode_switch and %s.\n\n", - index_to_name (mode_bit), warn), - warned_about_overlapping_modifiers = 1; - } - } - - MetaIndex = meta_bit; - HyperIndex = hyper_bit; - SuperIndex = super_bit; - AltIndex = alt_bit; - ModeIndex = mode_bit; - - if (x_modifier_keymap != NULL) - XFreeModifiermap(x_modifier_keymap); -} - - -int -ModifierFromKey(Display *dpy, char *key) -{ - static int eqw = 0; - - if (!eqw) - x_reset_modifier_mapping(dpy); - eqw = 1; - - if (strcasecmp(key, "SHIFT")==0) - return ShiftMapIndex; - else if (strcasecmp(key, "CONTROL")==0) - return ControlMapIndex; - else if (strcasecmp(key, "ALT")==0) - return AltIndex; - else if (strcasecmp(key, "META")==0) - return MetaIndex; - else if (strcasecmp(key, "SUPER")==0) - return SuperIndex; - else if (strcasecmp(key, "HYPER")==0) - return HyperIndex; - else if (strcasecmp(key, "MOD1")==0) - return Mod1MapIndex; - else if (strcasecmp(key, "MOD2")==0) - return Mod2MapIndex; - else if (strcasecmp(key, "MOD3")==0) - return Mod3MapIndex; - else if (strcasecmp(key, "MOD4")==0) - return Mod4MapIndex; - else if (strcasecmp(key, "MOD5")==0) - return Mod5MapIndex; - else - return -1; -} +/* Grok X modifier mappings for shortcuts. + +Most of this code was taken from src/event-Xt.c in XEmacs 20.3-b17. +The copyright(s) from the original XEmacs code are included below. + +Perpetrator: Sudish Joseph , Sept. 1997. */ + +/* + * More changes for WPrefs by Alfredo Kojima, Aug 1998 + */ + +/* The event_stream interface for X11 with Xt, and/or tty frames. + Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1995 Sun Microsystems, Inc. + Copyright (C) 1996 Ben Wing. + + This file is part of XEmacs. + + XEmacs 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, or (at your option) any + later version. + + XEmacs is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with XEmacs; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + + + +/************************************************************************/ +/* keymap handling */ +/************************************************************************/ + +/* X bogusly doesn't define the interpretations of any bits besides + ModControl, ModShift, and ModLock; so the Interclient Communication + Conventions Manual says that we have to bend over backwards to figure + out what the other modifier bits mean. According to ICCCM: + + - Any keycode which is assigned ModControl is a "control" key. + + - Any modifier bit which is assigned to a keycode which generates Meta_L + or Meta_R is the modifier bit meaning "meta". Likewise for Super, Hyper, + etc. + + - Any keypress event which contains ModControl in its state should be + interpreted as a "control" character. + + - Any keypress event which contains a modifier bit in its state which is + generated by a keycode whose corresponding keysym is Meta_L or Meta_R + should be interpreted as a "meta" character. Likewise for Super, Hyper, + etc. + + - It is illegal for a keysym to be associated with more than one modifier + bit. + + This means that the only thing that emacs can reasonably interpret as a + "meta" key is a key whose keysym is Meta_L or Meta_R, and which generates + one of the modifier bits Mod1-Mod5. + + Unfortunately, many keyboards don't have Meta keys in their default + configuration. So, if there are no Meta keys, but there are "Alt" keys, + emacs will interpret Alt as Meta. If there are both Meta and Alt keys, + then the Meta keys mean "Meta", and the Alt keys mean "Alt" (it used to + mean "Symbol," but that just confused the hell out of way too many people). + + This works with the default configurations of the 19 keyboard-types I've + checked. + + Emacs detects keyboard configurations which violate the above rules, and + prints an error message on the standard-error-output. (Perhaps it should + use a pop-up-window instead.) + */ + +static int MetaIndex, HyperIndex, SuperIndex, AltIndex, ModeIndex; + +static const char * +index_to_name (int indice) +{ + switch (indice) + { + case ShiftMapIndex: return "ModShift"; + case LockMapIndex: return "ModLock"; + case ControlMapIndex: return "ModControl"; + case Mod1MapIndex: return "Mod1"; + case Mod2MapIndex: return "Mod2"; + case Mod3MapIndex: return "Mod3"; + case Mod4MapIndex: return "Mod4"; + case Mod5MapIndex: return "Mod5"; + default: return "???"; + } +} + +static void +x_reset_modifier_mapping (Display *display) +{ + int modifier_index, modifier_key, column, mkpm; + int warned_about_overlapping_modifiers = 0; + int warned_about_predefined_modifiers = 0; + int warned_about_duplicate_modifiers = 0; + int meta_bit = 0; + int hyper_bit = 0; + int super_bit = 0; + int alt_bit = 0; + int mode_bit = 0; + XModifierKeymap *x_modifier_keymap = XGetModifierMapping (display); + +#define modwarn(name,old,other) \ + wwarning ("%s (0x%x) generates %s, which is generated by %s.\n\n", \ + name, code, index_to_name (old), other), \ + warned_about_overlapping_modifiers = 1 + +#define modbarf(name,other) \ + wwarning ("%s (0x%x) generates %s, which is nonsensical.\n\n", \ + name, code, other), \ + warned_about_predefined_modifiers = 1 + +#define check_modifier(name,mask) \ + if ((1<max_keypermod; + for (modifier_index = 0; modifier_index < 8; modifier_index++) + for (modifier_key = 0; modifier_key < mkpm; modifier_key++) { + KeySym last_sym = 0; + for (column = 0; column < 4; column += 2) { + KeyCode code = x_modifier_keymap->modifiermap[modifier_index * mkpm + + modifier_key]; + KeySym sym = (code ? XKeycodeToKeysym (display, code, column) : 0); + if (sym == last_sym) continue; + last_sym = sym; + switch (sym) { + case XK_Mode_switch:store_modifier ("Mode_switch", mode_bit); break; + case XK_Meta_L: store_modifier ("Meta_L", meta_bit); break; + case XK_Meta_R: store_modifier ("Meta_R", meta_bit); break; + case XK_Super_L: store_modifier ("Super_L", super_bit); break; + case XK_Super_R: store_modifier ("Super_R", super_bit); break; + case XK_Hyper_L: store_modifier ("Hyper_L", hyper_bit); break; + case XK_Hyper_R: store_modifier ("Hyper_R", hyper_bit); break; + case XK_Alt_L: store_modifier ("Alt_L", alt_bit); break; + case XK_Alt_R: store_modifier ("Alt_R", alt_bit); break; + case XK_Control_L: check_modifier ("Control_L", ControlMask); break; + case XK_Control_R: check_modifier ("Control_R", ControlMask); break; + case XK_Shift_L: check_modifier ("Shift_L", ShiftMask); break; + case XK_Shift_R: check_modifier ("Shift_R", ShiftMask); break; + case XK_Shift_Lock: check_modifier ("Shift_Lock", LockMask); break; + case XK_Caps_Lock: check_modifier ("Caps_Lock", LockMask); break; + + /* It probably doesn't make any sense for a modifier bit to be + assigned to a key that is not one of the above, but OpenWindows + assigns modifier bits to a couple of random function keys for + no reason that I can discern, so printing a warning here would + be annoying. */ + } + } + } +#undef store_modifier +#undef check_modifier +#undef modwarn +#undef modbarf + + /* If there was no Meta key, then try using the Alt key instead. + If there is both a Meta key and an Alt key, then the Alt key + is not disturbed and remains an Alt key. */ + if (! meta_bit && alt_bit) + meta_bit = alt_bit, alt_bit = 0; + + /* mode_bit overrides everything, since it's processed down inside of + XLookupString() instead of by us. If Meta and Mode_switch both + generate the same modifier bit (which is an error), then we don't + interpret that bit as Meta, because we can't make XLookupString() + not interpret it as Mode_switch; and interpreting it as both would + be totally wrong. */ + if (mode_bit) + { + const char *warn = 0; + if (mode_bit == meta_bit) warn = "Meta", meta_bit = 0; + else if (mode_bit == hyper_bit) warn = "Hyper", hyper_bit = 0; + else if (mode_bit == super_bit) warn = "Super", super_bit = 0; + else if (mode_bit == alt_bit) warn = "Alt", alt_bit = 0; + if (warn) + { + wwarning + ("%s is being used for both Mode_switch and %s.\n\n", + index_to_name (mode_bit), warn), + warned_about_overlapping_modifiers = 1; + } + } + + MetaIndex = meta_bit; + HyperIndex = hyper_bit; + SuperIndex = super_bit; + AltIndex = alt_bit; + ModeIndex = mode_bit; + + if (x_modifier_keymap != NULL) + XFreeModifiermap(x_modifier_keymap); +} + + +int +ModifierFromKey(Display *dpy, char *key) +{ + static int eqw = 0; + + if (!eqw) + x_reset_modifier_mapping(dpy); + eqw = 1; + + if (strcasecmp(key, "SHIFT")==0) + return ShiftMapIndex; + else if (strcasecmp(key, "CONTROL")==0) + return ControlMapIndex; + else if (strcasecmp(key, "ALT")==0) + return AltIndex; + else if (strcasecmp(key, "META")==0) + return MetaIndex; + else if (strcasecmp(key, "SUPER")==0) + return SuperIndex; + else if (strcasecmp(key, "HYPER")==0) + return HyperIndex; + else if (strcasecmp(key, "MOD1")==0) + return Mod1MapIndex; + else if (strcasecmp(key, "MOD2")==0) + return Mod2MapIndex; + else if (strcasecmp(key, "MOD3")==0) + return Mod3MapIndex; + else if (strcasecmp(key, "MOD4")==0) + return Mod4MapIndex; + else if (strcasecmp(key, "MOD5")==0) + return Mod5MapIndex; + else + return -1; +} + + diff --git a/src/GNUstep.h b/src/GNUstep.h index 7e6b23b0..be749159 100644 --- a/src/GNUstep.h +++ b/src/GNUstep.h @@ -1,9 +1,9 @@ /* GNUstep.h-- stuff for compatibility with GNUstep applications * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -33,9 +33,9 @@ #define GNUSTEP_TITLEBAR_STATE "_GNUSTEP_TITLEBAR_STATE" enum { - WMTitleBarKey = 0, - WMTitleBarNormal = 1, - WMTitleBarMain = 2 + WMTitleBarKey = 0, + WMTitleBarNormal = 1, + WMTitleBarMain = 2 }; #ifndef _DEFINED_GNUSTEP_WINDOW_INFO @@ -50,29 +50,29 @@ enum { * range INT_MIN+1 to INT_MAX */ enum { - WMDesktopWindowLevel = -1000, /* GNUstep addition */ - WMNormalWindowLevel = 0, - WMFloatingWindowLevel = 3, - WMSubmenuWindowLevel = 3, - WMTornOffMenuWindowLevel = 3, - WMMainMenuWindowLevel = 20, - WMDockWindowLevel = 21, /* Deprecated - use NSStatusWindowLevel */ - WMStatusWindowLevel = 21, - WMModalPanelWindowLevel = 100, - WMPopUpMenuWindowLevel = 101, - WMScreenSaverWindowLevel = 1000 + WMDesktopWindowLevel = -1000, /* GNUstep addition */ + WMNormalWindowLevel = 0, + WMFloatingWindowLevel = 3, + WMSubmenuWindowLevel = 3, + WMTornOffMenuWindowLevel = 3, + WMMainMenuWindowLevel = 20, + WMDockWindowLevel = 21, /* Deprecated - use NSStatusWindowLevel */ + WMStatusWindowLevel = 21, + WMModalPanelWindowLevel = 100, + WMPopUpMenuWindowLevel = 101, + WMScreenSaverWindowLevel = 1000 }; /* window attributes */ enum { - WMBorderlessWindowMask = 0, - WMTitledWindowMask = 1, - WMClosableWindowMask = 2, - WMMiniaturizableWindowMask = 4, - WMResizableWindowMask = 8, - WMIconWindowMask = 64, - WMMiniWindowMask = 128 + WMBorderlessWindowMask = 0, + WMTitledWindowMask = 1, + WMClosableWindowMask = 2, + WMMiniaturizableWindowMask = 4, + WMResizableWindowMask = 8, + WMIconWindowMask = 64, + WMMiniWindowMask = 128 }; #endif @@ -110,3 +110,4 @@ typedef struct { #define WMFHideApplication 12 #endif + diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 711e133c..ff45612f 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -42,15 +42,15 @@ /* class codes */ typedef enum { WCLASS_UNKNOWN = 0, - WCLASS_WINDOW = 1, /* managed client windows */ - WCLASS_MENU = 2, /* root menus */ - WCLASS_APPICON = 3, - WCLASS_DUMMYWINDOW = 4, /* window that holds window group leader */ - WCLASS_MINIWINDOW = 5, - WCLASS_DOCK_ICON = 6, - WCLASS_PAGER = 7, - WCLASS_TEXT_INPUT = 8, - WCLASS_FRAME = 9 + WCLASS_WINDOW = 1, /* managed client windows */ + WCLASS_MENU = 2, /* root menus */ + WCLASS_APPICON = 3, + WCLASS_DUMMYWINDOW = 4, /* window that holds window group leader */ + WCLASS_MINIWINDOW = 5, + WCLASS_DOCK_ICON = 6, + WCLASS_PAGER = 7, + WCLASS_TEXT_INPUT = 8, + WCLASS_FRAME = 9 } WClassType; @@ -61,25 +61,25 @@ typedef enum { * but discouraged. */ enum { - WMBackLevel = INT_MIN+1, /* Very lowest level */ - WMDesktopLevel = -1000, /* Lowest level of normal use */ - WMSunkenLevel = -1, - WMNormalLevel = 0, - WMFloatingLevel = 3, - WMDockLevel = 5, - WMSubmenuLevel = 6, - WMMainMenuLevel = 20, - WMStatusLevel = 21, - WMFullscreenLevel = 50, - WMModalLevel = 100, - WMPopUpLevel = 101, - WMScreensaverLevel = 1000, - WMOuterSpaceLevel = INT_MAX + WMBackLevel = INT_MIN+1, /* Very lowest level */ + WMDesktopLevel = -1000, /* Lowest level of normal use */ + WMSunkenLevel = -1, + WMNormalLevel = 0, + WMFloatingLevel = 3, + WMDockLevel = 5, + WMSubmenuLevel = 6, + WMMainMenuLevel = 20, + WMStatusLevel = 21, + WMFullscreenLevel = 50, + WMModalLevel = 100, + WMPopUpLevel = 101, + WMScreensaverLevel = 1000, + WMOuterSpaceLevel = INT_MAX }; /* * WObjDescriptor will be used by the event dispatcher to - * send events to a particular object through the methods in the + * send events to a particular object through the methods in the * method table. If all objects of the same class share the * same methods, the class method table should be used, otherwise * a new method table must be created for each object. @@ -88,10 +88,10 @@ enum { */ typedef struct WObjDescriptor { - void *self; /* the object that will be called */ - /* event handlers */ + void *self; /* the object that will be called */ + /* event handlers */ void (*handle_expose)(struct WObjDescriptor *sender, XEvent *event); - + void (*handle_mousedown)(struct WObjDescriptor *sender, XEvent *event); void (*handle_anything)(struct WObjDescriptor *sender, XEvent *event); @@ -107,9 +107,9 @@ typedef struct WObjDescriptor { /* shutdown modes */ typedef enum { WSExitMode, - WSLogoutMode, - WSKillMode, - WSRestartPreparationMode + WSLogoutMode, + WSKillMode, + WSRestartPreparationMode } WShutdownMode; @@ -262,10 +262,10 @@ typedef enum { #define WCHANGE_STATE(nstate) {\ if (WProgramState == WSTATE_NORMAL\ - || nstate != WSTATE_MODAL)\ - WProgramState = (nstate); \ + || nstate != WSTATE_MODAL)\ + WProgramState = (nstate); \ if (WProgramSigState != 0)\ - WProgramState = WProgramSigState;\ + WProgramState = WProgramSigState;\ } @@ -303,8 +303,8 @@ NOTIFICATION(MenuTitleAppearanceSettingsChanged); /* appearance settings clientdata flags */ enum { WFontSettings = 1 << 0, - WTextureSettings = 1 << 1, - WColorSettings = 1 << 2 + WTextureSettings = 1 << 1, + WColorSettings = 1 << 2 }; @@ -320,9 +320,9 @@ typedef struct WCoord { typedef struct WPreferences { char *pixmap_path; /* : separate list of */ - /* paths to find pixmaps */ + /* paths to find pixmaps */ char *icon_path; /* : separated list of */ - /* paths to find icons */ + /* paths to find icons */ WMArray *fallbackWMs; /* fallback window manager list */ char *logger_shell; /* shell to log child stdi/o */ @@ -335,25 +335,25 @@ typedef struct WPreferences { signed char window_placement; /* window placement mode */ signed char colormap_mode; /* colormap focus mode */ signed char focus_mode; /* window focusing mode */ - + char opaque_move; /* update window position during */ - /* move */ + /* move */ char wrap_menus; /* wrap menus at edge of screen */ char scrollable_menus; /* let them be scrolled */ char align_menus; /* align menu with their parents */ - + char use_saveunders; /* turn on SaveUnders for menus, - * icons etc. */ + * icons etc. */ char no_window_over_dock; char no_window_over_icons; WCoord window_place_origin; /* Offset for windows placed on - * screen */ + * screen */ - char constrain_window_size; /* don't let windows get bigger than - * screen */ + char constrain_window_size; /* don't let windows get bigger than + * screen */ char windows_cycling; /* windoze cycling */ char circ_raise; /* raise window after Alt-tabbing */ @@ -361,7 +361,7 @@ typedef struct WPreferences { char ignore_focus_click; char open_transients_with_parent; /* open transient window in - same workspace as parent */ + same workspace as parent */ signed char title_justification; /* titlebar text alignment */ int window_title_clearance; @@ -374,21 +374,21 @@ typedef struct WPreferences { #endif char no_dithering; /* use dithering or not */ - + char no_sound; /* enable/disable sound */ char no_animations; /* enable/disable animations */ - + char no_autowrap; /* wrap workspace when window is moved - * to the edge */ - + * to the edge */ + char auto_arrange_icons; /* automagically arrange icons */ - + char icon_box_position; /* position to place icons */ - + signed char iconification_style; /* position to place icons */ - + char disable_root_mouse; /* disable button events in root window */ - + char auto_focus; /* focus window when it's mapped */ @@ -398,20 +398,20 @@ typedef struct WPreferences { WCoord *app_menu_pos; WCoord *win_menu_pos; - + signed char icon_yard; /* aka iconbox */ int raise_delay; /* delay for autoraise. 0 is disabled */ int cmap_size; /* size of dithering colormap in colors - * per channel */ + * per channel */ int icon_size; /* size of the icon */ signed char menu_style; /* menu decoration style */ signed char workspace_name_display_position; - + unsigned int modifier_mask; /* mask to use as kbd modifier */ @@ -437,7 +437,7 @@ typedef struct WPreferences { char disable_miniwindows; char dont_blink; /* do not blink icon selection */ - + /* Appearance options */ char new_style; /* Use newstyle buttons */ char superfluous; /* Use superfluous things */ @@ -453,7 +453,7 @@ typedef struct WPreferences { char miniwin_balloon; char appicon_balloon; char help_balloon; - + /* some constants */ int dblclick_time; /* double click delay time in ms */ @@ -475,11 +475,11 @@ typedef struct WPreferences { struct { unsigned int nodock:1; /* don't display the dock */ unsigned int noclip:1; /* don't display the clip */ - unsigned int nocpp:1; /* don't use cpp */ - unsigned int noupdates:1; /* don't require ~/GNUstep (-static) */ - unsigned int noautolaunch:1; /* don't autolaunch apps */ - unsigned int norestore:1; /* don't restore session */ - unsigned int create_stdcmap:1; /* create std colormap */ + unsigned int nocpp:1; /* don't use cpp */ + unsigned int noupdates:1; /* don't require ~/GNUstep (-static) */ + unsigned int noautolaunch:1; /* don't autolaunch apps */ + unsigned int norestore:1; /* don't restore session */ + unsigned int create_stdcmap:1; /* create std colormap */ unsigned int nopolling:1; /* don't poll for defaults changes */ } flags; /* internal flags */ } WPreferences; @@ -514,3 +514,4 @@ extern const char *WMNWorkspaceNameChanged; extern const char *WMNResetStacking; #endif + diff --git a/src/actions.c b/src/actions.c index c218f17a..e4248024 100644 --- a/src/actions.c +++ b/src/actions.c @@ -110,7 +110,7 @@ wSetFocusTo(WScreen *scr, WWindow *wwin) int timestamp=LastTimestamp; WApplication *oapp=NULL, *napp=NULL; int wasfocused; - + if (scr->flags.ignore_focus_events || LastFocusChange > timestamp) return; @@ -548,9 +548,9 @@ wUnfullscreenWindow(WWindow *wwin) if (wwin->frame->core->stacking->window_level == WMFullscreenLevel) { if (WFLAGP(wwin, sunken)) { - ChangeStackingLevel(wwin->frame->core, WMSunkenLevel); + ChangeStackingLevel(wwin->frame->core, WMSunkenLevel); } else if (WFLAGP(wwin, floating)) { - ChangeStackingLevel(wwin->frame->core, WMFloatingLevel); + ChangeStackingLevel(wwin->frame->core, WMFloatingLevel); } else { ChangeStackingLevel(wwin->frame->core, WMNormalLevel); } @@ -960,11 +960,11 @@ wIconifyWindow(WWindow *wwin) GrabModeAsync, None, None, CurrentTime); } - if (!wPreferences.disable_miniwindows + if (!wPreferences.disable_miniwindows #ifdef NETWM_HINTS - && !wwin->flags.net_handle_icon + && !wwin->flags.net_handle_icon #endif - ) { + ) { if (!wwin->flags.icon_moved) { PlaceIcon(wwin->screen_ptr, &wwin->icon_x, &wwin->icon_y, wGetHeadForWindow(wwin)); } @@ -989,11 +989,11 @@ wIconifyWindow(WWindow *wwin) * something before the animation starts (and the server is grabbed) */ XSync(dpy, 0); - if (wPreferences.disable_miniwindows + if (wPreferences.disable_miniwindows #ifdef NETWM_HINTS - || wwin->flags.net_handle_icon + || wwin->flags.net_handle_icon #endif - ) + ) wClientSetState(wwin, IconicState, None); else wClientSetState(wwin, IconicState, wwin->icon->icon_win); @@ -1004,11 +1004,11 @@ wIconifyWindow(WWindow *wwin) && !wPreferences.no_animations) { int ix, iy, iw, ih; - if (!wPreferences.disable_miniwindows + if (!wPreferences.disable_miniwindows #ifdef NETWM_HINTS - && !wwin->flags.net_handle_icon + && !wwin->flags.net_handle_icon #endif - ) { + ) { ix = wwin->icon_x; iy = wwin->icon_y; iw = wwin->icon->core->width; @@ -1025,19 +1025,19 @@ wIconifyWindow(WWindow *wwin) } else #endif /* KWM_HINTS */ #ifdef NETWM_HINTS - if (wwin->flags.net_handle_icon) { - ix = wwin->icon_x; - iy = wwin->icon_y; - iw = wwin->icon_w; - ih = wwin->icon_h; - } else + if (wwin->flags.net_handle_icon) { + ix = wwin->icon_x; + iy = wwin->icon_y; + iw = wwin->icon_w; + ih = wwin->icon_h; + } else #endif - { - ix = 0; - iy = 0; - iw = wwin->screen_ptr->scr_width; - ih = wwin->screen_ptr->scr_height; - } + { + ix = 0; + iy = 0; + iw = wwin->screen_ptr->scr_width; + ih = wwin->screen_ptr->scr_height; + } } animateResize(wwin->screen_ptr, wwin->frame_x, wwin->frame_y, wwin->frame->core->width, wwin->frame->core->height, @@ -1050,9 +1050,9 @@ wIconifyWindow(WWindow *wwin) if (!wPreferences.disable_miniwindows #ifdef NETWM_HINTS - && !wwin->flags.net_handle_icon + && !wwin->flags.net_handle_icon #endif - ) { + ) { if (wwin->screen_ptr->current_workspace==wwin->frame->workspace || IS_OMNIPRESENT(wwin) || wPreferences.sticky_icons) @@ -1105,14 +1105,14 @@ wIconifyWindow(WWindow *wwin) #endif } - /* maybe we want to do this regardless of net_handle_icon + /* maybe we want to do this regardless of net_handle_icon * it seems to me we might break behaviour this way. */ if (wwin->flags.selected && !wPreferences.disable_miniwindows #ifdef NETWM_HINTS - && !wwin->flags.net_handle_icon + && !wwin->flags.net_handle_icon #endif - ) + ) wIconSelect(wwin->icon); WMPostNotificationName(WMNChangedState, wwin, "iconify"); @@ -1127,13 +1127,13 @@ wDeiconifyWindow(WWindow *wwin) #ifdef NETWM_HINTS /* we're hiding for show_desktop */ int netwm_hidden = wwin->flags.net_show_desktop && - wwin->frame->workspace!=wwin->screen_ptr->current_workspace; + wwin->frame->workspace!=wwin->screen_ptr->current_workspace; #else int netwm_hidden = False; #endif if (!netwm_hidden) - wWindowChangeWorkspace(wwin, wwin->screen_ptr->current_workspace); + wWindowChangeWorkspace(wwin, wwin->screen_ptr->current_workspace); if (!wwin->flags.miniaturized) return; @@ -1157,90 +1157,90 @@ wDeiconifyWindow(WWindow *wwin) } if (!netwm_hidden || wPreferences.sticky_icons) { - /* maybe we want to do this regardless of net_handle_icon - * it seems to me we might break behaviour this way. - */ - if (!wPreferences.disable_miniwindows + /* maybe we want to do this regardless of net_handle_icon + * it seems to me we might break behaviour this way. + */ + if (!wPreferences.disable_miniwindows #ifdef NETWM_HINTS - && !wwin->flags.net_handle_icon + && !wwin->flags.net_handle_icon #endif - && wwin->icon != NULL) { - if (wwin->icon->selected) - wIconSelect(wwin->icon); + && wwin->icon != NULL) { + if (wwin->icon->selected) + wIconSelect(wwin->icon); - XUnmapWindow(dpy, wwin->icon->core->window); - } + XUnmapWindow(dpy, wwin->icon->core->window); + } } if (!netwm_hidden) - wSoundPlay(WSOUND_DEICONIFY); + wSoundPlay(WSOUND_DEICONIFY); /* if the window is in another workspace, do it silently */ if (!netwm_hidden) { #ifdef ANIMATIONS - if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations - && !wwin->flags.skip_next_animation && wwin->icon != NULL) { - int ix, iy, iw, ih; + if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations + && !wwin->flags.skip_next_animation && wwin->icon != NULL) { + int ix, iy, iw, ih; - if (!wPreferences.disable_miniwindows + if (!wPreferences.disable_miniwindows #ifdef NETWM_HINTS - && !wwin->flags.net_handle_icon + && !wwin->flags.net_handle_icon #endif - ) { - ix = wwin->icon_x; - iy = wwin->icon_y; - iw = wwin->icon->core->width; - ih = wwin->icon->core->height; - } else { + ) { + ix = wwin->icon_x; + iy = wwin->icon_y; + iw = wwin->icon->core->width; + ih = wwin->icon->core->height; + } else { #ifdef KWM_HINTS - WArea area; - - if (wKWMGetIconGeometry(wwin, &area)) { - ix = area.x1; - iy = area.y1; - iw = area.x2 - ix; - ih = area.y2 - iy; - } else + WArea area; + + if (wKWMGetIconGeometry(wwin, &area)) { + ix = area.x1; + iy = area.y1; + iw = area.x2 - ix; + ih = area.y2 - iy; + } else #endif /* KWM_HINTS */ #ifdef NETWM_HINTS - if (wwin->flags.net_handle_icon) { - ix = wwin->icon_x; - iy = wwin->icon_y; - iw = wwin->icon_w; - ih = wwin->icon_h; - } else + if (wwin->flags.net_handle_icon) { + ix = wwin->icon_x; + iy = wwin->icon_y; + iw = wwin->icon_w; + ih = wwin->icon_h; + } else #endif - { - ix = 0; - iy = 0; - iw = wwin->screen_ptr->scr_width; - ih = wwin->screen_ptr->scr_height; - } - } - animateResize(wwin->screen_ptr, ix, iy, iw, ih, - wwin->frame_x, wwin->frame_y, - wwin->frame->core->width, wwin->frame->core->height, - False); - } + { + ix = 0; + iy = 0; + iw = wwin->screen_ptr->scr_width; + ih = wwin->screen_ptr->scr_height; + } + } + animateResize(wwin->screen_ptr, ix, iy, iw, ih, + wwin->frame_x, wwin->frame_y, + wwin->frame->core->width, wwin->frame->core->height, + False); + } #endif /* ANIMATIONS */ - wwin->flags.skip_next_animation = 0; - XGrabServer(dpy); - if (!wwin->flags.shaded) { - XMapWindow(dpy, wwin->client_win); - } - XMapWindow(dpy, wwin->frame->core->window); - wRaiseFrame(wwin->frame->core); - if (!wwin->flags.shaded) { - wClientSetState(wwin, NormalState, None); - } - mapTransientsFor(wwin); + wwin->flags.skip_next_animation = 0; + XGrabServer(dpy); + if (!wwin->flags.shaded) { + XMapWindow(dpy, wwin->client_win); + } + XMapWindow(dpy, wwin->frame->core->window); + wRaiseFrame(wwin->frame->core); + if (!wwin->flags.shaded) { + wClientSetState(wwin, NormalState, None); + } + mapTransientsFor(wwin); } if (!wPreferences.disable_miniwindows && wwin->icon != NULL #ifdef NETWM_HINTS && !wwin->flags.net_handle_icon #endif - ) { + ) { RemoveFromStackList(wwin->icon->core); /* removeIconGrabs(wwin->icon);*/ wIconDestroy(wwin->icon); @@ -1248,22 +1248,22 @@ wDeiconifyWindow(WWindow *wwin) } if (!netwm_hidden) { - XUngrabServer(dpy); + XUngrabServer(dpy); - wSetFocusTo(wwin->screen_ptr, wwin); + wSetFocusTo(wwin->screen_ptr, wwin); #ifdef ANIMATIONS - if (!wwin->screen_ptr->flags.startup) { + if (!wwin->screen_ptr->flags.startup) { /* Catch up with events not processed while animation was running */ - Window clientwin = wwin->client_win; + Window clientwin = wwin->client_win; - ProcessPendingEvents(); + ProcessPendingEvents(); /* the window can disappear while ProcessPendingEvents() runs */ if (!wWindowFor(clientwin)) { return; } - } + } #endif } @@ -1275,7 +1275,7 @@ wDeiconifyWindow(WWindow *wwin) /* In case we were shaded and iconified, also unshade */ if (!netwm_hidden) - wUnshadeWindow(wwin); + wUnshadeWindow(wwin); } @@ -1940,7 +1940,7 @@ wSelectWindow(WWindow *wwin, Bool flag) wwin->flags.selected = 1; XSetWindowBorder(dpy, wwin->frame->core->window, scr->white_pixel); - if (!HAS_BORDER(wwin)) { + if (!HAS_BORDER(wwin)) { XSetWindowBorderWidth(dpy, wwin->frame->core->window, FRAME_BORDER_WIDTH); } @@ -1953,7 +1953,7 @@ wSelectWindow(WWindow *wwin, Bool flag) XSetWindowBorder(dpy, wwin->frame->core->window, scr->frame_border_pixel); - if (!HAS_BORDER(wwin)) { + if (!HAS_BORDER(wwin)) { XSetWindowBorderWidth(dpy, wwin->frame->core->window, 0); } diff --git a/src/actions.h b/src/actions.h index bdabdb43..1974e4b0 100644 --- a/src/actions.h +++ b/src/actions.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -56,8 +56,8 @@ void wHideOtherApplications(WWindow *wwin); void wShowAllWindows(WScreen *scr); void wHideApplication(WApplication *wapp); -void wUnhideApplication(WApplication *wapp, Bool miniwindows, - Bool bringToCurrentWS); +void wUnhideApplication(WApplication *wapp, Bool miniwindows, + Bool bringToCurrentWS); void wRefreshDesktop(WScreen *scr); @@ -70,3 +70,4 @@ void wUnfullscreenWindow(WWindow *wwin); #endif + diff --git a/src/appicon.c b/src/appicon.c index 68a67527..994fa821 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -69,7 +69,7 @@ static void iconExpose(WObjDescriptor *desc, XEvent *event); WAppIcon* wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, - char *wm_class, int tile) + char *wm_class, int tile) { WAppIcon *dicon; char *path; @@ -88,26 +88,26 @@ wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, scr->app_icon_list = dicon; if (command) { - dicon->command = wstrdup(command); + dicon->command = wstrdup(command); } if (wm_class) - dicon->wm_class = wstrdup(wm_class); + dicon->wm_class = wstrdup(wm_class); if (wm_instance) - dicon->wm_instance = wstrdup(wm_instance); + dicon->wm_instance = wstrdup(wm_instance); path = wDefaultGetIconFile(scr, wm_instance, wm_class, True); if (!path && command) { - wApplicationExtractDirPackIcon(scr, command, wm_instance, wm_class); + wApplicationExtractDirPackIcon(scr, command, wm_instance, wm_class); - path = wDefaultGetIconFile(scr, wm_instance, wm_class, False); + path = wDefaultGetIconFile(scr, wm_instance, wm_class, False); } if (path) - path = FindImage(wPreferences.icon_path, path); + path = FindImage(wPreferences.icon_path, path); dicon->icon = wIconCreateWithIconFile(scr, path, tile); if (path) - wfree(path); + wfree(path); #ifdef XDND wXDNDMakeAwareness(dicon->icon->core->window); #endif @@ -117,7 +117,7 @@ wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, XSetWindowAttributes attribs; attribs.save_under = True; XChangeWindowAttributes(dpy, dicon->icon->core->window, - CWSaveUnder, &attribs); + CWSaveUnder, &attribs); } #endif @@ -164,7 +164,7 @@ wAppIconCreate(WWindow *leader_win) XSetWindowAttributes attribs; attribs.save_under = True; XChangeWindowAttributes(dpy, aicon->icon->core->window, - CWSaveUnder, &attribs); + CWSaveUnder, &attribs); } #endif #ifdef XDND @@ -192,15 +192,15 @@ wAppIconDestroy(WAppIcon *aicon) RemoveFromStackList(aicon->icon->core); wIconDestroy(aicon->icon); if (aicon->command) - wfree(aicon->command); + wfree(aicon->command); #ifdef OFFIX_DND if (aicon->dnd_command) - wfree(aicon->dnd_command); + wfree(aicon->dnd_command); #endif if (aicon->wm_instance) - wfree(aicon->wm_instance); + wfree(aicon->wm_instance); if (aicon->wm_class) - wfree(aicon->wm_class); + wfree(aicon->wm_class); if (aicon == scr->app_icon_list) { if (aicon->next) @@ -235,12 +235,12 @@ drawCorner(WIcon *icon, WWindow *wwin, int active) points[2].x = 2; points[2].y = 12; if (active) { - gc=scr->focused_texture->any.gc; + gc=scr->focused_texture->any.gc; } else { - gc=scr->unfocused_texture->any.gc; + gc=scr->unfocused_texture->any.gc; } XFillPolygon(dpy, icon->core->window, gc, points, 3, - Convex, CoordModeOrigin); + Convex, CoordModeOrigin); } #endif /* NEWAPPICON */ @@ -292,17 +292,17 @@ updateDockNumbers(WScreen *scr) ws_numbers = wmalloc(20); snprintf(ws_numbers, 20, "%i [ %i ]", scr->current_workspace+1, - ((scr->current_workspace/10)+1)); + ((scr->current_workspace/10)+1)); length = strlen(ws_numbers); - + XClearArea(dpy, dicon->icon->core->window, 2, 2, 50, - WMFontHeight(scr->icon_title_font)+1, False); - + WMFontHeight(scr->icon_title_font)+1, False); + WMDrawString(scr->wmscreen, dicon->icon->core->window, scr->black, - scr->icon_title_font, 4, 3, ws_numbers, length); + scr->icon_title_font, 4, 3, ws_numbers, length); WMDrawString(scr->wmscreen, dicon->icon->core->window, scr->white, - scr->icon_title_font, 3, 2, ws_numbers, length); + scr->icon_title_font, 3, 2, ws_numbers, length); wfree(ws_numbers); } @@ -312,13 +312,13 @@ updateDockNumbers(WScreen *scr) void wAppIconPaint(WAppIcon *aicon) { - WApplication *wapp; + WApplication *wapp; WScreen *scr = aicon->icon->core->screen_ptr; if (aicon->icon->owner) - wapp = wApplicationOf(aicon->icon->owner->main_window); + wapp = wApplicationOf(aicon->icon->owner->main_window); else - wapp = NULL; + wapp = NULL; wIconPaint(aicon->icon); @@ -326,25 +326,25 @@ wAppIconPaint(WAppIcon *aicon) # ifdef WS_INDICATOR if (aicon->docked && scr->dock && scr->dock==aicon->dock && aicon->yindex==0) - updateDockNumbers(scr); + updateDockNumbers(scr); # endif if (scr->dock_dots && aicon->docked && !aicon->running - && aicon->command!=NULL) { - XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask); - XSetClipOrigin(dpy, scr->copy_gc, 0, 0); - XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window, - scr->copy_gc, 0, 0, scr->dock_dots->width, - scr->dock_dots->height, 0, 0); - } - + && aicon->command!=NULL) { + XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask); + XSetClipOrigin(dpy, scr->copy_gc, 0, 0); + XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window, + scr->copy_gc, 0, 0, scr->dock_dots->width, + scr->dock_dots->height, 0, 0); + } + #ifdef HIDDENDOT if (wapp && wapp->flags.hidden) { - XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask); - XSetClipOrigin(dpy, scr->copy_gc, 0, 0); - XCopyArea(dpy, scr->dock_dots->image, - aicon->icon->core->window, - scr->copy_gc, 0, 0, 7, - scr->dock_dots->height, 0, 0); + XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask); + XSetClipOrigin(dpy, scr->copy_gc, 0, 0); + XCopyArea(dpy, scr->dock_dots->image, + aicon->icon->core->window, + scr->copy_gc, 0, 0, 7, + scr->dock_dots->height, 0, 0); } #endif /* HIDDENDOT */ @@ -353,8 +353,8 @@ wAppIconPaint(WAppIcon *aicon) XSetClipMask(dpy, scr->copy_gc, None); if (aicon->launching) { - XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc, - 0, 0, wPreferences.icon_size, wPreferences.icon_size); + XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc, + 0, 0, wPreferences.icon_size, wPreferences.icon_size); } } @@ -370,10 +370,10 @@ hideCallback(WMenu *menu, WMenuEntry *entry) WApplication *wapp = (WApplication*)entry->clientdata; if (wapp->flags.hidden) { - wWorkspaceChange(menu->menu->screen_ptr, wapp->last_workspace); - wUnhideApplication(wapp, False, False); + wWorkspaceChange(menu->menu->screen_ptr, wapp->last_workspace); + wUnhideApplication(wapp, False, False); } else { - wHideApplication(wapp); + wHideApplication(wapp); } } @@ -398,7 +398,7 @@ setIconCallback(WMenu *menu, WMenuEntry *entry) assert(icon!=NULL); if (icon->editing) - return; + return; icon->editing = 1; scr = icon->icon->core->screen_ptr; @@ -407,20 +407,20 @@ setIconCallback(WMenu *menu, WMenuEntry *entry) result = wIconChooserDialog(scr, &file, icon->wm_instance, icon->wm_class); if (result && !icon->destroyed) { - if (file && *file==0) { - wfree(file); - file = NULL; - } - if (!wIconChangeImageFile(icon->icon, file)) { - wMessageDialog(scr, _("Error"), - _("Could not open specified icon file"), - _("OK"), NULL, NULL); - } else { - wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file); - wAppIconPaint(icon); - } - if (file) - wfree(file); + if (file && *file==0) { + wfree(file); + file = NULL; + } + if (!wIconChangeImageFile(icon->icon, file)) { + wMessageDialog(scr, _("Error"), + _("Could not open specified icon file"), + _("OK"), NULL, NULL); + } else { + wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file); + wAppIconPaint(icon); + } + if (file) + wfree(file); } icon->editing = 0; wrelease(icon); @@ -435,23 +435,23 @@ killCallback(WMenu *menu, WMenuEntry *entry) char *buffer; if (!WCHECK_STATE(WSTATE_NORMAL)) - return; + return; WCHANGE_STATE(WSTATE_MODAL); assert(entry->clientdata!=NULL); buffer = wstrconcat(wapp->app_icon ? wapp->app_icon->wm_class : NULL, - _(" will be forcibly closed.\n" - "Any unsaved changes will be lost.\n" - "Please confirm.")); + _(" will be forcibly closed.\n" + "Any unsaved changes will be lost.\n" + "Please confirm.")); fPtr = wapp->main_window_desc->fake_group; wretain(wapp->main_window_desc); if (wPreferences.dont_confirm_kill - || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"), - buffer, _("Yes"), _("No"), NULL)==WAPRDefault) { + || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"), + buffer, _("Yes"), _("No"), NULL)==WAPRDefault) { if (fPtr!=NULL) { WWindow *wwin, *twin; @@ -498,16 +498,16 @@ openApplicationMenu(WApplication *wapp, int x, int y) int i; if (!scr->icon_menu) { - scr->icon_menu = createApplicationMenu(scr); - wfree(scr->icon_menu->entries[1]->text); + scr->icon_menu = createApplicationMenu(scr); + wfree(scr->icon_menu->entries[1]->text); } menu = scr->icon_menu; if (wapp->flags.hidden) { - menu->entries[1]->text = _("Unhide"); + menu->entries[1]->text = _("Unhide"); } else { - menu->entries[1]->text = _("Hide"); + menu->entries[1]->text = _("Hide"); } menu->flags.realized = 0; @@ -515,13 +515,13 @@ openApplicationMenu(WApplication *wapp, int x, int y) x -= menu->frame->core->width/2; if (x + menu->frame->core->width > scr->scr_width) - x = scr->scr_width - menu->frame->core->width; + x = scr->scr_width - menu->frame->core->width; if (x < 0) - x = 0; + x = 0; /* set client data */ for (i = 0; i < menu->entry_no; i++) { - menu->entries[i]->clientdata = wapp; + menu->entries[i]->clientdata = wapp; } wMenuMapAt(menu, x, y, False); } @@ -549,8 +549,8 @@ iconDblClick(WObjDescriptor *desc, XEvent *event) wapp = wApplicationOf(aicon->icon->owner->main_window); #ifdef DEBUG0 if (!wapp) { - wwarning("could not find application descriptor for app icon!!"); - return; + wwarning("could not find application descriptor for app icon!!"); + return; } #endif @@ -558,12 +558,12 @@ iconDblClick(WObjDescriptor *desc, XEvent *event) /* go to the last workspace that the user worked on the app */ if (!unhideHere && wapp->last_workspace != scr->current_workspace) - wWorkspaceChange(scr, wapp->last_workspace); + wWorkspaceChange(scr, wapp->last_workspace); wUnhideApplication(wapp, event->xbutton.button==Button2, unhideHere); if (event->xbutton.state & MOD_MASK) { - wHideOtherApplications(aicon->icon->owner); + wHideOtherApplications(aicon->icon->owner); } } @@ -592,56 +592,56 @@ appIconMouseDown(WObjDescriptor *desc, XEvent *event) int oldY = y; if (aicon->editing || WCHECK_STATE(WSTATE_MODAL)) - return; + return; if (IsDoubleClick(scr, event)) { - iconDblClick(desc, event); - return; + iconDblClick(desc, event); + return; } if (event->xbutton.button == Button3) { - WObjDescriptor *desc; - WApplication *wapp = wApplicationOf(aicon->icon->owner->main_window); - - if (!wapp) - return; - - if (event->xbutton.send_event && - XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, - GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { - wwarning("pointer grab failed for appicon menu"); - return; - } - - openApplicationMenu(wapp, event->xbutton.x_root, - event->xbutton.y_root); - - /* allow drag select of menu */ - desc = &scr->icon_menu->menu->descriptor; - event->xbutton.send_event = True; - (*desc->handle_mousedown)(desc, event); - return; + WObjDescriptor *desc; + WApplication *wapp = wApplicationOf(aicon->icon->owner->main_window); + + if (!wapp) + return; + + if (event->xbutton.send_event && + XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask + |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { + wwarning("pointer grab failed for appicon menu"); + return; + } + + openApplicationMenu(wapp, event->xbutton.x_root, + event->xbutton.y_root); + + /* allow drag select of menu */ + desc = &scr->icon_menu->menu->descriptor; + event->xbutton.send_event = True; + (*desc->handle_mousedown)(desc, event); + return; } #ifdef DEBUG puts("Moving icon"); #endif if (event->xbutton.state & MOD_MASK) - wLowerFrame(icon->core); + wLowerFrame(icon->core); else - wRaiseFrame(icon->core); + wRaiseFrame(icon->core); if (XGrabPointer(dpy, icon->core->window, True, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, - GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { - wwarning("pointer grab failed for appicon move"); + |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { + wwarning("pointer grab failed for appicon move"); } if (wPreferences.flags.nodock && wPreferences.flags.noclip) - dockable = 0; + dockable = 0; else - dockable = canBeDocked(icon->owner); + dockable = canBeDocked(icon->owner); wins[0] = icon->core->window; wins[1] = scr->dock_shadow; @@ -655,41 +655,41 @@ appIconMouseDown(WObjDescriptor *desc, XEvent *event) ghost); XClearWindow(dpy, scr->dock_shadow); } - + while (!done) { - WMMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask - |ButtonMotionMask|ExposureMask, &ev); - switch (ev.type) { - case Expose: - WMHandleEvent(&ev); - break; - - case MotionNotify: - if (!grabbed) { - if (abs(dx-ev.xmotion.x)>=MOVE_THRESHOLD - || abs(dy-ev.xmotion.y)>=MOVE_THRESHOLD) { - XChangeActivePointerGrab(dpy, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, - wCursor[WCUR_MOVE], CurrentTime); - grabbed=1; - } else { - break; - } - } - x = ev.xmotion.x_root - dx; - y = ev.xmotion.y_root - dy; - - if (movingSingle) { - XMoveWindow(dpy, icon->core->window, x, y); - } else { - wAppIconMove(aicon, x, y); - } - - if (dockable) { + WMMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask + |ButtonMotionMask|ExposureMask, &ev); + switch (ev.type) { + case Expose: + WMHandleEvent(&ev); + break; + + case MotionNotify: + if (!grabbed) { + if (abs(dx-ev.xmotion.x)>=MOVE_THRESHOLD + || abs(dy-ev.xmotion.y)>=MOVE_THRESHOLD) { + XChangeActivePointerGrab(dpy, ButtonMotionMask + |ButtonReleaseMask|ButtonPressMask, + wCursor[WCUR_MOVE], CurrentTime); + grabbed=1; + } else { + break; + } + } + x = ev.xmotion.x_root - dx; + y = ev.xmotion.y_root - dy; + + if (movingSingle) { + XMoveWindow(dpy, icon->core->window, x, y); + } else { + wAppIconMove(aicon, x, y); + } + + if (dockable) { if (scr->dock && wDockSnapIcon(scr->dock, aicon, x, y, &ix, &iy, False)) { shad_x = scr->dock->x_pos + ix*wPreferences.icon_size; - shad_y = scr->dock->y_pos + iy*wPreferences.icon_size; + shad_y = scr->dock->y_pos + iy*wPreferences.icon_size; if (scr->last_dock != scr->dock && collapsed) { scr->last_dock->collapsed = 1; @@ -706,16 +706,16 @@ appIconMouseDown(WObjDescriptor *desc, XEvent *event) scr->last_dock = scr->dock; - XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y); - if (!docking) { + XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y); + if (!docking) { XMapWindow(dpy, scr->dock_shadow); - } - docking = 1; + } + docking = 1; } else if (workspace->clip && wDockSnapIcon(workspace->clip, aicon, x, y, &ix, &iy, False)) { shad_x = workspace->clip->x_pos + ix*wPreferences.icon_size; - shad_y = workspace->clip->y_pos + iy*wPreferences.icon_size; + shad_y = workspace->clip->y_pos + iy*wPreferences.icon_size; if (scr->last_dock != workspace->clip && collapsed) { scr->last_dock->collapsed = 1; @@ -732,33 +732,33 @@ appIconMouseDown(WObjDescriptor *desc, XEvent *event) scr->last_dock = workspace->clip; - XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y); - if (!docking) { - XMapWindow(dpy, scr->dock_shadow); - } + XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y); + if (!docking) { + XMapWindow(dpy, scr->dock_shadow); + } docking = 1; - } else if (docking) { - XUnmapWindow(dpy, scr->dock_shadow); + } else if (docking) { + XUnmapWindow(dpy, scr->dock_shadow); docking = 0; - } + } } - break; + break; - case ButtonPress: - break; + case ButtonPress: + break; - case ButtonRelease: - if (ev.xbutton.button != clickButton) - break; - XUngrabPointer(dpy, CurrentTime); + case ButtonRelease: + if (ev.xbutton.button != clickButton) + break; + XUngrabPointer(dpy, CurrentTime); if (docking) { - Bool docked; + Bool docked; - /* icon is trying to be docked */ - SlideWindow(icon->core->window, x, y, shad_x, shad_y); - XUnmapWindow(dpy, scr->dock_shadow); + /* icon is trying to be docked */ + SlideWindow(icon->core->window, x, y, shad_x, shad_y); + XUnmapWindow(dpy, scr->dock_shadow); docked = wDockAttachIcon(scr->last_dock, aicon, ix, iy); if (scr->last_dock->auto_collapse) { collapsed = 0; @@ -768,43 +768,43 @@ appIconMouseDown(WObjDescriptor *desc, XEvent *event) workspace->clip->auto_raise_lower) wDockLower(workspace->clip); - if (!docked) { + if (!docked) { /* If icon could not be docked, slide it back to the old * position */ SlideWindow(icon->core->window, x, y, oldX, oldY); } - wSoundPlay(WSOUND_DOCK); + wSoundPlay(WSOUND_DOCK); } else { - if (movingSingle) { - /* move back to its place */ - SlideWindow(icon->core->window, x, y, oldX, oldY); - wAppIconMove(aicon, oldX, oldY); - } else { - XMoveWindow(dpy, icon->core->window, x, y); - aicon->x_pos = x; - aicon->y_pos = y; - } + if (movingSingle) { + /* move back to its place */ + SlideWindow(icon->core->window, x, y, oldX, oldY); + wAppIconMove(aicon, oldX, oldY); + } else { + XMoveWindow(dpy, icon->core->window, x, y); + aicon->x_pos = x; + aicon->y_pos = y; + } if (workspace->clip && workspace->clip->auto_raise_lower) wDockLower(workspace->clip); } - if (collapsed) { - scr->last_dock->collapsed = 1; - wDockHideIcons(scr->last_dock); - collapsed = 0; - } - if (superfluous) { - if (ghost!=None) - XFreePixmap(dpy, ghost); - XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel); - } - - if (wPreferences.auto_arrange_icons) - wArrangeIcons(scr, True); - - done = 1; - break; - } + if (collapsed) { + scr->last_dock->collapsed = 1; + wDockHideIcons(scr->last_dock); + collapsed = 0; + } + if (superfluous) { + if (ghost!=None) + XFreePixmap(dpy, ghost); + XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel); + } + + if (wPreferences.auto_arrange_icons) + wArrangeIcons(scr, True); + + done = 1; + break; + } } #ifdef DEBUG puts("End icon move"); diff --git a/src/appicon.h b/src/appicon.h index aa4161d3..42314286 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -1,9 +1,9 @@ /* appicon.h- application icon - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -38,29 +38,29 @@ typedef struct WAppIcon { struct WAppIcon *next; struct WAppIcon *prev; WIcon *icon; - + char *client_machine; - + int x_pos, y_pos; /* absolute screen coordinate */ - + char *command; /* command used to launch app */ - + #ifdef OFFIX_DND char *dnd_command; /* command to use when something is */ - /* dropped on us */ + /* dropped on us */ #endif - + char *paste_command; /* command to run when something is pasted */ - + char *wm_class; char *wm_instance; pid_t pid; /* for apps launched from the dock */ Window main_window; struct WDock *dock; /* In which dock is docked. */ - - struct _AppSettingsPanel *panel; /* Settings Panel */ - + + struct _AppSettingsPanel *panel; /* Settings Panel */ + unsigned int gnustep_app:1; /* if this is a GNUstep application */ unsigned int docked:1; unsigned int omnipresent:1; /* If omnipresent when docked in clip */ @@ -77,17 +77,17 @@ typedef struct WAppIcon { unsigned int drop_launch:1; /* launching from drop action */ unsigned int paste_launch:1; /* launching from paste action */ unsigned int destroyed:1; /* appicon was destroyed */ - unsigned int buggy_app:1; /* do not make dock rely on hints - * set by app */ - + unsigned int buggy_app:1; /* do not make dock rely on hints + * set by app */ + unsigned int lock:1; /* do not allow to be destroyed */ - + } WAppIcon; WAppIcon *wAppIconCreate(WWindow *leader_win); WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, - char *wm_class, int tile); + char *wm_class, int tile); void wAppIconDestroy(WAppIcon *aicon); @@ -98,3 +98,4 @@ Bool wAppIconChangeImage(WAppIcon *icon, char *file); void wAppIconMove(WAppIcon *aicon, int x, int y); #endif + diff --git a/src/application.c b/src/application.c index 9b6e1872..60cc68fe 100644 --- a/src/application.c +++ b/src/application.c @@ -1,9 +1,9 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima * Copyright (c) 1998-2003 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 @@ -16,7 +16,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. */ #include "wconfig.h" @@ -71,7 +71,7 @@ makeMainWindow(WScreen *scr, Window window) XWindowAttributes attr; if (!XGetWindowAttributes(dpy, window, &attr)) { - return NULL; + return NULL; } wwin = wWindowCreate(); @@ -79,18 +79,18 @@ makeMainWindow(WScreen *scr, Window window) wwin->client_win = window; wwin->main_window = window; wwin->wm_hints = XGetWMHints(dpy, window); -/* if (!MyXFetchName(dpy, window, &(wwin->frame->title))) { - wwin->frame->title = NULL; - } - */ + /* if (!MyXFetchName(dpy, window, &(wwin->frame->title))) { + wwin->frame->title = NULL; + } + */ PropGetWMClass(window, &wwin->wm_class, &wwin->wm_instance); wDefaultFillAttributes(scr, wwin->wm_instance, wwin->wm_class, - &wwin->user_flags, &wwin->defined_user_flags, True); - + &wwin->user_flags, &wwin->defined_user_flags, True); + XSelectInput(dpy, window, attr.your_event_mask | PropertyChangeMask - | StructureNotifyMask); + | StructureNotifyMask); return wwin; } @@ -100,10 +100,10 @@ wApplicationOf(Window window) { WApplication *wapp; - if (window == None) - return NULL; + if (window == None) + return NULL; if (XFindContext(dpy, window, wAppWinContext, (XPointer*)&wapp)!=XCSUCCESS) - return NULL; + return NULL; return wapp; } @@ -147,40 +147,40 @@ saveIconNameFor(char *iconPath, char *wm_instance, char *wm_class) i = 0; if (wm_instance) - i += strlen(wm_instance); + i += strlen(wm_instance); if (wm_class) - i += strlen(wm_class); + i += strlen(wm_class); tmp = wmalloc(i+8); *tmp = 0; if (wm_class && wm_instance) { - sprintf(tmp, "%s.%s", wm_instance, wm_class); + sprintf(tmp, "%s.%s", wm_instance, wm_class); } else { - if (wm_instance) - strcat(tmp, wm_instance); - if (wm_class) - strcat(tmp, wm_class); + if (wm_instance) + strcat(tmp, wm_instance); + if (wm_class) + strcat(tmp, wm_class); } - - key = WMCreatePLString(tmp); + + key = WMCreatePLString(tmp); wfree(tmp); adict = WMGetFromPLDictionary(dict, key); - + iconk = WMCreatePLString("Icon"); - + if (adict) { - val = WMGetFromPLDictionary(adict, iconk); + val = WMGetFromPLDictionary(adict, iconk); } else { - /* no dictionary for app, so create one */ - adict = WMCreatePLDictionary(NULL, NULL); - WMPutInPLDictionary(dict, key, adict); - WMReleasePropList(adict); - val = NULL; + /* no dictionary for app, so create one */ + adict = WMCreatePLDictionary(NULL, NULL); + WMPutInPLDictionary(dict, key, adict); + WMReleasePropList(adict); + val = NULL; } if (!val) { - val = WMCreatePLString(iconPath); - WMPutInPLDictionary(adict, iconk, val); - WMReleasePropList(val); + val = WMCreatePLString(iconPath); + WMPutInPLDictionary(adict, iconk, val); + WMReleasePropList(val); } WMReleasePropList(key); WMReleasePropList(iconk); @@ -192,38 +192,38 @@ saveIconNameFor(char *iconPath, char *wm_instance, char *wm_class) void -wApplicationExtractDirPackIcon(WScreen *scr, char *path, - char *wm_instance, char *wm_class) +wApplicationExtractDirPackIcon(WScreen *scr, char *path, + char *wm_instance, char *wm_class) { char *iconPath=NULL; /* Maybe the app is a .app and it has an icon in it, like * /usr/local/GNUstep/Apps/WPrefs.app/WPrefs.tiff */ if (strstr(path, ".app")) { - char *tmp; - - tmp = wmalloc(strlen(path)+16); - - if (scr->flags.supports_tiff) { - strcpy(tmp, path); - strcat(tmp, ".tiff"); - if (access(tmp, R_OK)==0) - iconPath = tmp; - } - if (!path) { - strcpy(tmp, path); - strcat(tmp, ".xpm"); - if (access(tmp, R_OK)==0) - iconPath = tmp; - } - if (!iconPath) - wfree(tmp); + char *tmp; + + tmp = wmalloc(strlen(path)+16); + + if (scr->flags.supports_tiff) { + strcpy(tmp, path); + strcat(tmp, ".tiff"); + if (access(tmp, R_OK)==0) + iconPath = tmp; + } + if (!path) { + strcpy(tmp, path); + strcat(tmp, ".xpm"); + if (access(tmp, R_OK)==0) + iconPath = tmp; + } + if (!iconPath) + wfree(tmp); } - + if (iconPath) { - saveIconNameFor(iconPath, wm_instance, wm_class); + saveIconNameFor(iconPath, wm_instance, wm_class); - wfree(iconPath); + wfree(iconPath); } } @@ -235,7 +235,7 @@ extractClientIcon(WAppIcon *icon) path = wIconStore(icon->icon); if (!path) - return False; + return False; saveIconNameFor(path, icon->wm_instance, icon->wm_class); @@ -255,22 +255,22 @@ wApplicationCreate(WWindow *wwin) if (main_window==None || main_window==scr->root_win) { #ifdef DEBUG0 - wwarning("trying to create application for %x",(unsigned)main_window); + wwarning("trying to create application for %x",(unsigned)main_window); #endif - return NULL; + return NULL; } - + { - Window root; - int foo; - unsigned int bar; - /* check if the window is valid */ - if (!XGetGeometry(dpy, main_window, &root, &foo, &foo, &bar, &bar, - &bar, &bar)) { - return NULL; - } + Window root; + int foo; + unsigned int bar; + /* check if the window is valid */ + if (!XGetGeometry(dpy, main_window, &root, &foo, &foo, &bar, &bar, + &bar, &bar)) { + return NULL; + } } - + wapp = wApplicationOf(main_window); if (wapp) { wapp->refcount++; @@ -281,32 +281,32 @@ wApplicationCreate(WWindow *wwin) return wapp; } - + wapp = wmalloc(sizeof(WApplication)); memset(wapp, 0, sizeof(WApplication)); wapp->refcount = 1; wapp->last_focused = NULL; - + wapp->last_workspace = 0; - + wapp->main_window = main_window; wapp->main_window_desc = makeMainWindow(scr, main_window); if (!wapp->main_window_desc) { - wfree(wapp); - return NULL; + wfree(wapp); + return NULL; } - + wapp->main_window_desc->fake_group = wwin->fake_group; #ifdef NETWM_HINTS wapp->main_window_desc->net_icon_image = RRetainImage(wwin->net_icon_image); #endif - + extractIcon(wapp->main_window_desc); leader = wWindowFor(main_window); if (leader) { - leader->main_window = main_window; + leader->main_window = main_window; } wapp->menu = wAppMenuGet(scr, main_window); #ifdef USER_MENU @@ -318,7 +318,7 @@ wApplicationCreate(WWindow *wwin) * Set application wide attributes from the leader. */ wapp->flags.hidden = WFLAGP(wapp->main_window_desc, start_hidden); - + wapp->flags.emulated = WFLAGP(wapp->main_window_desc, emulate_appicon); /* application descriptor */ @@ -330,8 +330,8 @@ wApplicationCreate(WWindow *wwin) wapp->app_icon = findDockIconFor(scr->last_dock, main_window); /* check main dock if we did not find it in last dock */ if (!wapp->app_icon && scr->dock) { - wapp->app_icon = findDockIconFor(scr->dock, main_window); - } + wapp->app_icon = findDockIconFor(scr->dock, main_window); + } /* finally check clips */ if (!wapp->app_icon) { int i; @@ -354,12 +354,12 @@ wApplicationCreate(WWindow *wwin) wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window; wAppIconPaint(wapp->app_icon); } else { - wapp->app_icon = wAppIconCreate(wapp->main_window_desc); - } + wapp->app_icon = wAppIconCreate(wapp->main_window_desc); + } } else { - wapp->app_icon = NULL; + wapp->app_icon = NULL; } - + if (wapp->app_icon) { wapp->app_icon->main_window = main_window; } @@ -379,24 +379,24 @@ wApplicationCreate(WWindow *wwin) wDockAttachIcon(clip, wapp->app_icon, x, y); } else { PlaceIcon(scr, &x, &y, wGetHeadForWindow(wapp->main_window_desc)); - wAppIconMove(wapp->app_icon, x, y); - wLowerFrame(icon->core); + wAppIconMove(wapp->app_icon, x, y); + wLowerFrame(icon->core); } if (!clip || !wapp->app_icon->attracted || !clip->collapsed) - XMapWindow(dpy, icon->core->window); + XMapWindow(dpy, icon->core->window); } if (wPreferences.auto_arrange_icons && wapp->app_icon && !wapp->app_icon->attracted) { - wArrangeIcons(scr, True); + wArrangeIcons(scr, True); } if (wapp->app_icon) { - char *tmp, *path; + char *tmp, *path; struct stat dummy; RImage *image; - tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, - wapp->app_icon->wm_class, True); + tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, + wapp->app_icon->wm_class, True); /* If the icon was saved by us from the client supplied icon, but is * missing, recreate it. */ @@ -420,9 +420,9 @@ wApplicationCreate(WWindow *wwin) } } - /* if the displayed icon was supplied by the client, save the icon */ + /* if the displayed icon was supplied by the client, save the icon */ if (!tmp) - extractClientIcon(wapp->app_icon); + extractClientIcon(wapp->app_icon); } wSoundPlay(WSOUND_APPSTART); @@ -442,11 +442,11 @@ wApplicationDestroy(WApplication *wapp) WScreen *scr; if (!wapp) - return; - + return; + wapp->refcount--; if (wapp->refcount>0) - return; + return; scr = wapp->main_window_desc->screen_ptr; @@ -467,34 +467,34 @@ wApplicationDestroy(WApplication *wapp) wAppMenuDestroy(wapp->menu); if (wapp->app_icon) { if (wapp->app_icon->docked && !wapp->app_icon->attracted) { - wapp->app_icon->running = 0; - /* since we keep it, we don't care if it was attracted or not */ - wapp->app_icon->attracted = 0; - wapp->app_icon->icon->shadowed = 0; - wapp->app_icon->main_window = None; - wapp->app_icon->pid = 0; - wapp->app_icon->icon->owner = NULL; - wapp->app_icon->icon->icon_win = None; - wapp->app_icon->icon->force_paint = 1; - wAppIconPaint(wapp->app_icon); + wapp->app_icon->running = 0; + /* since we keep it, we don't care if it was attracted or not */ + wapp->app_icon->attracted = 0; + wapp->app_icon->icon->shadowed = 0; + wapp->app_icon->main_window = None; + wapp->app_icon->pid = 0; + wapp->app_icon->icon->owner = NULL; + wapp->app_icon->icon->icon_win = None; + wapp->app_icon->icon->force_paint = 1; + wAppIconPaint(wapp->app_icon); } else if (wapp->app_icon->docked) { - wapp->app_icon->running = 0; - wDockDetach(wapp->app_icon->dock, wapp->app_icon); + wapp->app_icon->running = 0; + wDockDetach(wapp->app_icon->dock, wapp->app_icon); } else { - wAppIconDestroy(wapp->app_icon); - } + wAppIconDestroy(wapp->app_icon); + } } wwin = wWindowFor(wapp->main_window_desc->client_win); wWindowDestroy(wapp->main_window_desc); if (wwin) { - /* undelete client window context that was deleted in - * wWindowDestroy */ - XSaveContext(dpy, wwin->client_win, wWinContext, - (XPointer)&wwin->client_descriptor); + /* undelete client window context that was deleted in + * wWindowDestroy */ + XSaveContext(dpy, wwin->client_win, wWinContext, + (XPointer)&wwin->client_descriptor); } wfree(wapp); - + #ifdef DEBUG printf("Destroyed application for %x\n", (unsigned)main_window); #endif diff --git a/src/application.h b/src/application.h index c867298e..57a1b5cc 100644 --- a/src/application.h +++ b/src/application.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -27,7 +27,7 @@ typedef struct WApplication { struct WApplication *next; struct WApplication *prev; - + Window main_window; /* ID of the group leader */ struct WWindow *main_window_desc; /* main (leader) window descriptor */ @@ -40,12 +40,12 @@ typedef struct WApplication { struct WWindow *last_focused; /* focused window before hide */ - int last_workspace; /* last workspace used to work on the - * app */ + int last_workspace; /* last workspace used to work on the + * app */ struct { - unsigned int skip_next_animation:1; - unsigned int hidden:1; - unsigned int emulated:1; + unsigned int skip_next_animation:1; + unsigned int hidden:1; + unsigned int emulated:1; } flags; } WApplication; @@ -55,19 +55,20 @@ void wApplicationDestroy(WApplication *wapp); WApplication *wApplicationOf(Window window); -void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance, - char *wm_class); +void wApplicationExtractDirPackIcon(WScreen *scr,char *path, char *wm_instance, + char *wm_class); #ifdef NEWAPPICON # define wApplicationActivate(wapp) {\ - wapp->main_window_desc->flags.focused=1; \ - wAppIconPaint(wapp->app_icon);\ - } + wapp->main_window_desc->flags.focused=1; \ + wAppIconPaint(wapp->app_icon);\ + } #define wApplicationDeactivate(wapp) {\ - wapp->main_window_desc->flags.focused=0;\ - wAppIconPaint(wapp->app_icon);\ - } + wapp->main_window_desc->flags.focused=0;\ + wAppIconPaint(wapp->app_icon);\ + } #endif #endif + diff --git a/src/appmenu.c b/src/appmenu.c index 6366cdb4..5a4910e7 100644 --- a/src/appmenu.c +++ b/src/appmenu.c @@ -1,9 +1,9 @@ /* appmenu.c- application defined menu * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -57,10 +57,10 @@ typedef struct { enum { wmBeginMenu = 1, - wmEndMenu = 2, - wmNormalItem = 10, - wmDoubleItem = 11, - wmSubmenuItem = 12 + wmEndMenu = 2, + wmNormalItem = 10, + wmDoubleItem = 11, + wmSubmenuItem = 12 }; enum { @@ -87,11 +87,11 @@ sendMessage(Window window, int what, int tag) } -static void +static void notifyClient(WMenu *menu, WMenuEntry *entry) { WAppMenuData *data = entry->clientdata; - + sendMessage(data->window, wmSelectItem, data->tag); } @@ -107,123 +107,123 @@ parseMenuCommand(WScreen *scr, Window win, char **slist, int count, int *index) char rtext[300]; if (strlen(slist[*index])>300) { - wwarning("appmenu: menu command size exceeded in window %x", win); - return NULL; + wwarning("appmenu: menu command size exceeded in window %x", win); + return NULL; } if (sscanf(slist[*index], "%i %i %n", &command, &code, &pos)<2 - || command!=wmBeginMenu) { - wwarning("appmenu: bad menu entry \"%s\" in window %x", - slist[*index], win); - return NULL; + || command!=wmBeginMenu) { + wwarning("appmenu: bad menu entry \"%s\" in window %x", + slist[*index], win); + return NULL; } strcpy(title, &slist[*index][pos]); menu = wMenuCreateForApp(scr, title, *index==1); if (!menu) - return NULL; + return NULL; *index += 1; while (*indexcode = code; - data->tag = etag; - data->window = win; - entry = wMenuAddCallback(menu, title, notifyClient, data); - if (!entry) { - wMenuDestroy(menu, True); - wwarning("appmenu: out of memory creating menu for window %x", - slist[*index], win); - wfree(data); - return NULL; - } - if (rtext[0]!=0) - entry->rtext = wstrdup(rtext); - else - entry->rtext = NULL; - entry->free_cdata = free; - *index += 1; - - } else if (command==wmSubmenuItem) { - int ncode; - WMenuEntry *entry; - WMenu *submenu; - - if (sscanf(slist[*index], "%i %i %i %i %i %n", - &command, &ecode, &etag, &enab, &ncode, &pos)!=5 - || ecode!=code) { - wMenuDestroy(menu, True); - wwarning("appmenu: bad menu entry \"%s\" in window %x", - slist[*index], win); - - return NULL; - } - strcpy(title, &slist[*index][pos]); - *index += 1; - - submenu = parseMenuCommand(scr, win, slist, count, index); - - entry = wMenuAddCallback(menu, title, NULL, NULL); - - if (!entry) { - wMenuDestroy(menu, True); - wMenuDestroy(submenu, True); - wwarning("appmenu: out of memory creating menu for window %x", - slist[*index], win); - return NULL; - } - - wMenuEntrySetCascade(menu, entry, submenu); - - } else { - wMenuDestroy(menu, True); - wwarning("appmenu: bad menu entry \"%s\" in window %x", - slist[*index], win); - return NULL; - } - } + int ecode, etag, enab; + + if (sscanf(slist[*index], "%i", &command)!=1) { + wMenuDestroy(menu, True); + wwarning("appmenu: bad menu entry \"%s\" in window %x", + slist[*index], win); + return NULL; + } + + if (command==wmEndMenu) { + *index += 1; + break; + + } else if (command==wmNormalItem + || command==wmDoubleItem) { + WAppMenuData *data; + WMenuEntry *entry; + + if (command == wmNormalItem) { + if (sscanf(slist[*index], "%i %i %i %i %n", + &command, &ecode, &etag, &enab, &pos)!=4 + || ecode!=code) { + wMenuDestroy(menu, True); + wwarning("appmenu: bad menu entry \"%s\" in window %x", + slist[*index], win); + return NULL; + } + strcpy(title, &slist[*index][pos]); + rtext[0] = 0; + } else { + if (sscanf(slist[*index], "%i %i %i %i %s %n", + &command, &ecode, &etag, &enab, rtext, &pos)!=5 + || ecode!=code) { + wMenuDestroy(menu, True); + wwarning("appmenu: bad menu entry \"%s\" in window %x", + slist[*index], win); + return NULL; + } + strcpy(title, &slist[*index][pos]); + } + if (!(data = malloc(sizeof(WAppMenuData)))) { + wwarning("appmenu: out of memory making menu for window %x", + win); + wMenuDestroy(menu, True); + return NULL; + } + data->code = code; + data->tag = etag; + data->window = win; + entry = wMenuAddCallback(menu, title, notifyClient, data); + if (!entry) { + wMenuDestroy(menu, True); + wwarning("appmenu: out of memory creating menu for window %x", + slist[*index], win); + wfree(data); + return NULL; + } + if (rtext[0]!=0) + entry->rtext = wstrdup(rtext); + else + entry->rtext = NULL; + entry->free_cdata = free; + *index += 1; + + } else if (command==wmSubmenuItem) { + int ncode; + WMenuEntry *entry; + WMenu *submenu; + + if (sscanf(slist[*index], "%i %i %i %i %i %n", + &command, &ecode, &etag, &enab, &ncode, &pos)!=5 + || ecode!=code) { + wMenuDestroy(menu, True); + wwarning("appmenu: bad menu entry \"%s\" in window %x", + slist[*index], win); + + return NULL; + } + strcpy(title, &slist[*index][pos]); + *index += 1; + + submenu = parseMenuCommand(scr, win, slist, count, index); + + entry = wMenuAddCallback(menu, title, NULL, NULL); + + if (!entry) { + wMenuDestroy(menu, True); + wMenuDestroy(submenu, True); + wwarning("appmenu: out of memory creating menu for window %x", + slist[*index], win); + return NULL; + } + + wMenuEntrySetCascade(menu, entry, submenu); + + } else { + wMenuDestroy(menu, True); + wwarning("appmenu: bad menu entry \"%s\" in window %x", + slist[*index], win); + return NULL; + } + } return menu; } @@ -236,37 +236,37 @@ wAppMenuGet(WScreen *scr, Window window) int count, i; char **slist; WMenu *menu; - + if (!XGetTextProperty(dpy, window, &text_prop, _XA_WINDOWMAKER_MENU)) { - return NULL; + return NULL; } if (!XTextPropertyToStringList(&text_prop, &slist, &count) || count<1) { - XFree(text_prop.value); - return NULL; + XFree(text_prop.value); + return NULL; } XFree(text_prop.value); if (strcmp(slist[0], "WMMenu 0")!=0) { - wwarning("appmenu: unknown version of WMMenu in window %x: %s", - window, slist[0]); - XFreeStringList(slist); - return NULL; + wwarning("appmenu: unknown version of WMMenu in window %x: %s", + window, slist[0]); + XFreeStringList(slist); + return NULL; } i = 1; menu = parseMenuCommand(scr, window, slist, count, &i); if (menu) - menu->parent = NULL; - + menu->parent = NULL; + XFreeStringList(slist); return menu; } void -wAppMenuDestroy(WMenu *menu) +wAppMenuDestroy(WMenu *menu) { if (menu) - wMenuDestroy(menu, True); + wMenuDestroy(menu, True); } @@ -276,12 +276,12 @@ mapmenus(WMenu *menu) int i; if (menu->flags.mapped) - XMapWindow(dpy, menu->frame->core->window); + XMapWindow(dpy, menu->frame->core->window); if (menu->brother->flags.mapped) - XMapWindow(dpy, menu->brother->frame->core->window); + XMapWindow(dpy, menu->brother->frame->core->window); for (i=0; icascade_no; i++) { - if (menu->cascades[i]) - mapmenus(menu->cascades[i]); + if (menu->cascades[i]) + mapmenus(menu->cascades[i]); } } @@ -291,25 +291,25 @@ wAppMenuMap(WMenu *menu, WWindow *wwin) { if (!menu) - return; - + return; + if (!menu->flags.mapped) { - wMenuMap(menu); + wMenuMap(menu); } if(wwin && (wPreferences.focus_mode!=WKF_CLICK)) { - int x, min; + int x, min; min = 20; /* Keep at least 20 pixels visible */ - if (wwin->frame_x > min) { - x = wwin->frame_x - menu->frame->core->width; - } - else { - x = min - menu->frame->core->width; - } - wMenuMove(menu, x, wwin->frame_y, True); + if (wwin->frame_x > min) { + x = wwin->frame_x - menu->frame->core->width; + } + else { + x = min - menu->frame->core->width; + } + wMenuMove(menu, x, wwin->frame_y, True); } mapmenus(menu); - + } @@ -317,14 +317,14 @@ static void unmapmenus(WMenu *menu) { int i; - + if (menu->flags.mapped) - XUnmapWindow(dpy, menu->frame->core->window); + XUnmapWindow(dpy, menu->frame->core->window); if (menu->brother->flags.mapped) - XUnmapWindow(dpy, menu->brother->frame->core->window); + XUnmapWindow(dpy, menu->brother->frame->core->window); for (i=0; icascade_no; i++) { - if (menu->cascades[i]) - unmapmenus(menu->cascades[i]); + if (menu->cascades[i]) + unmapmenus(menu->cascades[i]); } } @@ -332,6 +332,6 @@ void wAppMenuUnmap(WMenu *menu) { if (menu) - unmapmenus(menu); + unmapmenus(menu); } diff --git a/src/appmenu.h b/src/appmenu.h index 4ed0a9da..6ba71e3d 100644 --- a/src/appmenu.h +++ b/src/appmenu.h @@ -1,9 +1,9 @@ /* appmenu.h- application defined menu * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ diff --git a/src/balloon.h b/src/balloon.h index ecd1e618..7080406b 100644 --- a/src/balloon.h +++ b/src/balloon.h @@ -1,8 +1,8 @@ -/* +/* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ diff --git a/src/client.c b/src/client.c index 96b5d90e..f00e6eb0 100644 --- a/src/client.c +++ b/src/client.c @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ #include "wconfig.h" @@ -74,7 +74,7 @@ extern Bool wShapeSupported; *-------------------------------------------------------------------- * wClientRestore-- * Reparent the window back to the root window. - * + * *-------------------------------------------------------------------- */ void @@ -89,88 +89,88 @@ wClientRestore(WWindow *wwin) wwin->frame_y -= gy * FRAME_BORDER_WIDTH; /* if gravity is to the south, account for the border sizes */ if (gy > 0) - wwin->frame_y += (wwin->frame->top_width + wwin->frame->bottom_width); + wwin->frame_y += (wwin->frame->top_width + wwin->frame->bottom_width); #endif - XSetWindowBorderWidth(dpy, wwin->client_win, wwin->old_border_width); + XSetWindowBorderWidth(dpy, wwin->client_win, wwin->old_border_width); XReparentWindow(dpy, wwin->client_win, wwin->screen_ptr->root_win, - wwin->frame_x, wwin->frame_y); - + wwin->frame_x, wwin->frame_y); + /* don't let the window get iconified after restart */ /* - if (wwin->flags.shaded) - wClientSetState(wwin, NormalState, None); + if (wwin->flags.shaded) + wClientSetState(wwin, NormalState, None); */ } /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * wClientSetState-- * Set the state of the client window to one of the window * states defined in ICCCM (Iconic, Withdrawn, Normal) - * + * * Side effects: * The WM_STATE property of the window is updated as well as the * WWindow.state variable. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ void wClientSetState(WWindow *wwin, int state, Window icon_win) { CARD32 data[2]; - + wwin->state = state; data[0] = (unsigned long) state; data[1] = (unsigned long) icon_win; - XChangeProperty(dpy, wwin->client_win, _XA_WM_STATE, _XA_WM_STATE, 32, - PropModeReplace, (unsigned char *) data, 2); + XChangeProperty(dpy, wwin->client_win, _XA_WM_STATE, _XA_WM_STATE, 32, + PropModeReplace, (unsigned char *) data, 2); } void wClientGetGravityOffsets(WWindow *wwin, int *ofs_x, int *ofs_y) { - switch (wwin->normal_hints->win_gravity) { - case ForgetGravity: - case CenterGravity: - case StaticGravity: - *ofs_x = 0; - *ofs_y = 0; - break; - case NorthWestGravity: - *ofs_x = -1; - *ofs_y = -1; - break; - case NorthGravity: - *ofs_x = 0; - *ofs_y = -1; - break; - case NorthEastGravity: - *ofs_x = 1; - *ofs_y = -1; - break; - case WestGravity: - *ofs_x = -1; - *ofs_y = 0; - break; - case EastGravity: - *ofs_x = 1; - *ofs_y = 0; - break; - case SouthWestGravity: - *ofs_x = -1; - *ofs_y = 1; - break; - case SouthGravity: - *ofs_x = 0; - *ofs_y = 1; - break; - case SouthEastGravity: - *ofs_x = 1; - *ofs_y = 1; - break; + switch (wwin->normal_hints->win_gravity) { + case ForgetGravity: + case CenterGravity: + case StaticGravity: + *ofs_x = 0; + *ofs_y = 0; + break; + case NorthWestGravity: + *ofs_x = -1; + *ofs_y = -1; + break; + case NorthGravity: + *ofs_x = 0; + *ofs_y = -1; + break; + case NorthEastGravity: + *ofs_x = 1; + *ofs_y = -1; + break; + case WestGravity: + *ofs_x = -1; + *ofs_y = 0; + break; + case EastGravity: + *ofs_x = 1; + *ofs_y = 0; + break; + case SouthWestGravity: + *ofs_x = -1; + *ofs_y = 1; + break; + case SouthGravity: + *ofs_x = 0; + *ofs_y = 1; + break; + case SouthEastGravity: + *ofs_x = 1; + *ofs_y = 1; + break; } } @@ -183,76 +183,76 @@ wClientConfigure(WWindow *wwin, XConfigureRequestEvent *xcre) int nx, ny, nwidth, nheight; int ofs_x, ofs_y; -/* printf("configure event: %d %d %d %d\n", xcre->x, xcre->y, xcre->width, xcre->height);*/ + /* printf("configure event: %d %d %d %d\n", xcre->x, xcre->y, xcre->width, xcre->height);*/ if (wwin==NULL) { - /* - * configure a window that was not mapped by us - */ - xwc.x = xcre->x; - xwc.y = xcre->y; - xwc.width = xcre->width; - xwc.height = xcre->height; - xwc.border_width = xcre->border_width; - xwc.stack_mode = xcre->detail; - xwc.sibling = xcre->above; - XConfigureWindow(dpy, xcre->window, xcre->value_mask, &xwc); - return; + /* + * configure a window that was not mapped by us + */ + xwc.x = xcre->x; + xwc.y = xcre->y; + xwc.width = xcre->width; + xwc.height = xcre->height; + xwc.border_width = xcre->border_width; + xwc.stack_mode = xcre->detail; + xwc.sibling = xcre->above; + XConfigureWindow(dpy, xcre->window, xcre->value_mask, &xwc); + return; } #ifdef SHAPE if (wShapeSupported) { - int junk; - unsigned int ujunk; - int b_shaped; - - XShapeSelectInput(dpy, wwin->client_win, ShapeNotifyMask); - XShapeQueryExtents(dpy, wwin->client_win, &b_shaped, &junk, &junk, - &ujunk, &ujunk, &junk, &junk, &junk, &ujunk, - &ujunk); - wwin->flags.shaped = b_shaped; + int junk; + unsigned int ujunk; + int b_shaped; + + XShapeSelectInput(dpy, wwin->client_win, ShapeNotifyMask); + XShapeQueryExtents(dpy, wwin->client_win, &b_shaped, &junk, &junk, + &ujunk, &ujunk, &junk, &junk, &junk, &ujunk, + &ujunk); + wwin->flags.shaped = b_shaped; } #endif if (xcre->value_mask & CWStackMode) { - WObjDescriptor *desc; - WWindow *sibling; - - if ((xcre->value_mask & CWSibling) && - (XFindContext(dpy, xcre->above, wWinContext, - (XPointer *)&desc) == XCSUCCESS) - && (desc->parent_type==WCLASS_WINDOW)) { - sibling=desc->parent; - xwc.sibling = sibling->frame->core->window; - } else { - xwc.sibling = xcre->above; - } - xwc.stack_mode = xcre->detail; - XConfigureWindow(dpy, wwin->frame->core->window, - xcre->value_mask & (CWSibling | CWStackMode), &xwc); - /* fix stacking order */ - RemakeStackList(wwin->screen_ptr); + WObjDescriptor *desc; + WWindow *sibling; + + if ((xcre->value_mask & CWSibling) && + (XFindContext(dpy, xcre->above, wWinContext, + (XPointer *)&desc) == XCSUCCESS) + && (desc->parent_type==WCLASS_WINDOW)) { + sibling=desc->parent; + xwc.sibling = sibling->frame->core->window; + } else { + xwc.sibling = xcre->above; + } + xwc.stack_mode = xcre->detail; + XConfigureWindow(dpy, wwin->frame->core->window, + xcre->value_mask & (CWSibling | CWStackMode), &xwc); + /* fix stacking order */ + RemakeStackList(wwin->screen_ptr); } wClientGetGravityOffsets(wwin, &ofs_x, &ofs_y); - + if (xcre->value_mask & CWBorderWidth) { - wwin->old_border_width = xcre->border_width; + wwin->old_border_width = xcre->border_width; } if (!wwin->flags.shaded) { /* If the window is shaded, wrong height will be set for the window */ if (xcre->value_mask & CWX) { nx = xcre->x; - if (HAS_BORDER(wwin)) - nx -= FRAME_BORDER_WIDTH; - } + if (HAS_BORDER(wwin)) + nx -= FRAME_BORDER_WIDTH; + } else nx = wwin->frame_x; if (xcre->value_mask & CWY) { ny = xcre->y - ((ofs_y < 0) ? 0 : wwin->frame->top_width); - if (HAS_BORDER(wwin)) - ny -= FRAME_BORDER_WIDTH; - } + if (HAS_BORDER(wwin)) + ny -= FRAME_BORDER_WIDTH; + } else ny = wwin->frame_y; @@ -306,308 +306,308 @@ wClientKill(WWindow *wwin) /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * wClientCheckProperty-- * Handles PropertyNotify'es, verifying which property was * changed and updating internal state according to that, like redrawing * the icon title when it is changed. - * + * * Side effects: * Depends on the changed property. - * + * * TODO: _GNUSTEP_WM_ATTR - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ void -wClientCheckProperty(WWindow *wwin, XPropertyEvent *event) +wClientCheckProperty(WWindow *wwin, XPropertyEvent *event) { XWindowAttributes attribs; XWMHints *new_hints; int i, g1, g2; char *tmp = NULL; - + switch (event->atom) { - case XA_WM_NAME: - /* window title was changed */ - if (!wFetchName(dpy, wwin->client_win, &tmp)) { - wWindowUpdateName(wwin, NULL); - } else { - wWindowUpdateName(wwin, tmp); - } - if (tmp) - XFree(tmp); - break; - - case XA_WM_ICON_NAME: + case XA_WM_NAME: + /* window title was changed */ + if (!wFetchName(dpy, wwin->client_win, &tmp)) { + wWindowUpdateName(wwin, NULL); + } else { + wWindowUpdateName(wwin, tmp); + } + if (tmp) + XFree(tmp); + break; + + case XA_WM_ICON_NAME: #ifdef KWM_HINTS - wKWMSendEventMessage(wwin, WKWMChangedClient); + wKWMSendEventMessage(wwin, WKWMChangedClient); #endif - if (!wwin->icon) - break; - else { - char *new_title; - - /* icon title was changed */ - wGetIconName(dpy, wwin->client_win, &new_title); - wIconChangeTitle(wwin->icon, new_title); - } - break; - - case XA_WM_COMMAND: - if (wwin->main_window!=None) { - WApplication *wapp = wApplicationOf(wwin->main_window); + if (!wwin->icon) + break; + else { + char *new_title; + + /* icon title was changed */ + wGetIconName(dpy, wwin->client_win, &new_title); + wIconChangeTitle(wwin->icon, new_title); + } + break; + + case XA_WM_COMMAND: + if (wwin->main_window!=None) { + WApplication *wapp = wApplicationOf(wwin->main_window); char *command; if (!wapp || !wapp->app_icon || wapp->app_icon->docked) - break; + break; command = GetCommandForWindow(wwin->main_window); - if (command) { + if (command) { if (wapp->app_icon->command) wfree(wapp->app_icon->command); wapp->app_icon->command = command; } - } - break; - - case XA_WM_HINTS: - /* WM_HINTS */ - - new_hints = XGetWMHints(dpy, wwin->client_win); - - /* group leader update - * - * This means that the window is setting the leader after - * it was mapped, changing leaders or removing the leader. - * - * Valid state transitions are: - * - * _1 __2 - * / \ / \ - * v | v | - * (GC) (GC') - * / ^ / ^ - * 3| |4 5| |6 - * | | | | - * v / v / - * (G'C) (G'C') - * - * Where G is the window_group hint, C is CLIENT_LEADER property - * and ' indicates the hint is unset. - * - * 1,2 - change group leader to new value of window_group - * 3 - change leader to value of CLIENT_LEADER - * 4 - change leader to value of window_group - * 5 - destroy application - * 6 - create application - */ - if (new_hints && (new_hints->flags & WindowGroupHint) - && new_hints->window_group!=None) { - g2 = 1; - } else { - g2 = 0; - } - if (wwin->wm_hints && (wwin->wm_hints->flags & WindowGroupHint) - && wwin->wm_hints->window_group!=None) { - g1 = 1; - } else { - g1 = 0; - } - - if (wwin->client_leader) { - if (g1 && g2 - && wwin->wm_hints->window_group!=new_hints->window_group) { - i = 1; - } else if (g1 && !g2) { - i = 3; - } else if (!g1 && g2) { - i = 4; - } else { - i = 0; - } - } else { - if (g1 && g2 - && wwin->wm_hints->window_group!=new_hints->window_group) { - i = 2; - } else if (g1 && !g2) { - i = 5; - } else if (!g1 && g2) { - i = 6; - } else { - i = 0; - } - } + } + break; + + case XA_WM_HINTS: + /* WM_HINTS */ + + new_hints = XGetWMHints(dpy, wwin->client_win); + + /* group leader update + * + * This means that the window is setting the leader after + * it was mapped, changing leaders or removing the leader. + * + * Valid state transitions are: + * + * _1 __2 + * / \ / \ + * v | v | + * (GC) (GC') + * / ^ / ^ + * 3| |4 5| |6 + * | | | | + * v / v / + * (G'C) (G'C') + * + * Where G is the window_group hint, C is CLIENT_LEADER property + * and ' indicates the hint is unset. + * + * 1,2 - change group leader to new value of window_group + * 3 - change leader to value of CLIENT_LEADER + * 4 - change leader to value of window_group + * 5 - destroy application + * 6 - create application + */ + if (new_hints && (new_hints->flags & WindowGroupHint) + && new_hints->window_group!=None) { + g2 = 1; + } else { + g2 = 0; + } + if (wwin->wm_hints && (wwin->wm_hints->flags & WindowGroupHint) + && wwin->wm_hints->window_group!=None) { + g1 = 1; + } else { + g1 = 0; + } + + if (wwin->client_leader) { + if (g1 && g2 + && wwin->wm_hints->window_group!=new_hints->window_group) { + i = 1; + } else if (g1 && !g2) { + i = 3; + } else if (!g1 && g2) { + i = 4; + } else { + i = 0; + } + } else { + if (g1 && g2 + && wwin->wm_hints->window_group!=new_hints->window_group) { + i = 2; + } else if (g1 && !g2) { + i = 5; + } else if (!g1 && g2) { + i = 6; + } else { + i = 0; + } + } /* Handling this may require more work. -Dan */ if (wwin->fake_group!=NULL) { i = 7; } - if (wwin->wm_hints) - XFree(wwin->wm_hints); - - wwin->wm_hints = new_hints; - - /* do action according to state transition */ - switch (i) { - /* 3 - change leader to value of CLIENT_LEADER */ - case 3: - wApplicationDestroy(wApplicationOf(wwin->main_window)); - wwin->main_window = wwin->client_leader; - wwin->group_id = None; - wApplicationCreate(wwin); - break; - - /* 1,2,4 - change leader to new value of window_group */ - case 1: - case 2: - case 4: - wApplicationDestroy(wApplicationOf(wwin->main_window)); - wwin->main_window = new_hints->window_group; - wwin->group_id = wwin->main_window; - wApplicationCreate(wwin); - break; - - /* 5 - destroy application */ - case 5: - wApplicationDestroy(wApplicationOf(wwin->main_window)); - wwin->main_window = None; - wwin->group_id = None; - break; - - /* 6 - create application */ - case 6: - wwin->main_window = new_hints->window_group; - wwin->group_id = wwin->main_window; - wApplicationCreate(wwin); - break; - /* 7 - we have a fake window group id, so just ignore anything else */ - case 7: + if (wwin->wm_hints) + XFree(wwin->wm_hints); + + wwin->wm_hints = new_hints; + + /* do action according to state transition */ + switch (i) { + /* 3 - change leader to value of CLIENT_LEADER */ + case 3: + wApplicationDestroy(wApplicationOf(wwin->main_window)); + wwin->main_window = wwin->client_leader; + wwin->group_id = None; + wApplicationCreate(wwin); + break; + + /* 1,2,4 - change leader to new value of window_group */ + case 1: + case 2: + case 4: + wApplicationDestroy(wApplicationOf(wwin->main_window)); + wwin->main_window = new_hints->window_group; + wwin->group_id = wwin->main_window; + wApplicationCreate(wwin); + break; + + /* 5 - destroy application */ + case 5: + wApplicationDestroy(wApplicationOf(wwin->main_window)); + wwin->main_window = None; + wwin->group_id = None; + break; + + /* 6 - create application */ + case 6: + wwin->main_window = new_hints->window_group; + wwin->group_id = wwin->main_window; + wApplicationCreate(wwin); + break; + /* 7 - we have a fake window group id, so just ignore anything else */ + case 7: break; } #ifdef DEBUG - if (i) { - printf("window leader update caused state transition %i\n",i); - } + if (i) { + printf("window leader update caused state transition %i\n",i); + } #endif - if (wwin->wm_hints) { - /* update icon */ - if ((wwin->wm_hints->flags & IconPixmapHint) - || (wwin->wm_hints->flags & IconWindowHint)) { - WApplication *wapp; - - if (wwin->flags.miniaturized && wwin->icon) { - wIconUpdate(wwin->icon); - } - wapp = wApplicationOf(wwin->main_window); - if (wapp && wapp->app_icon) { - wIconUpdate(wapp->app_icon->icon); - } + if (wwin->wm_hints) { + /* update icon */ + if ((wwin->wm_hints->flags & IconPixmapHint) + || (wwin->wm_hints->flags & IconWindowHint)) { + WApplication *wapp; + + if (wwin->flags.miniaturized && wwin->icon) { + wIconUpdate(wwin->icon); + } + wapp = wApplicationOf(wwin->main_window); + if (wapp && wapp->app_icon) { + wIconUpdate(wapp->app_icon->icon); + } #ifdef KWM_HINTS - wKWMSendEventMessage(wwin, WKWMIconChange); + wKWMSendEventMessage(wwin, WKWMIconChange); #endif - } - - if (wwin->wm_hints->flags & UrgencyHint) - wwin->flags.urgent = 1; - else - wwin->flags.urgent = 0; - /*} else if (wwin->fake_group!=NULL) { - wwin->group_id = wwin->fake_group->leader;*/ + } + + if (wwin->wm_hints->flags & UrgencyHint) + wwin->flags.urgent = 1; + else + wwin->flags.urgent = 0; + /*} else if (wwin->fake_group!=NULL) { + wwin->group_id = wwin->fake_group->leader;*/ } else { wwin->group_id = None; - } - break; - - case XA_WM_NORMAL_HINTS: - /* normal (geometry) hints */ - { - int foo; - unsigned bar; - - XGetWindowAttributes(dpy, wwin->client_win, &attribs); - wClientGetNormalHints(wwin, &attribs, False, &foo, &foo, - &bar, &bar); - /* TODO: should we check for consistency of the current - * size against the new geometry hints? */ - } - break; - - case XA_WM_TRANSIENT_FOR: - { - Window new_owner; - WWindow *owner; - - if (!XGetTransientForHint(dpy, wwin->client_win, &new_owner)) { - new_owner = None; - } else { - if (new_owner==0 || new_owner == wwin->client_win) { - new_owner = wwin->screen_ptr->root_win; - } - } - if (new_owner!=wwin->transient_for) { - owner = wWindowFor(wwin->transient_for); - if (owner) { - if (owner->flags.semi_focused) { - owner->flags.semi_focused = 0; - if ((owner->flags.mapped || owner->flags.shaded) - && owner->frame) - wFrameWindowPaint(owner->frame); - } - } - owner = wWindowFor(new_owner); - if (owner) { - if (!owner->flags.semi_focused) { - owner->flags.semi_focused = 1; - if ((owner->flags.mapped || owner->flags.shaded) - && owner->frame) - wFrameWindowPaint(owner->frame); - } - } - wwin->transient_for = new_owner; - if (new_owner==None) { - if (WFLAGP(wwin, no_miniaturizable)) { - WSETUFLAG(wwin, no_miniaturizable, 0); - WSETUFLAG(wwin, no_miniaturize_button, 0); - if (wwin->frame) - wWindowConfigureBorders(wwin); - } - } else if (!WFLAGP(wwin, no_miniaturizable)) { - WSETUFLAG(wwin, no_miniaturizable, 1); - WSETUFLAG(wwin, no_miniaturize_button, 1); - if (wwin->frame) - wWindowConfigureBorders(wwin); - } - } - } - break; - - default: - if (event->atom==_XA_WM_PROTOCOLS) { - - PropGetProtocols(wwin->client_win, &wwin->protocols); - - WSETUFLAG(wwin, kill_close, !wwin->protocols.DELETE_WINDOW); - - if (wwin->frame) - wWindowUpdateButtonImages(wwin); - - } else if (event->atom==_XA_WM_COLORMAP_WINDOWS) { - - GetColormapWindows(wwin); - wColormapInstallForWindow(wwin->screen_ptr, wwin); - - } else if (event->atom==_XA_WINDOWMAKER_MENU) { - WApplication *wapp; - - wapp = wApplicationOf(wwin->main_window); - if (wapp) { - if (wapp->menu) { - /* update menu */ - /* TODO: remake appmenu update */ - wAppMenuDestroy(wapp->menu); - } + } + break; + + case XA_WM_NORMAL_HINTS: + /* normal (geometry) hints */ + { + int foo; + unsigned bar; + + XGetWindowAttributes(dpy, wwin->client_win, &attribs); + wClientGetNormalHints(wwin, &attribs, False, &foo, &foo, + &bar, &bar); + /* TODO: should we check for consistency of the current + * size against the new geometry hints? */ + } + break; + + case XA_WM_TRANSIENT_FOR: + { + Window new_owner; + WWindow *owner; + + if (!XGetTransientForHint(dpy, wwin->client_win, &new_owner)) { + new_owner = None; + } else { + if (new_owner==0 || new_owner == wwin->client_win) { + new_owner = wwin->screen_ptr->root_win; + } + } + if (new_owner!=wwin->transient_for) { + owner = wWindowFor(wwin->transient_for); + if (owner) { + if (owner->flags.semi_focused) { + owner->flags.semi_focused = 0; + if ((owner->flags.mapped || owner->flags.shaded) + && owner->frame) + wFrameWindowPaint(owner->frame); + } + } + owner = wWindowFor(new_owner); + if (owner) { + if (!owner->flags.semi_focused) { + owner->flags.semi_focused = 1; + if ((owner->flags.mapped || owner->flags.shaded) + && owner->frame) + wFrameWindowPaint(owner->frame); + } + } + wwin->transient_for = new_owner; + if (new_owner==None) { + if (WFLAGP(wwin, no_miniaturizable)) { + WSETUFLAG(wwin, no_miniaturizable, 0); + WSETUFLAG(wwin, no_miniaturize_button, 0); + if (wwin->frame) + wWindowConfigureBorders(wwin); + } + } else if (!WFLAGP(wwin, no_miniaturizable)) { + WSETUFLAG(wwin, no_miniaturizable, 1); + WSETUFLAG(wwin, no_miniaturize_button, 1); + if (wwin->frame) + wWindowConfigureBorders(wwin); + } + } + } + break; + + default: + if (event->atom==_XA_WM_PROTOCOLS) { + + PropGetProtocols(wwin->client_win, &wwin->protocols); + + WSETUFLAG(wwin, kill_close, !wwin->protocols.DELETE_WINDOW); + + if (wwin->frame) + wWindowUpdateButtonImages(wwin); + + } else if (event->atom==_XA_WM_COLORMAP_WINDOWS) { + + GetColormapWindows(wwin); + wColormapInstallForWindow(wwin->screen_ptr, wwin); + + } else if (event->atom==_XA_WINDOWMAKER_MENU) { + WApplication *wapp; + + wapp = wApplicationOf(wwin->main_window); + if (wapp) { + if (wapp->menu) { + /* update menu */ + /* TODO: remake appmenu update */ + wAppMenuDestroy(wapp->menu); + } if (wwin->fake_group) { extern WPreferences wPreferences; WScreen *scr = wwin->screen_ptr; @@ -653,21 +653,21 @@ wClientCheckProperty(WWindow *wwin, XPropertyEvent *event) /* make the appmenu be mapped */ wSetFocusTo(wwin->screen_ptr, NULL); wSetFocusTo(wwin->screen_ptr, wwin->screen_ptr->focused_window); - } - } else if (event->atom==_XA_GNUSTEP_WM_ATTR) { - GNUstepWMAttributes *attr; - - PropGetGNUstepWMAttr(wwin->client_win, &attr); - - wWindowUpdateGNUstepAttr(wwin, attr); - - XFree(attr); - } else { + } + } else if (event->atom==_XA_GNUSTEP_WM_ATTR) { + GNUstepWMAttributes *attr; + + PropGetGNUstepWMAttr(wwin->client_win, &attr); + + wWindowUpdateGNUstepAttr(wwin, attr); + + XFree(attr); + } else { #if defined(KWM_HINTS) || defined(NETWM_HINTS) Bool done = False; #endif #ifdef KWM_HINTS - if (!done) + if (!done) done = wKWMCheckClientHintChange(wwin, event); #endif /* KWM_HINTS */ #ifdef NETWM_HINTS @@ -675,26 +675,26 @@ wClientCheckProperty(WWindow *wwin, XPropertyEvent *event) done = wNETWMCheckClientHintChange(wwin, event); } #endif - } + } } } /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * wClientGetNormalHints-- - * Get size (normal) hints and a default geometry for the client + * Get size (normal) hints and a default geometry for the client * window. The hints are also checked for inconsistency. If geometry is * True, the returned data will account for client specified initial * geometry. - * + * * Side effects: * normal_hints is filled with valid data. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ void wClientGetNormalHints(WWindow *wwin, XWindowAttributes *wattribs, Bool geometry, - int *x, int *y, unsigned *width, unsigned *height) + int *x, int *y, unsigned *width, unsigned *height) { int pre_icccm = 0; /* not used */ @@ -703,71 +703,71 @@ wClientGetNormalHints(WWindow *wwin, XWindowAttributes *wattribs, Bool geometry, wwin->normal_hints = XAllocSizeHints(); if (!PropGetNormalHints(wwin->client_win, wwin->normal_hints, &pre_icccm)) { - wwin->normal_hints->flags = 0; + wwin->normal_hints->flags = 0; } *x = wattribs->x; *y = wattribs->y; - + *width = wattribs->width; *height = wattribs->height; if (!(wwin->normal_hints->flags & PWinGravity)) { - wwin->normal_hints->win_gravity = NorthWestGravity; + wwin->normal_hints->win_gravity = NorthWestGravity; } if (!(wwin->normal_hints->flags & PMinSize)) { - wwin->normal_hints->min_width = MIN_WINDOW_SIZE; - wwin->normal_hints->min_height = MIN_WINDOW_SIZE; + wwin->normal_hints->min_width = MIN_WINDOW_SIZE; + wwin->normal_hints->min_height = MIN_WINDOW_SIZE; } if (!(wwin->normal_hints->flags & PBaseSize)) { - wwin->normal_hints->base_width = 0; - wwin->normal_hints->base_height = 0; + wwin->normal_hints->base_width = 0; + wwin->normal_hints->base_height = 0; } if (!(wwin->normal_hints->flags & PMaxSize)) { - wwin->normal_hints->max_width = wwin->screen_ptr->scr_width*2; - wwin->normal_hints->max_height = wwin->screen_ptr->scr_height*2; + wwin->normal_hints->max_width = wwin->screen_ptr->scr_width*2; + wwin->normal_hints->max_height = wwin->screen_ptr->scr_height*2; } /* some buggy apps set weird hints.. */ - if (wwin->normal_hints->min_width <= 0) - wwin->normal_hints->min_width = MIN_WINDOW_SIZE; - + if (wwin->normal_hints->min_width <= 0) + wwin->normal_hints->min_width = MIN_WINDOW_SIZE; + if (wwin->normal_hints->min_height <= 0) - wwin->normal_hints->min_height = MIN_WINDOW_SIZE; + wwin->normal_hints->min_height = MIN_WINDOW_SIZE; if (wwin->normal_hints->max_width < wwin->normal_hints->min_width) - wwin->normal_hints->max_width = wwin->normal_hints->min_width; + wwin->normal_hints->max_width = wwin->normal_hints->min_width; if (wwin->normal_hints->max_height < wwin->normal_hints->min_height) - wwin->normal_hints->max_height = wwin->normal_hints->min_height; + wwin->normal_hints->max_height = wwin->normal_hints->min_height; if (!(wwin->normal_hints->flags & PResizeInc)) { - wwin->normal_hints->width_inc = 1; - wwin->normal_hints->height_inc = 1; - } else { - if (wwin->normal_hints->width_inc <= 0) - wwin->normal_hints->width_inc = 1; - if (wwin->normal_hints->height_inc <= 0) - wwin->normal_hints->height_inc = 1; + wwin->normal_hints->width_inc = 1; + wwin->normal_hints->height_inc = 1; + } else { + if (wwin->normal_hints->width_inc <= 0) + wwin->normal_hints->width_inc = 1; + if (wwin->normal_hints->height_inc <= 0) + wwin->normal_hints->height_inc = 1; } - + if (wwin->normal_hints->flags & PAspect) { - if (wwin->normal_hints->min_aspect.x < 1) - wwin->normal_hints->min_aspect.x = 1; - if (wwin->normal_hints->min_aspect.y < 1) - wwin->normal_hints->min_aspect.y = 1; - - if (wwin->normal_hints->max_aspect.x < 1) - wwin->normal_hints->max_aspect.x = 1; - if (wwin->normal_hints->max_aspect.y < 1) - wwin->normal_hints->max_aspect.y = 1; + if (wwin->normal_hints->min_aspect.x < 1) + wwin->normal_hints->min_aspect.x = 1; + if (wwin->normal_hints->min_aspect.y < 1) + wwin->normal_hints->min_aspect.y = 1; + + if (wwin->normal_hints->max_aspect.x < 1) + wwin->normal_hints->max_aspect.x = 1; + if (wwin->normal_hints->max_aspect.y < 1) + wwin->normal_hints->max_aspect.y = 1; } - + if (wwin->normal_hints->min_height > wwin->normal_hints->max_height) { - wwin->normal_hints->min_height = wwin->normal_hints->max_height; + wwin->normal_hints->min_height = wwin->normal_hints->max_height; } if (wwin->normal_hints->min_width > wwin->normal_hints->max_width) { - wwin->normal_hints->min_width = wwin->normal_hints->max_width; + wwin->normal_hints->min_width = wwin->normal_hints->max_width; } #ifdef IGNORE_PPOSITION @@ -775,34 +775,34 @@ wClientGetNormalHints(WWindow *wwin, XWindowAttributes *wattribs, Bool geometry, #endif if (pre_icccm && !wwin->screen_ptr->flags.startup && geometry) { - if (wwin->normal_hints->flags & (USPosition|PPosition)) { - *x = wwin->normal_hints->x; - *y = wwin->normal_hints->y; - } - if (wwin->normal_hints->flags & (USSize|PSize)) { - *width = wwin->normal_hints->width; - *height = wwin->normal_hints->height; - } + if (wwin->normal_hints->flags & (USPosition|PPosition)) { + *x = wwin->normal_hints->x; + *y = wwin->normal_hints->y; + } + if (wwin->normal_hints->flags & (USSize|PSize)) { + *width = wwin->normal_hints->width; + *height = wwin->normal_hints->height; + } } } -void +void GetColormapWindows(WWindow *wwin) { #ifndef NO_CRASHES if (wwin->cmap_windows) { - XFree(wwin->cmap_windows); + XFree(wwin->cmap_windows); } - + wwin->cmap_windows = NULL; wwin->cmap_window_no = 0; if (!XGetWMColormapWindows(dpy, wwin->client_win, &(wwin->cmap_windows), - &(wwin->cmap_window_no)) - || !wwin->cmap_windows) { - wwin->cmap_window_no = 0; - wwin->cmap_windows = NULL; + &(wwin->cmap_window_no)) + || !wwin->cmap_windows) { + wwin->cmap_window_no = 0; + wwin->cmap_windows = NULL; } #endif diff --git a/src/client.h b/src/client.h index ea50f7d5..5cde399c 100644 --- a/src/client.h +++ b/src/client.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -33,8 +33,8 @@ void wClientCheckProperty(WWindow *wwin, XPropertyEvent *event); void wClientGetNormalHints(WWindow *wwin, XWindowAttributes *wattribs, - Bool geometry, int *x, int *y, unsigned *width, - unsigned *height); + Bool geometry, int *x, int *y, unsigned *width, + unsigned *height); void GetColormapWindows(WWindow *wwin); #endif diff --git a/src/colormap.c b/src/colormap.c index e10fd8aa..7e0f7e7b 100644 --- a/src/colormap.c +++ b/src/colormap.c @@ -1,13 +1,13 @@ /* colormap.c - colormap handling code - * + * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * - * This code slightly based on fvwm code, + * + * This code slightly based on fvwm code, * Copyright (c) Rob Nation and others * but completely rewritten. - * + * * 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 @@ -33,7 +33,7 @@ #include "framewin.h" -void +void wColormapInstallForWindow(WScreen *scr, WWindow *wwin) { int i; @@ -41,69 +41,69 @@ wColormapInstallForWindow(WScreen *scr, WWindow *wwin) int done = 0; Window xwin = None; - + if (wwin) { - xwin = wwin->client_win; + xwin = wwin->client_win; } else { - xwin = scr->root_win; + xwin = scr->root_win; } scr->cmap_window = wwin; if (scr->root_colormap_install_count > 0) { - scr->original_cmap_window = wwin; - return; + scr->original_cmap_window = wwin; + return; } /* install colormap for all windows of the client */ if (wwin && wwin->cmap_window_no > 0 && wwin->cmap_windows) { - for (i = wwin->cmap_window_no - 1; i >= 0; i--) { - Window w; - - w = wwin->cmap_windows[i]; - if (w == wwin->client_win) - done = 1; - - XGetWindowAttributes(dpy, w, &attributes); - if (attributes.colormap == None) - attributes.colormap = scr->colormap; - - if (scr->current_colormap != attributes.colormap) { - scr->current_colormap = attributes.colormap; - /* - * ICCCM 2.0: some client requested permission - * to install colormaps by itself and we granted. - * So, we can't install any colormaps. - */ - if (!scr->flags.colormap_stuff_blocked) - XInstallColormap(dpy, attributes.colormap); - } - } + for (i = wwin->cmap_window_no - 1; i >= 0; i--) { + Window w; + + w = wwin->cmap_windows[i]; + if (w == wwin->client_win) + done = 1; + + XGetWindowAttributes(dpy, w, &attributes); + if (attributes.colormap == None) + attributes.colormap = scr->colormap; + + if (scr->current_colormap != attributes.colormap) { + scr->current_colormap = attributes.colormap; + /* + * ICCCM 2.0: some client requested permission + * to install colormaps by itself and we granted. + * So, we can't install any colormaps. + */ + if (!scr->flags.colormap_stuff_blocked) + XInstallColormap(dpy, attributes.colormap); + } + } } if (!done) { - attributes.colormap = None; - if (xwin != None) - XGetWindowAttributes(dpy, xwin, &attributes); - if (attributes.colormap == None) - attributes.colormap = scr->colormap; - - if (scr->current_colormap != attributes.colormap) { - scr->current_colormap = attributes.colormap; - if (!scr->flags.colormap_stuff_blocked) - XInstallColormap(dpy, attributes.colormap); - } + attributes.colormap = None; + if (xwin != None) + XGetWindowAttributes(dpy, xwin, &attributes); + if (attributes.colormap == None) + attributes.colormap = scr->colormap; + + if (scr->current_colormap != attributes.colormap) { + scr->current_colormap = attributes.colormap; + if (!scr->flags.colormap_stuff_blocked) + XInstallColormap(dpy, attributes.colormap); + } } XSync(dpy, False); } -void +void wColormapInstallRoot(WScreen *scr) { if (scr->root_colormap_install_count == 0) { - wColormapInstallForWindow(scr, NULL); - scr->original_cmap_window = scr->cmap_window; + wColormapInstallForWindow(scr, NULL); + scr->original_cmap_window = scr->cmap_window; } scr->root_colormap_install_count++; } @@ -113,11 +113,11 @@ void wColormapUninstallRoot(WScreen *scr) { if (scr->root_colormap_install_count > 0) - scr->root_colormap_install_count--; + scr->root_colormap_install_count--; if (scr->root_colormap_install_count == 0) { - wColormapInstallForWindow(scr, scr->original_cmap_window); - scr->original_cmap_window = NULL; + wColormapInstallForWindow(scr, scr->original_cmap_window); + scr->original_cmap_window = NULL; } } @@ -126,13 +126,14 @@ void wColormapAllowClientInstallation(WScreen *scr, Bool starting) { scr->flags.colormap_stuff_blocked = starting; - /* + /* * Client stopped managing the colormap stuff. Restore the colormap * that would be installed if the client did not request colormap * stuff. */ if (!starting) { - XInstallColormap(dpy, scr->current_colormap); - XSync(dpy, False); + XInstallColormap(dpy, scr->current_colormap); + XSync(dpy, False); } } + diff --git a/src/cycling.c b/src/cycling.c index e5ace829..800f4068 100644 --- a/src/cycling.c +++ b/src/cycling.c @@ -1,9 +1,9 @@ /* cycling.c- window cycling - * + * * Window Maker window manager - * + * * Copyright (c) 2000-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -54,22 +54,22 @@ nextToFocusAfter(WWindow *wwin) WWindow *tmp = wwin->prev; while (tmp) { - if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { - return tmp; - } - tmp = tmp->prev; + if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { + return tmp; + } + tmp = tmp->prev; } tmp = wwin; /* start over from the beginning of the list */ while (tmp->next) - tmp = tmp->next; + tmp = tmp->next; while (tmp && tmp != wwin) { - if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { - return tmp; - } - tmp = tmp->prev; + if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { + return tmp; + } + tmp = tmp->prev; } return wwin; @@ -82,23 +82,23 @@ nextToFocusBefore(WWindow *wwin) WWindow *tmp = wwin->next; while (tmp) { - if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { - return tmp; - } - tmp = tmp->next; + if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { + return tmp; + } + tmp = tmp->next; } /* start over from the beginning of the list */ tmp = wwin; while (tmp->prev) - tmp = tmp->prev; + tmp = tmp->prev; while (tmp && tmp != wwin) { - if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { + if (wWindowCanReceiveFocus(tmp) && !WFLAGP(tmp, skip_window_list)) { - return tmp; - } - tmp = tmp->next; + return tmp; + } + tmp = tmp->next; } return wwin; @@ -120,10 +120,10 @@ nextFocusWindow(WWindow *wwin) min = wwin; d = 0xffffffff; while (tmp) { - if (wWindowCanReceiveFocus(tmp) + if (wWindowCanReceiveFocus(tmp) && (!WFLAGP(tmp, skip_window_list)|| tmp->flags.internal_window)) { if (min->client_win > tmp->client_win) - min = tmp; + min = tmp; if (tmp->client_win > wwin->client_win && (!closest || (tmp->client_win - wwin->client_win) < d)) { @@ -134,7 +134,7 @@ nextFocusWindow(WWindow *wwin) tmp = tmp->prev; } if (!closest||closest==wwin) - return min; + return min; return closest; } @@ -144,7 +144,7 @@ prevFocusWindow(WWindow *wwin) { WWindow *tmp, *closest, *max; Window d; - + if (!wwin) return NULL; tmp = wwin->prev; @@ -155,7 +155,7 @@ prevFocusWindow(WWindow *wwin) if (wWindowCanReceiveFocus(tmp) && (!WFLAGP(tmp, skip_window_list) || tmp->flags.internal_window)) { if (max->client_win < tmp->client_win) - max = tmp; + max = tmp; if (tmp->client_win < wwin->client_win && (!closest || (wwin->client_win - tmp->client_win) < d)) { @@ -166,7 +166,7 @@ prevFocusWindow(WWindow *wwin) tmp = tmp->prev; } if (!closest||closest==wwin) - return max; + return max; return closest; } @@ -188,144 +188,144 @@ StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next) XEvent ev; if (!wwin) - return; - + return; + if (next) - hasModifier = (wKeyBindings[WKBD_FOCUSNEXT].modifier != 0); + hasModifier = (wKeyBindings[WKBD_FOCUSNEXT].modifier != 0); else - hasModifier = (wKeyBindings[WKBD_FOCUSPREV].modifier != 0); + hasModifier = (wKeyBindings[WKBD_FOCUSPREV].modifier != 0); if (hasModifier) { - keymap = XGetModifierMapping(dpy); + keymap = XGetModifierMapping(dpy); #ifdef DEBUG printf("Grabbing keyboard\n"); #endif - XGrabKeyboard(dpy, scr->root_win, False, GrabModeAsync, GrabModeAsync, - CurrentTime); + XGrabKeyboard(dpy, scr->root_win, False, GrabModeAsync, GrabModeAsync, + CurrentTime); } if (next) { - if (wPreferences.windows_cycling) - newFocused = nextToFocusAfter(wwin); - else - newFocused = nextFocusWindow(wwin); + if (wPreferences.windows_cycling) + newFocused = nextToFocusAfter(wwin); + else + newFocused = nextFocusWindow(wwin); } else { - if (wPreferences.windows_cycling) - newFocused = nextToFocusBefore(wwin); - else - newFocused = prevFocusWindow(wwin); + if (wPreferences.windows_cycling) + newFocused = nextToFocusBefore(wwin); + else + newFocused = prevFocusWindow(wwin); } scr->flags.doing_alt_tab = 1; if (wPreferences.circ_raise) - XRaiseWindow(dpy, newFocused->frame->core->window); + XRaiseWindow(dpy, newFocused->frame->core->window); wWindowFocus(newFocused, scr->focused_window); oldFocused = newFocused; #if 0 - if (wPreferences.popup_switchmenu && - (!scr->switch_menu || !scr->switch_menu->flags.mapped)) { + if (wPreferences.popup_switchmenu && + (!scr->switch_menu || !scr->switch_menu->flags.mapped)) { - OpenSwitchMenu(scr, scr->scr_width/2, scr->scr_height/2, False); - openedSwitchMenu = True; + OpenSwitchMenu(scr, scr->scr_width/2, scr->scr_height/2, False); + openedSwitchMenu = True; } #endif while (hasModifier && !done) { - WMMaskEvent(dpy, KeyPressMask|KeyReleaseMask|ExposureMask, &ev); + WMMaskEvent(dpy, KeyPressMask|KeyReleaseMask|ExposureMask, &ev); - if (ev.type != KeyRelease && ev.type != KeyPress) { - WMHandleEvent(&ev); - continue; - } - /* ignore CapsLock */ - modifiers = ev.xkey.state & ValidModMask; + if (ev.type != KeyRelease && ev.type != KeyPress) { + WMHandleEvent(&ev); + continue; + } + /* ignore CapsLock */ + modifiers = ev.xkey.state & ValidModMask; - if (ev.type == KeyPress) { + if (ev.type == KeyPress) { #ifdef DEBUG printf("Got key press\n"); #endif if (wKeyBindings[WKBD_FOCUSNEXT].keycode == ev.xkey.keycode - && wKeyBindings[WKBD_FOCUSNEXT].modifier == modifiers) { - - newFocused = nextToFocusAfter(newFocused); - wWindowFocus(newFocused, oldFocused); - oldFocused = newFocused; - - if (wPreferences.circ_raise) { - /* restore order */ - CommitStacking(scr); - XRaiseWindow(dpy, newFocused->frame->core->window); - } - - } else if (wKeyBindings[WKBD_FOCUSPREV].keycode == ev.xkey.keycode - && wKeyBindings[WKBD_FOCUSPREV].modifier == modifiers) { - - newFocused = nextToFocusBefore(newFocused); - wWindowFocus(newFocused, oldFocused); - oldFocused = newFocused; - - if (wPreferences.circ_raise) { - /* restore order */ - CommitStacking(scr); - XRaiseWindow(dpy, newFocused->frame->core->window); - } - - } else { + && wKeyBindings[WKBD_FOCUSNEXT].modifier == modifiers) { + + newFocused = nextToFocusAfter(newFocused); + wWindowFocus(newFocused, oldFocused); + oldFocused = newFocused; + + if (wPreferences.circ_raise) { + /* restore order */ + CommitStacking(scr); + XRaiseWindow(dpy, newFocused->frame->core->window); + } + + } else if (wKeyBindings[WKBD_FOCUSPREV].keycode == ev.xkey.keycode + && wKeyBindings[WKBD_FOCUSPREV].modifier == modifiers) { + + newFocused = nextToFocusBefore(newFocused); + wWindowFocus(newFocused, oldFocused); + oldFocused = newFocused; + + if (wPreferences.circ_raise) { + /* restore order */ + CommitStacking(scr); + XRaiseWindow(dpy, newFocused->frame->core->window); + } + + } else { #ifdef DEBUG printf("Got something else\n"); #endif - somethingElse = True; - done = True; - } - } else if (ev.type == KeyRelease) { - int i; + somethingElse = True; + done = True; + } + } else if (ev.type == KeyRelease) { + int i; #ifdef DEBUG printf("Got key release\n"); #endif - for (i = 0; i < 8 * keymap->max_keypermod; i++) { - if (keymap->modifiermap[i] == ev.xkey.keycode && - wKeyBindings[WKBD_FOCUSNEXT].modifier - & 1<<(i/keymap->max_keypermod)) { - done = True; - break; - } - } - } + for (i = 0; i < 8 * keymap->max_keypermod; i++) { + if (keymap->modifiermap[i] == ev.xkey.keycode && + wKeyBindings[WKBD_FOCUSNEXT].modifier + & 1<<(i/keymap->max_keypermod)) { + done = True; + break; + } + } + } } if (keymap) - XFreeModifiermap(keymap); + XFreeModifiermap(keymap); if (hasModifier) { #ifdef DEBUG printf("Ungrabbing keyboard\n"); #endif - XUngrabKeyboard(dpy, CurrentTime); + XUngrabKeyboard(dpy, CurrentTime); } wSetFocusTo(scr, newFocused); if (wPreferences.circ_raise) { - wRaiseFrame(newFocused->frame->core); - CommitStacking(scr); + wRaiseFrame(newFocused->frame->core); + CommitStacking(scr); } scr->flags.doing_alt_tab = 0; if (openedSwitchMenu) { - /* - * place window in center of current head - */ - WMPoint center = wGetPointToCenterRectInHead(scr, - wGetHeadForPointerLocation(scr), - 0, 0); - OpenSwitchMenu(scr, center.x, center.y, False); + /* + * place window in center of current head + */ + WMPoint center = + wGetPointToCenterRectInHead(scr, wGetHeadForPointerLocation(scr), + 0, 0); + OpenSwitchMenu(scr, center.x, center.y, False); } if (somethingElse) { - WMHandleEvent(&ev); + WMHandleEvent(&ev); } } diff --git a/src/def_pixmaps.h b/src/def_pixmaps.h dissimilarity index 61% index 5e05b70d..07c8b6b0 100644 --- a/src/def_pixmaps.h +++ b/src/def_pixmaps.h @@ -1,104 +1,104 @@ -/* diamond mark */ -#define MENU_RADIO_INDICATOR_XBM_SIZE 9 -static unsigned char MENU_RADIO_INDICATOR_XBM_DATA[] = { - 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xee, 0x00, 0xc7, 0x01, 0xee, 0x00, - 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00}; - -/* check mark */ -#define MENU_CHECK_INDICATOR_XBM_SIZE 9 -static unsigned char MENU_CHECK_INDICATOR_XBM_DATA[] = { - 0x00, 0x01, 0x83, 0x01, 0xc3, 0x00, 0x63, 0x00, 0x33, 0x00, 0x1b, 0x00, - 0x0f, 0x00, 0x07, 0x00, 0x03, 0x00}; - -#define MENU_MINI_INDICATOR_XBM_SIZE 9 -static unsigned char MENU_MINI_INDICATOR_XBM_DATA[] = { - 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0xff, 0x01}; - -#define MENU_HIDE_INDICATOR_XBM_SIZE 9 -static unsigned char MENU_HIDE_INDICATOR_XBM_DATA[] = { - 0x99, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x33, 0x01}; - -#define MENU_SHADE_INDICATOR_XBM_SIZE 9 -static unsigned char MENU_SHADE_INDICATOR_XBM_DATA[] = { - 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - - -/* button pixmaps */ -/* the first one is for normal state, the second is for when - * the button is pushed */ -static char *PRED_CLOSE_XPM[] = { -"10 10 3 1", -" c #000000", -". c #616561", -"X c None", -" .XXXXXX. ", -". .XXXX. .", -"X. .XX. .X", -"XX. .. .XX", -"XXX. .XXX", -"XXX. .XXX", -"XX. .. .XX", -"X. .XX. .X", -". .XXXX. .", -" .XXXXXX. "}; - - -static char *PRED_BROKEN_CLOSE_XPM[] = { -"10 10 3 1", -" c #000000", -". c #616561", -"X c None", -" .XXXXXX. ", -". .XXXX. .", -"X. XXXX .X", -"XXXXXXXXXX", -"XXXXXXXXXX", -"XXXXXXXXXX", -"XXXXXXXXXX", -"X. XXXX .X", -". .XXXX. .", -" .XXXXXX. "}; - - -static char *PRED_KILL_XPM[] = { -"10 10 3 1", -" c #000000", -". c #616561", -"X c None", -" .XXXXXX. ", -". XXXXXX .", -"XXXXXXXXXX", -"XXX .. XXX", -"XXX. .XXX", -"XXX. .XXX", -"XXX .. XXX", -"XXXXXXXXXX", -". XXXXXX .", -" .XXXXXX. "}; - - -static char *PRED_ICONIFY_XPM[] = { -" 10 10 2 1", -". c #000000", -"# c None", -"..........", -"..........", -"..........", -".########.", -".########.", -".########.", -".########.", -".########.", -".########.", -".........." -}; - -#ifdef XKB_BUTTON_HINT -#include "extend_pixmaps.h" -#endif /* XKB_BUTTON_HINT */ - - +/* diamond mark */ +#define MENU_RADIO_INDICATOR_XBM_SIZE 9 +static unsigned char MENU_RADIO_INDICATOR_XBM_DATA[] = { + 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xee, 0x00, 0xc7, 0x01, 0xee, 0x00, + 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00}; + +/* check mark */ +#define MENU_CHECK_INDICATOR_XBM_SIZE 9 +static unsigned char MENU_CHECK_INDICATOR_XBM_DATA[] = { + 0x00, 0x01, 0x83, 0x01, 0xc3, 0x00, 0x63, 0x00, 0x33, 0x00, 0x1b, 0x00, + 0x0f, 0x00, 0x07, 0x00, 0x03, 0x00}; + +#define MENU_MINI_INDICATOR_XBM_SIZE 9 +static unsigned char MENU_MINI_INDICATOR_XBM_DATA[] = { + 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0xff, 0x01}; + +#define MENU_HIDE_INDICATOR_XBM_SIZE 9 +static unsigned char MENU_HIDE_INDICATOR_XBM_DATA[] = { + 0x99, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x33, 0x01}; + +#define MENU_SHADE_INDICATOR_XBM_SIZE 9 +static unsigned char MENU_SHADE_INDICATOR_XBM_DATA[] = { + 0xff, 0x01, 0xff, 0x01, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + + +/* button pixmaps */ +/* the first one is for normal state, the second is for when + * the button is pushed */ +static char *PRED_CLOSE_XPM[] = { + "10 10 3 1", + " c #000000", + ". c #616561", + "X c None", + " .XXXXXX. ", + ". .XXXX. .", + "X. .XX. .X", + "XX. .. .XX", + "XXX. .XXX", + "XXX. .XXX", + "XX. .. .XX", + "X. .XX. .X", + ". .XXXX. .", + " .XXXXXX. "}; + + +static char *PRED_BROKEN_CLOSE_XPM[] = { + "10 10 3 1", + " c #000000", + ". c #616561", + "X c None", + " .XXXXXX. ", + ". .XXXX. .", + "X. XXXX .X", + "XXXXXXXXXX", + "XXXXXXXXXX", + "XXXXXXXXXX", + "XXXXXXXXXX", + "X. XXXX .X", + ". .XXXX. .", + " .XXXXXX. "}; + + +static char *PRED_KILL_XPM[] = { + "10 10 3 1", + " c #000000", + ". c #616561", + "X c None", + " .XXXXXX. ", + ". XXXXXX .", + "XXXXXXXXXX", + "XXX .. XXX", + "XXX. .XXX", + "XXX. .XXX", + "XXX .. XXX", + "XXXXXXXXXX", + ". XXXXXX .", + " .XXXXXX. "}; + + +static char *PRED_ICONIFY_XPM[] = { + " 10 10 2 1", + ". c #000000", + "# c None", + "..........", + "..........", + "..........", + ".########.", + ".########.", + ".########.", + ".########.", + ".########.", + ".########.", + ".........." +}; + +#ifdef XKB_BUTTON_HINT +#include "extend_pixmaps.h" +#endif /* XKB_BUTTON_HINT */ + + diff --git a/src/defaults.c b/src/defaults.c index de2c296e..65868128 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -876,7 +876,7 @@ 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 */ @@ -978,10 +978,10 @@ static void appendMenu(WMPropList *destarr, WMPropList *array) void wDefaultsMergeGlobalMenus(WDDomain *menuDomain) -{ +{ WMPropList *menu = menuDomain->dictionary; WMPropList *submenu; - + if (!menu || !WMIsPLArray(menu)) return; @@ -1014,7 +1014,7 @@ void wDefaultsMergeGlobalMenus(WDDomain *menuDomain) WMReleasePropList(submenu); } #endif - + menuDomain->dictionary = menu; } diff --git a/src/defaults.h b/src/defaults.h index 04100d88..4b6b2ad7 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -51,13 +51,13 @@ void wDefaultsCheckDomains(void *screen); void wSaveDefaults(WScreen *scr); char *wDefaultGetIconFile(WScreen *scr, char *instance, char *class, - Bool noDefault); + Bool noDefault); RImage *wDefaultGetImage(WScreen *scr, char *winstance, char *wclass); void wDefaultFillAttributes(WScreen *scr, char *instance, char *class, - WWindowAttributes *attr, WWindowAttributes *mask, - Bool useGlobalDefault); + WWindowAttributes *attr, WWindowAttributes *mask, + Bool useGlobalDefault); int wDefaultGetStartWorkspace(WScreen *scr, char *instance, char *class); diff --git a/src/dialog.c b/src/dialog.c index 418ec5e9..c021152d 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -67,17 +67,17 @@ extern WPreferences wPreferences; -static WMPoint getCenter(WScreen *scr, int width, int height) +static WMPoint +getCenter(WScreen *scr, int width, int height) { - return wGetPointToCenterRectInHead(scr, - wGetHeadForPointerLocation(scr), - width, height); + return wGetPointToCenterRectInHead(scr, wGetHeadForPointerLocation(scr), + width, height); } int wMessageDialog(WScreen *scr, char *title, char *message, - char *defBtn, char *altBtn, char *othBtn) + char *defBtn, char *altBtn, char *othBtn) { WMAlertPanel *panel; Window parent; @@ -86,16 +86,16 @@ wMessageDialog(WScreen *scr, char *title, char *message, WMPoint center; panel = WMCreateAlertPanel(scr->wmscreen, NULL, title, message, - defBtn, altBtn, othBtn); + defBtn, altBtn, othBtn); parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 400, 180, 0, 0, 0); XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); - + center = getCenter(scr, 400, 180); wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, - 400, 180); + 400, 180); wwin->client_leader = WMWidgetXID(panel->win); WMMapWidget(panel->win); @@ -143,7 +143,7 @@ wExitDialog(WScreen *scr, char *title, char *message, saveSessionBtn = WMCreateSwitchButton(panel->hbox); WMSetButtonAction(saveSessionBtn, toggleSaveSession, NULL); WMAddBoxSubview(panel->hbox, WMWidgetView(saveSessionBtn), - False, True, 200, 0, 0); + False, True, 200, 0, 0); WMSetButtonText(saveSessionBtn, _("Save workspace state")); WMSetButtonSelected(saveSessionBtn, wPreferences.save_session_on_exit); WMRealizeWidget(saveSessionBtn); @@ -155,7 +155,7 @@ wExitDialog(WScreen *scr, char *title, char *message, center = getCenter(scr, 400, 180); wwin = wManageInternalWindow(scr, parent, None, NULL, - center.x, center.y, 400, 180); + center.x, center.y, 400, 180); wwin->client_leader = WMWidgetXID(panel->win); @@ -189,7 +189,7 @@ wInputDialog(WScreen *scr, char *title, char *message, char **text) WMPoint center; panel = WMCreateInputPanel(scr->wmscreen, NULL, title, message, *text, - _("OK"), _("Cancel")); + _("OK"), _("Cancel")); parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 320, 160, 0, 0, 0); @@ -199,7 +199,7 @@ wInputDialog(WScreen *scr, char *title, char *message, char **text) center = getCenter(scr, 320, 160); wwin = wManageInternalWindow(scr, parent, None, NULL, center.x, center.y, - 320, 160); + 320, 160); wwin->client_leader = WMWidgetXID(panel->win); @@ -210,9 +210,9 @@ wInputDialog(WScreen *scr, char *title, char *message, char **text) WMRunModalLoop(WMWidgetScreen(panel->win), WMWidgetView(panel->win)); if (panel->result == WAPRDefault) - result = WMGetTextFieldText(panel->text); + result = WMGetTextFieldText(panel->text); else - result = NULL; + result = NULL; wUnmanageWindow(wwin, False, False); @@ -221,7 +221,7 @@ wInputDialog(WScreen *scr, char *title, char *message, char **text) XDestroyWindow(dpy, parent); if (result==NULL) - return False; + return False; else { if (*text) wfree(*text); @@ -285,38 +285,38 @@ listPixmaps(WScreen *scr, WMList *lPtr, char *path) dir = opendir(apath); if (!dir) { - char *msg; - char *tmp; - tmp = _("Could not open directory "); - msg = wmalloc(strlen(tmp)+strlen(path)+6); - strcpy(msg, tmp); - strcat(msg, path); - - wMessageDialog(scr, _("Error"), msg, _("OK"), NULL, NULL); - wfree(msg); - wfree(apath); - return; + char *msg; + char *tmp; + tmp = _("Could not open directory "); + msg = wmalloc(strlen(tmp)+strlen(path)+6); + strcpy(msg, tmp); + strcat(msg, path); + + wMessageDialog(scr, _("Error"), msg, _("OK"), NULL, NULL); + wfree(msg); + wfree(apath); + return; } /* list contents in the column */ while ((dentry = readdir(dir))) { - struct stat statb; + struct stat statb; - if (strcmp(dentry->d_name, ".")==0 || - strcmp(dentry->d_name, "..")==0) - continue; + if (strcmp(dentry->d_name, ".")==0 || + strcmp(dentry->d_name, "..")==0) + continue; - strcpy(pbuf, apath); - strcat(pbuf, "/"); - strcat(pbuf, dentry->d_name); + strcpy(pbuf, apath); + strcat(pbuf, "/"); + strcat(pbuf, dentry->d_name); - if (stat(pbuf, &statb)<0) - continue; + if (stat(pbuf, &statb)<0) + continue; - if (statb.st_mode & (S_IRUSR|S_IRGRP|S_IROTH) - && statb.st_mode & (S_IFREG|S_IFLNK)) { - WMAddListItem(lPtr, dentry->d_name); - } + if (statb.st_mode & (S_IRUSR|S_IRGRP|S_IROTH) + && statb.st_mode & (S_IFREG|S_IFLNK)) { + WMAddListItem(lPtr, dentry->d_name); + } } WMSortListItems(lPtr); @@ -338,19 +338,19 @@ setViewedImage(IconPanel *panel, char *file) color.blue = 0xae; color.alpha = 0; pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), - file, &color); + file, &color); if (!pixmap) { - WMSetButtonEnabled(panel->okButton, False); + WMSetButtonEnabled(panel->okButton, False); - WMSetLabelText(panel->iconView, _("Could not load image file ")); + WMSetLabelText(panel->iconView, _("Could not load image file ")); - WMSetLabelImage(panel->iconView, NULL); + WMSetLabelImage(panel->iconView, NULL); } else { - WMSetButtonEnabled(panel->okButton, True); + WMSetButtonEnabled(panel->okButton, True); - WMSetLabelText(panel->iconView, NULL); - WMSetLabelImage(panel->iconView, pixmap); - WMReleasePixmap(pixmap); + WMSetLabelText(panel->iconView, NULL); + WMSetLabelImage(panel->iconView, pixmap); + WMReleasePixmap(pixmap); } } @@ -363,42 +363,42 @@ listCallback(void *self, void *data) char *path; if (lPtr==panel->dirList) { - WMListItem *item = WMGetListSelectedItem(lPtr); + WMListItem *item = WMGetListSelectedItem(lPtr); - if (item == NULL) - return; - path = item->text; + if (item == NULL) + return; + path = item->text; - WMSetTextFieldText(panel->fileField, path); + WMSetTextFieldText(panel->fileField, path); - WMSetLabelImage(panel->iconView, NULL); + WMSetLabelImage(panel->iconView, NULL); - WMSetButtonEnabled(panel->okButton, False); + WMSetButtonEnabled(panel->okButton, False); - WMClearList(panel->iconList); - listPixmaps(panel->scr, panel->iconList, path); + WMClearList(panel->iconList); + listPixmaps(panel->scr, panel->iconList, path); } else { - char *tmp, *iconFile; - WMListItem *item = WMGetListSelectedItem(panel->dirList); - - if (item == NULL) - return; - path = item->text; - tmp = wexpandpath(path); - - item = WMGetListSelectedItem(panel->iconList); - if (item == NULL) - return; - iconFile = item->text; - - path = wmalloc(strlen(tmp)+strlen(iconFile)+4); - strcpy(path, tmp); - strcat(path, "/"); - strcat(path, iconFile); - wfree(tmp); - WMSetTextFieldText(panel->fileField, path); - setViewedImage(panel, path); - wfree(path); + char *tmp, *iconFile; + WMListItem *item = WMGetListSelectedItem(panel->dirList); + + if (item == NULL) + return; + path = item->text; + tmp = wexpandpath(path); + + item = WMGetListSelectedItem(panel->iconList); + if (item == NULL) + return; + iconFile = item->text; + + path = wmalloc(strlen(tmp)+strlen(iconFile)+4); + strcpy(path, tmp); + strcat(path, "/"); + strcat(path, iconFile); + wfree(tmp); + WMSetTextFieldText(panel->fileField, path); + setViewedImage(panel, path); + wfree(path); } } @@ -414,14 +414,14 @@ listIconPaths(WMList *lPtr) path = strtok(paths, ":"); do { - char *tmp; - - tmp = wexpandpath(path); - /* do not sort, because the order implies the order of - * directories searched */ - if (access(tmp, X_OK)==0) - WMAddListItem(lPtr, path); - wfree(tmp); + char *tmp; + + tmp = wexpandpath(path); + /* do not sort, because the order implies the order of + * directories searched */ + if (access(tmp, X_OK)==0) + WMAddListItem(lPtr, path); + wfree(tmp); } while ((path=strtok(NULL, ":"))!=NULL); wfree(paths); @@ -483,21 +483,21 @@ drawIconProc(WMList *lPtr, int index, Drawable d, char *text, int state, XSetClipMask(dpy, copygc, WMGetPixmapMaskXID(pixmap)); XSetClipOrigin(dpy, copygc, x + (width-size.width)/2, y+2); XCopyArea(dpy, WMGetPixmapXID(pixmap), d, copygc, 0, 0, - size.width>100?100:size.width, size.height>64?64:size.height, - x + (width-size.width)/2, y+2); + size.width>100?100:size.width, size.height>64?64:size.height, + x + (width-size.width)/2, y+2); { int i,j; - int fheight = WMFontHeight(panel->normalfont); - int tlen = strlen(text); - int twidth = WMWidthOfString(panel->normalfont, text, tlen); - int ofx, ofy; + int fheight = WMFontHeight(panel->normalfont); + int tlen = strlen(text); + int twidth = WMWidthOfString(panel->normalfont, text, tlen); + int ofx, ofy; - ofx = x + (width - twidth)/2; - ofy = y + 64 - fheight; + ofx = x + (width - twidth)/2; + ofy = y + 64 - fheight; for(i=-1;i<2;i++) - for(j=-1;j<2;j++) + for(j=-1;j<2;j++) WMDrawString(wmscr, d, scr->white, panel->normalfont, ofx+i, ofy+j, text, tlen); @@ -519,11 +519,11 @@ buttonCallback(void *self, void *clientData) if (bPtr==panel->okButton) { - panel->done = True; - panel->result = True; + panel->done = True; + panel->result = True; } else if (bPtr==panel->cancelButton) { - panel->done = True; - panel->result = False; + panel->done = True; + panel->result = False; } else if (bPtr==panel->previewButton) { /**** Previewer ****/ WMSetButtonEnabled(bPtr, False); @@ -535,18 +535,18 @@ buttonCallback(void *self, void *clientData) } #if 0 else if (bPtr==panel->chooseButton) { - WMOpenPanel *op; - - op = WMCreateOpenPanel(WMWidgetScreen(bPtr)); - - if (WMRunModalFilePanelForDirectory(op, NULL, "/usr/local", NULL, NULL)) { - char *path; - path = WMGetFilePanelFile(op); - WMSetTextFieldText(panel->fileField, path); - setViewedImage(panel, path); - wfree(path); - } - WMDestroyFilePanel(op); + WMOpenPanel *op; + + op = WMCreateOpenPanel(WMWidgetScreen(bPtr)); + + if (WMRunModalFilePanelForDirectory(op, NULL, "/usr/local", NULL, NULL)) { + char *path; + path = WMGetFilePanelFile(op); + WMSetTextFieldText(panel->fileField, path); + setViewedImage(panel, path); + wfree(path); + } + WMDestroyFilePanel(op); } #endif } @@ -563,9 +563,9 @@ keyPressHandler(XEvent *event, void *data) int didx; int item; WMList *list = NULL; - + if (event->type == KeyRelease) - return; + return; buffer[0] = 0; count = XLookupString(&event->xkey, buffer, sizeof(buffer), &ksym, NULL); @@ -575,54 +575,54 @@ keyPressHandler(XEvent *event, void *data) didx = WMGetListSelectedItemRow(panel->dirList); switch (ksym) { - case XK_Up: - if (iidx > 0) - item = iidx-1; - else - item = iidx; - list = panel->iconList; - break; - case XK_Down: - if (iidx < WMGetListNumberOfRows(panel->iconList) - 1) - item = iidx+1; - else - item = iidx; - list = panel->iconList; - break; - case XK_Home: - item = 0; - list = panel->iconList; - break; - case XK_End: - item = WMGetListNumberOfRows(panel->iconList) - 1; - list = panel->iconList; - break; - case XK_Next: - if (didx < WMGetListNumberOfRows(panel->dirList) - 1) - item = didx + 1; - else - item = didx; - list = panel->dirList; - break; - case XK_Prior: - if (didx > 0) - item = didx - 1; - else - item = 0; - list = panel->dirList; - break; - case XK_Return: - WMPerformButtonClick(panel->okButton); - break; - case XK_Escape: - WMPerformButtonClick(panel->cancelButton); - break; + case XK_Up: + if (iidx > 0) + item = iidx-1; + else + item = iidx; + list = panel->iconList; + break; + case XK_Down: + if (iidx < WMGetListNumberOfRows(panel->iconList) - 1) + item = iidx+1; + else + item = iidx; + list = panel->iconList; + break; + case XK_Home: + item = 0; + list = panel->iconList; + break; + case XK_End: + item = WMGetListNumberOfRows(panel->iconList) - 1; + list = panel->iconList; + break; + case XK_Next: + if (didx < WMGetListNumberOfRows(panel->dirList) - 1) + item = didx + 1; + else + item = didx; + list = panel->dirList; + break; + case XK_Prior: + if (didx > 0) + item = didx - 1; + else + item = 0; + list = panel->dirList; + break; + case XK_Return: + WMPerformButtonClick(panel->okButton); + break; + case XK_Escape: + WMPerformButtonClick(panel->cancelButton); + break; } if (list) { - WMSelectListItem(list, item); - WMSetListPosition(list, item - 5); - listCallback(list, panel); + WMSelectListItem(list, item); + WMSetListPosition(list, item - 5); + listCallback(list, panel); } } @@ -647,7 +647,7 @@ wIconChooserDialog(WScreen *scr, char **file, char *instance, char *class) WMResizeWidget(panel->win, 450, 280); WMCreateEventHandler(WMWidgetView(panel->win), KeyPressMask|KeyReleaseMask, - keyPressHandler, panel); + keyPressHandler, panel); boldFont = WMBoldSystemFontOfSize(scr->wmscreen, 12); @@ -746,23 +746,23 @@ wIconChooserDialog(WScreen *scr, char **file, char *instance, char *class) XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); { - char *tmp; - int len = (instance ? strlen(instance) : 0) - + (class ? strlen(class) : 0) + 32; - WMPoint center; - - tmp = wmalloc(len); - - if (tmp && (instance || class)) - snprintf(tmp, len, "%s [%s.%s]", _("Icon Chooser"), instance, class); - else - strcpy(tmp, _("Icon Chooser")); - - center = getCenter(scr, 450, 280); - - wwin = wManageInternalWindow(scr, parent, None, tmp, center.x,center.y, - 450, 280); - wfree(tmp); + char *tmp; + int len = (instance ? strlen(instance) : 0) + + (class ? strlen(class) : 0) + 32; + WMPoint center; + + tmp = wmalloc(len); + + if (tmp && (instance || class)) + snprintf(tmp, len, "%s [%s.%s]", _("Icon Chooser"), instance, class); + else + strcpy(tmp, _("Icon Chooser")); + + center = getCenter(scr, 450, 280); + + wwin = wManageInternalWindow(scr, parent, None, tmp, center.x,center.y, + 450, 280); + wfree(tmp); } /* put icon paths in the list */ @@ -773,35 +773,35 @@ wIconChooserDialog(WScreen *scr, char **file, char *instance, char *class) wWindowMap(wwin); while (!panel->done) { - XEvent event; + XEvent event; - WMNextEvent(dpy, &event); - WMHandleEvent(&event); + WMNextEvent(dpy, &event); + WMHandleEvent(&event); } if (panel->result) { - char *defaultPath, *wantedPath; - - /* check if the file the user selected is not the one that - * would be loaded by default with the current search path */ - *file = WMGetListSelectedItem(panel->iconList)->text; - if (**file==0) { - wfree(*file); - *file = NULL; - } else { - defaultPath = FindImage(wPreferences.icon_path, *file); - wantedPath = WMGetTextFieldText(panel->fileField); - /* if the file is not the default, use full path */ - if (strcmp(wantedPath, defaultPath)!=0) { - *file = wantedPath; - } else { - *file = wstrdup(*file); - wfree(wantedPath); - } - wfree(defaultPath); - } + char *defaultPath, *wantedPath; + + /* check if the file the user selected is not the one that + * would be loaded by default with the current search path */ + *file = WMGetListSelectedItem(panel->iconList)->text; + if (**file==0) { + wfree(*file); + *file = NULL; + } else { + defaultPath = FindImage(wPreferences.icon_path, *file); + wantedPath = WMGetTextFieldText(panel->fileField); + /* if the file is not the default, use full path */ + if (strcmp(wantedPath, defaultPath)!=0) { + *file = wantedPath; + } else { + *file = wstrdup(*file); + wfree(wantedPath); + } + wfree(defaultPath); + } } else { - *file = NULL; + *file = NULL; } result = panel->result; @@ -862,8 +862,8 @@ typedef struct { #define COPYRIGHT_TEXT \ - "Copyright \xc2\xa9 1997-2004 Alfredo K. Kojima \n"\ - "Copyright \xc2\xa9 1998-2004 Dan Pascu " + "Copyright \xc2\xa9 1997-2004 Alfredo K. Kojima \n"\ + "Copyright \xc2\xa9 1998-2004 Dan Pascu " @@ -874,19 +874,19 @@ destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event) { #ifdef SILLYNESS if (thePanel->timer) { - WMDeleteTimerHandler(thePanel->timer); + WMDeleteTimerHandler(thePanel->timer); } if (thePanel->oldPix) { - WMReleasePixmap(thePanel->oldPix); + WMReleasePixmap(thePanel->oldPix); } if (thePanel->oldFont) { WMReleaseFont(thePanel->oldFont); } if (thePanel->icon) { - RReleaseImage(thePanel->icon); + RReleaseImage(thePanel->icon); } if (thePanel->pic) { - RReleaseImage(thePanel->pic); + RReleaseImage(thePanel->pic); } #endif /* SILLYNESS */ WMUnmapWidget(thePanel); @@ -928,7 +928,7 @@ logoPushCallback(void *data) XGetKeyboardControl(dpy, &ksave); - if (panel->x > 0) { + if (panel->x > 0) { if(jingobeu[panel->x-1]==0) { panel->x=-1; } else if (jingobeu[panel->x-1]<0) { @@ -949,18 +949,18 @@ logoPushCallback(void *data) c--; } } - if (!(panel->cycle % 4)) { - WMPixmap *p; + if (!(panel->cycle % 4)) { + WMPixmap *p; - p = DoXThing(panel->wwin); - WMSetLabelImage(panel->logoL, p); + p = DoXThing(panel->wwin); + WMSetLabelImage(panel->logoL, p); } kc.bell_pitch = ksave.bell_pitch; kc.bell_percent = ksave.bell_percent; kc.bell_duration = ksave.bell_duration; XChangeKeyboardControl(dpy, mask, &kc); } else if (panel->cycle < 30) { - RImage *image; + RImage *image; WMPixmap *pix; RColor gray; @@ -968,11 +968,11 @@ logoPushCallback(void *data) gray.blue = 0xae; gray.alpha = 0; image = RScaleImage(panel->icon, panel->pic->width, panel->pic->height); - RCombineImagesWithOpaqueness(image, panel->pic, panel->cycle*255/30); - pix = WMCreateBlendedPixmapFromRImage(panel->scr->wmscreen, image, &gray); - RReleaseImage(image); - WMSetLabelImage(panel->logoL, pix); - WMReleasePixmap(pix); + RCombineImagesWithOpaqueness(image, panel->pic, panel->cycle*255/30); + pix = WMCreateBlendedPixmapFromRImage(panel->scr->wmscreen, image, &gray); + RReleaseImage(image); + WMSetLabelImage(panel->logoL, pix); + WMReleasePixmap(pix); } /* slow down text a little */ @@ -1133,37 +1133,37 @@ handleLogoPush(XEvent *event, void *data) if (!panel->timer && !broken && clicks > 0) { WMFont *font; - panel->x = 0; - clicks = 0; - if (!panel->icon) { + panel->x = 0; + clicks = 0; + if (!panel->icon) { panel->icon = WMGetApplicationIconImage(panel->scr->wmscreen); - if (!panel->icon) { - broken = 1; - return; + if (!panel->icon) { + broken = 1; + return; } else { - RColor color; + RColor color; color.red = 0xae; color.green = 0xaa; color.blue = 0xae; color.alpha = 0; panel->icon = RCloneImage(panel->icon); - RCombineImageWithColor(panel->icon, &color); + RCombineImageWithColor(panel->icon, &color); } - } - if (!panel->pic) { - panel->pic = RGetImageFromXPMData(panel->scr->rcontext, pic_data); - if (!panel->pic) { - broken = 1; - RReleaseImage(panel->icon); - panel->icon = NULL; - return; - } - } - - panel->str = msgs[rand()%(sizeof(msgs)/sizeof(char*))]; - - panel->timer = WMAddTimerHandler(50, logoPushCallback, panel); - panel->cycle = 0; + } + if (!panel->pic) { + panel->pic = RGetImageFromXPMData(panel->scr->rcontext, pic_data); + if (!panel->pic) { + broken = 1; + RReleaseImage(panel->icon); + panel->icon = NULL; + return; + } + } + + panel->str = msgs[rand()%(sizeof(msgs)/sizeof(char*))]; + + panel->timer = WMAddTimerHandler(50, logoPushCallback, panel); + panel->cycle = 0; panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL)); /* If we don't use a fixed font, scrolling will be jumpy */ /* Alternatively we can draw text in a pixmap and scroll it smoothly */ @@ -1176,31 +1176,31 @@ handleLogoPush(XEvent *event, void *data) } WMSetLabelText(panel->versionL, ""); } else if (panel->timer) { - char version[20]; + char version[20]; - panel->x = 0; - clicks = 0; - WMSetLabelImage(panel->logoL, panel->oldPix); - WMReleasePixmap(panel->oldPix); - panel->oldPix = NULL; + panel->x = 0; + clicks = 0; + WMSetLabelImage(panel->logoL, panel->oldPix); + WMReleasePixmap(panel->oldPix); + panel->oldPix = NULL; - WMDeleteTimerHandler(panel->timer); - panel->timer = NULL; + WMDeleteTimerHandler(panel->timer); + panel->timer = NULL; WMSetLabelFont(panel->versionL, panel->oldFont); if (panel->oldFont) { WMReleaseFont(panel->oldFont); panel->oldFont = NULL; } - snprintf(version, sizeof(version), _("Version %s"), VERSION); + snprintf(version, sizeof(version), _("Version %s"), VERSION); WMSetLabelText(panel->versionL, version); XFlush(WMScreenDisplay(WMWidgetScreen(panel->versionL))); } { - XEvent ev; - while (XCheckTypedWindowEvent(dpy, WMWidgetXID(panel->versionL), - ButtonPress, &ev)); + XEvent ev; + while (XCheckTypedWindowEvent(dpy, WMWidgetXID(panel->versionL), + ButtonPress, &ev)); } } #endif /* SILLYNESS */ @@ -1220,21 +1220,21 @@ wShowInfoPanel(WScreen *scr) char **strl; int i, width, sepWidth; char *visuals[] = { - "StaticGray", - "GrayScale", - "StaticColor", - "PseudoColor", - "TrueColor", - "DirectColor" + "StaticGray", + "GrayScale", + "StaticColor", + "PseudoColor", + "TrueColor", + "DirectColor" }; if (thePanel) { - if (thePanel->scr == scr) { - wRaiseFrame(thePanel->wwin->frame->core); - wSetFocusTo(scr, thePanel->wwin); - } - return; + if (thePanel->scr == scr) { + wRaiseFrame(thePanel->wwin->frame->core); + wSetFocusTo(scr, thePanel->wwin); + } + return; } panel = wmalloc(sizeof(InfoPanel)); @@ -1250,15 +1250,15 @@ wShowInfoPanel(WScreen *scr) logo = WMRetainPixmap(WMGetApplicationIconPixmap(scr->wmscreen)); } if (logo) { - size = WMGetPixmapSize(logo); - panel->logoL = WMCreateLabel(panel->win); - WMResizeWidget(panel->logoL, 64, 64); - WMMoveWidget(panel->logoL, 30, 20); - WMSetLabelImagePosition(panel->logoL, WIPImageOnly); - WMSetLabelImage(panel->logoL, logo); + size = WMGetPixmapSize(logo); + panel->logoL = WMCreateLabel(panel->win); + WMResizeWidget(panel->logoL, 64, 64); + WMMoveWidget(panel->logoL, 30, 20); + WMSetLabelImagePosition(panel->logoL, WIPImageOnly); + WMSetLabelImage(panel->logoL, logo); #ifdef SILLYNESS - WMCreateEventHandler(WMWidgetView(panel->logoL), ButtonPressMask, - handleLogoPush, panel); + WMCreateEventHandler(WMWidgetView(panel->logoL), ButtonPressMask, + handleLogoPush, panel); #endif WMReleasePixmap(logo); } @@ -1294,9 +1294,9 @@ wShowInfoPanel(WScreen *scr) WMMoveWidget(panel->name2L, 100, 60); font = WMBoldSystemFontOfSize(scr->wmscreen, 18); if (font) { - WMSetLabelFont(panel->name2L, font); - WMReleaseFont(font); - font = NULL; + WMSetLabelFont(panel->name2L, font); + WMReleaseFont(font); + font = NULL; } WMSetLabelTextAlignment(panel->name2L, WACenter); WMSetLabelText(panel->name2L, _("Window Manager for X")); @@ -1323,80 +1323,80 @@ wShowInfoPanel(WScreen *scr) strbuf = NULL; snprintf(buffer, sizeof(buffer), _("Using visual 0x%x: %s %ibpp "), - (unsigned)scr->w_visual->visualid, - visuals[scr->w_visual->class], scr->w_depth); - + (unsigned)scr->w_visual->visualid, + visuals[scr->w_visual->class], scr->w_depth); + strbuf = wstrappend(strbuf, buffer); - + switch (scr->w_depth) { - case 15: - strbuf = wstrappend(strbuf, _("(32 thousand colors)\n")); - break; - case 16: - strbuf = wstrappend(strbuf, _("(64 thousand colors)\n")); - break; - case 24: - case 32: - strbuf = wstrappend(strbuf, _("(16 million colors)\n")); - break; - default: - snprintf(buffer, sizeof(buffer), _("(%d colors)\n"), 1<w_depth); - strbuf = wstrappend(strbuf, buffer); - break; + case 15: + strbuf = wstrappend(strbuf, _("(32 thousand colors)\n")); + break; + case 16: + strbuf = wstrappend(strbuf, _("(64 thousand colors)\n")); + break; + case 24: + case 32: + strbuf = wstrappend(strbuf, _("(16 million colors)\n")); + break; + default: + snprintf(buffer, sizeof(buffer), _("(%d colors)\n"), 1<w_depth); + strbuf = wstrappend(strbuf, buffer); + break; } - + #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO) { - struct mallinfo ma = mallinfo(); - snprintf(buffer, sizeof(buffer), - _("Total allocated memory: %i kB. Total memory in use: %i kB.\n"), - (ma.arena+ma.hblkhd)/1024, (ma.uordblks+ma.hblkhd)/1024); - - strbuf = wstrappend(strbuf, buffer); + struct mallinfo ma = mallinfo(); + snprintf(buffer, sizeof(buffer), + _("Total allocated memory: %i kB. Total memory in use: %i kB.\n"), + (ma.arena+ma.hblkhd)/1024, (ma.uordblks+ma.hblkhd)/1024); + + strbuf = wstrappend(strbuf, buffer); } #endif strbuf = wstrappend(strbuf, _("Supported image formats: ")); strl = RSupportedFileFormats(); for (i=0; strl[i]!=NULL; i++) { - strbuf = wstrappend(strbuf, strl[i]); - strbuf = wstrappend(strbuf, " "); + strbuf = wstrappend(strbuf, strl[i]); + strbuf = wstrappend(strbuf, " "); } strbuf = wstrappend(strbuf, _("\nAdditional support for: ")); { - char *list[9]; - char buf[80]; - int j = 0; + char *list[9]; + char buf[80]; + int j = 0; #ifdef MWM_HINTS - list[j++] = "MWM"; + list[j++] = "MWM"; #endif #ifdef KWM_HINTS - list[j++] = "KDE"; + list[j++] = "KDE"; #endif #ifdef GNOME_STUFF - list[j++] = "GNOME"; + list[j++] = "GNOME"; #endif #ifdef OLWM_HINTS - list[j++] = "OLWM"; + list[j++] = "OLWM"; #endif #ifdef NETWM_HINTS - list[j++] = "WMSPEC"; + list[j++] = "WMSPEC"; #endif - buf[0] = 0; - for (i = 0; i < j; i++) { - if (i > 0) { - if (i == j - 1) - strcat(buf, _(" and ")); - else - strcat(buf, ", "); - } - strcat(buf, list[i]); - } - strbuf = wstrappend(strbuf, buf); + buf[0] = 0; + for (i = 0; i < j; i++) { + if (i > 0) { + if (i == j - 1) + strcat(buf, _(" and ")); + else + strcat(buf, ", "); + } + strcat(buf, list[i]); + } + strbuf = wstrappend(strbuf, buf); } if (wPreferences.no_sound) { @@ -1420,9 +1420,9 @@ wShowInfoPanel(WScreen *scr) #endif strbuf = wstrappend(strbuf, _("Xinerama: ")); { - char tmp[128]; - snprintf(tmp, sizeof(tmp)-1, "%d heads found.", scr->xine_info.count); - strbuf = wstrappend(strbuf, tmp); + char tmp[128]; + snprintf(tmp, sizeof(tmp)-1, "%d heads found.", scr->xine_info.count); + strbuf = wstrappend(strbuf, tmp); } #endif @@ -1433,7 +1433,7 @@ wShowInfoPanel(WScreen *scr) WMSetLabelText(panel->infoL, strbuf); font = WMSystemFontOfSize(scr->wmscreen, 11); if (font) { - WMSetLabelFont(panel->infoL, font); + WMSetLabelFont(panel->infoL, font); WMReleaseFont(font); font = NULL; } @@ -1450,11 +1450,11 @@ wShowInfoPanel(WScreen *scr) WMMapWidget(panel->win); { - WMPoint center = getCenter(scr, 382, 230); - - wwin = wManageInternalWindow(scr, parent, None, _("Info"), - center.x, center.y, - 382, 230); + WMPoint center = getCenter(scr, 382, 230); + + wwin = wManageInternalWindow(scr, parent, None, _("Info"), + center.x, center.y, + 382, 230); } WSETUFLAG(wwin, no_closable, 0); @@ -1473,11 +1473,11 @@ wShowInfoPanel(WScreen *scr) thePanel = panel; #ifdef SILLYNESS if (InitXThing(panel->scr)) { - panel->timer = WMAddTimerHandler(100, logoPushCallback, panel); - panel->cycle = 0; - panel->x = 1; - panel->str = _("Merry Christmas!"); - panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL)); + panel->timer = WMAddTimerHandler(100, logoPushCallback, panel); + panel->cycle = 0; + panel->x = 1; + panel->str = _("Merry Christmas!"); + panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL)); } #endif } @@ -1525,11 +1525,11 @@ wShowLegalPanel(WScreen *scr) WWindow *wwin; if (legalPanel) { - if (legalPanel->scr == scr) { - wRaiseFrame(legalPanel->wwin->frame->core); - wSetFocusTo(scr, legalPanel->wwin); - } - return; + if (legalPanel->scr == scr) { + wRaiseFrame(legalPanel->wwin->frame->core); + wSetFocusTo(scr, legalPanel->wwin); + } + return; } panel = wmalloc(sizeof(LegalPanel)); @@ -1546,18 +1546,18 @@ wShowLegalPanel(WScreen *scr) WMMoveWidget(panel->licenseL, 10, 10); WMSetLabelTextAlignment(panel->licenseL, WALeft); WMSetLabelText(panel->licenseL, - _(" Window Maker is free software; you can redistribute it and/or\n" - "modify it under the terms of the GNU General Public License as\n" - "published by the Free Software Foundation; either version 2 of the\n" - "License, or (at your option) any later version.\n\n" - " Window Maker is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty\n" - "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" - "See the GNU General Public License for more details.\n\n" - " You should have received a copy of the GNU General Public\n" - "License along with this program; if not, write to the Free Software\n" - "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\n" - "02111-1307, USA.")); + _(" Window Maker is free software; you can redistribute it and/or\n" + "modify it under the terms of the GNU General Public License as\n" + "published by the Free Software Foundation; either version 2 of the\n" + "License, or (at your option) any later version.\n\n" + " Window Maker is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty\n" + "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" + "See the GNU General Public License for more details.\n\n" + " You should have received a copy of the GNU General Public\n" + "License along with this program; if not, write to the Free Software\n" + "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\n" + "02111-1307, USA.")); WMSetLabelRelief(panel->licenseL, WRGroove); WMRealizeWidget(panel->win); @@ -1568,11 +1568,11 @@ wShowLegalPanel(WScreen *scr) XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); { - WMPoint center = getCenter(scr, 420, 250); - - wwin = wManageInternalWindow(scr, parent, None, _("Legal"), - center.x, center.y, - 420, 250); + WMPoint center = getCenter(scr, 420, 250); + + wwin = wManageInternalWindow(scr, parent, None, _("Legal"), + center.x, center.y, + 420, 250); } WSETUFLAG(wwin, no_closable, 0); @@ -1633,7 +1633,7 @@ handleKeyPress(XEvent *event, void *clientData) CrashPanel *panel = (CrashPanel*)clientData; if (event->xkey.keycode == panel->retKey) { - WMPerformButtonClick(panel->okB); + WMPerformButtonClick(panel->okB); } } @@ -1723,7 +1723,7 @@ wShowCrashingDialogPanel(int whatSig) scr = WMCreateScreen(dpy, screen_no); if (!scr) { wsyserror(_("cannot open connection for crashing dialog panel. Aborting.")); - return WMAbort; + return WMAbort; } panel->retKey = XKeysymToKeycode(dpy, XK_Return); @@ -1760,7 +1760,7 @@ wShowCrashingDialogPanel(int whatSig) WMSetLabelTextAlignment(panel->noteL, WAJustified); #ifdef SYS_SIGLIST_DECLARED snprintf(buf, sizeof(buf), _("Window Maker received signal %i\n(%s)."), - whatSig, sys_siglist[whatSig]); + whatSig, sys_siglist[whatSig]); #else snprintf(buf, sizeof(buf), _("Window Maker received signal %i."), whatSig); #endif @@ -1772,8 +1772,8 @@ wShowCrashingDialogPanel(int whatSig) WMSetLabelTextAlignment(panel->note2L, WALeft); WMSetLabelText(panel->note2L, _(" This fatal error occured probably due to a bug." - " Please fill the included BUGFORM and " - "report it to bugs@windowmaker.org.")); + " Please fill the included BUGFORM and " + "report it to bugs@windowmaker.org.")); WMSetLabelWraps(panel->note2L, True); @@ -1843,7 +1843,7 @@ wShowCrashingDialogPanel(int whatSig) static void drawGNUstepLogo(Display *dpy, Drawable d, int width, int height, - unsigned long blackPixel, unsigned long whitePixel) + unsigned long blackPixel, unsigned long whitePixel) { GC gc; XGCValues gcv; @@ -1853,7 +1853,7 @@ drawGNUstepLogo(Display *dpy, Drawable d, int width, int height, gc = XCreateGC(dpy, d, GCForeground, &gcv); XFillArc(dpy, d, gc, width/45, height/45, - width - 2*width/45, height - 2*height/45, 0, 360*64); + width - 2*width/45, height - 2*height/45, 0, 360*64); rects[0].x = 0; rects[0].y = 37*height/45; @@ -1875,7 +1875,7 @@ drawGNUstepLogo(Display *dpy, Drawable d, int width, int height, XSetForeground(dpy, gc, whitePixel); XFillArc(dpy, d, gc, width/45, height/45, - width - 2*width/45, height - 2*height/45, 0, 360*64); + width - 2*width/45, height - 2*height/45, 0, 360*64); XFreeGC(dpy, gc); } @@ -1920,11 +1920,11 @@ wShowGNUstepPanel(WScreen *scr) WMColor *color; if (gnustepPanel) { - if (gnustepPanel->scr == scr) { - wRaiseFrame(gnustepPanel->wwin->frame->core); - wSetFocusTo(scr, gnustepPanel->wwin); - } - return; + if (gnustepPanel->scr == scr) { + wRaiseFrame(gnustepPanel->wwin->frame->core); + wSetFocusTo(scr, gnustepPanel->wwin); + } + return; } panel = wmalloc(sizeof(GNUstepPanel)); @@ -1935,18 +1935,18 @@ wShowGNUstepPanel(WScreen *scr) WMResizeWidget(panel->win, 325, 205); pixmap = WMCreatePixmap(scr->wmscreen, 130, 130, - WMScreenDepth(scr->wmscreen), True); + WMScreenDepth(scr->wmscreen), True); color = WMCreateNamedColor(scr->wmscreen, "gray50", True); drawGNUstepLogo(dpy, WMGetPixmapXID(pixmap), 130, 130, - WMColorPixel(color), scr->white_pixel); + WMColorPixel(color), scr->white_pixel); WMReleaseColor(color); XSetForeground(dpy, scr->mono_gc, 0); XFillRectangle(dpy, WMGetPixmapMaskXID(pixmap), scr->mono_gc, 0, 0, - 130, 130); + 130, 130); drawGNUstepLogo(dpy, WMGetPixmapMaskXID(pixmap), 130, 130, 1, 1); panel->gstepL = WMCreateLabel(panel->win); @@ -1955,10 +1955,10 @@ wShowGNUstepPanel(WScreen *scr) WMSetLabelTextAlignment(panel->gstepL, WARight); WMSetLabelText(panel->gstepL, "GNUstep"); { - WMFont *font = WMBoldSystemFontOfSize(scr->wmscreen, 24); + WMFont *font = WMBoldSystemFontOfSize(scr->wmscreen, 24); - WMSetLabelFont(panel->gstepL, font); - WMReleaseFont(font); + WMSetLabelFont(panel->gstepL, font); + WMReleaseFont(font); } panel->textL = WMCreateLabel(panel->win); @@ -1967,15 +1967,15 @@ wShowGNUstepPanel(WScreen *scr) WMSetLabelTextAlignment(panel->textL, WARight); WMSetLabelImagePosition(panel->textL, WIPOverlaps); WMSetLabelText(panel->textL, - _("Window Maker is part of the GNUstep project.\n"\ - "The GNUstep project aims to create a free\n"\ - "implementation of the OpenStep(tm) specification\n"\ - "which is a object-oriented framework for\n"\ - "creating advanced graphical, multi-platform\n"\ - "applications. Additionally, a development and\n"\ - "user desktop enviroment will be created on top\n"\ - "of the framework. For more information about\n"\ - "GNUstep, please visit: www.gnustep.org")); + _("Window Maker is part of the GNUstep project.\n"\ + "The GNUstep project aims to create a free\n"\ + "implementation of the OpenStep(tm) specification\n"\ + "which is a object-oriented framework for\n"\ + "creating advanced graphical, multi-platform\n"\ + "applications. Additionally, a development and\n"\ + "user desktop enviroment will be created on top\n"\ + "of the framework. For more information about\n"\ + "GNUstep, please visit: www.gnustep.org")); WMSetLabelImage(panel->textL, pixmap); WMReleasePixmap(pixmap); @@ -1988,11 +1988,11 @@ wShowGNUstepPanel(WScreen *scr) XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); { - WMPoint center = getCenter(scr, 325, 200); - - wwin = wManageInternalWindow(scr, parent, None, _("About GNUstep"), - center.x, center.y, - 325, 200); + WMPoint center = getCenter(scr, 325, 200); + + wwin = wManageInternalWindow(scr, parent, None, _("About GNUstep"), + center.x, center.y, + 325, 200); } WSETUFLAG(wwin, no_closable, 0); @@ -2012,3 +2012,4 @@ wShowGNUstepPanel(WScreen *scr) gnustepPanel = panel; } + diff --git a/src/dialog.h b/src/dialog.h index dc801bca..1c4af3b1 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -31,8 +31,8 @@ enum { }; -int wMessageDialog(WScreen *scr, char *title, char *message, - char *defBtn, char *altBtn, char *othBtn); +int wMessageDialog(WScreen *scr, char *title, char *message, + char *defBtn, char *altBtn, char *othBtn); int wInputDialog(WScreen *scr, char *title, char *message, char **text); int wExitDialog(WScreen *scr, char *title, char *message, char *defBtn, diff --git a/src/dock.c b/src/dock.c index c89fb275..37e6f2c8 100644 --- a/src/dock.c +++ b/src/dock.c @@ -164,10 +164,10 @@ static void make_keys() { if (dCommand!=NULL) - return; + return; dCommand = WMRetainPropList(WMCreatePLString("Command")); - dPasteCommand = WMRetainPropList(WMCreatePLString("PasteCommand")); + dPasteCommand = WMRetainPropList(WMCreatePLString("PasteCommand")); dDropCommand = WMRetainPropList(WMCreatePLString("DropCommand")); dLock = WMRetainPropList(WMCreatePLString("Lock")); dAutoLaunch = WMRetainPropList(WMCreatePLString("AutoLaunch")); @@ -210,11 +210,11 @@ renameCallback(WMenu *menu, WMenuEntry *entry) snprintf(buffer, sizeof(buffer), _("Type the name for workspace %i:"), wspace+1); if (wInputDialog(dock->screen_ptr, _("Rename Workspace"), buffer, - &name)) { - wWorkspaceRename(dock->screen_ptr, wspace, name); + &name)) { + wWorkspaceRename(dock->screen_ptr, wspace, name); } if (name) { - wfree(name); + wfree(name); } } @@ -248,7 +248,7 @@ killCallback(WMenu *menu, WMenuEntry *entry) char *buffer; if (!WCHECK_STATE(WSTATE_NORMAL)) - return; + return; assert(entry->clientdata!=NULL); @@ -259,9 +259,9 @@ killCallback(WMenu *menu, WMenuEntry *entry) WCHANGE_STATE(WSTATE_MODAL); buffer = wstrconcat(icon->wm_class, - _(" will be forcibly closed.\n" - "Any unsaved changes will be lost.\n" - "Please confirm.")); + _(" will be forcibly closed.\n" + "Any unsaved changes will be lost.\n" + "Please confirm.")); if (icon->icon && icon->icon->owner) { fPtr = icon->icon->owner->fake_group; @@ -278,8 +278,8 @@ killCallback(WMenu *menu, WMenuEntry *entry) } if (wPreferences.dont_confirm_kill - || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"), - buffer, _("Yes"), _("No"), NULL)==WAPRDefault) { + || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"), + buffer, _("Yes"), _("No"), NULL)==WAPRDefault) { if (fPtr!=NULL) { WWindow *wwin, *twin; @@ -292,8 +292,8 @@ killCallback(WMenu *menu, WMenuEntry *entry) wwin = twin; } } else if (icon->icon && icon->icon->owner) { - wClientKill(icon->icon->owner); - } + wClientKill(icon->icon->owner); + } } wfree(buffer); @@ -333,7 +333,7 @@ getSelected(WDock *dock) for (i=1; imax_icons; i++) { btn = dock->icon_array[i]; if (btn && btn->icon->selected) { - WMAddToArray(ret, btn); + WMAddToArray(ret, btn); } } @@ -365,31 +365,31 @@ paintClipButtons(WAppIcon *clipIcon, Bool lpushed, Bool rpushed) XSetForeground(dpy, gc, WMColorPixel(color)); if (rpushed) { - p[0].x = tp+1; - p[0].y = 1; - p[1].x = ICON_SIZE-2; - p[1].y = 1; - p[2].x = ICON_SIZE-2; - p[2].y = pt-1; + p[0].x = tp+1; + p[0].y = 1; + p[1].x = ICON_SIZE-2; + p[1].y = 1; + p[2].x = ICON_SIZE-2; + p[2].y = pt-1; } else if (lpushed) { - p[0].x = 1; - p[0].y = tp; - p[1].x = pt; - p[1].y = ICON_SIZE-2; - p[2].x = 1; - p[2].y = ICON_SIZE-2; + p[0].x = 1; + p[0].y = tp; + p[1].x = pt; + p[1].y = ICON_SIZE-2; + p[2].x = 1; + p[2].y = ICON_SIZE-2; } if (lpushed || rpushed) { - XSetForeground(dpy, scr->draw_gc, scr->white_pixel); - XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin); - XSetForeground(dpy, scr->draw_gc, scr->black_pixel); + XSetForeground(dpy, scr->draw_gc, scr->white_pixel); + XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin); + XSetForeground(dpy, scr->draw_gc, scr->black_pixel); } #ifdef GRADIENT_CLIP_ARROW if (!collapsed) { - XSetFillStyle(dpy, scr->copy_gc, FillTiled); - XSetTile(dpy, scr->copy_gc, scr->clip_arrow_gradient); - XSetClipMask(dpy, scr->copy_gc, None); - gc = scr->copy_gc; + XSetFillStyle(dpy, scr->copy_gc, FillTiled); + XSetTile(dpy, scr->copy_gc, scr->clip_arrow_gradient); + XSetClipMask(dpy, scr->copy_gc, None); + gc = scr->copy_gc; } #endif /* GRADIENT_CLIP_ARROW */ @@ -405,10 +405,10 @@ paintClipButtons(WAppIcon *clipIcon, Bool lpushed, Bool rpushed) XDrawLines(dpy, win, scr->draw_gc, p, 4, CoordModeOrigin); } else { #ifdef GRADIENT_CLIP_ARROW - if (!collapsed) - XSetTSOrigin(dpy, gc, ICON_SIZE-6-as, 5); + if (!collapsed) + XSetTSOrigin(dpy, gc, ICON_SIZE-6-as, 5); #endif - XFillPolygon(dpy, win, gc, p,3,Convex,CoordModeOrigin); + XFillPolygon(dpy, win, gc, p,3,Convex,CoordModeOrigin); XDrawLines(dpy, win, gc, p,4,CoordModeOrigin); } @@ -420,19 +420,19 @@ paintClipButtons(WAppIcon *clipIcon, Bool lpushed, Bool rpushed) p[2].x = 4+as; p[2].y = ICON_SIZE-6; if (lpushed) { - XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin); + XFillPolygon(dpy, win, scr->draw_gc, p, 3, Convex, CoordModeOrigin); XDrawLines(dpy, win, scr->draw_gc, p, 4, CoordModeOrigin); } else { #ifdef GRADIENT_CLIP_ARROW - if (!collapsed) - XSetTSOrigin(dpy, gc, 5, ICON_SIZE-6-as); + if (!collapsed) + XSetTSOrigin(dpy, gc, 5, ICON_SIZE-6-as); #endif XFillPolygon(dpy, win, gc, p,3,Convex,CoordModeOrigin); XDrawLines(dpy, win, gc, p,4,CoordModeOrigin); } #ifdef GRADIENT_CLIP_ARROW if (!collapsed) - XSetFillStyle(dpy, scr->copy_gc, FillSolid); + XSetFillStyle(dpy, scr->copy_gc, FillSolid); #endif } @@ -463,33 +463,33 @@ wClipMakeTile(WScreen *scr, RImage *normalTile) /* top right */ ROperateLine(tile, RSubtractOperation, tp, 0, wPreferences.icon_size-2, - pt-1, &dark); + pt-1, &dark); RDrawLine(tile, tp-1, 0, wPreferences.icon_size-1, pt+1, &black); ROperateLine(tile, RAddOperation, tp, 2, wPreferences.icon_size-3, - pt, &light); + pt, &light); /* arrow bevel */ ROperateLine(tile, RSubtractOperation, ICON_SIZE - 7 - as, 4, ICON_SIZE - 5, 4, &dark); ROperateLine(tile, RSubtractOperation, ICON_SIZE - 6 - as, 5, - ICON_SIZE - 5, 6 + as, &dark); + ICON_SIZE - 5, 6 + as, &dark); ROperateLine(tile, RAddOperation, ICON_SIZE - 5, 4, ICON_SIZE - 5, 6 + as, - &light); + &light); /* bottom left */ ROperateLine(tile, RAddOperation, 2, tp+2, pt-2, - wPreferences.icon_size-3, &dark); + wPreferences.icon_size-3, &dark); RDrawLine(tile, 0, tp-1, pt+1, wPreferences.icon_size-1, &black); ROperateLine(tile, RSubtractOperation, 0, tp-2, pt+1, - wPreferences.icon_size-2, &light); + wPreferences.icon_size-2, &light); /* arrow bevel */ ROperateLine(tile, RSubtractOperation, 4, ICON_SIZE - 7 - as, 4, ICON_SIZE - 5, &dark); ROperateLine(tile, RSubtractOperation, 5, ICON_SIZE - 6 - as, - 6 + as, ICON_SIZE - 5, &dark); + 6 + as, ICON_SIZE - 5, &dark); ROperateLine(tile, RAddOperation, 4, ICON_SIZE - 5, 6 + as, ICON_SIZE - 5, - &light); + &light); return tile; } @@ -560,25 +560,25 @@ removeIconsCallback(WMenu *menu, WMenuEntry *entry) selectedIcons = getSelected(dock); if (WMGetArrayItemCount(selectedIcons)) { - if (wMessageDialog(dock->screen_ptr, _("Workspace Clip"), - _("All selected icons will be removed!"), - _("OK"), _("Cancel"), NULL)!=WAPRDefault) { - WMFreeArray(selectedIcons); - return; - } + if (wMessageDialog(dock->screen_ptr, _("Workspace Clip"), + _("All selected icons will be removed!"), + _("OK"), _("Cancel"), NULL)!=WAPRDefault) { + WMFreeArray(selectedIcons); + return; + } } else { - if (clickedIcon->xindex==0 && clickedIcon->yindex==0) { - WMFreeArray(selectedIcons); - return; - } - WMAddToArray(selectedIcons, clickedIcon); + if (clickedIcon->xindex==0 && clickedIcon->yindex==0) { + WMFreeArray(selectedIcons); + return; + } + WMAddToArray(selectedIcons, clickedIcon); } WM_ITERATE_ARRAY(selectedIcons, aicon, it) { keepit = aicon->running && wApplicationOf(aicon->main_window); wDockDetach(dock, aicon); if (keepit) { - /* XXX: can: aicon->icon == NULL ? */ + /* XXX: can: aicon->icon == NULL ? */ PlaceIcon(dock->screen_ptr, &aicon->x_pos, &aicon->y_pos, wGetHeadForWindow(aicon->icon->owner)); XMoveWindow(dpy, aicon->icon->core->window, aicon->x_pos, aicon->y_pos); @@ -607,44 +607,44 @@ keepIconsCallback(WMenu *menu, WMenuEntry *entry) selectedIcons = getSelected(dock); - if (!WMGetArrayItemCount(selectedIcons) - && clickedIcon!=dock->screen_ptr->clip_icon) { - char *command = NULL; - - if (!clickedIcon->command && !clickedIcon->editing) { - clickedIcon->editing = 1; - if (wInputDialog(dock->screen_ptr, _("Keep Icon"), - _("Type the command used to launch the application"), - &command)) { - if (command && (command[0]==0 || - (command[0]=='-' && command[1]==0))) { - wfree(command); - command = NULL; - } - clickedIcon->command = command; - clickedIcon->editing = 0; - } else { - clickedIcon->editing = 0; - if (command) - wfree(command); - WMFreeArray(selectedIcons); - return; - } - } - - WMAddToArray(selectedIcons, clickedIcon); + if (!WMGetArrayItemCount(selectedIcons) + && clickedIcon!=dock->screen_ptr->clip_icon) { + char *command = NULL; + + if (!clickedIcon->command && !clickedIcon->editing) { + clickedIcon->editing = 1; + if (wInputDialog(dock->screen_ptr, _("Keep Icon"), + _("Type the command used to launch the application"), + &command)) { + if (command && (command[0]==0 || + (command[0]=='-' && command[1]==0))) { + wfree(command); + command = NULL; + } + clickedIcon->command = command; + clickedIcon->editing = 0; + } else { + clickedIcon->editing = 0; + if (command) + wfree(command); + WMFreeArray(selectedIcons); + return; + } + } + + WMAddToArray(selectedIcons, clickedIcon); } WM_ITERATE_ARRAY(selectedIcons, aicon, it) { - if (aicon->icon->selected) + if (aicon->icon->selected) wIconSelect(aicon->icon); if (aicon && aicon->attracted && aicon->command) { - aicon->attracted = 0; - if (aicon->icon->shadowed) { - aicon->icon->shadowed = 0; - aicon->icon->force_paint = 1; - wAppIconPaint(aicon); - } + aicon->attracted = 0; + if (aicon->icon->shadowed) { + aicon->icon->shadowed = 0; + aicon->icon->force_paint = 1; + wAppIconPaint(aicon); + } } } WMFreeArray(selectedIcons); @@ -662,7 +662,7 @@ toggleAutoAttractCallback(WMenu *menu, WMenuEntry *entry) dock->attract_icons = !dock->attract_icons; /*if (!dock->attract_icons) - dock->keep_attracted = 0;*/ + dock->keep_attracted = 0;*/ entry->flags.indicator_on = dock->attract_icons; @@ -713,7 +713,7 @@ colectIconsCallback(WMenu *menu, WMenuEntry *entry) #endif /* ANIMATIONS */ } aicon->attracted = 1; - if (!aicon->icon->shadowed) { + if (!aicon->icon->shadowed) { aicon->icon->shadowed = 1; aicon->icon->force_paint = 1; /* We don't do an wAppIconPaint() here because it's in @@ -748,12 +748,12 @@ selectIconsCallback(WMenu *menu, WMenuEntry *entry) for (i=1; imax_icons; i++) { btn = dock->icon_array[i]; if (btn && !btn->icon->selected) { - wIconSelect(btn->icon); + wIconSelect(btn->icon); } } } else { WM_ITERATE_ARRAY(selectedIcons, btn, iter) { - wIconSelect(btn->icon); + wIconSelect(btn->icon); } } WMFreeArray(selectedIcons); @@ -822,7 +822,7 @@ settingsCallback(WMenu *menu, WMenuEntry *entry) WAppIcon *btn = (WAppIcon*)entry->clientdata; if (btn->editing) - return; + return; ShowDockAppSettingsPanel(btn); } @@ -836,10 +836,10 @@ hideCallback(WMenu *menu, WMenuEntry *entry) wapp = wApplicationOf(btn->icon->owner->main_window); if (wapp->flags.hidden) { - wWorkspaceChange(btn->icon->core->screen_ptr, wapp->last_workspace); - wUnhideApplication(wapp, False, False); + wWorkspaceChange(btn->icon->core->screen_ptr, wapp->last_workspace); + wUnhideApplication(wapp, False, False); } else { - wHideApplication(wapp); + wHideApplication(wapp); } } @@ -935,41 +935,41 @@ launchDockedApplication(WAppIcon *btn, Bool withSelection) { WScreen *scr = btn->icon->core->screen_ptr; - if (!btn->launching && - ((!withSelection && btn->command!=NULL) || - (withSelection && btn->paste_command!=NULL))) { - if (!btn->forced_dock) { - btn->relaunching = btn->running; - btn->running = 1; - } - if (btn->wm_instance || btn->wm_class) { - WWindowAttributes attr; - memset(&attr, 0, sizeof(WWindowAttributes)); - wDefaultFillAttributes(scr, btn->wm_instance, btn->wm_class, - &attr, NULL, True); - - if (!attr.no_appicon && !btn->buggy_app) - btn->launching = 1; - else - btn->running = 0; - } - btn->drop_launch = 0; - btn->paste_launch = withSelection; + if (!btn->launching && + ((!withSelection && btn->command!=NULL) || + (withSelection && btn->paste_command!=NULL))) { + if (!btn->forced_dock) { + btn->relaunching = btn->running; + btn->running = 1; + } + if (btn->wm_instance || btn->wm_class) { + WWindowAttributes attr; + memset(&attr, 0, sizeof(WWindowAttributes)); + wDefaultFillAttributes(scr, btn->wm_instance, btn->wm_class, + &attr, NULL, True); + + if (!attr.no_appicon && !btn->buggy_app) + btn->launching = 1; + else + btn->running = 0; + } + btn->drop_launch = 0; + btn->paste_launch = withSelection; scr->last_dock = btn->dock; btn->pid = execCommand(btn, (withSelection ? btn->paste_command : btn->command), NULL); if (btn->pid>0) { - if (btn->buggy_app) { - /* give feedback that the app was launched */ - btn->launching = 1; - dockIconPaint(btn); - btn->launching = 0; - WMAddTimerHandler(200, (WMCallback*)dockIconPaint, btn); - } else { - dockIconPaint(btn); - } + if (btn->buggy_app) { + /* give feedback that the app was launched */ + btn->launching = 1; + dockIconPaint(btn); + btn->launching = 0; + WMAddTimerHandler(200, (WMCallback*)dockIconPaint, btn); + } else { + dockIconPaint(btn); + } } else { - wwarning(_("could not launch application %s\n"), btn->command); + wwarning(_("could not launch application %s\n"), btn->command); btn->launching = 0; if (!btn->relaunching) { btn->running = 0; @@ -1085,7 +1085,7 @@ makeClipOptionsMenu(WScreen *scr) menu = wMenuCreate(scr, NULL, False); if (!menu) { wwarning(_("could not create options submenu for Clip menu")); - return NULL; + return NULL; } entry = wMenuAddCallback(menu, _("Keep on Top"), @@ -1263,7 +1263,7 @@ wDockDestroy(WDock *dock) int keepit = aicon->running && wApplicationOf(aicon->main_window); wDockDetach(dock, aicon); if (keepit) { - /* XXX: can: aicon->icon == NULL ? */ + /* XXX: can: aicon->icon == NULL ? */ PlaceIcon(dock->screen_ptr, &aicon->x_pos, &aicon->y_pos, wGetHeadForWindow(aicon->icon->owner)); XMoveWindow(dpy, aicon->icon->core->window, aicon->x_pos, aicon->y_pos); @@ -1312,24 +1312,24 @@ wClipIconPaint(WAppIcon *aicon) tx = CLIP_BUTTON_SIZE*ICON_SIZE/64; WMDrawString(scr->wmscreen, win, color, scr->clip_title_font, tx, - ty, ws_name, length); + ty, ws_name, length); /*WMDrawString(scr->wmscreen, win, color, scr->clip_title_font, 4, - 2, ws_name, length);*/ + 2, ws_name, length);*/ tx = (ICON_SIZE/2 - WMWidthOfString(scr->clip_title_font, ws_number, - nlength))/2; + nlength))/2; WMDrawString(scr->wmscreen, win, color, scr->clip_title_font, tx, - 2, ws_number, nlength); + 2, ws_number, nlength); wfree(ws_name); if (aicon->launching) { - XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc, - 0, 0, wPreferences.icon_size, wPreferences.icon_size); + XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc, + 0, 0, wPreferences.icon_size, wPreferences.icon_size); } paintClipButtons(aicon, aicon->dock->lclip_button_pushed, - aicon->dock->rclip_button_pushed); + aicon->dock->rclip_button_pushed); } @@ -1360,24 +1360,24 @@ make_icon_state(WAppIcon *btn) char buffer[64]; if (btn) { - if (!btn->command) - command = WMCreatePLString("-"); - else - command = WMCreatePLString(btn->command); + if (!btn->command) + command = WMCreatePLString("-"); + else + command = WMCreatePLString(btn->command); - autolaunch = btn->auto_launch ? dYes : dNo; + autolaunch = btn->auto_launch ? dYes : dNo; - lock = btn->lock ? dYes : dNo; + lock = btn->lock ? dYes : dNo; - tmp = EscapeWM_CLASS(btn->wm_instance, btn->wm_class); + tmp = EscapeWM_CLASS(btn->wm_instance, btn->wm_class); - name = WMCreatePLString(tmp); + name = WMCreatePLString(tmp); - wfree(tmp); + wfree(tmp); - forced = btn->forced_dock ? dYes : dNo; + forced = btn->forced_dock ? dYes : dNo; - buggy = btn->buggy_app ? dYes : dNo; + buggy = btn->buggy_app ? dYes : dNo; if (btn == btn->icon->core->screen_ptr->clip_icon) snprintf(buffer, sizeof(buffer), "%i,%i", btn->x_pos, btn->y_pos); @@ -1407,20 +1407,20 @@ make_icon_state(WAppIcon *btn) command = WMCreatePLString(btn->dnd_command); WMPutInPLDictionary(node, dDropCommand, command); WMReleasePropList(command); - } + } #endif /* OFFIX_DND */ - - if (btn->paste_command) { - command = WMCreatePLString(btn->paste_command); - WMPutInPLDictionary(node, dPasteCommand, command); - WMReleasePropList(command); - } - if (btn->client_machine && btn->remote_start) { - host = WMCreatePLString(btn->client_machine); - WMPutInPLDictionary(node, dHost, host); - WMReleasePropList(host); - } + if (btn->paste_command) { + command = WMCreatePLString(btn->paste_command); + WMPutInPLDictionary(node, dPasteCommand, command); + WMReleasePropList(command); + } + + if (btn->client_machine && btn->remote_start) { + host = WMCreatePLString(btn->client_machine); + WMPutInPLDictionary(node, dHost, host); + WMReleasePropList(host); + } } return node; @@ -1449,18 +1449,18 @@ dockSaveState(WDock *dock) WMReleasePropList(icon_info); } } - + dock_state = WMCreatePLDictionary(dApplications, list, NULL); if (dock->type == WM_DOCK) { - snprintf(buffer, sizeof(buffer), "Applications%i", dock->screen_ptr->scr_height); - key = WMCreatePLString(buffer); - WMPutInPLDictionary(dock_state, key, list); - WMReleasePropList(key); + snprintf(buffer, sizeof(buffer), "Applications%i", dock->screen_ptr->scr_height); + key = WMCreatePLString(buffer); + WMPutInPLDictionary(dock_state, key, list); + WMReleasePropList(key); + - snprintf(buffer, sizeof(buffer), "%i,%i", (dock->on_right_side ? -ICON_SIZE : 0), - dock->y_pos); + dock->y_pos); value = WMCreatePLString(buffer); WMPutInPLDictionary(dock_state, dPosition, value); WMReleasePropList(value); @@ -1476,10 +1476,10 @@ dockSaveState(WDock *dock) WMPutInPLDictionary(dock_state, dCollapsed, value); value = (dock->auto_collapse ? dYes : dNo); - WMPutInPLDictionary(dock_state, dAutoCollapse, value); + WMPutInPLDictionary(dock_state, dAutoCollapse, value); value = (dock->auto_raise_lower ? dYes : dNo); - WMPutInPLDictionary(dock_state, dAutoRaiseLower, value); + WMPutInPLDictionary(dock_state, dAutoRaiseLower, value); value = (dock->attract_icons ? dYes : dNo); WMPutInPLDictionary(dock_state, dAutoAttractIcons, value); @@ -1501,23 +1501,23 @@ wDockSaveState(WScreen *scr, WMPropList *old_state) * Copy saved states of docks with different sizes. */ if (old_state) { - int i; - WMPropList *tmp; + int i; + WMPropList *tmp; - keys = WMGetPLDictionaryKeys(old_state); - for (i = 0; i < WMGetPropListItemCount(keys); i++) { - tmp = WMGetFromPLArray(keys, i); + keys = WMGetPLDictionaryKeys(old_state); + for (i = 0; i < WMGetPropListItemCount(keys); i++) { + tmp = WMGetFromPLArray(keys, i); - if (strncasecmp(WMGetFromPLString(tmp), "applications", 12) == 0 - && !WMGetFromPLDictionary(dock_state, tmp)) { + if (strncasecmp(WMGetFromPLString(tmp), "applications", 12) == 0 + && !WMGetFromPLDictionary(dock_state, tmp)) { WMPutInPLDictionary(dock_state, tmp, WMGetFromPLDictionary(old_state, tmp)); - } - } - WMReleasePropList(keys); + } + } + WMReleasePropList(keys); } - + WMPutInPLDictionary(scr->session_state, dDock, dock_state); @@ -1570,50 +1570,50 @@ restore_icon_state(WScreen *scr, WMPropList *info, int type, int index) cmd = WMGetFromPLDictionary(info, dCommand); if (!cmd || !WMIsPLString(cmd)) { - return NULL; + return NULL; } /* parse window name */ value = WMGetFromPLDictionary(info, dName); if (!value) - return NULL; + return NULL; { - char *wclass, *winstance; - char *command; - - ParseWindowName(value, &winstance, &wclass, "dock"); - - if (!winstance && !wclass) { - return NULL; - } - - /* get commands */ - - if (cmd) - command = wstrdup(WMGetFromPLString(cmd)); - else - command = NULL; - - if (!command || strcmp(command, "-")==0) { - if (command) - wfree(command); - if (wclass) - wfree(wclass); - if (winstance) - wfree(winstance); - - return NULL; - } - - aicon = wAppIconCreateForDock(scr, command, winstance, wclass, - TILE_NORMAL); - if (wclass) - wfree(wclass); - if (winstance) - wfree(winstance); - if (command) - wfree(command); + char *wclass, *winstance; + char *command; + + ParseWindowName(value, &winstance, &wclass, "dock"); + + if (!winstance && !wclass) { + return NULL; + } + + /* get commands */ + + if (cmd) + command = wstrdup(WMGetFromPLString(cmd)); + else + command = NULL; + + if (!command || strcmp(command, "-")==0) { + if (command) + wfree(command); + if (wclass) + wfree(wclass); + if (winstance) + wfree(winstance); + + return NULL; + } + + aicon = wAppIconCreateForDock(scr, command, winstance, wclass, + TILE_NORMAL); + if (wclass) + wfree(wclass); + if (winstance) + wfree(winstance); + if (command) + wfree(command); } aicon->icon->core->descriptor.handle_mousedown = iconMouseDown; @@ -1628,12 +1628,12 @@ restore_icon_state(WScreen *scr, WMPropList *info, int type, int index) #ifdef OFFIX_DND cmd = WMGetFromPLDictionary(info, dDropCommand); if (cmd) - aicon->dnd_command = wstrdup(WMGetFromPLString(cmd)); + aicon->dnd_command = wstrdup(WMGetFromPLString(cmd)); #endif - + cmd = WMGetFromPLDictionary(info, dPasteCommand); if (cmd) - aicon->paste_command = wstrdup(WMGetFromPLString(cmd)); + aicon->paste_command = wstrdup(WMGetFromPLString(cmd)); /* check auto launch */ value = WMGetFromPLDictionary(info, dAutoLaunch); @@ -1701,7 +1701,7 @@ wClipRestoreState(WScreen *scr, WMPropList *clip_state) icon = mainIconCreate(scr, WM_CLIP); if (!clip_state) - return icon; + return icon; else WMRetainPropList(clip_state); @@ -1710,37 +1710,37 @@ wClipRestoreState(WScreen *scr, WMPropList *clip_state) value = WMGetFromPLDictionary(clip_state, dPosition); if (value) { - if (!WMIsPLString(value)) - COMPLAIN("Position"); - else { - WMRect rect; - int flags; - - if (sscanf(WMGetFromPLString(value), "%i,%i", &icon->x_pos, - &icon->y_pos)!=2) - COMPLAIN("Position"); - - /* check position sanity */ - rect.pos.x = icon->x_pos; - rect.pos.y = icon->y_pos; - rect.size.width = rect.size.height = ICON_SIZE; - - wGetRectPlacementInfo(scr, rect, &flags); - if (flags & (XFLAG_DEAD | XFLAG_PARTIAL)) - wScreenKeepInside(scr, &icon->x_pos, &icon->y_pos, - ICON_SIZE, ICON_SIZE); - } + if (!WMIsPLString(value)) + COMPLAIN("Position"); + else { + WMRect rect; + int flags; + + if (sscanf(WMGetFromPLString(value), "%i,%i", &icon->x_pos, + &icon->y_pos)!=2) + COMPLAIN("Position"); + + /* check position sanity */ + rect.pos.x = icon->x_pos; + rect.pos.y = icon->y_pos; + rect.size.width = rect.size.height = ICON_SIZE; + + wGetRectPlacementInfo(scr, rect, &flags); + if (flags & (XFLAG_DEAD | XFLAG_PARTIAL)) + wScreenKeepInside(scr, &icon->x_pos, &icon->y_pos, + ICON_SIZE, ICON_SIZE); + } } #ifdef OFFIX_DND value = WMGetFromPLDictionary(clip_state, dDropCommand); if (value && WMIsPLString(value)) - icon->dnd_command = wstrdup(WMGetFromPLString(value)); + icon->dnd_command = wstrdup(WMGetFromPLString(value)); #endif - + value = WMGetFromPLDictionary(clip_state, dPasteCommand); if (value && WMIsPLString(value)) - icon->paste_command = wstrdup(WMGetFromPLString(value)); + icon->paste_command = wstrdup(WMGetFromPLString(value)); WMReleasePropList(clip_state); @@ -1775,23 +1775,23 @@ wDockRestoreState(WScreen *scr, WMPropList *dock_state, int type) if (!WMIsPLString(value)) { COMPLAIN("Position"); } else { - WMRect rect; - int flags; + WMRect rect; + int flags; if (sscanf(WMGetFromPLString(value), "%i,%i", &dock->x_pos, &dock->y_pos)!=2) COMPLAIN("Position"); /* check position sanity */ - rect.pos.x = dock->x_pos; - rect.pos.y = dock->y_pos; - rect.size.width = rect.size.height = ICON_SIZE; - - wGetRectPlacementInfo(scr, rect, &flags); - if (flags & (XFLAG_DEAD | XFLAG_PARTIAL)) { - int x = dock->x_pos; - wScreenKeepInside(scr, &x, &dock->y_pos, ICON_SIZE, ICON_SIZE); - } + rect.pos.x = dock->x_pos; + rect.pos.y = dock->y_pos; + rect.size.width = rect.size.height = ICON_SIZE; + + wGetRectPlacementInfo(scr, rect, &flags); + if (flags & (XFLAG_DEAD | XFLAG_PARTIAL)) { + int x = dock->x_pos; + wScreenKeepInside(scr, &x, &dock->y_pos, ICON_SIZE, ICON_SIZE); + } /* Is this needed any more? */ if (type == WM_CLIP) { @@ -1854,10 +1854,10 @@ wDockRestoreState(WScreen *scr, WMPropList *dock_state, int type) if (!WMIsPLString(value)) { COMPLAIN("AutoCollapse"); } else { - if (strcasecmp(WMGetFromPLString(value), "YES")==0) { + if (strcasecmp(WMGetFromPLString(value), "YES")==0) { dock->auto_collapse = 1; - dock->collapsed = 1; - } + dock->collapsed = 1; + } } } @@ -1870,9 +1870,9 @@ wDockRestoreState(WScreen *scr, WMPropList *dock_state, int type) if (!WMIsPLString(value)) { COMPLAIN("AutoRaiseLower"); } else { - if (strcasecmp(WMGetFromPLString(value), "YES")==0) { + if (strcasecmp(WMGetFromPLString(value), "YES")==0) { dock->auto_raise_lower = 1; - } + } } } @@ -1894,28 +1894,28 @@ wDockRestoreState(WScreen *scr, WMPropList *dock_state, int type) /* application list */ - + { - WMPropList *tmp; - char buffer[64]; - - /* - * When saving, it saves the dock state in - * Applications and Applicationsnnn - * - * When loading, it will first try Applicationsnnn. - * If it does not exist, use Applications as default. - */ - - snprintf(buffer, sizeof(buffer), "Applications%i", scr->scr_height); - - tmp = WMCreatePLString(buffer); - apps = WMGetFromPLDictionary(dock_state, tmp); - WMReleasePropList(tmp); - - if (!apps) { - apps = WMGetFromPLDictionary(dock_state, dApplications); - } + WMPropList *tmp; + char buffer[64]; + + /* + * When saving, it saves the dock state in + * Applications and Applicationsnnn + * + * When loading, it will first try Applicationsnnn. + * If it does not exist, use Applications as default. + */ + + snprintf(buffer, sizeof(buffer), "Applications%i", scr->scr_height); + + tmp = WMCreatePLString(buffer); + apps = WMGetFromPLDictionary(dock_state, tmp); + WMReleasePropList(tmp); + + if (!apps) { + apps = WMGetFromPLDictionary(dock_state, dApplications); + } } if (!apps) { @@ -2004,7 +2004,7 @@ wDockLaunchWithState(WDock *dock, WAppIcon *btn, WSavedState *state) if (btn && btn->command && !btn->running && !btn->launching) { btn->drop_launch = 0; - btn->paste_launch = 0; + btn->paste_launch = 0; btn->pid = execCommand(btn, btn->command, state); @@ -2035,8 +2035,8 @@ wDockDoAutoLaunch(WDock *dock, int workspace) state = wmalloc(sizeof(WSavedState)); memset(state, 0, sizeof(WSavedState)); state->workspace = workspace; - /* TODO: this is klugy and is very difficult to understand - * what's going on. Try to clean up */ + /* TODO: this is klugy and is very difficult to understand + * what's going on. Try to clean up */ wDockLaunchWithState(dock, btn, state); } } @@ -2083,7 +2083,7 @@ wDockReceiveDNDDrop(WScreen *scr, XEvent *event) dock = findDock(scr, event, &icon_pos); if (!dock) - return False; + return False; /* * Return True if the drop was on an application icon window. @@ -2104,7 +2104,7 @@ wDockReceiveDNDDrop(WScreen *scr, XEvent *event) } if (btn->wm_instance || btn->wm_class) { WWindowAttributes attr; - memset(&attr, 0, sizeof(WWindowAttributes)); + memset(&attr, 0, sizeof(WWindowAttributes)); wDefaultFillAttributes(btn->icon->core->screen_ptr, btn->wm_instance, btn->wm_class, &attr, NULL, True); @@ -2115,7 +2115,7 @@ wDockReceiveDNDDrop(WScreen *scr, XEvent *event) btn->running = 0; } - btn->paste_launch = 0; + btn->paste_launch = 0; btn->drop_launch = 1; scr->last_dock = dock; btn->pid = execCommand(btn, btn->dnd_command, NULL); @@ -2148,49 +2148,49 @@ wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y) command = GetCommandForWindow(wwin->client_win); if (command) { - icon->command = command; - } else { + icon->command = command; + } else { /* icon->forced_dock = 1;*/ if (dock->type!=WM_CLIP || !icon->attracted) { - icon->editing = 1; + icon->editing = 1; if (wInputDialog(dock->screen_ptr, _("Dock Icon"), _("Type the command used to launch the application"), - &command)) { + &command)) { if (command && (command[0]==0 || (command[0]=='-' && command[1]==0))) { wfree(command); command = NULL; } icon->command = command; - icon->editing = 0; + icon->editing = 0; } else { - icon->editing = 0; - if (command) - wfree(command); - /* If the target is the dock, reject the icon. If - * the target is the clip, make it an attracted icon - */ - if (dock->type==WM_CLIP) { - icon->attracted = 1; - if (!icon->icon->shadowed) { - icon->icon->shadowed = 1; - icon->icon->force_paint = 1; - } - } else { - return False; - } + icon->editing = 0; + if (command) + wfree(command); + /* If the target is the dock, reject the icon. If + * the target is the clip, make it an attracted icon + */ + if (dock->type==WM_CLIP) { + icon->attracted = 1; + if (!icon->icon->shadowed) { + icon->icon->shadowed = 1; + icon->icon->force_paint = 1; + } + } else { + return False; + } } } } } else { - icon->editing = 0; + icon->editing = 0; } for (index=1; indexmax_icons; index++) if (dock->icon_array[index] == NULL) break; /* if (index == dock->max_icons) - return; */ + return; */ assert(index < dock->max_icons); @@ -2227,18 +2227,18 @@ wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y) #ifdef OFFIX_DND if (icon->command && !icon->dnd_command) { - int len = strlen(icon->command)+8; - icon->dnd_command = wmalloc(len); - snprintf(icon->dnd_command, len, "%s %%d", icon->command); + int len = strlen(icon->command)+8; + icon->dnd_command = wmalloc(len); + snprintf(icon->dnd_command, len, "%s %%d", icon->command); } #endif if (icon->command && !icon->paste_command) { - int len = strlen(icon->command)+8; - icon->paste_command = wmalloc(len); - snprintf(icon->paste_command, len, "%s %%s", icon->command); + int len = strlen(icon->command)+8; + icon->paste_command = wmalloc(len); + snprintf(icon->paste_command, len, "%s %%s", icon->command); } - + return True; } @@ -2288,10 +2288,10 @@ moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, int y) if (command) { icon->command = command; } else { - icon->editing = 1; + icon->editing = 1; /* icon->forced_dock = 1;*/ if (wInputDialog(src->screen_ptr, _("Dock Icon"), - _("Type the command used to launch the application"), + _("Type the command used to launch the application"), &command)) { if (command && (command[0]==0 || (command[0]=='-' && command[1]==0))) { @@ -2300,12 +2300,12 @@ moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, int y) } icon->command = command; } else { - icon->editing = 0; - if (command) - wfree(command); - return False; + icon->editing = 0; + if (command) + wfree(command); + return False; } - icon->editing = 0; + icon->editing = 0; } } @@ -2326,7 +2326,7 @@ moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, int y) break; } /* if (index == dest->max_icons) - return; */ + return; */ assert(index < dest->max_icons); @@ -2349,11 +2349,11 @@ moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, int y) * Unless the icon does not have a command set */ if (icon->command && dest->type==WM_DOCK) { - icon->attracted = 0; - if (icon->icon->shadowed) { - icon->icon->shadowed = 0; - icon->icon->force_paint = 1; - } + icon->attracted = 0; + if (icon->icon->shadowed) { + icon->icon->shadowed = 0; + icon->icon->force_paint = 1; + } } if (src->auto_collapse || src->auto_raise_lower) @@ -2382,7 +2382,7 @@ wDockDetach(WDock *dock, WAppIcon *icon) /* make the settings panel be closed */ if (icon->panel) { - DestroyDockAppSettingsPanel(icon->panel); + DestroyDockAppSettingsPanel(icon->panel); } /* This must be called before icon->dock is set to NULL. @@ -2395,17 +2395,17 @@ wDockDetach(WDock *dock, WAppIcon *icon) icon->attracted = 0; icon->auto_launch = 0; if (icon->icon->shadowed) { - icon->icon->shadowed = 0; - icon->icon->force_paint = 1; + icon->icon->shadowed = 0; + icon->icon->force_paint = 1; } /* deselect the icon */ if (icon->icon->selected) - wIconSelect(icon->icon); + wIconSelect(icon->icon); if (icon->command) { - wfree(icon->command); - icon->command = NULL; + wfree(icon->command); + icon->command = NULL; } #ifdef OFFIX_DND if (icon->dnd_command) { @@ -2416,7 +2416,7 @@ wDockDetach(WDock *dock, WAppIcon *icon) if (icon->paste_command) { wfree(icon->paste_command); icon->paste_command = NULL; - } + } for (index=1; indexmax_icons; index++) if (dock->icon_array[index] == icon) @@ -2432,20 +2432,20 @@ wDockDetach(WDock *dock, WAppIcon *icon) * the the application did not set the approriate hints yet, * destroy the icon */ if (!icon->running || !wApplicationOf(icon->main_window)) - wAppIconDestroy(icon); + wAppIconDestroy(icon); else { - icon->icon->core->descriptor.handle_mousedown = appIconMouseDown; - icon->icon->core->descriptor.handle_enternotify = NULL; - icon->icon->core->descriptor.handle_leavenotify = NULL; + icon->icon->core->descriptor.handle_mousedown = appIconMouseDown; + icon->icon->core->descriptor.handle_enternotify = NULL; + icon->icon->core->descriptor.handle_leavenotify = NULL; icon->icon->core->descriptor.parent_type = WCLASS_APPICON; - icon->icon->core->descriptor.parent = icon; + icon->icon->core->descriptor.parent = icon; - ChangeStackingLevel(icon->icon->core, NORMAL_ICON_LEVEL); + ChangeStackingLevel(icon->icon->core, NORMAL_ICON_LEVEL); - wAppIconPaint(icon); + wAppIconPaint(icon); if (wPreferences.auto_arrange_icons) { - wArrangeIcons(dock->screen_ptr, True); - } + wArrangeIcons(dock->screen_ptr, True); + } } if (dock->auto_collapse || dock->auto_raise_lower) clipLeave(dock); @@ -2463,7 +2463,7 @@ wDockDetach(WDock *dock, WAppIcon *icon) */ Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, - int *ret_x, int *ret_y, int redocking) + int *ret_x, int *ret_y, int redocking) { WScreen *scr = dock->screen_ptr; int dx, dy; @@ -2478,7 +2478,7 @@ wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, max_y_icons = scr->scr_height/ICON_SIZE-1; if (wPreferences.flags.noupdates) - return False; + return False; dx = dock->x_pos; dy = dock->y_pos; @@ -2486,7 +2486,7 @@ wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, /* if the dock is full */ if (!redocking && (dock->icon_count >= dock->max_icons)) { - return False; + return False; } /* exact position */ @@ -2502,97 +2502,97 @@ wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, /* check if the icon is outside the screen boundaries */ { - WMRect rect; - int flags; + WMRect rect; + int flags; - rect.pos.x = dx + ex_x*ICON_SIZE; - rect.pos.y = dy + ex_y*ICON_SIZE; - rect.size.width = rect.size.height = ICON_SIZE; + rect.pos.x = dx + ex_x*ICON_SIZE; + rect.pos.y = dy + ex_y*ICON_SIZE; + rect.size.width = rect.size.height = ICON_SIZE; - wGetRectPlacementInfo(scr, rect, &flags); - if (flags & (XFLAG_DEAD | XFLAG_PARTIAL)) - return False; + wGetRectPlacementInfo(scr, rect, &flags); + if (flags & (XFLAG_DEAD | XFLAG_PARTIAL)) + return False; } if (dock->type == WM_DOCK) { - if (icon->dock != dock && ex_x != 0) - return False; + if (icon->dock != dock && ex_x != 0) + return False; aicon = NULL; - for (i=0; imax_icons; i++) { - nicon = dock->icon_array[i]; - if (nicon && nicon->yindex == ex_y) { - aicon = nicon; - break; - } - } - - if (redocking) { - int sig, done, closest; - - /* Possible cases when redocking: - * - * icon dragged out of range of any slot -> false - * icon dragged to range of free slot - * icon dragged to range of same slot - * icon dragged to range of different icon - */ - if (abs(ex_x) > DOCK_DETTACH_THRESHOLD) - return False; - - if (ex_y>=0 && ex_y<=max_y_icons && (aicon==icon || !aicon)) { + for (i=0; imax_icons; i++) { + nicon = dock->icon_array[i]; + if (nicon && nicon->yindex == ex_y) { + aicon = nicon; + break; + } + } + + if (redocking) { + int sig, done, closest; + + /* Possible cases when redocking: + * + * icon dragged out of range of any slot -> false + * icon dragged to range of free slot + * icon dragged to range of same slot + * icon dragged to range of different icon + */ + if (abs(ex_x) > DOCK_DETTACH_THRESHOLD) + return False; + + if (ex_y>=0 && ex_y<=max_y_icons && (aicon==icon || !aicon)) { *ret_x = 0; *ret_y = ex_y; return True; - } - - /* start looking at the upper slot or lower? */ - if (ex_y*ICON_SIZE < (req_y + offset - dy)) - sig = 1; - else - sig = -1; - - closest = -1; - done = 0; - /* look for closest free slot */ - for (i=0; i<(DOCK_DETTACH_THRESHOLD+1)*2 && !done; i++) { - int j; - - done = 1; - closest = sig*(i/2) + ex_y; - /* check if this slot is used */ - if (closest >= 0) { - for (j = 0; jmax_icons; j++) { - if (dock->icon_array[j] - && dock->icon_array[j]->yindex==closest) { - /* slot is used by someone else */ - if (dock->icon_array[j]!=icon) - done = 0; - break; - } - } - } - sig = -sig; - } - if (done && closest >= 0 && closest <= max_y_icons && - ((ex_y >= closest && ex_y - closest < DOCK_DETTACH_THRESHOLD+1) - || - (ex_y < closest && closest - ex_y <= DOCK_DETTACH_THRESHOLD+1))) { + } + + /* start looking at the upper slot or lower? */ + if (ex_y*ICON_SIZE < (req_y + offset - dy)) + sig = 1; + else + sig = -1; + + closest = -1; + done = 0; + /* look for closest free slot */ + for (i=0; i<(DOCK_DETTACH_THRESHOLD+1)*2 && !done; i++) { + int j; + + done = 1; + closest = sig*(i/2) + ex_y; + /* check if this slot is used */ + if (closest >= 0) { + for (j = 0; jmax_icons; j++) { + if (dock->icon_array[j] + && dock->icon_array[j]->yindex==closest) { + /* slot is used by someone else */ + if (dock->icon_array[j]!=icon) + done = 0; + break; + } + } + } + sig = -sig; + } + if (done && closest >= 0 && closest <= max_y_icons && + ((ex_y >= closest && ex_y - closest < DOCK_DETTACH_THRESHOLD+1) + || + (ex_y < closest && closest - ex_y <= DOCK_DETTACH_THRESHOLD+1))) { *ret_x = 0; *ret_y = closest; return True; - } - } else { /* !redocking */ + } + } else { /* !redocking */ - /* if slot is free and the icon is close enough, return it */ - if (!aicon && ex_x == 0 && ex_y >= 0 && ex_y <= max_y_icons) { + /* if slot is free and the icon is close enough, return it */ + if (!aicon && ex_x == 0 && ex_y >= 0 && ex_y <= max_y_icons) { *ret_x = 0; *ret_y = ex_y; return True; - } - } + } + } } else { /* CLIP */ - int neighbours = 0; + int neighbours = 0; int start, stop, k; start = icon->omnipresent ? 0 : scr->current_workspace; @@ -2630,11 +2630,11 @@ wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, break; } - if (neighbours && (aicon==NULL || (redocking && aicon == icon))) { - *ret_x = ex_x; - *ret_y = ex_y; - return True; - } + if (neighbours && (aicon==NULL || (redocking && aicon == icon))) { + *ret_x = ex_x; + *ret_y = ex_y; + return True; + } } return False; } @@ -2678,7 +2678,7 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) /* if the dock is full */ if (dock->icon_count+extra_count >= dock->max_icons) { - return False; + return False; } if (!wPreferences.flags.nodock && scr->dock) { @@ -2700,146 +2700,146 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) /* check if clip is in a corner */ if (dock->type==WM_CLIP) { - if (dock->x_pos < 1 && dock->y_pos < 1) - corner = C_NE; - else if (dock->x_pos < 1 && dock->y_pos >= (ey-ICON_SIZE)) - corner = C_SE; - else if (dock->x_pos >= (ex-ICON_SIZE)&& dock->y_pos >= (ey-ICON_SIZE)) - corner = C_SW; - else if (dock->x_pos >= (ex-ICON_SIZE) && dock->y_pos < 1) - corner = C_NW; - else - corner = C_NONE; + if (dock->x_pos < 1 && dock->y_pos < 1) + corner = C_NE; + else if (dock->x_pos < 1 && dock->y_pos >= (ey-ICON_SIZE)) + corner = C_SE; + else if (dock->x_pos >= (ex-ICON_SIZE)&& dock->y_pos >= (ey-ICON_SIZE)) + corner = C_SW; + else if (dock->x_pos >= (ex-ICON_SIZE) && dock->y_pos < 1) + corner = C_NW; + else + corner = C_NONE; } else - corner = C_NONE; + corner = C_NONE; /* If the clip is in the corner, use only slots that are in the border * of the screen */ if (corner!=C_NONE) { - char *hmap, *vmap; - int hcount, vcount; - - hcount = WMIN(dock->max_icons, scr->scr_width/ICON_SIZE); - vcount = WMIN(dock->max_icons, scr->scr_height/ICON_SIZE); - hmap = wmalloc(hcount+1); - memset(hmap, 0, hcount+1); - vmap = wmalloc(vcount+1); - memset(vmap, 0, vcount+1); - - /* mark used positions */ - switch (corner) { - case C_NE: - for (i=0; imax_icons; i++) { - btn = dock->icon_array[i]; - if (!btn) - continue; - - if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) - vmap[btn->yindex] = 1; - else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; + char *hmap, *vmap; + int hcount, vcount; + + hcount = WMIN(dock->max_icons, scr->scr_width/ICON_SIZE); + vcount = WMIN(dock->max_icons, scr->scr_height/ICON_SIZE); + hmap = wmalloc(hcount+1); + memset(hmap, 0, hcount+1); + vmap = wmalloc(vcount+1); + memset(vmap, 0, vcount+1); + + /* mark used positions */ + switch (corner) { + case C_NE: + for (i=0; imax_icons; i++) { + btn = dock->icon_array[i]; + if (!btn) + continue; + + if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) + vmap[btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; } for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { btn = chain->aicon; - if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) - vmap[btn->yindex] = 1; - else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; + if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) + vmap[btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; } break; - case C_NW: - for (i=0; imax_icons; i++) { - btn = dock->icon_array[i]; - if (!btn) - continue; - - if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) - vmap[btn->yindex] = 1; - else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) - hmap[-btn->xindex] = 1; + case C_NW: + for (i=0; imax_icons; i++) { + btn = dock->icon_array[i]; + if (!btn) + continue; + + if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) + vmap[btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) + hmap[-btn->xindex] = 1; } for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { btn = chain->aicon; - if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) - vmap[btn->yindex] = 1; - else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) - hmap[-btn->xindex] = 1; + if (btn->xindex==0 && btn->yindex > 0 && btn->yindex < vcount) + vmap[btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) + hmap[-btn->xindex] = 1; } break; - case C_SE: - for (i=0; imax_icons; i++) { - btn = dock->icon_array[i]; - if (!btn) - continue; - - if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) - vmap[-btn->yindex] = 1; - else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; + case C_SE: + for (i=0; imax_icons; i++) { + btn = dock->icon_array[i]; + if (!btn) + continue; + + if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) + vmap[-btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; } for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { btn = chain->aicon; - if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) - vmap[-btn->yindex] = 1; - else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; + if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) + vmap[-btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex>0 && btn->xindexxindex] = 1; } break; - case C_SW: - default: - for (i=0; imax_icons; i++) { - btn = dock->icon_array[i]; - if (!btn) - continue; - - if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) - vmap[-btn->yindex] = 1; - else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) - hmap[-btn->xindex] = 1; - } + case C_SW: + default: + for (i=0; imax_icons; i++) { + btn = dock->icon_array[i]; + if (!btn) + continue; + + if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) + vmap[-btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) + hmap[-btn->xindex] = 1; + } for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { btn = chain->aicon; - if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) - vmap[-btn->yindex] = 1; - else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) - hmap[-btn->xindex] = 1; + if (btn->xindex==0 && btn->yindex < 0 && btn->yindex > -vcount) + vmap[-btn->yindex] = 1; + else if (btn->yindex==0 && btn->xindex<0 &&btn->xindex>-hcount) + hmap[-btn->xindex] = 1; } - } - x=0; y=0; - done = 0; - /* search a vacant slot */ - for (i=1; imax_icons; i++) { - btn = dock->icon_array[i]; - if (btn) - slot_map[XY2OFS(btn->xindex, btn->yindex)] = 1; + btn = dock->icon_array[i]; + if (btn) + slot_map[XY2OFS(btn->xindex, btn->yindex)] = 1; } for (chain=scr->global_icons; chain!=NULL; chain=chain->next) { slot_map[XY2OFS(chain->aicon->xindex, chain->aicon->yindex)] = 1; @@ -2876,52 +2876,52 @@ wDockFindFreeSlot(WDock *dock, int *x_pos, int *y_pos) */ done = 0; for (i = 1; i <= r && !done; i++) { - int tx, ty; - - /* top and bottom parts of the ring */ - for (x = -i; x <= i && !done; x++) { - tx = dock->x_pos + x*ICON_SIZE; - y = -i; - ty = dock->y_pos + y*ICON_SIZE; - if (slot_map[XY2OFS(x,y)]==0 - && onScreen(scr, tx, ty, sx, ex, sy, ey)) { - *x_pos = x; - *y_pos = y; - done = 1; - break; - } - y = i; - ty = dock->y_pos + y*ICON_SIZE; - if (slot_map[XY2OFS(x,y)]==0 - && onScreen(scr, tx, ty, sx, ex, sy, ey)) { - *x_pos = x; - *y_pos = y; - done = 1; - break; - } - } - /* left and right parts of the ring */ - for (y = -i+1; y <= i-1; y++) { - ty = dock->y_pos + y*ICON_SIZE; - x = -i; - tx = dock->x_pos + x*ICON_SIZE; - if (slot_map[XY2OFS(x,y)]==0 - && onScreen(scr, tx, ty, sx, ex, sy, ey)) { - *x_pos = x; - *y_pos = y; - done = 1; - break; - } - x = i; - tx = dock->x_pos + x*ICON_SIZE; - if (slot_map[XY2OFS(x,y)]==0 - && onScreen(scr, tx, ty, sx, ex, sy, ey)) { - *x_pos = x; - *y_pos = y; - done = 1; - break; - } - } + int tx, ty; + + /* top and bottom parts of the ring */ + for (x = -i; x <= i && !done; x++) { + tx = dock->x_pos + x*ICON_SIZE; + y = -i; + ty = dock->y_pos + y*ICON_SIZE; + if (slot_map[XY2OFS(x,y)]==0 + && onScreen(scr, tx, ty, sx, ex, sy, ey)) { + *x_pos = x; + *y_pos = y; + done = 1; + break; + } + y = i; + ty = dock->y_pos + y*ICON_SIZE; + if (slot_map[XY2OFS(x,y)]==0 + && onScreen(scr, tx, ty, sx, ex, sy, ey)) { + *x_pos = x; + *y_pos = y; + done = 1; + break; + } + } + /* left and right parts of the ring */ + for (y = -i+1; y <= i-1; y++) { + ty = dock->y_pos + y*ICON_SIZE; + x = -i; + tx = dock->x_pos + x*ICON_SIZE; + if (slot_map[XY2OFS(x,y)]==0 + && onScreen(scr, tx, ty, sx, ex, sy, ey)) { + *x_pos = x; + *y_pos = y; + done = 1; + break; + } + x = i; + tx = dock->x_pos + x*ICON_SIZE; + if (slot_map[XY2OFS(x,y)]==0 + && onScreen(scr, tx, ty, sx, ex, sy, ey)) { + *x_pos = x; + *y_pos = y; + done = 1; + break; + } + } } wfree(slot_map); #undef XY2OFS @@ -2938,12 +2938,12 @@ moveDock(WDock *dock, int new_x, int new_y) dock->x_pos = new_x; dock->y_pos = new_y; for (i=0; imax_icons; i++) { - btn = dock->icon_array[i]; + btn = dock->icon_array[i]; if (btn) { btn->x_pos = new_x + btn->xindex*ICON_SIZE; - btn->y_pos = new_y + btn->yindex*ICON_SIZE; - XMoveWindow(dpy, btn->icon->core->window, btn->x_pos, btn->y_pos); - } + btn->y_pos = new_y + btn->yindex*ICON_SIZE; + XMoveWindow(dpy, btn->icon->core->window, btn->x_pos, btn->y_pos); + } } } @@ -2951,23 +2951,23 @@ moveDock(WDock *dock, int new_x, int new_y) static void swapDock(WDock *dock) { - WScreen *scr = dock->screen_ptr; - WAppIcon *btn; - int x, i; + WScreen *scr = dock->screen_ptr; + WAppIcon *btn; + int x, i; if (dock->on_right_side) { - x = dock->x_pos = scr->scr_width - ICON_SIZE - DOCK_EXTRA_SPACE; + x = dock->x_pos = scr->scr_width - ICON_SIZE - DOCK_EXTRA_SPACE; } else { - x = dock->x_pos = DOCK_EXTRA_SPACE; + x = dock->x_pos = DOCK_EXTRA_SPACE; } for (i=0; imax_icons; i++) { - btn = dock->icon_array[i]; - if (btn) { - btn->x_pos = x; - XMoveWindow(dpy, btn->icon->core->window, btn->x_pos, btn->y_pos); - } + btn = dock->icon_array[i]; + if (btn) { + btn->x_pos = x; + XMoveWindow(dpy, btn->icon->core->window, btn->x_pos, btn->y_pos); + } } wScreenUpdateUsableArea(scr); @@ -2986,8 +2986,8 @@ execCommand(WAppIcon *btn, char *command, WSavedState *state) cmdline = ExpandOptions(scr, command); if (scr->flags.dnd_data_convertion_status || !cmdline) { - if (cmdline) - wfree(cmdline); + if (cmdline) + wfree(cmdline); if (state) wfree(state); return 0; @@ -3000,28 +3000,28 @@ execCommand(WAppIcon *btn, char *command, WSavedState *state) wfree(cmdline); if (state) wfree(state); - return 0; + return 0; } if ((pid=fork())==0) { - char **args; - int i; + char **args; + int i; - SetupEnvironment(scr); + SetupEnvironment(scr); #ifdef HAVE_SETSID setsid(); #endif - args = malloc(sizeof(char*)*(argc+1)); - if (!args) - exit(111); - for (i=0; iworkspace = scr->current_workspace; } wWindowAddSavedState(btn->wm_instance, btn->wm_class, cmdline, pid, - state); + state); wAddDeathHandler(pid, (WDeathHandler*)trackDeadProcess, btn->dock); } else if (state) { @@ -3155,9 +3155,9 @@ wDockFindIconForWindow(WDock *dock, Window window) int i; for (i=0; imax_icons; i++) { - icon = dock->icon_array[i]; - if (icon && icon->main_window == window) - return icon; + icon = dock->icon_array[i]; + if (icon && icon->main_window == window) + return icon; } return NULL; } @@ -3185,46 +3185,46 @@ wDockTrackWindowLaunch(WDock *dock, Window window) retry: for (i=0; imax_icons; i++) { - icon = dock->icon_array[i]; - if (!icon) - continue; + icon = dock->icon_array[i]; + if (!icon) + continue; - /* app is already attached to icon */ - if (icon->main_window == window) { - found = True; - break; - } + /* app is already attached to icon */ + if (icon->main_window == window) { + found = True; + break; + } - if ((icon->wm_instance || icon->wm_class) + if ((icon->wm_instance || icon->wm_class) && (icon->launching || !icon->running)) { - if (icon->wm_instance && wm_instance && - strcmp(icon->wm_instance, wm_instance)!=0) { - continue; - } - if (icon->wm_class && wm_class && - strcmp(icon->wm_class, wm_class)!=0) { - continue; - } - if (firstPass && command && strcmp(icon->command, command)!=0) { - continue; - } - - if (!icon->relaunching) { - WApplication *wapp; - - /* Possibly an application that was docked with dockit, - * but the user did not update WMState to indicate that - * it was docked by force */ - wapp = wApplicationOf(window); - if (!wapp) { - icon->forced_dock = 1; - icon->running = 0; - } + if (icon->wm_instance && wm_instance && + strcmp(icon->wm_instance, wm_instance)!=0) { + continue; + } + if (icon->wm_class && wm_class && + strcmp(icon->wm_class, wm_class)!=0) { + continue; + } + if (firstPass && command && strcmp(icon->command, command)!=0) { + continue; + } + + if (!icon->relaunching) { + WApplication *wapp; + + /* Possibly an application that was docked with dockit, + * but the user did not update WMState to indicate that + * it was docked by force */ + wapp = wApplicationOf(window); + if (!wapp) { + icon->forced_dock = 1; + icon->running = 0; + } if (!icon->forced_dock) { icon->main_window = window; } - } + } found = True; if (!wPreferences.no_animations && !icon->launching && !dock->screen_ptr->flags.startup && !dock->collapsed) { @@ -3237,7 +3237,7 @@ retry: aicon = wAppIconCreateForDock(dock->screen_ptr, NULL, wm_instance, wm_class, TILE_NORMAL); - /* XXX: can: aicon->icon == NULL ? */ + /* XXX: can: aicon->icon == NULL ? */ PlaceIcon(dock->screen_ptr, &x0, &y0, wGetHeadForWindow(aicon->icon->owner)); wAppIconMove(aicon, x0, y0); /* Should this always be lowered? -Dan */ @@ -3251,23 +3251,23 @@ retry: XUnmapWindow(dpy, aicon->icon->core->window); wAppIconDestroy(aicon); } - wDockFinishLaunch(dock, icon); - break; - } + wDockFinishLaunch(dock, icon); + break; + } } if (firstPass && !found) { - firstPass = False; - goto retry; + firstPass = False; + goto retry; } if (command) - wfree(command); + wfree(command); if (wm_class) - XFree(wm_class); + XFree(wm_class); if (wm_instance) - XFree(wm_instance); + XFree(wm_instance); } @@ -3308,8 +3308,8 @@ wClipUpdateForWorkspaceChange(WScreen *scr, int workspace) } wDockShowIcons(scr->workspaces[workspace]->clip); } - if (scr->flags.clip_balloon_mapped) - showClipBalloon(scr->clip_icon->dock, workspace); + if (scr->flags.clip_balloon_mapped) + showClipBalloon(scr->clip_icon->dock, workspace); } } @@ -3322,36 +3322,36 @@ trackDeadProcess(pid_t pid, unsigned char status, WDock *dock) int i; for (i=0; imax_icons; i++) { - icon = dock->icon_array[i]; - if (!icon) - continue; - - if (icon->launching && icon->pid == pid) { - if (!icon->relaunching) { - icon->running = 0; - icon->main_window = None; - } - wDockFinishLaunch(dock, icon); - icon->pid = 0; - if (status==111) { - char msg[PATH_MAX]; + icon = dock->icon_array[i]; + if (!icon) + continue; + + if (icon->launching && icon->pid == pid) { + if (!icon->relaunching) { + icon->running = 0; + icon->main_window = None; + } + wDockFinishLaunch(dock, icon); + icon->pid = 0; + if (status==111) { + char msg[PATH_MAX]; char *cmd; if (icon->drop_launch) cmd = icon->dnd_command; - else if (icon->paste_launch) + else if (icon->paste_launch) cmd = icon->paste_command; - else + else cmd = icon->command; snprintf(msg, sizeof(msg), _("Could not execute command \"%s\""), cmd); - wMessageDialog(dock->screen_ptr, _("Error"), msg, - _("OK"), NULL, NULL); - } - break; - } + wMessageDialog(dock->screen_ptr, _("Error"), msg, + _("OK"), NULL, NULL); + } + break; + } } } @@ -3364,25 +3364,25 @@ toggleLowered(WDock *dock) /* lower/raise Dock */ if (!dock->lowered) { - newlevel = WMNormalLevel; - dock->lowered = 1; + newlevel = WMNormalLevel; + dock->lowered = 1; } else { - newlevel = WMDockLevel; - dock->lowered = 0; + newlevel = WMDockLevel; + dock->lowered = 0; } for (i=0; imax_icons; i++) { - tmp = dock->icon_array[i]; - if (!tmp) - continue; + tmp = dock->icon_array[i]; + if (!tmp) + continue; - ChangeStackingLevel(tmp->icon->core, newlevel); - if (dock->lowered) - wLowerFrame(tmp->icon->core); + ChangeStackingLevel(tmp->icon->core, newlevel); + if (dock->lowered) + wLowerFrame(tmp->icon->core); } if (dock->type == WM_DOCK) - wScreenUpdateUsableArea(dock->screen_ptr); + wScreenUpdateUsableArea(dock->screen_ptr); } @@ -3413,20 +3413,20 @@ openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) int appIsRunning = aicon->running && aicon->icon && aicon->icon->owner; if (dock->type == WM_DOCK) { - /* keep on top */ - entry = dock->menu->entries[index]; + /* keep on top */ + entry = dock->menu->entries[index]; entry->flags.indicator_on = !dock->lowered; - entry->clientdata = dock; - dock->menu->flags.realized = 0; + entry->clientdata = dock; + dock->menu->flags.realized = 0; } else { - /* clip options */ - if (scr->clip_options) - updateClipOptionsMenu(scr->clip_options, dock); + /* clip options */ + if (scr->clip_options) + updateClipOptionsMenu(scr->clip_options, dock); n_selected = numberOfSelectedIcons(dock); - /* Rename Workspace */ - entry = dock->menu->entries[++index]; + /* Rename Workspace */ + entry = dock->menu->entries[++index]; if (aicon == scr->clip_icon) { entry->callback = renameCallback; entry->clientdata = dock; @@ -3446,64 +3446,64 @@ openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) } } - /* select/unselect icon */ - entry = dock->menu->entries[++index]; + /* select/unselect icon */ + entry = dock->menu->entries[++index]; entry->clientdata = aicon; entry->flags.indicator_on = aicon->icon->selected; - wMenuSetEnabled(dock->menu, index, aicon!=scr->clip_icon); + wMenuSetEnabled(dock->menu, index, aicon!=scr->clip_icon); - /* select/unselect all icons */ - entry = dock->menu->entries[++index]; + /* select/unselect all icons */ + entry = dock->menu->entries[++index]; entry->clientdata = aicon; if (n_selected > 0) entry->text = _("Unselect All Icons"); else entry->text = _("Select All Icons"); - wMenuSetEnabled(dock->menu, index, dock->icon_count > 1); + wMenuSetEnabled(dock->menu, index, dock->icon_count > 1); - /* keep icon(s) */ - entry = dock->menu->entries[++index]; + /* keep icon(s) */ + entry = dock->menu->entries[++index]; entry->clientdata = aicon; if (n_selected > 1) entry->text = _("Keep Icons"); else entry->text = _("Keep Icon"); - wMenuSetEnabled(dock->menu, index, dock->icon_count > 1); + wMenuSetEnabled(dock->menu, index, dock->icon_count > 1); - /* this is the workspace submenu part */ + /* this is the workspace submenu part */ entry = dock->menu->entries[++index]; if (n_selected > 1) entry->text = _("Move Icons To"); else entry->text = _("Move Icon To"); - if (scr->clip_submenu) - updateWorkspaceMenu(scr->clip_submenu, aicon); + if (scr->clip_submenu) + updateWorkspaceMenu(scr->clip_submenu, aicon); wMenuSetEnabled(dock->menu, index, !aicon->omnipresent); - /* remove icon(s) */ - entry = dock->menu->entries[++index]; - entry->clientdata = aicon; + /* remove icon(s) */ + entry = dock->menu->entries[++index]; + entry->clientdata = aicon; if (n_selected > 1) entry->text = _("Remove Icons"); else entry->text = _("Remove Icon"); - wMenuSetEnabled(dock->menu, index, dock->icon_count > 1); + wMenuSetEnabled(dock->menu, index, dock->icon_count > 1); - /* attract icon(s) */ - entry = dock->menu->entries[++index]; + /* attract icon(s) */ + entry = dock->menu->entries[++index]; entry->clientdata = aicon; dock->menu->flags.realized = 0; wMenuRealize(dock->menu); } - + if (aicon->icon->owner) { wapp = wApplicationOf(aicon->icon->owner->main_window); } else { - wapp = NULL; + wapp = NULL; } - + /* launch */ entry = dock->menu->entries[++index]; entry->clientdata = aicon; @@ -3513,9 +3513,9 @@ openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) entry = dock->menu->entries[++index]; entry->clientdata = aicon; if (wapp && wapp->flags.hidden) { - entry->text = _("Unhide Here"); + entry->text = _("Unhide Here"); } else { - entry->text = _("Bring Here"); + entry->text = _("Bring Here"); } wMenuSetEnabled(dock->menu, index, appIsRunning); @@ -3523,9 +3523,9 @@ openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) entry = dock->menu->entries[++index]; entry->clientdata = aicon; if (wapp && wapp->flags.hidden) { - entry->text = _("Unhide"); + entry->text = _("Unhide"); } else { - entry->text = _("Hide"); + entry->text = _("Hide"); } wMenuSetEnabled(dock->menu, index, appIsRunning); @@ -3533,7 +3533,7 @@ openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) entry = dock->menu->entries[++index]; entry->clientdata = aicon; wMenuSetEnabled(dock->menu, index, !aicon->editing - && !wPreferences.flags.noupdates); + && !wPreferences.flags.noupdates); /* kill */ entry = dock->menu->entries[++index]; @@ -3541,7 +3541,7 @@ openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) wMenuSetEnabled(dock->menu, index, appIsRunning); if (!dock->menu->flags.realized) - wMenuRealize(dock->menu); + wMenuRealize(dock->menu); if (dock->type == WM_CLIP) { /*x_pos = event->xbutton.x_root+2;*/ @@ -3552,8 +3552,8 @@ openDockMenu(WDock *dock, WAppIcon *aicon, XEvent *event) x_pos = scr->scr_width - dock->menu->frame->core->width - 4; } } else { - x_pos = dock->on_right_side ? - scr->scr_width - dock->menu->frame->core->width - 3 : 0; + x_pos = dock->on_right_side ? + scr->scr_width - dock->menu->frame->core->width - 3 : 0; } wMenuMapAt(dock->menu, x_pos, event->xbutton.y_root+2, False); @@ -3575,43 +3575,43 @@ iconDblClick(WObjDescriptor *desc, XEvent *event) int unhideHere = 0; if (btn->icon->owner && !(event->xbutton.state & ControlMask)) { - wapp = wApplicationOf(btn->icon->owner->main_window); + wapp = wApplicationOf(btn->icon->owner->main_window); - assert(wapp!=NULL); + assert(wapp!=NULL); - unhideHere = (event->xbutton.state & ShiftMask); + unhideHere = (event->xbutton.state & ShiftMask); /* go to the last workspace that the user worked on the app */ - if (wapp->last_workspace != dock->screen_ptr->current_workspace - && !unhideHere) { - wWorkspaceChange(dock->screen_ptr, wapp->last_workspace); - } + if (wapp->last_workspace != dock->screen_ptr->current_workspace + && !unhideHere) { + wWorkspaceChange(dock->screen_ptr, wapp->last_workspace); + } - wUnhideApplication(wapp, event->xbutton.button==Button2, unhideHere); + wUnhideApplication(wapp, event->xbutton.button==Button2, unhideHere); - if (event->xbutton.state & MOD_MASK) { - wHideOtherApplications(btn->icon->owner); - } + if (event->xbutton.state & MOD_MASK) { + wHideOtherApplications(btn->icon->owner); + } } else { - if (event->xbutton.button==Button1) { + if (event->xbutton.button==Button1) { - if (event->xbutton.state & MOD_MASK) { + if (event->xbutton.state & MOD_MASK) { /* raise/lower dock */ toggleLowered(dock); } else if (btn == dock->screen_ptr->clip_icon) { - if (getClipButton(event->xbutton.x, event->xbutton.y)==CLIP_IDLE) - toggleCollapsed(dock); - else - handleClipChangeWorkspace(dock->screen_ptr, event); - } else if (btn->command) { - if (!btn->launching && - (!btn->running || (event->xbutton.state & ControlMask))) { - launchDockedApplication(btn, False); + if (getClipButton(event->xbutton.x, event->xbutton.y)==CLIP_IDLE) + toggleCollapsed(dock); + else + handleClipChangeWorkspace(dock->screen_ptr, event); + } else if (btn->command) { + if (!btn->launching && + (!btn->running || (event->xbutton.state & ControlMask))) { + launchDockedApplication(btn, False); } } else if (btn->xindex==0 && btn->yindex==0 && btn->dock->type==WM_DOCK) { - wShowGNUstepPanel(dock->screen_ptr); - } + wShowGNUstepPanel(dock->screen_ptr); + } } } } @@ -3633,9 +3633,9 @@ handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event) puts("moving dock"); #endif if (XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, - GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { - wwarning("pointer grab failed for dock move"); + |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { + wwarning("pointer grab failed for dock move"); } y = 0; for (x=0; xmax_icons; x++) { @@ -3648,105 +3648,105 @@ handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event) done = 0; while (!done) { - WMMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask - |ButtonMotionMask|ExposureMask, &ev); - switch (ev.type) { - case Expose: - WMHandleEvent(&ev); - break; - - case MotionNotify: - if (!grabbed) { - if (abs(ofs_x-ev.xmotion.x)>=MOVE_THRESHOLD - || abs(ofs_y-ev.xmotion.y)>=MOVE_THRESHOLD) { - XChangeActivePointerGrab(dpy, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, - wCursor[WCUR_MOVE], CurrentTime); - grabbed=1; - } - break; - } + WMMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask + |ButtonMotionMask|ExposureMask, &ev); + switch (ev.type) { + case Expose: + WMHandleEvent(&ev); + break; + + case MotionNotify: + if (!grabbed) { + if (abs(ofs_x-ev.xmotion.x)>=MOVE_THRESHOLD + || abs(ofs_y-ev.xmotion.y)>=MOVE_THRESHOLD) { + XChangeActivePointerGrab(dpy, ButtonMotionMask + |ButtonReleaseMask|ButtonPressMask, + wCursor[WCUR_MOVE], CurrentTime); + grabbed=1; + } + break; + } if (dock->type == WM_CLIP) { - x = ev.xmotion.x_root - ofs_x; - y = ev.xmotion.y_root - ofs_y; - wScreenKeepInside(scr, &x, &y, ICON_SIZE, ICON_SIZE); + x = ev.xmotion.x_root - ofs_x; + y = ev.xmotion.y_root - ofs_y; + wScreenKeepInside(scr, &x, &y, ICON_SIZE, ICON_SIZE); moveDock(dock, x, y); } else { - /* move vertically if pointer is inside the dock*/ - if ((dock->on_right_side && - ev.xmotion.x_root >= dock->x_pos - ICON_SIZE) - || (!dock->on_right_side && - ev.xmotion.x_root <= dock->x_pos + ICON_SIZE*2)) { - - x = ev.xmotion.x_root - ofs_x; - y = ev.xmotion.y_root - ofs_y; - wScreenKeepInside(scr, &x, &y, ICON_SIZE, ICON_SIZE); - moveDock(dock, dock->x_pos, y); - } - /* move horizontally to change sides */ - x = ev.xmotion.x_root - ofs_x; - if (!dock->on_right_side) { - - /* is on left */ - - if (ev.xmotion.x_root > dock->x_pos + ICON_SIZE*2) { - XMoveWindow(dpy, scr->dock_shadow, scr->scr_width-ICON_SIZE - -DOCK_EXTRA_SPACE-1, dock->y_pos); - if (superfluous && ghost==None) { - ghost = MakeGhostDock(dock, dock->x_pos, - scr->scr_width-ICON_SIZE - -DOCK_EXTRA_SPACE-1, - dock->y_pos); - XSetWindowBackgroundPixmap(dpy, scr->dock_shadow, - ghost); - XClearWindow(dpy, scr->dock_shadow); + /* move vertically if pointer is inside the dock*/ + if ((dock->on_right_side && + ev.xmotion.x_root >= dock->x_pos - ICON_SIZE) + || (!dock->on_right_side && + ev.xmotion.x_root <= dock->x_pos + ICON_SIZE*2)) { + + x = ev.xmotion.x_root - ofs_x; + y = ev.xmotion.y_root - ofs_y; + wScreenKeepInside(scr, &x, &y, ICON_SIZE, ICON_SIZE); + moveDock(dock, dock->x_pos, y); + } + /* move horizontally to change sides */ + x = ev.xmotion.x_root - ofs_x; + if (!dock->on_right_side) { + + /* is on left */ + + if (ev.xmotion.x_root > dock->x_pos + ICON_SIZE*2) { + XMoveWindow(dpy, scr->dock_shadow, scr->scr_width-ICON_SIZE + -DOCK_EXTRA_SPACE-1, dock->y_pos); + if (superfluous && ghost==None) { + ghost = MakeGhostDock(dock, dock->x_pos, + scr->scr_width-ICON_SIZE + -DOCK_EXTRA_SPACE-1, + dock->y_pos); + XSetWindowBackgroundPixmap(dpy, scr->dock_shadow, + ghost); + XClearWindow(dpy, scr->dock_shadow); + } + XMapRaised(dpy, scr->dock_shadow); + swapped = 1; + } else { + if (superfluous && ghost!=None) { + XFreePixmap(dpy, ghost); + ghost = None; + } + XUnmapWindow(dpy, scr->dock_shadow); + swapped = 0; } - XMapRaised(dpy, scr->dock_shadow); - swapped = 1; - } else { - if (superfluous && ghost!=None) { - XFreePixmap(dpy, ghost); - ghost = None; - } - XUnmapWindow(dpy, scr->dock_shadow); - swapped = 0; - } - } else { - /* is on right */ - if (ev.xmotion.x_root < dock->x_pos - ICON_SIZE) { - XMoveWindow(dpy, scr->dock_shadow, - DOCK_EXTRA_SPACE, dock->y_pos); - if (superfluous && ghost==None) { - ghost = MakeGhostDock(dock, dock->x_pos, - DOCK_EXTRA_SPACE, dock->y_pos); - XSetWindowBackgroundPixmap(dpy, scr->dock_shadow, - ghost); - XClearWindow(dpy, scr->dock_shadow); + } else { + /* is on right */ + if (ev.xmotion.x_root < dock->x_pos - ICON_SIZE) { + XMoveWindow(dpy, scr->dock_shadow, + DOCK_EXTRA_SPACE, dock->y_pos); + if (superfluous && ghost==None) { + ghost = MakeGhostDock(dock, dock->x_pos, + DOCK_EXTRA_SPACE, dock->y_pos); + XSetWindowBackgroundPixmap(dpy, scr->dock_shadow, + ghost); + XClearWindow(dpy, scr->dock_shadow); + } + XMapRaised(dpy, scr->dock_shadow); + swapped = -1; + } else { + XUnmapWindow(dpy, scr->dock_shadow); + swapped = 0; + if (superfluous && ghost!=None) { + XFreePixmap(dpy, ghost); + ghost = None; + } } - XMapRaised(dpy, scr->dock_shadow); - swapped = -1; - } else { - XUnmapWindow(dpy, scr->dock_shadow); - swapped = 0; - if (superfluous && ghost!=None) { - XFreePixmap(dpy, ghost); - ghost = None; - } - } - } + } } - break; + break; - case ButtonPress: - break; + case ButtonPress: + break; - case ButtonRelease: - if (ev.xbutton.button != event->xbutton.button) - break; - XUngrabPointer(dpy, CurrentTime); - XUnmapWindow(dpy, scr->dock_shadow); - XResizeWindow(dpy, scr->dock_shadow, ICON_SIZE, ICON_SIZE); + case ButtonRelease: + if (ev.xbutton.button != event->xbutton.button) + break; + XUngrabPointer(dpy, CurrentTime); + XUnmapWindow(dpy, scr->dock_shadow); + XResizeWindow(dpy, scr->dock_shadow, ICON_SIZE, ICON_SIZE); if (dock->type == WM_DOCK) { if (swapped!=0) { if (swapped>0) @@ -3757,14 +3757,14 @@ handleDockMove(WDock *dock, WAppIcon *aicon, XEvent *event) wArrangeIcons(scr, False); } } - done = 1; - break; - } + done = 1; + break; + } } if (superfluous) { - if (ghost!=None) - XFreePixmap(dpy, ghost); - XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel); + if (ghost!=None) + XFreePixmap(dpy, ghost); + XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel); } #ifdef DEBUG puts("End dock move"); @@ -3794,18 +3794,18 @@ handleIconMove(WDock *dock, WAppIcon *aicon, XEvent *event) if (wPreferences.flags.noupdates) - return; + return; if (XGrabPointer(dpy, icon->core->window, True, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, - GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { + |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { #ifdef DEBUG0 - wwarning("pointer grab failed for icon move"); + wwarning("pointer grab failed for icon move"); #endif } if (!(event->xbutton.state & MOD_MASK)) - wRaiseFrame(icon->core); + wRaiseFrame(icon->core); if (!wPreferences.flags.noclip) clip = scr->workspaces[scr->current_workspace]->clip; @@ -3819,15 +3819,15 @@ handleIconMove(WDock *dock, WAppIcon *aicon, XEvent *event) wins[1] = scr->dock_shadow; XRestackWindows(dpy, wins, 2); XMoveResizeWindow(dpy, scr->dock_shadow, aicon->x_pos, aicon->y_pos, - ICON_SIZE, ICON_SIZE); + ICON_SIZE, ICON_SIZE); if (superfluous) { - if (icon->pixmap!=None) - ghost = MakeGhostIcon(scr, icon->pixmap); - else - ghost = MakeGhostIcon(scr, icon->core->window); + if (icon->pixmap!=None) + ghost = MakeGhostIcon(scr, icon->pixmap); + else + ghost = MakeGhostIcon(scr, icon->core->window); - XSetWindowBackgroundPixmap(dpy, scr->dock_shadow, ghost); - XClearWindow(dpy, scr->dock_shadow); + XSetWindowBackgroundPixmap(dpy, scr->dock_shadow, ghost); + XClearWindow(dpy, scr->dock_shadow); } XMapWindow(dpy, scr->dock_shadow); @@ -3835,25 +3835,25 @@ handleIconMove(WDock *dock, WAppIcon *aicon, XEvent *event) while(1) { - XMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask - |ButtonMotionMask|ExposureMask, &ev); - switch (ev.type) { - case Expose: - WMHandleEvent(&ev); - break; - - case MotionNotify: - if (!grabbed) { - if (abs(ofs_x-ev.xmotion.x)>=MOVE_THRESHOLD - || abs(ofs_y-ev.xmotion.y)>=MOVE_THRESHOLD) { - XChangeActivePointerGrab(dpy, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, - wCursor[WCUR_MOVE], CurrentTime); - grabbed=1; - } else { - break; - } - } + XMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask + |ButtonMotionMask|ExposureMask, &ev); + switch (ev.type) { + case Expose: + WMHandleEvent(&ev); + break; + + case MotionNotify: + if (!grabbed) { + if (abs(ofs_x-ev.xmotion.x)>=MOVE_THRESHOLD + || abs(ofs_y-ev.xmotion.y)>=MOVE_THRESHOLD) { + XChangeActivePointerGrab(dpy, ButtonMotionMask + |ButtonReleaseMask|ButtonPressMask, + wCursor[WCUR_MOVE], CurrentTime); + grabbed=1; + } else { + break; + } + } if (omnipresent) { int i; @@ -3864,8 +3864,8 @@ handleIconMove(WDock *dock, WAppIcon *aicon, XEvent *event) } } - x = ev.xmotion.x_root - ofs_x; - y = ev.xmotion.y_root - ofs_y; + x = ev.xmotion.x_root - ofs_x; + y = ev.xmotion.y_root - ofs_y; tmp = wDockSnapIcon(dock, aicon, x, y, &ix, &iy, True); if (tmp && dock2) { change_dock = 0; @@ -3900,36 +3900,36 @@ handleIconMove(WDock *dock, WAppIcon *aicon, XEvent *event) } } if (aicon->launching - || aicon->lock - || (aicon->running && !(ev.xmotion.state & MOD_MASK)) - || (!aicon->running && tmp)) { + || aicon->lock + || (aicon->running && !(ev.xmotion.state & MOD_MASK)) + || (!aicon->running && tmp)) { shad_x = last_dock->x_pos + ix*wPreferences.icon_size; shad_y = last_dock->y_pos + iy*wPreferences.icon_size; - XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y); + XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y); - if (!ondock) { - XMapWindow(dpy, scr->dock_shadow); - } - ondock = 1; - } else { + if (!ondock) { + XMapWindow(dpy, scr->dock_shadow); + } + ondock = 1; + } else { if (ondock) { XUnmapWindow(dpy, scr->dock_shadow); } - ondock = 0; - } - XMoveWindow(dpy, icon->core->window, x, y); - break; - - case ButtonPress: - break; - - case ButtonRelease: - if (ev.xbutton.button != event->xbutton.button) - break; - XUngrabPointer(dpy, CurrentTime); - if (ondock) { - SlideWindow(icon->core->window, x, y, shad_x, shad_y); + ondock = 0; + } + XMoveWindow(dpy, icon->core->window, x, y); + break; + + case ButtonPress: + break; + + case ButtonRelease: + if (ev.xbutton.button != event->xbutton.button) + break; + XUngrabPointer(dpy, CurrentTime); + if (ondock) { + SlideWindow(icon->core->window, x, y, shad_x, shad_y); XUnmapWindow(dpy, scr->dock_shadow); if (!change_dock) { reattachIcon(dock, aicon, ix, iy); @@ -3937,38 +3937,38 @@ handleIconMove(WDock *dock, WAppIcon *aicon, XEvent *event) wDockLower(clip); } else { docked = moveIconBetweenDocks(dock, dock2, aicon, ix, iy); - if (!docked) { - /* Slide it back if dock rejected it */ - SlideWindow(icon->core->window, x, y, aicon->x_pos, - aicon->y_pos); - reattachIcon(dock, aicon, aicon->xindex,aicon->yindex); - } + if (!docked) { + /* Slide it back if dock rejected it */ + SlideWindow(icon->core->window, x, y, aicon->x_pos, + aicon->y_pos); + reattachIcon(dock, aicon, aicon->xindex,aicon->yindex); + } if (last_dock->type==WM_CLIP && last_dock->auto_collapse) { collapsed = 0; } } - } else { - aicon->x_pos = x; - aicon->y_pos = y; + } else { + aicon->x_pos = x; + aicon->y_pos = y; if (superfluous) { - if (!aicon->running && !wPreferences.no_animations) { - /* We need to deselect it, even if is deselected in - * wDockDetach(), because else DoKaboom() will fail. - */ - if (aicon->icon->selected) - wIconSelect(aicon->icon); - - wSoundPlay(WSOUND_KABOOM); - DoKaboom(scr,aicon->icon->core->window, x, y); - } else { + if (!aicon->running && !wPreferences.no_animations) { + /* We need to deselect it, even if is deselected in + * wDockDetach(), because else DoKaboom() will fail. + */ + if (aicon->icon->selected) + wIconSelect(aicon->icon); + + wSoundPlay(WSOUND_KABOOM); + DoKaboom(scr,aicon->icon->core->window, x, y); + } else { wSoundPlay(WSOUND_UNDOCK); } - } else { + } else { wSoundPlay(WSOUND_UNDOCK); } if (clip && clip->auto_raise_lower) wDockLower(clip); - wDockDetach(dock, aicon); + wDockDetach(dock, aicon); } if (collapsed) { last_dock->collapsed = 1; @@ -3976,9 +3976,9 @@ handleIconMove(WDock *dock, WAppIcon *aicon, XEvent *event) collapsed = 0; } if (superfluous) { - if (ghost!=None) - XFreePixmap(dpy, ghost); - XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel); + if (ghost!=None) + XFreePixmap(dpy, ghost); + XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel); } if (omnipresent) { int i; @@ -3990,10 +3990,10 @@ handleIconMove(WDock *dock, WAppIcon *aicon, XEvent *event) } #ifdef DEBUG - puts("End icon move"); + puts("End icon move"); #endif - return; - } + return; + } } } @@ -4004,12 +4004,12 @@ getClipButton(int px, int py) int pt = (CLIP_BUTTON_SIZE+2)*ICON_SIZE/64; if (px < 0 || py < 0 || px >= ICON_SIZE || py >= ICON_SIZE) - return CLIP_IDLE; + return CLIP_IDLE; if (py <= pt-((int)ICON_SIZE-1-px)) - return CLIP_FORWARD; + return CLIP_FORWARD; else if (px <= pt-((int)ICON_SIZE-1-py)) - return CLIP_REWIND; + return CLIP_REWIND; return CLIP_IDLE; } @@ -4031,8 +4031,8 @@ handleClipChangeWorkspace(WScreen *scr, XEvent *event) wClipIconPaint(scr->clip_icon); done = 0; while(!done) { - WMMaskEvent(dpy, ExposureMask|ButtonMotionMask|ButtonReleaseMask - |ButtonPressMask, &ev); + WMMaskEvent(dpy, ExposureMask|ButtonMotionMask|ButtonReleaseMask + |ButtonPressMask, &ev); switch (ev.type) { case Expose: WMHandleEvent(&ev); @@ -4041,19 +4041,19 @@ handleClipChangeWorkspace(WScreen *scr, XEvent *event) case MotionNotify: new_dir = getClipButton(ev.xmotion.x, ev.xmotion.y); if (new_dir != direction) { - direction = new_dir; - clip->lclip_button_pushed = direction==CLIP_REWIND; - clip->rclip_button_pushed = direction==CLIP_FORWARD; + direction = new_dir; + clip->lclip_button_pushed = direction==CLIP_REWIND; + clip->rclip_button_pushed = direction==CLIP_FORWARD; wClipIconPaint(scr->clip_icon); } break; - case ButtonPress: - break; + case ButtonPress: + break; case ButtonRelease: - if (ev.xbutton.button == event->xbutton.button) - done = 1; + if (ev.xbutton.button == event->xbutton.button) + done = 1; } } @@ -4089,25 +4089,25 @@ iconMouseDown(WObjDescriptor *desc, XEvent *event) WScreen *scr = aicon->icon->core->screen_ptr; if (aicon->editing || WCHECK_STATE(WSTATE_MODAL)) - return; + return; scr->last_dock = dock; if (dock->menu->flags.mapped) - wMenuUnmap(dock->menu); + wMenuUnmap(dock->menu); if (IsDoubleClick(scr, event)) { - /* double-click was not in the main clip icon */ + /* double-click was not in the main clip icon */ if (dock->type != WM_CLIP || aicon->xindex!=0 || aicon->yindex!=0 - || getClipButton(event->xbutton.x, event->xbutton.y)==CLIP_IDLE) { + || getClipButton(event->xbutton.x, event->xbutton.y)==CLIP_IDLE) { iconDblClick(desc, event); return; } } if (dock->type == WM_CLIP && scr->flags.clip_balloon_mapped) { - XUnmapWindow(dpy, scr->clip_balloon); - scr->flags.clip_balloon_mapped = 0; + XUnmapWindow(dpy, scr->clip_balloon); + scr->flags.clip_balloon_mapped = 0; } #ifdef DEBUG @@ -4127,12 +4127,12 @@ iconMouseDown(WObjDescriptor *desc, XEvent *event) if (aicon->yindex==0 && aicon->xindex==0) { if (getClipButton(event->xbutton.x, event->xbutton.y)!=CLIP_IDLE - && dock->type==WM_CLIP) + && dock->type==WM_CLIP) handleClipChangeWorkspace(scr, event); else handleDockMove(dock, aicon, event); } else - handleIconMove(dock, aicon, event); + handleIconMove(dock, aicon, event); } else if (event->xbutton.button==Button2 && dock->type==WM_CLIP && aicon==scr->clip_icon) { @@ -4161,21 +4161,21 @@ iconMouseDown(WObjDescriptor *desc, XEvent *event) (event->xbutton.state & ShiftMask) && aicon!=scr->clip_icon) { wClipMakeIconOmnipresent(aicon, !aicon->omnipresent); } else if (event->xbutton.button == Button3) { - if (event->xbutton.send_event && - XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, - GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { - wwarning("pointer grab failed for dockicon menu"); - return; - } - - openDockMenu(dock, aicon, event); + if (event->xbutton.send_event && + XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask + |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { + wwarning("pointer grab failed for dockicon menu"); + return; + } + + openDockMenu(dock, aicon, event); } else if (event->xbutton.button == Button2) { - WAppIcon *btn = desc->parent; + WAppIcon *btn = desc->parent; - if (!btn->launching && - (!btn->running || (event->xbutton.state & ControlMask))) { - launchDockedApplication(btn, True); + if (!btn->launching && + (!btn->running || (event->xbutton.state & ControlMask))) { + launchDockedApplication(btn, True); } } } @@ -4204,16 +4204,16 @@ showClipBalloon(WDock *dock, int workspace) y = dock->y_pos + ICON_SIZE - WMFontHeight(scr->clip_title_font) - 3; if (x+w > scr->scr_width) { - x = scr->scr_width - w; + x = scr->scr_width - w; if (dock->y_pos + ICON_SIZE + h > scr->scr_height) y = dock->y_pos - h - 1; else y = dock->y_pos + ICON_SIZE; XRaiseWindow(dpy, scr->clip_balloon); } else { - stack[0] = scr->clip_icon->icon->core->window; - stack[1] = scr->clip_balloon; - XRestackWindows(dpy, stack, 2); + stack[0] = scr->clip_icon->icon->core->window; + stack[1] = scr->clip_balloon; + XRestackWindows(dpy, stack, 2); } XMoveWindow(dpy, scr->clip_balloon, x, y); XClearWindow(dpy, scr->clip_balloon); @@ -4268,12 +4268,12 @@ clipEnterNotify(WObjDescriptor *desc, XEvent *event) } if (btn->xindex == 0 && btn->yindex == 0) - showClipBalloon(dock, dock->screen_ptr->current_workspace); + showClipBalloon(dock, dock->screen_ptr->current_workspace); else { - if (dock->screen_ptr->flags.clip_balloon_mapped) { - XUnmapWindow(dpy, dock->screen_ptr->clip_balloon); - dock->screen_ptr->flags.clip_balloon_mapped = 0; - } + if (dock->screen_ptr->flags.clip_balloon_mapped) { + XUnmapWindow(dpy, dock->screen_ptr->clip_balloon); + dock->screen_ptr->flags.clip_balloon_mapped = 0; + } } } @@ -4285,7 +4285,7 @@ clipLeave(WDock *dock) WObjDescriptor *desc = NULL; if (!dock || dock->type!=WM_CLIP) - return; + return; if (XCheckTypedEvent(dpy, EnterNotify, &event)!=False) { if (XFindContext(dpy, event.xcrossing.window, wWinContext, diff --git a/src/dock.h b/src/dock.h index ec7c5898..52634c3e 100644 --- a/src/dock.h +++ b/src/dock.h @@ -1,10 +1,10 @@ /* dock.h- built-in Dock module for WindowMaker - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima * Copyright (c) 1998-2003 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. */ @@ -59,7 +59,7 @@ typedef struct WDock { unsigned int lclip_button_pushed:1; unsigned int rclip_button_pushed:1; - + struct WMenu *menu; struct WDDomain *defaults; @@ -82,7 +82,7 @@ void wDockSaveState(WScreen *scr, WMPropList *old_state); Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y); Bool wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y, - int *ret_x, int *ret_y, int redocking); + int *ret_x, int *ret_y, int redocking); Bool wDockFindFreeSlot(WDock *dock, int *req_x, int *req_y); void wDockDetach(WDock *dock, WAppIcon *icon); diff --git a/src/dockedapp.c b/src/dockedapp.c index 6746cd6f..85fbba26 100644 --- a/src/dockedapp.c +++ b/src/dockedapp.c @@ -65,7 +65,7 @@ typedef struct _AppSettingsPanel { WMFrame *pasteCommandFrame; WMTextField *pasteCommandField; WMLabel *pasteCommandLabel; - + WMFrame *iconFrame; WMTextField *iconField; WMButton *browseBtn; @@ -91,16 +91,16 @@ static void updateCommand(WAppIcon *icon, char *command) { if (icon->command) - wfree(icon->command); + wfree(icon->command); if (command && (command[0]==0 || (command[0]=='-' && command[1]==0))) { - wfree(command); - command = NULL; + wfree(command); + command = NULL; } icon->command = command; if (!icon->wm_class && !icon->wm_instance && icon->command - && strlen(icon->command)>0) { - icon->forced_dock = 1; + && strlen(icon->command)>0) { + icon->forced_dock = 1; } } @@ -109,10 +109,10 @@ static void updatePasteCommand(WAppIcon *icon, char *command) { if (icon->paste_command) - wfree(icon->paste_command); + wfree(icon->paste_command); if (command && (command[0]==0 || (command[0]=='-' && command[1]==0))) { - wfree(command); - command = NULL; + wfree(command); + command = NULL; } icon->paste_command = command; } @@ -124,10 +124,10 @@ static void updateDNDCommand(WAppIcon *icon, char *command) { if (icon->dnd_command) - wfree(icon->dnd_command); + wfree(icon->dnd_command); if (command && (command[0]==0 || (command[0]=='-' && command[1]==0))) { - wfree(command); - command = NULL; + wfree(command); + command = NULL; } icon->dnd_command = command; } @@ -141,36 +141,36 @@ updateSettingsPanelIcon(AppSettingsPanel *panel) file = WMGetTextFieldText(panel->iconField); if (!file) - WMSetLabelImage(panel->iconLabel, NULL); + WMSetLabelImage(panel->iconLabel, NULL); else { - char *path; - - path = FindImage(wPreferences.icon_path, file); - if (!path) { - wwarning(_("could not find icon %s, used in a docked application"), - file); - wfree(file); - WMSetLabelImage(panel->iconLabel, NULL); - return; - } else { - WMPixmap *pixmap; - RColor color; - - color.red = 0xae; - color.green = 0xaa; - color.blue = 0xae; - color.alpha = 0; - pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), - path, &color); - if (!pixmap) { - WMSetLabelImage(panel->iconLabel, NULL); - } else { - WMSetLabelImage(panel->iconLabel, pixmap); - WMReleasePixmap(pixmap); - } - } - wfree(file); - wfree(path); + char *path; + + path = FindImage(wPreferences.icon_path, file); + if (!path) { + wwarning(_("could not find icon %s, used in a docked application"), + file); + wfree(file); + WMSetLabelImage(panel->iconLabel, NULL); + return; + } else { + WMPixmap *pixmap; + RColor color; + + color.red = 0xae; + color.green = 0xaa; + color.blue = 0xae; + color.alpha = 0; + pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), + path, &color); + if (!pixmap) { + WMSetLabelImage(panel->iconLabel, NULL); + } else { + WMSetLabelImage(panel->iconLabel, pixmap); + WMReleasePixmap(pixmap); + } + } + wfree(file); + wfree(path); } } @@ -187,22 +187,22 @@ chooseIconCallback(WMWidget *self, void *clientData) WMSetButtonEnabled(panel->browseBtn, False); result = wIconChooserDialog(panel->wwin->screen_ptr, &file, - panel->editedIcon->wm_instance, - panel->editedIcon->wm_class); + panel->editedIcon->wm_instance, + panel->editedIcon->wm_class); panel->choosingIcon = 0; if (!panel->destroyed) { - if (result) { - WMSetTextFieldText(panel->iconField, file); - wfree(file); - updateSettingsPanelIcon(panel); - } + if (result) { + WMSetTextFieldText(panel->iconField, file); + wfree(file); + updateSettingsPanelIcon(panel); + } - WMSetButtonEnabled(panel->browseBtn, True); + WMSetButtonEnabled(panel->browseBtn, True); } else { - /* kluge for the case, the user asked to close the panel before - * the icon chooser */ - DestroyDockAppSettingsPanel(panel); + /* kluge for the case, the user asked to close the panel before + * the icon chooser */ + DestroyDockAppSettingsPanel(panel); } } @@ -217,66 +217,66 @@ panelBtnCallback(WMWidget *self, void *data) done = 1; if (panel->okBtn == btn) { - text = WMGetTextFieldText(panel->iconField); - if (text[0]==0) { - wfree(text); - text = NULL; - } - if (!wIconChangeImageFile(panel->editedIcon->icon, text)) { - char *buf; - int len = strlen(text) + 64; - - buf = wmalloc(len); - snprintf(buf, len, _("Could not open specified icon file: %s"), text); - if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf, - _("OK"), _("Ignore"), NULL) == WAPRDefault) { - if (text) - wfree(text); - wfree(buf); - return; - } - wfree(buf); - } else { - WAppIcon *aicon = panel->editedIcon; - - if (aicon == aicon->icon->core->screen_ptr->clip_icon) - wClipIconPaint(aicon); - else - wAppIconPaint(aicon); - - wDefaultChangeIcon(panel->wwin->screen_ptr, aicon->wm_instance, - aicon->wm_class, text); - } - if (text) - wfree(text); - - /* cannot free text from this, because it will be not be duplicated - * in updateCommand */ - text = WMGetTextFieldText(panel->commandField); - if (text[0]==0) { - wfree(text); - text = NULL; - } - updateCommand(panel->editedIcon, text); + text = WMGetTextFieldText(panel->iconField); + if (text[0]==0) { + wfree(text); + text = NULL; + } + if (!wIconChangeImageFile(panel->editedIcon->icon, text)) { + char *buf; + int len = strlen(text) + 64; + + buf = wmalloc(len); + snprintf(buf, len, _("Could not open specified icon file: %s"), text); + if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf, + _("OK"), _("Ignore"), NULL) == WAPRDefault) { + if (text) + wfree(text); + wfree(buf); + return; + } + wfree(buf); + } else { + WAppIcon *aicon = panel->editedIcon; + + if (aicon == aicon->icon->core->screen_ptr->clip_icon) + wClipIconPaint(aicon); + else + wAppIconPaint(aicon); + + wDefaultChangeIcon(panel->wwin->screen_ptr, aicon->wm_instance, + aicon->wm_class, text); + } + if (text) + wfree(text); + + /* cannot free text from this, because it will be not be duplicated + * in updateCommand */ + text = WMGetTextFieldText(panel->commandField); + if (text[0]==0) { + wfree(text); + text = NULL; + } + updateCommand(panel->editedIcon, text); #ifdef OFFIX_DND - /* cannot free text from this, because it will be not be duplicated - * in updateDNDCommand */ - text = WMGetTextFieldText(panel->dndCommandField); - updateDNDCommand(panel->editedIcon, text); + /* cannot free text from this, because it will be not be duplicated + * in updateDNDCommand */ + text = WMGetTextFieldText(panel->dndCommandField); + updateDNDCommand(panel->editedIcon, text); #endif - text = WMGetTextFieldText(panel->pasteCommandField); - updatePasteCommand(panel->editedIcon, text); + text = WMGetTextFieldText(panel->pasteCommandField); + updatePasteCommand(panel->editedIcon, text); - panel->editedIcon->auto_launch = - WMGetButtonSelected(panel->autoLaunchBtn); + panel->editedIcon->auto_launch = + WMGetButtonSelected(panel->autoLaunchBtn); - panel->editedIcon->lock = - WMGetButtonSelected(panel->lockBtn); + panel->editedIcon->lock = + WMGetButtonSelected(panel->lockBtn); } if (done) - DestroyDockAppSettingsPanel(panel); + DestroyDockAppSettingsPanel(panel); } @@ -304,7 +304,7 @@ ShowDockAppSettingsPanel(WAppIcon *aicon) panel->win = WMCreateWindow(scr->wmscreen, "applicationSettings"); WMResizeWidget(panel->win, PWIDTH, PHEIGHT); - + panel->iconLabel = WMCreateLabel(panel->win); WMResizeWidget(panel->iconLabel, 64, 64); WMMoveWidget(panel->iconLabel, 10, 10); @@ -318,46 +318,46 @@ ShowDockAppSettingsPanel(WAppIcon *aicon) WMSetLabelFont(panel->nameLabel, font); WMReleaseFont(font); if (aicon->wm_class && strcmp(aicon->wm_class, "DockApp")==0) - WMSetLabelText(panel->nameLabel, aicon->wm_instance); + WMSetLabelText(panel->nameLabel, aicon->wm_instance); else - WMSetLabelText(panel->nameLabel, aicon->wm_class); + WMSetLabelText(panel->nameLabel, aicon->wm_class); + - vbox = WMCreateBox(panel->win); WMResizeWidget(vbox, PWIDTH-20, PHEIGHT-84-10); WMMoveWidget(vbox, 10, 84); - + panel->autoLaunchBtn = WMCreateSwitchButton(vbox); WMAddBoxSubview(vbox, WMWidgetView(panel->autoLaunchBtn), False, True, - 20, 20, 2); + 20, 20, 2); WMSetButtonText(panel->autoLaunchBtn, - _("Start when Window Maker is started")); + _("Start when Window Maker is started")); WMSetButtonSelected(panel->autoLaunchBtn, aicon->auto_launch); panel->lockBtn = WMCreateSwitchButton(vbox); WMAddBoxSubview(vbox, WMWidgetView(panel->lockBtn), False, True, - 20, 20, 5); + 20, 20, 5); WMSetButtonText(panel->lockBtn, - _("Lock (prevent accidental removal)")); + _("Lock (prevent accidental removal)")); WMSetButtonSelected(panel->lockBtn, aicon->lock); panel->commandFrame = WMCreateFrame(vbox); WMSetFrameTitle(panel->commandFrame, _("Application path and arguments")); WMAddBoxSubview(vbox, WMWidgetView(panel->commandFrame), False, True, - 50, 50, 5); + 50, 50, 5); panel->commandField = WMCreateTextField(panel->commandFrame); WMResizeWidget(panel->commandField, 256, 20); WMMoveWidget(panel->commandField, 10, 20); WMSetTextFieldText(panel->commandField, aicon->command); - WMMapSubwidgets(panel->commandFrame); + WMMapSubwidgets(panel->commandFrame); panel->pasteCommandFrame = WMCreateFrame(vbox); WMSetFrameTitle(panel->pasteCommandFrame, - _("Command for middle-click launch")); + _("Command for middle-click launch")); WMAddBoxSubview(vbox, WMWidgetView(panel->pasteCommandFrame), False, True, - 70, 70, 5); + 70, 70, 5); panel->pasteCommandField = WMCreateTextField(panel->pasteCommandFrame); WMResizeWidget(panel->pasteCommandField, 256, 20); @@ -369,14 +369,14 @@ ShowDockAppSettingsPanel(WAppIcon *aicon) WMSetTextFieldText(panel->pasteCommandField, aicon->paste_command); WMSetLabelText(panel->pasteCommandLabel, - _("%s will be replaced with current selection")); - WMMapSubwidgets(panel->pasteCommandFrame); - + _("%s will be replaced with current selection")); + WMMapSubwidgets(panel->pasteCommandFrame); + panel->dndCommandFrame = WMCreateFrame(vbox); WMSetFrameTitle(panel->dndCommandFrame, - _("Command for files dropped with DND")); + _("Command for files dropped with DND")); WMAddBoxSubview(vbox, WMWidgetView(panel->dndCommandFrame), False, True, - 70, 70, 5); + 70, 70, 5); panel->dndCommandField = WMCreateTextField(panel->dndCommandFrame); WMResizeWidget(panel->dndCommandField, 256, 20); @@ -388,25 +388,25 @@ ShowDockAppSettingsPanel(WAppIcon *aicon) #ifdef OFFIX_DND WMSetTextFieldText(panel->dndCommandField, aicon->dnd_command); WMSetLabelText(panel->dndCommandLabel, - _("%d will be replaced with the file name")); + _("%d will be replaced with the file name")); #else WMSetTextFieldEditable(panel->dndCommandField, False); WMSetLabelText(panel->dndCommandLabel, - _("DND support was not compiled in")); + _("DND support was not compiled in")); #endif - WMMapSubwidgets(panel->dndCommandFrame); + WMMapSubwidgets(panel->dndCommandFrame); panel->iconFrame = WMCreateFrame(vbox); WMSetFrameTitle(panel->iconFrame, _("Icon Image")); WMAddBoxSubview(vbox, WMWidgetView(panel->iconFrame), False, True, - 50, 50, 10); + 50, 50, 10); panel->iconField = WMCreateTextField(panel->iconFrame); WMResizeWidget(panel->iconField, 176, 20); WMMoveWidget(panel->iconField, 10, 20); WMSetTextFieldText(panel->iconField, - wDefaultGetIconFile(scr, aicon->wm_instance, - aicon->wm_class, True)); + wDefaultGetIconFile(scr, aicon->wm_instance, + aicon->wm_class, True)); panel->browseBtn = WMCreateCommandButton(panel->iconFrame); WMResizeWidget(panel->browseBtn, 70, 24); @@ -416,26 +416,26 @@ ShowDockAppSettingsPanel(WAppIcon *aicon) { - WMBox *hbox; - - hbox = WMCreateBox(vbox); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubview(vbox, WMWidgetView(hbox), False, True, 24, 24, 0); - - - panel->okBtn = WMCreateCommandButton(hbox); - WMSetButtonText(panel->okBtn, _("OK")); - WMSetButtonAction(panel->okBtn, panelBtnCallback, panel); - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->okBtn), False, True, 80, 80, 0); - - panel->cancelBtn = WMCreateCommandButton(hbox); - WMSetButtonText(panel->cancelBtn, _("Cancel")); - WMSetButtonAction(panel->cancelBtn, panelBtnCallback, panel); - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->cancelBtn), False, True, 80, 80, 5); - - WMMapSubwidgets(hbox); + WMBox *hbox; + + hbox = WMCreateBox(vbox); + WMSetBoxHorizontal(hbox, True); + WMAddBoxSubview(vbox, WMWidgetView(hbox), False, True, 24, 24, 0); + + + panel->okBtn = WMCreateCommandButton(hbox); + WMSetButtonText(panel->okBtn, _("OK")); + WMSetButtonAction(panel->okBtn, panelBtnCallback, panel); + WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->okBtn), False, True, 80, 80, 0); + + panel->cancelBtn = WMCreateCommandButton(hbox); + WMSetButtonText(panel->cancelBtn, _("Cancel")); + WMSetButtonAction(panel->cancelBtn, panelBtnCallback, panel); + WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->cancelBtn), False, True, 80, 80, 5); + + WMMapSubwidgets(hbox); } - + WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win); WMMapSubwidgets(vbox); @@ -444,7 +444,7 @@ ShowDockAppSettingsPanel(WAppIcon *aicon) updateSettingsPanelIcon(panel); parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT, - 0, 0, 0); + 0, 0, 0); XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask); XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); @@ -453,27 +453,27 @@ ShowDockAppSettingsPanel(WAppIcon *aicon) * make things relative to head */ { - WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr)); - - y = aicon->y_pos; - if (y < 0) - y = 0; - else if (y + PHEIGHT > rect.pos.y + rect.size.height) - y = rect.pos.y + rect.size.height - PHEIGHT - 30; - - if (aicon->dock && aicon->dock->type == WM_DOCK) { - if (aicon->dock->on_right_side) - x = rect.pos.x + rect.size.width/2; - else - x = rect.pos.x + rect.size.width/2 - PWIDTH - 2; - } else { - x = rect.pos.x + (rect.size.width - PWIDTH)/2; - } + WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr)); + + y = aicon->y_pos; + if (y < 0) + y = 0; + else if (y + PHEIGHT > rect.pos.y + rect.size.height) + y = rect.pos.y + rect.size.height - PHEIGHT - 30; + + if (aicon->dock && aicon->dock->type == WM_DOCK) { + if (aicon->dock->on_right_side) + x = rect.pos.x + rect.size.width/2; + else + x = rect.pos.x + rect.size.width/2 - PWIDTH - 2; + } else { + x = rect.pos.x + (rect.size.width - PWIDTH)/2; + } } panel->wwin = wManageInternalWindow(scr, parent, None, - _("Docked Application Settings"), - x, y, PWIDTH, PHEIGHT); + _("Docked Application Settings"), + x, y, PWIDTH, PHEIGHT); panel->wwin->client_leader = WMWidgetXID(panel->win); @@ -489,10 +489,10 @@ void DestroyDockAppSettingsPanel(AppSettingsPanel *panel) { if (!panel->destroyed) { - XUnmapWindow(dpy, panel->wwin->client_win); - XReparentWindow(dpy, panel->wwin->client_win, - panel->wwin->screen_ptr->root_win, 0, 0); - wUnmanageWindow(panel->wwin, False, False); + XUnmapWindow(dpy, panel->wwin->client_win); + XReparentWindow(dpy, panel->wwin->client_win, + panel->wwin->screen_ptr->root_win, 0, 0); + wUnmanageWindow(panel->wwin, False, False); } panel->destroyed = 1; @@ -504,7 +504,7 @@ DestroyDockAppSettingsPanel(AppSettingsPanel *panel) * but it is not working for some reason. */ if (panel->choosingIcon) - return; + return; WMDestroyWidget(panel->win); @@ -516,3 +516,4 @@ DestroyDockAppSettingsPanel(AppSettingsPanel *panel) wfree(panel); } + diff --git a/src/event.c b/src/event.c index d5cab4dc..b3a16b66 100644 --- a/src/event.c +++ b/src/event.c @@ -1,9 +1,9 @@ /* event.c- event loop and handling - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -40,8 +40,8 @@ #include "xdnd.h" #endif -#ifdef KEEP_XKB_LOCK_STATUS -#include +#ifdef KEEP_XKB_LOCK_STATUS +#include #endif /* KEEP_XKB_LOCK_STATUS */ #include "WindowMaker.h" @@ -105,7 +105,7 @@ extern Bool wShapeSupported; extern int wShapeEventBase; #endif -#ifdef KEEP_XKB_LOCK_STATUS +#ifdef KEEP_XKB_LOCK_STATUS extern int wXkbEventBase; #endif @@ -118,8 +118,10 @@ extern char WDelayedActionSet; static void saveTimestamp(XEvent *event); static void handleColormapNotify(); -static void handleMapNotify(), handleUnmapNotify(); -static void handleButtonPress(), handleExpose(); +static void handleMapNotify(); +static void handleUnmapNotify(); +static void handleButtonPress(); +static void handleExpose(); static void handleDestroyNotify(); static void handleConfigureRequest(); static void handleMapRequest(); @@ -169,17 +171,17 @@ WMagicNumber wAddDeathHandler(pid_t pid, WDeathHandler *callback, void *cdata) { DeathHandler *handler; - + handler = malloc(sizeof(DeathHandler)); if (!handler) - return 0; + return 0; handler->pid = pid; handler->callback = callback; handler->client_data = cdata; if (!deathHandlers) - deathHandlers = WMCreateArrayWithDestructor(8, wfree); + deathHandlers = WMCreateArrayWithDestructor(8, wfree); WMAddToArray(deathHandlers, handler); @@ -188,13 +190,13 @@ wAddDeathHandler(pid_t pid, WDeathHandler *callback, void *cdata) -void +void wDeleteDeathHandler(WMagicNumber id) { DeathHandler *handler=(DeathHandler*)id; if (!handler || !deathHandlers) - return; + return; /* array destructor will call wfree(handler) */ WMRemoveFromArray(deathHandlers, handler); @@ -205,24 +207,24 @@ void DispatchEvent(XEvent *event) { if (deathHandlers) - handleDeadProcess(NULL); + handleDeadProcess(NULL); if (WCHECK_STATE(WSTATE_NEED_EXIT)) { - WCHANGE_STATE(WSTATE_EXITING); - /* received SIGTERM */ - /* - * WMHandleEvent() can't be called from anything - * executed inside here, or we can get in a infinite - * recursive loop. - */ - Shutdown(WSExitMode); + WCHANGE_STATE(WSTATE_EXITING); + /* received SIGTERM */ + /* + * WMHandleEvent() can't be called from anything + * executed inside here, or we can get in a infinite + * recursive loop. + */ + Shutdown(WSExitMode); } else if (WCHECK_STATE(WSTATE_NEED_RESTART)) { - WCHANGE_STATE(WSTATE_RESTARTING); + WCHANGE_STATE(WSTATE_RESTARTING); - Shutdown(WSRestartPreparationMode); - /* received SIGHUP */ - Restart(NULL, True); + Shutdown(WSRestartPreparationMode); + /* received SIGHUP */ + Restart(NULL, True); } else if (WCHECK_STATE(WSTATE_NEED_REREAD)) { WCHANGE_STATE(WSTATE_NORMAL); wDefaultsCheckDomains("bla"); @@ -231,82 +233,82 @@ DispatchEvent(XEvent *event) /* for the case that all that is wanted to be dispatched is * the stuff above */ if (!event) - return; + return; saveTimestamp(event); switch (event->type) { - case MapRequest: - handleMapRequest(event); - break; - - case KeyPress: - handleKeyPress(event); - break; - - case MotionNotify: - handleMotionNotify(event); - break; - - case ConfigureRequest: - handleConfigureRequest(event); - break; - - case DestroyNotify: - handleDestroyNotify(event); - break; - - case MapNotify: - handleMapNotify(event); - break; - - case UnmapNotify: - handleUnmapNotify(event); - break; - - case ButtonPress: - handleButtonPress(event); - break; - - case Expose: - handleExpose(event); - break; - - case PropertyNotify: - handlePropertyNotify(event); - break; - - case EnterNotify: - handleEnterNotify(event); - break; - - case LeaveNotify: + case MapRequest: + handleMapRequest(event); + break; + + case KeyPress: + handleKeyPress(event); + break; + + case MotionNotify: + handleMotionNotify(event); + break; + + case ConfigureRequest: + handleConfigureRequest(event); + break; + + case DestroyNotify: + handleDestroyNotify(event); + break; + + case MapNotify: + handleMapNotify(event); + break; + + case UnmapNotify: + handleUnmapNotify(event); + break; + + case ButtonPress: + handleButtonPress(event); + break; + + case Expose: + handleExpose(event); + break; + + case PropertyNotify: + handlePropertyNotify(event); + break; + + case EnterNotify: + handleEnterNotify(event); + break; + + case LeaveNotify: handleLeaveNotify(event); - break; - - case ClientMessage: - handleClientMessage(event); - break; - - case ColormapNotify: - handleColormapNotify(event); - break; - - case MappingNotify: - if (event->xmapping.request == MappingKeyboard - || event->xmapping.request == MappingModifier) - XRefreshKeyboardMapping(&event->xmapping); - break; - - case FocusIn: - handleFocusIn(event); - break; - - case VisibilityNotify: - handleVisibilityNotify(event); - break; - default: - handleExtensions(event); - break; + break; + + case ClientMessage: + handleClientMessage(event); + break; + + case ColormapNotify: + handleColormapNotify(event); + break; + + case MappingNotify: + if (event->xmapping.request == MappingKeyboard + || event->xmapping.request == MappingModifier) + XRefreshKeyboardMapping(&event->xmapping); + break; + + case FocusIn: + handleFocusIn(event); + break; + + case VisibilityNotify: + handleVisibilityNotify(event); + break; + default: + handleExtensions(event); + break; } } @@ -315,13 +317,13 @@ DispatchEvent(XEvent *event) *---------------------------------------------------------------------- * EventLoop- * Processes X and internal events indefinitely. - * + * * Returns: * Never returns - * + * * Side effects: * The LastTimestamp global variable is updated. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ void EventLoop() @@ -329,8 +331,8 @@ EventLoop() XEvent event; for(;;) { - WMNextEvent(dpy, &event); - WMHandleEvent(&event); + WMNextEvent(dpy, &event); + WMHandleEvent(&event); } } @@ -346,7 +348,7 @@ EventLoop() * are processed. * * Side effects: - * Many -- whatever handling events may involve. + * Many -- whatever handling events may involve. * *---------------------------------------------------------------------- */ @@ -369,19 +371,19 @@ ProcessPendingEvents() } -Bool +Bool IsDoubleClick(WScreen *scr, XEvent *event) { - if ((scr->last_click_time>0) && - (event->xbutton.time-scr->last_click_time<=wPreferences.dblclick_time) - && (event->xbutton.button == scr->last_click_button) - && (event->xbutton.window == scr->last_click_window)) { + if ((scr->last_click_time>0) && + (event->xbutton.time-scr->last_click_time<=wPreferences.dblclick_time) + && (event->xbutton.button == scr->last_click_button) + && (event->xbutton.window == scr->last_click_window)) { - scr->flags.next_click_is_not_double = 1; - scr->last_click_time = 0; - scr->last_click_window = event->xbutton.window; + scr->flags.next_click_is_not_double = 1; + scr->last_click_time = 0; + scr->last_click_window = event->xbutton.window; - return True; + return True; } return False; } @@ -391,8 +393,8 @@ void NotifyDeadProcess(pid_t pid, unsigned char status) { if (deadProcessPtr>=MAX_DEAD_PROCESSES-1) { - wwarning("stack overflow: too many dead processes"); - return; + wwarning("stack overflow: too many dead processes"); + return; } /* stack the process to be handled later, * as this is called from the signal handler */ @@ -409,30 +411,30 @@ handleDeadProcess(void *foo) int i; for (i=0; i0) { - deadProcessPtr--; - - for (i = WMGetArrayItemCount(deathHandlers)-1; i >= 0; i--) { - tmp = WMGetFromArray(deathHandlers, i); - if (!tmp) - continue; - - if (tmp->pid == deadProcesses[deadProcessPtr].pid) { - (*tmp->callback)(tmp->pid, - deadProcesses[deadProcessPtr].exit_status, - tmp->client_data); - wDeleteDeathHandler(tmp); - } - } + deadProcessPtr--; + + for (i = WMGetArrayItemCount(deathHandlers)-1; i >= 0; i--) { + tmp = WMGetFromArray(deathHandlers, i); + if (!tmp) + continue; + + if (tmp->pid == deadProcesses[deadProcessPtr].pid) { + (*tmp->callback)(tmp->pid, + deadProcesses[deadProcessPtr].exit_status, + tmp->client_data); + wDeleteDeathHandler(tmp); + } + } } } @@ -446,36 +448,36 @@ saveTimestamp(XEvent *event) */ switch (event->type) { - case ButtonRelease: - case ButtonPress: - LastTimestamp = event->xbutton.time; - break; - case KeyPress: - case KeyRelease: - LastTimestamp = event->xkey.time; - break; - case MotionNotify: - LastTimestamp = event->xmotion.time; - break; - case PropertyNotify: - LastTimestamp = event->xproperty.time; - break; - case EnterNotify: - case LeaveNotify: - LastTimestamp = event->xcrossing.time; - break; - case SelectionClear: - LastTimestamp = event->xselectionclear.time; - break; - case SelectionRequest: - LastTimestamp = event->xselectionrequest.time; - break; - case SelectionNotify: - LastTimestamp = event->xselection.time; + case ButtonRelease: + case ButtonPress: + LastTimestamp = event->xbutton.time; + break; + case KeyPress: + case KeyRelease: + LastTimestamp = event->xkey.time; + break; + case MotionNotify: + LastTimestamp = event->xmotion.time; + break; + case PropertyNotify: + LastTimestamp = event->xproperty.time; + break; + case EnterNotify: + case LeaveNotify: + LastTimestamp = event->xcrossing.time; + break; + case SelectionClear: + LastTimestamp = event->xselectionclear.time; + break; + case SelectionRequest: + LastTimestamp = event->xselectionrequest.time; + break; + case SelectionNotify: + LastTimestamp = event->xselection.time; #ifdef XDND wXDNDProcessSelection(event); #endif - break; + break; } } @@ -490,16 +492,16 @@ matchWindow(void *item, void *cdata) static void handleExtensions(XEvent *event) { -#ifdef KEEP_XKB_LOCK_STATUS +#ifdef KEEP_XKB_LOCK_STATUS XkbEvent *xkbevent; xkbevent = (XkbEvent *)event; #endif /*KEEP_XKB_LOCK_STATUS*/ #ifdef SHAPE if (wShapeSupported && event->type == (wShapeEventBase+ShapeNotify)) { - handleShapeNotify(event); + handleShapeNotify(event); } -#endif -#ifdef KEEP_XKB_LOCK_STATUS +#endif +#ifdef KEEP_XKB_LOCK_STATUS if (wPreferences.modelock && (xkbevent->type == wXkbEventBase)){ handleXkbIndicatorStateNotify(event); } @@ -507,7 +509,7 @@ handleExtensions(XEvent *event) } -static void +static void handleMapRequest(XEvent *ev) { WWindow *wwin; @@ -518,64 +520,64 @@ handleMapRequest(XEvent *ev) printf("got map request for %x\n", (unsigned)window); #endif if ((wwin = wWindowFor(window))) { - if (wwin->flags.shaded) { - wUnshadeWindow(wwin); - } - /* deiconify window */ - if (wwin->flags.miniaturized) { - wDeiconifyWindow(wwin); - } else if (wwin->flags.hidden) { + if (wwin->flags.shaded) { + wUnshadeWindow(wwin); + } + /* deiconify window */ + if (wwin->flags.miniaturized) { + wDeiconifyWindow(wwin); + } else if (wwin->flags.hidden) { WApplication *wapp = wApplicationOf(wwin->main_window); /* go to the last workspace that the user worked on the app */ if (wapp) { wWorkspaceChange(wwin->screen_ptr, wapp->last_workspace); } - wUnhideApplication(wapp, False, False); - } - return; + wUnhideApplication(wapp, False, False); + } + return; } scr = wScreenForRootWindow(ev->xmaprequest.parent); wwin = wManageWindow(scr, window); - /* + /* * This is to let the Dock know that the application it launched - * has already been mapped (eg: it has finished launching). + * has already been mapped (eg: it has finished launching). * It is not necessary for normally docked apps, but is needed for * apps that were forcedly docked (like with dockit). */ if (scr->last_dock) { - if (wwin && wwin->main_window!=None && wwin->main_window!=window) - wDockTrackWindowLaunch(scr->last_dock, wwin->main_window); - else - wDockTrackWindowLaunch(scr->last_dock, window); + if (wwin && wwin->main_window!=None && wwin->main_window!=window) + wDockTrackWindowLaunch(scr->last_dock, wwin->main_window); + else + wDockTrackWindowLaunch(scr->last_dock, window); } if (wwin) { - wClientSetState(wwin, NormalState, None); - if (wwin->flags.maximized) { - wMaximizeWindow(wwin, wwin->flags.maximized); - } - if (wwin->flags.shaded) { - wwin->flags.shaded = 0; - wwin->flags.skip_next_animation = 1; - wShadeWindow(wwin); - } - if (wwin->flags.miniaturized) { - wwin->flags.miniaturized = 0; - wwin->flags.skip_next_animation = 1; - wIconifyWindow(wwin); - } - if (wwin->flags.hidden) { - WApplication *wapp = wApplicationOf(wwin->main_window); - - wwin->flags.hidden = 0; - wwin->flags.skip_next_animation = 1; - if (wapp) { - wHideApplication(wapp); - } - } + wClientSetState(wwin, NormalState, None); + if (wwin->flags.maximized) { + wMaximizeWindow(wwin, wwin->flags.maximized); + } + if (wwin->flags.shaded) { + wwin->flags.shaded = 0; + wwin->flags.skip_next_animation = 1; + wShadeWindow(wwin); + } + if (wwin->flags.miniaturized) { + wwin->flags.miniaturized = 0; + wwin->flags.skip_next_animation = 1; + wIconifyWindow(wwin); + } + if (wwin->flags.hidden) { + WApplication *wapp = wApplicationOf(wwin->main_window); + + wwin->flags.hidden = 0; + wwin->flags.skip_next_animation = 1; + if (wapp) { + wHideApplication(wapp); + } + } } } @@ -594,7 +596,7 @@ handleDestroyNotify(XEvent *event) #endif wwin = wWindowFor(window); if (wwin) { - wUnmanageWindow(wwin, False, True); + wUnmanageWindow(wwin, False, True); } if (scr != NULL) { @@ -617,19 +619,19 @@ handleDestroyNotify(XEvent *event) app = wApplicationOf(window); if (app) { - if (window == app->main_window) { - app->refcount = 0; - wwin = app->main_window_desc->screen_ptr->focused_window; - while (wwin) { - if (wwin->main_window == window) { - wwin->main_window = None; - } - wwin = wwin->prev; - } - } - wApplicationDestroy(app); + if (window == app->main_window) { + app->refcount = 0; + wwin = app->main_window_desc->screen_ptr->focused_window; + while (wwin) { + if (wwin->main_window == window) { + wwin->main_window = None; + } + wwin = wwin->prev; + } + } + wApplicationDestroy(app); } - + #ifdef KWM_HINTS wKWMCheckDestroy(&event->xdestroywindow); #endif @@ -637,7 +639,7 @@ handleDestroyNotify(XEvent *event) -static void +static void handleExpose(XEvent *event) { WObjDescriptor *desc; @@ -648,13 +650,13 @@ handleExpose(XEvent *event) #endif while (XCheckTypedWindowEvent(dpy, event->xexpose.window, Expose, &ev)); - if (XFindContext(dpy, event->xexpose.window, wWinContext, - (XPointer *)&desc)==XCNOENT) { - return; + if (XFindContext(dpy, event->xexpose.window, wWinContext, + (XPointer *)&desc)==XCNOENT) { + return; } - + if (desc->handle_expose) { - (*desc->handle_expose)(desc, event); + (*desc->handle_expose)(desc, event); } } @@ -662,11 +664,11 @@ static void executeButtonAction(WScreen *scr, XEvent *event, int action) { switch(action) { - case WA_SELECT_WINDOWS: + case WA_SELECT_WINDOWS: wUnselectWindows(scr); wSelectWindows(scr, event); break; - case WA_OPEN_APPMENU: + case WA_OPEN_APPMENU: OpenRootMenu(scr, event->xbutton.x_root, event->xbutton.y_root, False); /* ugly hack */ if (scr->root_menu) { @@ -676,7 +678,7 @@ executeButtonAction(WScreen *scr, XEvent *event, int action) event->xbutton.window = scr->root_menu->frame->core->window; } break; - case WA_OPEN_WINLISTMENU: + case WA_OPEN_WINLISTMENU: OpenSwitchMenu(scr, event->xbutton.x_root, event->xbutton.y_root, False); if (scr->switch_menu) { if (scr->switch_menu->brother->flags.mapped) @@ -697,19 +699,19 @@ handleButtonPress(XEvent *event) { WObjDescriptor *desc; WScreen *scr; - + #ifdef DEBUG printf("got button press\n"); #endif scr = wScreenForRootWindow(event->xbutton.root); - + #ifdef BALLOON_TEXT wBalloonHide(scr); #endif - + #ifndef LITE - if (event->xbutton.window==scr->root_win) { + if (event->xbutton.window==scr->root_win) { if (event->xbutton.button==Button1 && wPreferences.mouse_button1!=WA_NONE) { executeButtonAction(scr, event, wPreferences.mouse_button1); @@ -721,62 +723,62 @@ handleButtonPress(XEvent *event) executeButtonAction(scr, event, wPreferences.mouse_button3); } else if (event->xbutton.button==Button4 && wPreferences.mouse_wheel!=WA_NONE) { - wWorkspaceRelativeChange(scr, 1); + wWorkspaceRelativeChange(scr, 1); } else if (event->xbutton.button==Button5 && wPreferences.mouse_wheel!=WA_NONE) { wWorkspaceRelativeChange(scr, -1); } #ifdef GNOME_STUFF - else if (wGNOMEProxyizeButtonEvent(scr, event)) - return; + else if (wGNOMEProxyizeButtonEvent(scr, event)) + return; #endif } #endif /* !LITE */ desc = NULL; if (XFindContext(dpy, event->xbutton.subwindow, wWinContext, - (XPointer *)&desc)==XCNOENT) { - if (XFindContext(dpy, event->xbutton.window, wWinContext, - (XPointer *)&desc)==XCNOENT) { - return; - } + (XPointer *)&desc)==XCNOENT) { + if (XFindContext(dpy, event->xbutton.window, wWinContext, + (XPointer *)&desc)==XCNOENT) { + return; + } } if (desc->parent_type == WCLASS_WINDOW) { - XSync(dpy, 0); - - if (event->xbutton.state & MOD_MASK) { - XAllowEvents(dpy, AsyncPointer, CurrentTime); - } - -/* if (wPreferences.focus_mode == WKF_CLICK) {*/ - if (wPreferences.ignore_focus_click) { - XAllowEvents(dpy, AsyncPointer, CurrentTime); - } - XAllowEvents(dpy, ReplayPointer, CurrentTime); -/* }*/ - XSync(dpy, 0); + XSync(dpy, 0); + + if (event->xbutton.state & MOD_MASK) { + XAllowEvents(dpy, AsyncPointer, CurrentTime); + } + + /* if (wPreferences.focus_mode == WKF_CLICK) {*/ + if (wPreferences.ignore_focus_click) { + XAllowEvents(dpy, AsyncPointer, CurrentTime); + } + XAllowEvents(dpy, ReplayPointer, CurrentTime); + /* }*/ + XSync(dpy, 0); } else if (desc->parent_type == WCLASS_APPICON - || desc->parent_type == WCLASS_MINIWINDOW - || desc->parent_type == WCLASS_DOCK_ICON) { - if (event->xbutton.state & MOD_MASK) { - XSync(dpy, 0); - XAllowEvents(dpy, AsyncPointer, CurrentTime); - XSync(dpy, 0); - } + || desc->parent_type == WCLASS_MINIWINDOW + || desc->parent_type == WCLASS_DOCK_ICON) { + if (event->xbutton.state & MOD_MASK) { + XSync(dpy, 0); + XAllowEvents(dpy, AsyncPointer, CurrentTime); + XSync(dpy, 0); + } } if (desc->handle_mousedown!=NULL) { - (*desc->handle_mousedown)(desc, event); + (*desc->handle_mousedown)(desc, event); } /* save double-click information */ if (scr->flags.next_click_is_not_double) { - scr->flags.next_click_is_not_double = 0; + scr->flags.next_click_is_not_double = 0; } else { - scr->last_click_time = event->xbutton.time; - scr->last_click_button = event->xbutton.button; - scr->last_click_window = event->xbutton.window; + scr->last_click_time = event->xbutton.time; + scr->last_click_button = event->xbutton.button; + scr->last_click_window = event->xbutton.window; } } @@ -790,14 +792,14 @@ handleMapNotify(XEvent *event) #endif wwin = wWindowFor(event->xmap.event); if (wwin && wwin->client_win == event->xmap.event) { - if (wwin->flags.miniaturized) { - wDeiconifyWindow(wwin); - } else { - XGrabServer(dpy); - wWindowMap(wwin); - wClientSetState(wwin, NormalState, None); - XUngrabServer(dpy); - } + if (wwin->flags.miniaturized) { + wDeiconifyWindow(wwin); + } else { + XGrabServer(dpy); + wWindowMap(wwin); + wClientSetState(wwin, NormalState, None); + XUngrabServer(dpy); + } } } @@ -811,24 +813,24 @@ handleUnmapNotify(XEvent *event) #ifdef DEBUG printf("got unmap\n"); #endif - /* only process windows with StructureNotify selected + /* only process windows with StructureNotify selected * (ignore SubstructureNotify) */ wwin = wWindowFor(event->xunmap.window); if (!wwin) - return; + return; /* whether the event is a Withdrawal request */ if (event->xunmap.event == wwin->screen_ptr->root_win - && event->xunmap.send_event) - withdraw = True; + && event->xunmap.send_event) + withdraw = True; if (wwin->client_win != event->xunmap.event && !withdraw) - return; + return; if (!wwin->flags.mapped && !withdraw - && wwin->frame->workspace == wwin->screen_ptr->current_workspace - && !wwin->flags.miniaturized && !wwin->flags.hidden) - return; + && wwin->frame->workspace == wwin->screen_ptr->current_workspace + && !wwin->flags.miniaturized && !wwin->flags.hidden) + return; XGrabServer(dpy); XUnmapWindow(dpy, wwin->frame->core->window); @@ -836,21 +838,21 @@ handleUnmapNotify(XEvent *event) XSync(dpy, 0); /* check if the window was destroyed */ if (XCheckTypedWindowEvent(dpy, wwin->client_win, DestroyNotify,&ev)) { - DispatchEvent(&ev); + DispatchEvent(&ev); } else { - Bool reparented = False; - - if (XCheckTypedWindowEvent(dpy, wwin->client_win, ReparentNotify, &ev)) - reparented = True; - - /* withdraw window */ - wwin->flags.mapped = 0; - if (!reparented) - wClientSetState(wwin, WithdrawnState, None); - - /* if the window was reparented, do not reparent it back to the - * root window */ - wUnmanageWindow(wwin, !reparented, False); + Bool reparented = False; + + if (XCheckTypedWindowEvent(dpy, wwin->client_win, ReparentNotify, &ev)) + reparented = True; + + /* withdraw window */ + wwin->flags.mapped = 0; + if (!reparented) + wClientSetState(wwin, WithdrawnState, None); + + /* if the window was reparented, do not reparent it back to the + * root window */ + wUnmanageWindow(wwin, !reparented, False); } XUngrabServer(dpy); } @@ -864,12 +866,12 @@ handleConfigureRequest(XEvent *event) printf("got configure request\n"); #endif if (!(wwin=wWindowFor(event->xconfigurerequest.window))) { - /* - * Configure request for unmapped window - */ - wClientConfigure(NULL, &(event->xconfigurerequest)); + /* + * Configure request for unmapped window + */ + wClientConfigure(NULL, &(event->xconfigurerequest)); } else { - wClientConfigure(wwin, &(event->xconfigurerequest)); + wClientConfigure(wwin, &(event->xconfigurerequest)); } } @@ -887,21 +889,21 @@ handlePropertyNotify(XEvent *event) printf("got property notify\n"); #endif if ((wwin=wWindowFor(event->xproperty.window))) { - if (!XGetGeometry(dpy, wwin->client_win, &jr, &ji, &ji, - &ju, &ju, &ju, &ju)) { - return; - } - wClientCheckProperty(wwin, &event->xproperty); + if (!XGetGeometry(dpy, wwin->client_win, &jr, &ji, &ji, + &ju, &ju, &ju, &ju)) { + return; + } + wClientCheckProperty(wwin, &event->xproperty); } wapp = wApplicationOf(event->xproperty.window); if (wapp) { - wClientCheckProperty(wapp->main_window_desc, &event->xproperty); + wClientCheckProperty(wapp->main_window_desc, &event->xproperty); } - + scr = wScreenForWindow(event->xproperty.window); if (scr && scr->root_win == event->xproperty.window) { #ifdef KWM_HINTS - wKWMCheckRootHintChange(scr, &event->xproperty); + wKWMCheckRootHintChange(scr, &event->xproperty); #endif } } @@ -917,137 +919,137 @@ handleClientMessage(XEvent *event) #endif /* handle transition from Normal to Iconic state */ if (event->xclient.message_type == _XA_WM_CHANGE_STATE - && event->xclient.format == 32 - && event->xclient.data.l[0] == IconicState) { - - wwin = wWindowFor(event->xclient.window); - if (!wwin) return; - if (!wwin->flags.miniaturized) - wIconifyWindow(wwin); + && event->xclient.format == 32 + && event->xclient.data.l[0] == IconicState) { + + wwin = wWindowFor(event->xclient.window); + if (!wwin) return; + if (!wwin->flags.miniaturized) + wIconifyWindow(wwin); } else if (event->xclient.message_type == _XA_WM_COLORMAP_NOTIFY - && event->xclient.format == 32) { - WScreen *scr = wScreenSearchForRootWindow(event->xclient.window); + && event->xclient.format == 32) { + WScreen *scr = wScreenSearchForRootWindow(event->xclient.window); - if (!scr) - return; + if (!scr) + return; - if (event->xclient.data.l[1] == 1) { /* starting */ - wColormapAllowClientInstallation(scr, True); - } else { /* stopping */ - wColormapAllowClientInstallation(scr, False); - } + if (event->xclient.data.l[1] == 1) { /* starting */ + wColormapAllowClientInstallation(scr, True); + } else { /* stopping */ + wColormapAllowClientInstallation(scr, False); + } } else if (event->xclient.message_type == _XA_WINDOWMAKER_COMMAND) { - wDefaultsCheckDomains("bla"); + wDefaultsCheckDomains("bla"); } else if (event->xclient.message_type == _XA_WINDOWMAKER_WM_FUNCTION) { - WApplication *wapp; - int done=0; - wapp = wApplicationOf(event->xclient.window); - if (wapp) { - switch (event->xclient.data.l[0]) { - case WMFHideOtherApplications: - wHideOtherApplications(wapp->main_window_desc); - done = 1; - break; - - case WMFHideApplication: - wHideApplication(wapp); - done = 1; - break; - } - } - if (!done) { - wwin = wWindowFor(event->xclient.window); - if (wwin) { - switch (event->xclient.data.l[0]) { - case WMFHideOtherApplications: - wHideOtherApplications(wwin); - break; - - case WMFHideApplication: - wHideApplication(wApplicationOf(wwin->main_window)); - break; - } - } - } + WApplication *wapp; + int done=0; + wapp = wApplicationOf(event->xclient.window); + if (wapp) { + switch (event->xclient.data.l[0]) { + case WMFHideOtherApplications: + wHideOtherApplications(wapp->main_window_desc); + done = 1; + break; + + case WMFHideApplication: + wHideApplication(wapp); + done = 1; + break; + } + } + if (!done) { + wwin = wWindowFor(event->xclient.window); + if (wwin) { + switch (event->xclient.data.l[0]) { + case WMFHideOtherApplications: + wHideOtherApplications(wwin); + break; + + case WMFHideApplication: + wHideApplication(wApplicationOf(wwin->main_window)); + break; + } + } + } } else if (event->xclient.message_type == _XA_GNUSTEP_WM_ATTR) { - wwin = wWindowFor(event->xclient.window); - if (!wwin) return; - switch (event->xclient.data.l[0]) { - case GSWindowLevelAttr: - { - int level = (int)event->xclient.data.l[1]; - - if (WINDOW_LEVEL(wwin) != level) { - ChangeStackingLevel(wwin->frame->core, level); - } - } - break; - } + wwin = wWindowFor(event->xclient.window); + if (!wwin) return; + switch (event->xclient.data.l[0]) { + case GSWindowLevelAttr: + { + int level = (int)event->xclient.data.l[1]; + + if (WINDOW_LEVEL(wwin) != level) { + ChangeStackingLevel(wwin->frame->core, level); + } + } + break; + } } else if (event->xclient.message_type == _XA_GNUSTEP_TITLEBAR_STATE) { - wwin = wWindowFor(event->xclient.window); - if (!wwin) return; - switch (event->xclient.data.l[0]) { - case WMTitleBarNormal: - wFrameWindowChangeState(wwin->frame, WS_UNFOCUSED); - break; - case WMTitleBarMain: - wFrameWindowChangeState(wwin->frame, WS_PFOCUSED); - break; - case WMTitleBarKey: - wFrameWindowChangeState(wwin->frame, WS_FOCUSED); - break; - } + wwin = wWindowFor(event->xclient.window); + if (!wwin) return; + switch (event->xclient.data.l[0]) { + case WMTitleBarNormal: + wFrameWindowChangeState(wwin->frame, WS_UNFOCUSED); + break; + case WMTitleBarMain: + wFrameWindowChangeState(wwin->frame, WS_PFOCUSED); + break; + case WMTitleBarKey: + wFrameWindowChangeState(wwin->frame, WS_FOCUSED); + break; + } #ifdef NETWM_HINTS } else if (wNETWMProcessClientMessage(&event->xclient)) { - /* do nothing */ + /* do nothing */ #endif #ifdef GNOME_STUFF } else if (wGNOMEProcessClientMessage(&event->xclient)) { - /* do nothing */ + /* do nothing */ #endif /* GNOME_STUFF */ #ifdef KWM_HINTS } else if (wKWMProcessClientMessage(&event->xclient)) { - /* do nothing */ + /* do nothing */ #endif /* KWM_HINTS */ #ifdef XDND } else if (wXDNDProcessClientMessage(&event->xclient)) { - /* do nothing */ + /* do nothing */ #endif /* XDND */ #ifdef OFFIX_DND } else if (event->xclient.message_type==_XA_DND_PROTOCOL) { - WScreen *scr = wScreenForWindow(event->xclient.window); + WScreen *scr = wScreenForWindow(event->xclient.window); if (scr && wDockReceiveDNDDrop(scr,event)) - goto redirect_message; + goto redirect_message; #endif /* OFFIX_DND */ } else { #ifdef OFFIX_DND - redirect_message: + redirect_message: #endif - /* - * Non-standard thing, but needed by OffiX DND. - * For when the icon frame gets a ClientMessage - * that should have gone to the icon_window. - */ - if (XFindContext(dpy, event->xbutton.window, wWinContext, - (XPointer *)&desc)!=XCNOENT) { - struct WIcon *icon=NULL; - - if (desc->parent_type == WCLASS_MINIWINDOW) { - icon = (WIcon*)desc->parent; - } else if (desc->parent_type == WCLASS_DOCK_ICON - || desc->parent_type == WCLASS_APPICON) { - icon = ((WAppIcon*)desc->parent)->icon; - } - if (icon && (wwin=icon->owner)) { - if (wwin->client_win!=event->xclient.window) { - event->xclient.window = wwin->client_win; - XSendEvent(dpy, wwin->client_win, False, NoEventMask, - event); - } - } - } + /* + * Non-standard thing, but needed by OffiX DND. + * For when the icon frame gets a ClientMessage + * that should have gone to the icon_window. + */ + if (XFindContext(dpy, event->xbutton.window, wWinContext, + (XPointer *)&desc)!=XCNOENT) { + struct WIcon *icon=NULL; + + if (desc->parent_type == WCLASS_MINIWINDOW) { + icon = (WIcon*)desc->parent; + } else if (desc->parent_type == WCLASS_DOCK_ICON + || desc->parent_type == WCLASS_APPICON) { + icon = ((WAppIcon*)desc->parent)->icon; + } + if (icon && (wwin=icon->owner)) { + if (wwin->client_win!=event->xclient.window) { + event->xclient.window = wwin->client_win; + XSendEvent(dpy, wwin->client_win, False, NoEventMask, + event); + } + } + } } } @@ -1059,19 +1061,19 @@ raiseWindow(WScreen *scr) scr->autoRaiseTimer = NULL; - wwin = wWindowFor(scr->autoRaiseWindow); + wwin = wWindowFor(scr->autoRaiseWindow); if (!wwin) - return; + return; if (!wwin->flags.destroyed && wwin->flags.focused) { - wRaiseFrame(wwin->frame->core); - /* this is needed or a race condition will occur */ - XSync(dpy, False); + wRaiseFrame(wwin->frame->core); + /* this is needed or a race condition will occur */ + XSync(dpy, False); } } -static void +static void handleEnterNotify(XEvent *event) { WWindow *wwin; @@ -1088,18 +1090,18 @@ handleEnterNotify(XEvent *event) #ifdef VIRTUAL_DESKTOP if (XFindContext(dpy, event->xcrossing.window, wVEdgeContext, (XPointer *)&vdHandler)!=XCNOENT) { - (*vdHandler)( event); + (*vdHandler)( event); } #endif if (XCheckTypedWindowEvent(dpy, event->xcrossing.window, LeaveNotify, - &ev)) { - /* already left the window... */ - saveTimestamp(&ev); - if (ev.xcrossing.mode==event->xcrossing.mode - && ev.xcrossing.detail==event->xcrossing.detail) { - return; - } + &ev)) { + /* already left the window... */ + saveTimestamp(&ev); + if (ev.xcrossing.mode==event->xcrossing.mode + && ev.xcrossing.detail==event->xcrossing.detail) { + return; + } } if (XFindContext(dpy, event->xcrossing.window, wWinContext, @@ -1111,70 +1113,70 @@ handleEnterNotify(XEvent *event) /* enter to window */ wwin = wWindowFor(event->xcrossing.window); if (!wwin) { - if (wPreferences.colormap_mode==WCM_POINTER) { - wColormapInstallForWindow(scr, NULL); - } - if (scr->autoRaiseTimer - && event->xcrossing.root==event->xcrossing.window) { - WMDeleteTimerHandler(scr->autoRaiseTimer); - scr->autoRaiseTimer = NULL; - } + if (wPreferences.colormap_mode==WCM_POINTER) { + wColormapInstallForWindow(scr, NULL); + } + if (scr->autoRaiseTimer + && event->xcrossing.root==event->xcrossing.window) { + WMDeleteTimerHandler(scr->autoRaiseTimer); + scr->autoRaiseTimer = NULL; + } } else { - /* set auto raise timer even if in focus-follows-mouse mode - * and the event is for the frame window, even if the window - * has focus already. useful if you move the pointer from a focused - * window to the root window and back pretty fast - * - * set focus if in focus-follows-mouse mode and the event - * is for the frame window and window doesn't have focus yet */ - if (wPreferences.focus_mode==WKF_SLOPPY - && wwin->frame->core->window==event->xcrossing.window - && !scr->flags.doing_alt_tab) { - - if (!wwin->flags.focused && !WFLAGP(wwin, no_focusable)) - wSetFocusTo(scr, wwin); - - if (scr->autoRaiseTimer) - WMDeleteTimerHandler(scr->autoRaiseTimer); - scr->autoRaiseTimer = NULL; - - if (wPreferences.raise_delay && !WFLAGP(wwin, no_focusable)) { - scr->autoRaiseWindow = wwin->frame->core->window; - scr->autoRaiseTimer - = WMAddTimerHandler(wPreferences.raise_delay, - (WMCallback*)raiseWindow, scr); - } - } - /* Install colormap for window, if the colormap installation mode - * is colormap_follows_mouse */ - if (wPreferences.colormap_mode==WCM_POINTER) { - if (wwin->client_win==event->xcrossing.window) - wColormapInstallForWindow(scr, wwin); - else - wColormapInstallForWindow(scr, NULL); - } + /* set auto raise timer even if in focus-follows-mouse mode + * and the event is for the frame window, even if the window + * has focus already. useful if you move the pointer from a focused + * window to the root window and back pretty fast + * + * set focus if in focus-follows-mouse mode and the event + * is for the frame window and window doesn't have focus yet */ + if (wPreferences.focus_mode==WKF_SLOPPY + && wwin->frame->core->window==event->xcrossing.window + && !scr->flags.doing_alt_tab) { + + if (!wwin->flags.focused && !WFLAGP(wwin, no_focusable)) + wSetFocusTo(scr, wwin); + + if (scr->autoRaiseTimer) + WMDeleteTimerHandler(scr->autoRaiseTimer); + scr->autoRaiseTimer = NULL; + + if (wPreferences.raise_delay && !WFLAGP(wwin, no_focusable)) { + scr->autoRaiseWindow = wwin->frame->core->window; + scr->autoRaiseTimer + = WMAddTimerHandler(wPreferences.raise_delay, + (WMCallback*)raiseWindow, scr); + } + } + /* Install colormap for window, if the colormap installation mode + * is colormap_follows_mouse */ + if (wPreferences.colormap_mode==WCM_POINTER) { + if (wwin->client_win==event->xcrossing.window) + wColormapInstallForWindow(scr, wwin); + else + wColormapInstallForWindow(scr, NULL); + } } - + /* a little kluge to hide the clip balloon */ if (!wPreferences.flags.noclip && scr->flags.clip_balloon_mapped) { - if (!desc) { - XUnmapWindow(dpy, scr->clip_balloon); - scr->flags.clip_balloon_mapped = 0; - } else { - if (desc->parent_type!=WCLASS_DOCK_ICON - || scr->clip_icon != desc->parent) { - XUnmapWindow(dpy, scr->clip_balloon); - scr->flags.clip_balloon_mapped = 0; - } - } + if (!desc) { + XUnmapWindow(dpy, scr->clip_balloon); + scr->flags.clip_balloon_mapped = 0; + } else { + if (desc->parent_type!=WCLASS_DOCK_ICON + || scr->clip_icon != desc->parent) { + XUnmapWindow(dpy, scr->clip_balloon); + scr->flags.clip_balloon_mapped = 0; + } + } } if (event->xcrossing.window == event->xcrossing.root - && event->xcrossing.detail == NotifyNormal - && event->xcrossing.detail != NotifyInferior - && wPreferences.focus_mode != WKF_CLICK) { - - wSetFocusTo(scr, scr->focused_window); + && event->xcrossing.detail == NotifyNormal + && event->xcrossing.detail != NotifyInferior + && wPreferences.focus_mode != WKF_CLICK) { + + wSetFocusTo(scr, scr->focused_window); } #ifdef BALLOON_TEXT @@ -1188,10 +1190,10 @@ handleLeaveNotify(XEvent *event) { WObjDescriptor *desc = NULL; - if (XFindContext(dpy, event->xcrossing.window, wWinContext, - (XPointer *)&desc)!=XCNOENT) { + if (XFindContext(dpy, event->xcrossing.window, wWinContext, + (XPointer *)&desc)!=XCNOENT) { if(desc->handle_leavenotify) - (*desc->handle_leavenotify)(desc, event); + (*desc->handle_leavenotify)(desc, event); } } @@ -1207,36 +1209,36 @@ handleShapeNotify(XEvent *event) printf("got shape notify\n"); #endif while (XCheckTypedWindowEvent(dpy, shev->window, event->type, &ev)) { - XShapeEvent *sev = (XShapeEvent*)&ev; - - if (sev->kind == ShapeBounding) { - if (sev->shaped == shev->shaped) { - *shev = *sev; - } else { - XPutBackEvent(dpy, &ev); - break; - } - } + XShapeEvent *sev = (XShapeEvent*)&ev; + + if (sev->kind == ShapeBounding) { + if (sev->shaped == shev->shaped) { + *shev = *sev; + } else { + XPutBackEvent(dpy, &ev); + break; + } + } } wwin = wWindowFor(shev->window); if (!wwin || shev->kind != ShapeBounding) - return; + return; if (!shev->shaped && wwin->flags.shaped) { - wwin->flags.shaped = 0; - wWindowClearShape(wwin); + wwin->flags.shaped = 0; + wWindowClearShape(wwin); } else if (shev->shaped) { - wwin->flags.shaped = 1; - wWindowSetShape(wwin); + wwin->flags.shaped = 1; + wWindowSetShape(wwin); } } #endif /* SHAPE */ -#ifdef KEEP_XKB_LOCK_STATUS +#ifdef KEEP_XKB_LOCK_STATUS /* please help ]d if you know what to do */ handleXkbIndicatorStateNotify(XEvent *event) { @@ -1247,68 +1249,68 @@ handleXkbIndicatorStateNotify(XEvent *event) for (i=0; ifocused_window; - if (wwin && wwin->flags.focused) { - XkbGetState(dpy,XkbUseCoreKbd,&staterec); - if (wwin->frame->languagemode != staterec.group) { - wwin->frame->last_languagemode = wwin->frame->languagemode; - wwin->frame->languagemode = staterec.group; - } + wwin = scr->focused_window; + if (wwin && wwin->flags.focused) { + XkbGetState(dpy,XkbUseCoreKbd,&staterec); + if (wwin->frame->languagemode != staterec.group) { + wwin->frame->last_languagemode = wwin->frame->languagemode; + wwin->frame->languagemode = staterec.group; + } #ifdef XKB_BUTTON_HINT - if (wwin->frame->titlebar) { - wFrameWindowPaint(wwin->frame); - } + if (wwin->frame->titlebar) { + wFrameWindowPaint(wwin->frame); + } #endif - } + } } } #endif /*KEEP_XKB_LOCK_STATUS*/ -static void +static void handleColormapNotify(XEvent *event) { WWindow *wwin; WScreen *scr; Bool reinstall = False; - + wwin = wWindowFor(event->xcolormap.window); if (!wwin) - return; - + return; + scr = wwin->screen_ptr; do { - if (wwin) { - if (event->xcolormap.new) { - XWindowAttributes attr; - - XGetWindowAttributes(dpy, wwin->client_win, &attr); - - if (wwin == scr->cmap_window && wwin->cmap_window_no == 0) - scr->current_colormap = attr.colormap; - - reinstall = True; - } else if (event->xcolormap.state == ColormapUninstalled && - scr->current_colormap == event->xcolormap.colormap) { - - /* some bastard app (like XV) removed our colormap */ - /* - * can't enforce or things like xscreensaver wont work - * reinstall = True; - */ - } else if (event->xcolormap.state == ColormapInstalled && - scr->current_colormap == event->xcolormap.colormap) { - - /* someone has put our colormap back */ - reinstall = False; - } - } + if (wwin) { + if (event->xcolormap.new) { + XWindowAttributes attr; + + XGetWindowAttributes(dpy, wwin->client_win, &attr); + + if (wwin == scr->cmap_window && wwin->cmap_window_no == 0) + scr->current_colormap = attr.colormap; + + reinstall = True; + } else if (event->xcolormap.state == ColormapUninstalled && + scr->current_colormap == event->xcolormap.colormap) { + + /* some bastard app (like XV) removed our colormap */ + /* + * can't enforce or things like xscreensaver wont work + * reinstall = True; + */ + } else if (event->xcolormap.state == ColormapInstalled && + scr->current_colormap == event->xcolormap.colormap) { + + /* someone has put our colormap back */ + reinstall = False; + } + } } while (XCheckTypedEvent(dpy, ColormapNotify, event) - && ((wwin = wWindowFor(event->xcolormap.window)) || 1)); + && ((wwin = wWindowFor(event->xcolormap.window)) || 1)); if (reinstall && scr->current_colormap!=None) { - if (!scr->flags.colormap_stuff_blocked) - XInstallColormap(dpy, scr->current_colormap); + if (!scr->flags.colormap_stuff_blocked) + XInstallColormap(dpy, scr->current_colormap); } } @@ -1322,24 +1324,24 @@ handleFocusIn(XEvent *event) /* * For applications that like stealing the focus. */ - while (XCheckTypedEvent(dpy, FocusIn, event)); + while (XCheckTypedEvent(dpy, FocusIn, event)); saveTimestamp(event); if (event->xfocus.mode == NotifyUngrab - || event->xfocus.mode == NotifyGrab - || event->xfocus.detail > NotifyNonlinearVirtual) { - return; + || event->xfocus.mode == NotifyGrab + || event->xfocus.detail > NotifyNonlinearVirtual) { + return; } wwin = wWindowFor(event->xfocus.window); if (wwin && !wwin->flags.focused) { - if (wwin->flags.mapped) - wSetFocusTo(wwin->screen_ptr, wwin); - else - wSetFocusTo(wwin->screen_ptr, NULL); + if (wwin->flags.mapped) + wSetFocusTo(wwin->screen_ptr, wwin); + else + wSetFocusTo(wwin->screen_ptr, NULL); } else if (!wwin) { - WScreen *scr = wScreenForWindow(event->xfocus.window); - if (scr) - wSetFocusTo(scr, NULL); + WScreen *scr = wScreenForWindow(event->xfocus.window); + if (scr) + wSetFocusTo(scr, NULL); } } @@ -1350,10 +1352,10 @@ windowUnderPointer(WScreen *scr) unsigned int mask; int foo; Window bar, win; - + if (XQueryPointer(dpy, scr->root_win, &bar, &win, &foo, &foo, &foo, &foo, - &mask)) - return wWindowFor(win); + &mask)) + return wWindowFor(win); return NULL; } @@ -1368,53 +1370,53 @@ handleKeyPress(XEvent *event) int i; int modifiers; int command=-1, index; -#ifdef KEEP_XKB_LOCK_STATUS - XkbStateRec staterec; +#ifdef KEEP_XKB_LOCK_STATUS + XkbStateRec staterec; #endif /*KEEP_XKB_LOCK_STATUS*/ /* ignore CapsLock */ modifiers = event->xkey.state & ValidModMask; for (i=0; ixkey.keycode - && (/*wKeyBindings[i].modifier==0 - ||*/ wKeyBindings[i].modifier==modifiers)) { - command = i; - break; - } + if (wKeyBindings[i].keycode==0) + continue; + + if (wKeyBindings[i].keycode==event->xkey.keycode + && (/*wKeyBindings[i].modifier==0 + ||*/ wKeyBindings[i].modifier==modifiers)) { + command = i; + break; + } } if (command < 0) { #ifdef LITE - { + { #if 0 - } + } #endif #else - if (!wRootMenuPerformShortcut(event)) { + if (!wRootMenuPerformShortcut(event)) { #endif - static int dontLoop = 0; - - if (dontLoop > 10) { - wwarning("problem with key event processing code"); - return; - } - dontLoop++; - /* if the focused window is an internal window, try redispatching - * the event to the managed window, as it can be a WINGs window */ - if (wwin && wwin->flags.internal_window - && wwin->client_leader!=None) { - /* client_leader contains the WINGs toplevel */ - event->xany.window = wwin->client_leader; - WMHandleEvent(event); - } - dontLoop--; - } - return; + static int dontLoop = 0; + + if (dontLoop > 10) { + wwarning("problem with key event processing code"); + return; + } + dontLoop++; + /* if the focused window is an internal window, try redispatching + * the event to the managed window, as it can be a WINGs window */ + if (wwin && wwin->flags.internal_window + && wwin->client_leader!=None) { + /* client_leader contains the WINGs toplevel */ + event->xany.window = wwin->client_leader; + WMHandleEvent(event); + } + dontLoop--; + } + return; } #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded)) @@ -1422,221 +1424,221 @@ handleKeyPress(XEvent *event) switch (command) { #ifndef LITE - case WKBD_ROOTMENU: - /*OpenRootMenu(scr, event->xkey.x_root, event->xkey.y_root, True);*/ - { - WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr)); + case WKBD_ROOTMENU: + /*OpenRootMenu(scr, event->xkey.x_root, event->xkey.y_root, True);*/ + { + WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr)); OpenRootMenu(scr, rect.pos.x + rect.size.width/2, rect.pos.y + rect.size.height/2, True); - } + } break; - case WKBD_WINDOWLIST: - { - WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr)); + case WKBD_WINDOWLIST: + { + WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr)); OpenSwitchMenu(scr, rect.pos.x + rect.size.width/2, rect.pos.y + rect.size.height/2, True); - } + } break; #endif /* !LITE */ - case WKBD_WINDOWMENU: - if (ISMAPPED(wwin) && ISFOCUSED(wwin)) - OpenWindowMenu(wwin, wwin->frame_x, - wwin->frame_y+wwin->frame->top_width, True); - break; - case WKBD_MINIATURIZE: - if (ISMAPPED(wwin) && ISFOCUSED(wwin) - && !WFLAGP(wwin, no_miniaturizable)) { - CloseWindowMenu(scr); - - if (wwin->protocols.MINIATURIZE_WINDOW) - wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, - event->xbutton.time); - else { - wIconifyWindow(wwin); - } - } - break; - case WKBD_HIDE: - if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { - WApplication *wapp = wApplicationOf(wwin->main_window); - CloseWindowMenu(scr); - - if (wapp && !WFLAGP(wapp->main_window_desc, no_appicon)) { - wHideApplication(wapp); - } - } - break; - case WKBD_HIDE_OTHERS: - if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { - CloseWindowMenu(scr); - + case WKBD_WINDOWMENU: + if (ISMAPPED(wwin) && ISFOCUSED(wwin)) + OpenWindowMenu(wwin, wwin->frame_x, + wwin->frame_y+wwin->frame->top_width, True); + break; + case WKBD_MINIATURIZE: + if (ISMAPPED(wwin) && ISFOCUSED(wwin) + && !WFLAGP(wwin, no_miniaturizable)) { + CloseWindowMenu(scr); + + if (wwin->protocols.MINIATURIZE_WINDOW) + wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, + event->xbutton.time); + else { + wIconifyWindow(wwin); + } + } + break; + case WKBD_HIDE: + if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { + WApplication *wapp = wApplicationOf(wwin->main_window); + CloseWindowMenu(scr); + + if (wapp && !WFLAGP(wapp->main_window_desc, no_appicon)) { + wHideApplication(wapp); + } + } + break; + case WKBD_HIDE_OTHERS: + if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { + CloseWindowMenu(scr); + wHideOtherApplications(wwin); - } - break; - case WKBD_MAXIMIZE: - if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) { + } + break; + case WKBD_MAXIMIZE: + if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) { int newdir = (MAX_VERTICAL|MAX_HORIZONTAL); CloseWindowMenu(scr); - if (wwin->flags.maximized == newdir) { - wUnmaximizeWindow(wwin); + if (wwin->flags.maximized == newdir) { + wUnmaximizeWindow(wwin); } else { - wMaximizeWindow(wwin, newdir|MAX_KEYBOARD); - } - } - break; - case WKBD_VMAXIMIZE: - if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) { + wMaximizeWindow(wwin, newdir|MAX_KEYBOARD); + } + } + break; + case WKBD_VMAXIMIZE: + if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) { int newdir = (MAX_VERTICAL ^ wwin->flags.maximized); - CloseWindowMenu(scr); + CloseWindowMenu(scr); if (newdir) { - wMaximizeWindow(wwin, newdir|MAX_KEYBOARD); - } else { - wUnmaximizeWindow(wwin); + wMaximizeWindow(wwin, newdir|MAX_KEYBOARD); + } else { + wUnmaximizeWindow(wwin); } - } - break; - case WKBD_HMAXIMIZE: - if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) { + } + break; + case WKBD_HMAXIMIZE: + if (ISMAPPED(wwin) && ISFOCUSED(wwin) && IS_RESIZABLE(wwin)) { int newdir = (MAX_HORIZONTAL ^ wwin->flags.maximized); - CloseWindowMenu(scr); + CloseWindowMenu(scr); if (newdir) { - wMaximizeWindow(wwin, newdir|MAX_KEYBOARD); - } else { - wUnmaximizeWindow(wwin); + wMaximizeWindow(wwin, newdir|MAX_KEYBOARD); + } else { + wUnmaximizeWindow(wwin); } - } - break; - case WKBD_RAISE: - if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { - CloseWindowMenu(scr); - - wRaiseFrame(wwin->frame->core); - } - break; - case WKBD_LOWER: - if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { - CloseWindowMenu(scr); - - wLowerFrame(wwin->frame->core); - } - break; - case WKBD_RAISELOWER: - /* raise or lower the window under the pointer, not the - * focused one - */ - wwin = windowUnderPointer(scr); - if (wwin) - wRaiseLowerFrame(wwin->frame->core); - break; - case WKBD_SHADE: - if (ISMAPPED(wwin) && ISFOCUSED(wwin) && !WFLAGP(wwin, no_shadeable)) { - if (wwin->flags.shaded) - wUnshadeWindow(wwin); - else - wShadeWindow(wwin); - } - break; - case WKBD_MOVERESIZE: - if (ISMAPPED(wwin) && ISFOCUSED(wwin) && - (IS_RESIZABLE(wwin) || IS_MOVABLE(wwin))) { - CloseWindowMenu(scr); - - wKeyboardMoveResizeWindow(wwin); - } - break; - case WKBD_CLOSE: - if (ISMAPPED(wwin) && ISFOCUSED(wwin) && !WFLAGP(wwin, no_closable)) { - CloseWindowMenu(scr); - if (wwin->protocols.DELETE_WINDOW) - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, - event->xkey.time); - } - break; + } + break; + case WKBD_RAISE: + if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { + CloseWindowMenu(scr); + + wRaiseFrame(wwin->frame->core); + } + break; + case WKBD_LOWER: + if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { + CloseWindowMenu(scr); + + wLowerFrame(wwin->frame->core); + } + break; + case WKBD_RAISELOWER: + /* raise or lower the window under the pointer, not the + * focused one + */ + wwin = windowUnderPointer(scr); + if (wwin) + wRaiseLowerFrame(wwin->frame->core); + break; + case WKBD_SHADE: + if (ISMAPPED(wwin) && ISFOCUSED(wwin) && !WFLAGP(wwin, no_shadeable)) { + if (wwin->flags.shaded) + wUnshadeWindow(wwin); + else + wShadeWindow(wwin); + } + break; + case WKBD_MOVERESIZE: + if (ISMAPPED(wwin) && ISFOCUSED(wwin) && + (IS_RESIZABLE(wwin) || IS_MOVABLE(wwin))) { + CloseWindowMenu(scr); + + wKeyboardMoveResizeWindow(wwin); + } + break; + case WKBD_CLOSE: + if (ISMAPPED(wwin) && ISFOCUSED(wwin) && !WFLAGP(wwin, no_closable)) { + CloseWindowMenu(scr); + if (wwin->protocols.DELETE_WINDOW) + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, + event->xkey.time); + } + break; case WKBD_SELECT: - if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { - wSelectWindow(wwin, !wwin->flags.selected); - } + if (ISMAPPED(wwin) && ISFOCUSED(wwin)) { + wSelectWindow(wwin, !wwin->flags.selected); + } + break; + case WKBD_FOCUSNEXT: + StartWindozeCycle(wwin, event, True); break; - case WKBD_FOCUSNEXT: - StartWindozeCycle(wwin, event, True); - break; - case WKBD_FOCUSPREV: - StartWindozeCycle(wwin, event, False); - break; + case WKBD_FOCUSPREV: + StartWindozeCycle(wwin, event, False); + break; #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP) #define GOTOWORKS(wk) case WKBD_WORKSPACE##wk:\ - i = (scr->current_workspace/10)*10 + wk - 1;\ - if (wPreferences.ws_advance || iworkspace_count)\ - wWorkspaceChange(scr, i);\ - break + i = (scr->current_workspace/10)*10 + wk - 1;\ + if (wPreferences.ws_advance || iworkspace_count)\ + wWorkspaceChange(scr, i);\ + break #else #define GOTOWORKS(wk) case WKBD_WORKSPACE/**/wk:\ - i = (scr->current_workspace/10)*10 + wk - 1;\ - if (wPreferences.ws_advance || iworkspace_count)\ - wWorkspaceChange(scr, i);\ - break + i = (scr->current_workspace/10)*10 + wk - 1;\ + if (wPreferences.ws_advance || iworkspace_count)\ + wWorkspaceChange(scr, i);\ + break #endif - GOTOWORKS(1); - GOTOWORKS(2); - GOTOWORKS(3); - GOTOWORKS(4); - GOTOWORKS(5); - GOTOWORKS(6); - GOTOWORKS(7); - GOTOWORKS(8); - GOTOWORKS(9); - GOTOWORKS(10); + GOTOWORKS(1); + GOTOWORKS(2); + GOTOWORKS(3); + GOTOWORKS(4); + GOTOWORKS(5); + GOTOWORKS(6); + GOTOWORKS(7); + GOTOWORKS(8); + GOTOWORKS(9); + GOTOWORKS(10); #undef GOTOWORKS - case WKBD_NEXTWORKSPACE: - wWorkspaceRelativeChange(scr, 1); - break; - case WKBD_PREVWORKSPACE: - wWorkspaceRelativeChange(scr, -1); - break; - case WKBD_WINDOW1: - case WKBD_WINDOW2: - case WKBD_WINDOW3: - case WKBD_WINDOW4: - case WKBD_WINDOW5: - case WKBD_WINDOW6: - case WKBD_WINDOW7: - case WKBD_WINDOW8: - case WKBD_WINDOW9: - case WKBD_WINDOW10: - - index = command-WKBD_WINDOW1; - + case WKBD_NEXTWORKSPACE: + wWorkspaceRelativeChange(scr, 1); + break; + case WKBD_PREVWORKSPACE: + wWorkspaceRelativeChange(scr, -1); + break; + case WKBD_WINDOW1: + case WKBD_WINDOW2: + case WKBD_WINDOW3: + case WKBD_WINDOW4: + case WKBD_WINDOW5: + case WKBD_WINDOW6: + case WKBD_WINDOW7: + case WKBD_WINDOW8: + case WKBD_WINDOW9: + case WKBD_WINDOW10: + + index = command-WKBD_WINDOW1; + if (scr->shortcutWindows[index]) { WMArray *list = scr->shortcutWindows[index]; int cw; - int count = WMGetArrayItemCount(list); - WWindow *twin; - WMArrayIterator iter; - WWindow *wwin; + int count = WMGetArrayItemCount(list); + WWindow *twin; + WMArrayIterator iter; + WWindow *wwin; wUnselectWindows(scr); cw = scr->current_workspace; WM_ETARETI_ARRAY(list, wwin, iter) { - if (count > 1) - wWindowChangeWorkspace(wwin, cw); + if (count > 1) + wWindowChangeWorkspace(wwin, cw); wMakeWindowVisible(wwin); - if (count > 1) - wSelectWindow(wwin, True); + if (count > 1) + wSelectWindow(wwin, True); } - - /* rotate the order of windows, to create a cycling effect */ - twin = WMGetFromArray(list, 0); - WMDeleteFromArray(list, 0); - WMAddToArray(list, twin); + + /* rotate the order of windows, to create a cycling effect */ + twin = WMGetFromArray(list, 0); + WMDeleteFromArray(list, 0); + WMAddToArray(list, twin); } else if (wwin && ISMAPPED(wwin) && ISFOCUSED(wwin)) { if (scr->shortcutWindows[index]) { @@ -1648,7 +1650,7 @@ handleKeyPress(XEvent *event) scr->shortcutWindows[index] = WMDuplicateArray(scr->selected_windows); /*WMRemoveFromArray(scr->shortcutWindows[index], wwin); - WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/ + WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/ } else { scr->shortcutWindows[index] = WMCreateArray(4); WMAddToArray(scr->shortcutWindows[index], wwin); @@ -1660,8 +1662,8 @@ handleKeyPress(XEvent *event) wSelectWindow(wwin, !wwin->flags.selected); XFlush(dpy); - } else if (scr->selected_windows - && WMGetArrayItemCount(scr->selected_windows)) { + } else if (scr->selected_windows + && WMGetArrayItemCount(scr->selected_windows)) { if (wwin->flags.selected && scr->selected_windows) { if (scr->shortcutWindows[index]) { @@ -1673,61 +1675,61 @@ handleKeyPress(XEvent *event) } break; - - case WKBD_SWITCH_SCREEN: - if (wScreenCount > 1) { - WScreen *scr2; - int i; - - /* find index of this screen */ - for (i = 0; i < wScreenCount; i++) { - if (wScreenWithNumber(i) == scr) - break; - } - i++; - if (i >= wScreenCount) { - i = 0; - } - scr2 = wScreenWithNumber(i); - - if (scr2) { - XWarpPointer(dpy, scr->root_win, scr2->root_win, 0, 0, 0, 0, - scr2->scr_width/2, scr2->scr_height/2); - } - } - break; - - case WKBD_NEXTWSLAYER: - case WKBD_PREVWSLAYER: - { - int row, column; - - row = scr->current_workspace/10; - column = scr->current_workspace%10; - - if (command==WKBD_NEXTWSLAYER) { - if ((row+1)*10 < scr->workspace_count) - wWorkspaceChange(scr, column+(row+1)*10); - } else { - if (row > 0) - wWorkspaceChange(scr, column+(row-1)*10); - } - } - break; + + case WKBD_SWITCH_SCREEN: + if (wScreenCount > 1) { + WScreen *scr2; + int i; + + /* find index of this screen */ + for (i = 0; i < wScreenCount; i++) { + if (wScreenWithNumber(i) == scr) + break; + } + i++; + if (i >= wScreenCount) { + i = 0; + } + scr2 = wScreenWithNumber(i); + + if (scr2) { + XWarpPointer(dpy, scr->root_win, scr2->root_win, 0, 0, 0, 0, + scr2->scr_width/2, scr2->scr_height/2); + } + } + break; + + case WKBD_NEXTWSLAYER: + case WKBD_PREVWSLAYER: + { + int row, column; + + row = scr->current_workspace/10; + column = scr->current_workspace%10; + + if (command==WKBD_NEXTWSLAYER) { + if ((row+1)*10 < scr->workspace_count) + wWorkspaceChange(scr, column+(row+1)*10); + } else { + if (row > 0) + wWorkspaceChange(scr, column+(row-1)*10); + } + } + break; case WKBD_CLIPLOWER: if (!wPreferences.flags.noclip) wDockLower(scr->workspaces[scr->current_workspace]->clip); break; - case WKBD_CLIPRAISE: + case WKBD_CLIPRAISE: if (!wPreferences.flags.noclip) wDockRaise(scr->workspaces[scr->current_workspace]->clip); break; - case WKBD_CLIPRAISELOWER: + case WKBD_CLIPRAISELOWER: if (!wPreferences.flags.noclip) wDockRaiseLower(scr->workspaces[scr->current_workspace]->clip); break; #ifdef KEEP_XKB_LOCK_STATUS - case WKBD_TOGGLE: + case WKBD_TOGGLE: if(wPreferences.modelock) { /*toggle*/ wwin = scr->focused_window; @@ -1740,34 +1742,34 @@ handleKeyPress(XEvent *event) wwin->frame->languagemode = wwin->frame->last_languagemode; wwin->frame->last_languagemode = staterec.group; XkbLockGroup(dpy,XkbUseCoreKbd, wwin->frame->languagemode); - + } } break; #endif /* KEEP_XKB_LOCK_STATUS */ #ifdef VIRTUAL_DESKTOP - case WKBD_VDESK_LEFT: - wWorkspaceKeyboardMoveDesktop(scr, VEC_LEFT); - break; + case WKBD_VDESK_LEFT: + wWorkspaceKeyboardMoveDesktop(scr, VEC_LEFT); + break; - case WKBD_VDESK_RIGHT: - wWorkspaceKeyboardMoveDesktop(scr, VEC_RIGHT); - break; + case WKBD_VDESK_RIGHT: + wWorkspaceKeyboardMoveDesktop(scr, VEC_RIGHT); + break; - case WKBD_VDESK_UP: - wWorkspaceKeyboardMoveDesktop(scr, VEC_UP); - break; + case WKBD_VDESK_UP: + wWorkspaceKeyboardMoveDesktop(scr, VEC_UP); + break; - case WKBD_VDESK_DOWN: - wWorkspaceKeyboardMoveDesktop(scr, VEC_DOWN); - break; + case WKBD_VDESK_DOWN: + wWorkspaceKeyboardMoveDesktop(scr, VEC_DOWN); + break; #endif } } -static void +static void handleMotionNotify(XEvent *event) { WScreen *scr = wScreenForRootWindow(event->xmotion.root); @@ -1776,12 +1778,12 @@ handleMotionNotify(XEvent *event) WMPoint p = wmkpoint(event->xmotion.x_root, event->xmotion.y_root); WMRect rect = wGetRectForHead(scr, wGetHeadForPoint(scr, p)); - if (scr->flags.jump_back_pending || - p.x <= (rect.pos.x + 1) || - p.x >= (rect.pos.x + rect.size.width - 2) || - p.y <= (rect.pos.y + 1) || - p.y >= (rect.pos.y + rect.size.height - 2)) { - WMenu *menu; + if (scr->flags.jump_back_pending || + p.x <= (rect.pos.x + 1) || + p.x >= (rect.pos.x + rect.size.width - 2) || + p.y <= (rect.pos.y + 1) || + p.y >= (rect.pos.y + rect.size.height - 2)) { + WMenu *menu; #ifdef DEBUG printf("pointer at screen edge\n"); #endif @@ -1790,52 +1792,53 @@ handleMotionNotify(XEvent *event) wMenuScroll(menu, event); } } -#if 0 + +#if 0 // what is with this? -Dan if (event->xmotion.subwindow == None) - return; + return; if (scr->scrolledFMaximize != None) { - WWindow *twin; - - twin = wWindowFor(scr->scrolledFMaximize); - if (twin && twin->frame_y ==) { - - - } - scr->scrolledFMaximize = NULL; - - } else { - - /* scroll full maximized window */ - if (event->xmotion.y_root < 1 - || event->xmotion.y_root > scr->scr_height - 1) { - - wwin = wWindowFor(event->xmotion.subwindow); - - if (wwin && (wwin->flags.maximized & MAX_VERTICAL) - && WFLAGP(wwin, full_maximize) - && event->xmotion.x_root >= wwin->frame_x - && event->xmotion.x_root <= wwin->frame_x + wwin->frame->core->width) { - - if (HAS_BORDER(wwin) - && wwin->frame_y <= - wwin->frame->top_width) { - - wWindowMove(wwin, wwin->frame_x, 0); - wwin->flags.dragged_while_fmaximized = 0; - - } else if (HAS_RESIZEBAR(wwin) - && wwin->frame_y + wwin->frame->core->height >= - scr->scr_height + wwin->frame->bottom_width) { - - int y = scr->scr_height + wwin->frame->bottom_width; - - y = scr->scr_height - wwin->frame_y - wwin->frame->core->height; - - wWindowMove(wwin, wwin->frame_x, y); - wwin->flags.dragged_while_fmaximized = 0; - } - } - } + WWindow *twin; + + twin = wWindowFor(scr->scrolledFMaximize); + if (twin && twin->frame_y ==) { + + + } + scr->scrolledFMaximize = NULL; + + } else { + + /* scroll full maximized window */ + if (event->xmotion.y_root < 1 + || event->xmotion.y_root > scr->scr_height - 1) { + + wwin = wWindowFor(event->xmotion.subwindow); + + if (wwin && (wwin->flags.maximized & MAX_VERTICAL) + && WFLAGP(wwin, full_maximize) + && event->xmotion.x_root >= wwin->frame_x + && event->xmotion.x_root <= wwin->frame_x + wwin->frame->core->width) { + + if (HAS_BORDER(wwin) + && wwin->frame_y <= - wwin->frame->top_width) { + + wWindowMove(wwin, wwin->frame_x, 0); + wwin->flags.dragged_while_fmaximized = 0; + + } else if (HAS_RESIZEBAR(wwin) + && wwin->frame_y + wwin->frame->core->height >= + scr->scr_height + wwin->frame->bottom_width) { + + int y = scr->scr_height + wwin->frame->bottom_width; + + y = scr->scr_height - wwin->frame_y - wwin->frame->core->height; + + wWindowMove(wwin, wwin->frame_x, y); + wwin->flags.dragged_while_fmaximized = 0; + } + } + } #endif } @@ -1847,7 +1850,9 @@ handleVisibilityNotify(XEvent *event) wwin = wWindowFor(event->xvisibility.window); if (!wwin) - return; - wwin->flags.obscured = - (event->xvisibility.state == VisibilityFullyObscured); + return; + wwin->flags.obscured = + (event->xvisibility.state == VisibilityFullyObscured); } + + diff --git a/src/extend_pixmaps.h b/src/extend_pixmaps.h dissimilarity index 78% index 24457716..8b735e58 100644 --- a/src/extend_pixmaps.h +++ b/src/extend_pixmaps.h @@ -1,117 +1,117 @@ -#include "wconfig.h" - -static char *PRED_XKBGROUP1_XPM[] = { -" 10 10 2 1", -". c #000000", -"# c None", -"........##", -".......###", -"..########", -"..########", -"......####", -".....#####", -"..########", -"..########", -"........##", -"........##" -}; - -#ifdef LANGUAGE_TH -static char *PRED_XKBGROUP2_XPM[] = { -" 10 10 2 1", -". c #000000", -"# c None", -"#..###..##", -".#..#.#..#", -".#...###..", -"#...####..", -"##..####..", -"##..####..", -"##..####..", -"##..####..", -"##..####..", -"##.#####.#" -}; -#elif defined LANGUAGE_SK -static char *PRED_XKBGROUP2_XPM[] = { -" 10 10 2 1", -". c #000000", -"# c None", -"####..####", -"####..####", -"##......##", -"##......##", -"####..####", -"#........#", -"#........#", -"####..####", -"###....###", -"##......##"}; -#elif defined LANGUAGE_EL -static char *PRED_XKBGROUP2_XPM[] = { -" 10 10 2 1", -". c #000000", -"# c None", -"##..######", -"##..##....", -"......####", -"##..##....", -"##..######", -"..........", -"##########", -"..........", -"##########", -"##########"}; -#else -static char *PRED_XKBGROUP2_XPM[] = { -" 10 10 2 1", -". c #000000", -"# c None", -"##########", -"#...##...#", -"..........", -"..........", -"..........", -"..........", -"#........#", -"##......##", -"###....###", -"####..####" -}; -#endif - -static char *PRED_XKBGROUP3_XPM[] = { -" 10 10 2 1", -". c #000000", -"# c None", -"..........", -"..........", -"..##..##..", -"..##..##..", -"..........", -"..........", -"..######..", -"...####...", -"....##....", -".........." -}; - -static char *PRED_XKBGROUP4_XPM[] = { -" 10 10 2 1", -". c #000000", -"# c None", -"..........", -".########.", -".#..##..#.", -".#..##..#.", -".########.", -".#......#.", -".##....##.", -".###..###.", -".########.", -".........." -}; - - - - +#include "wconfig.h" + +static char *PRED_XKBGROUP1_XPM[] = { + " 10 10 2 1", + ". c #000000", + "# c None", + "........##", + ".......###", + "..########", + "..########", + "......####", + ".....#####", + "..########", + "..########", + "........##", + "........##" +}; + +#ifdef LANGUAGE_TH +static char *PRED_XKBGROUP2_XPM[] = { + " 10 10 2 1", + ". c #000000", + "# c None", + "#..###..##", + ".#..#.#..#", + ".#...###..", + "#...####..", + "##..####..", + "##..####..", + "##..####..", + "##..####..", + "##..####..", + "##.#####.#" +}; +#elif defined LANGUAGE_SK +static char *PRED_XKBGROUP2_XPM[] = { + " 10 10 2 1", + ". c #000000", + "# c None", + "####..####", + "####..####", + "##......##", + "##......##", + "####..####", + "#........#", + "#........#", + "####..####", + "###....###", + "##......##"}; +#elif defined LANGUAGE_EL +static char *PRED_XKBGROUP2_XPM[] = { + " 10 10 2 1", + ". c #000000", + "# c None", + "##..######", + "##..##....", + "......####", + "##..##....", + "##..######", + "..........", + "##########", + "..........", + "##########", + "##########"}; +#else +static char *PRED_XKBGROUP2_XPM[] = { + " 10 10 2 1", + ". c #000000", + "# c None", + "##########", + "#...##...#", + "..........", + "..........", + "..........", + "..........", + "#........#", + "##......##", + "###....###", + "####..####" +}; +#endif + +static char *PRED_XKBGROUP3_XPM[] = { + " 10 10 2 1", + ". c #000000", + "# c None", + "..........", + "..........", + "..##..##..", + "..##..##..", + "..........", + "..........", + "..######..", + "...####...", + "....##....", + ".........." +}; + +static char *PRED_XKBGROUP4_XPM[] = { + " 10 10 2 1", + ". c #000000", + "# c None", + "..........", + ".########.", + ".#..##..#.", + ".#..##..#.", + ".########.", + ".#......#.", + ".##....##.", + ".###..###.", + ".########.", + ".........." +}; + + + + diff --git a/src/framewin.c b/src/framewin.c dissimilarity index 62% index 8e32326f..f8664bed 100644 --- a/src/framewin.c +++ b/src/framewin.c @@ -1,1594 +1,1594 @@ -/* - * Window Maker window manager - * - * Copyright (c) 1997-2003 Alfredo K. Kojima - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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, - * USA. - */ - -#include "wconfig.h" - -#include -#include -#ifdef KEEP_XKB_LOCK_STATUS -#include -#endif /* KEEP_XKB_LOCK_STATUS */ - -#include -#include - -#include - -#include "WindowMaker.h" -#include "GNUstep.h" -#include "texture.h" -#include "screen.h" -#include "wcore.h" -#include "framewin.h" -#include "stacking.h" -#include "funcs.h" - -#define DBLCLICK_TIME wPreferences.dblclick_time - -extern WPreferences wPreferences; - -static void handleExpose(WObjDescriptor *desc, XEvent *event); -static void handleButtonExpose(WObjDescriptor *desc, XEvent *event); - -static void buttonMouseDown(WObjDescriptor *desc, XEvent *event); -static void titlebarMouseDown(WObjDescriptor *desc, XEvent *event); -static void resizebarMouseDown(WObjDescriptor *desc, XEvent *event); - -static void checkTitleSize(WFrameWindow *fwin); - - -static void paintButton(WCoreWindow *button, WTexture *texture, - unsigned long color, WPixmap *image, int pushed); - -static void updateTitlebar(WFrameWindow *fwin); - - -WFrameWindow* -wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y, - int width, int height, int *clearance, int flags, - WTexture **title_texture, WTexture **resize_texture, - WMColor **color, WMFont **font) -{ - WFrameWindow *fwin; - - fwin = wmalloc(sizeof(WFrameWindow)); - memset(fwin, 0, sizeof(WFrameWindow)); - - fwin->screen_ptr = scr; - - fwin->flags.single_texture = (flags & WFF_SINGLE_STATE) ? 1 : 0; - - fwin->title_texture = title_texture; - fwin->resizebar_texture = resize_texture; - fwin->title_color = color; - fwin->title_clearance = clearance; - fwin->font = font; -#ifdef KEEP_XKB_LOCK_STATUS - fwin->languagemode = XkbGroup1Index; - fwin->last_languagemode = XkbGroup2Index; -#endif - - fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, - (flags & WFF_BORDER) - ? FRAME_BORDER_WIDTH : 0); - if (wPreferences.use_saveunders) { - unsigned long vmask; - XSetWindowAttributes attribs; - - vmask = CWSaveUnder; - attribs.save_under = True; - XChangeWindowAttributes(dpy, fwin->core->window, vmask, &attribs); - } - - /* setup stacking information */ - fwin->core->stacking = wmalloc(sizeof(WStacking)); - fwin->core->stacking->above = NULL; - fwin->core->stacking->under = NULL; - fwin->core->stacking->child_of = NULL; - fwin->core->stacking->window_level = wlevel; - - AddToStackList(fwin->core); - - wFrameWindowUpdateBorders(fwin, flags); - - return fwin; -} - - - -void -wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) -{ - int theight; - int bsize; - int width, height; - int i; - WScreen *scr = fwin->screen_ptr; - - width = fwin->core->width; - if (flags & WFF_IS_SHADED) - height = -1; - else - height = fwin->core->height - fwin->top_width - fwin->bottom_width; - - if (flags & WFF_TITLEBAR) - theight = WMFontHeight(*fwin->font) + (*fwin->title_clearance + TITLEBAR_EXTEND_SPACE) * 2; - else - theight = 0; - - if (wPreferences.new_style) { - bsize = theight; - } else { - bsize = theight - 7; - } - - if (fwin->titlebar) { - /* if we had a titlebar and is requesting for one, - * check if the size has changed and resize it */ - if (flags & WFF_TITLEBAR) { - fwin->top_width = theight; - - fwin->flags.need_texture_remake = 1; - - if (wPreferences.new_style) { - if (fwin->left_button) { - wCoreConfigure(fwin->left_button, 0, 0, bsize, bsize); - } -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - if (fwin->flags.hide_left_button || !fwin->left_button - || fwin->flags.lbutton_dont_fit) { - wCoreConfigure(fwin->language_button, 0, 0, bsize, bsize); - } else { - wCoreConfigure(fwin->language_button, bsize, 0, bsize, bsize); - } -#endif - - - if (fwin->right_button) { - wCoreConfigure(fwin->right_button, width-bsize+1, - 0, bsize, bsize); - } - } else { /* !new_style */ - if (fwin->left_button) { - wCoreConfigure(fwin->left_button, 3, (theight-bsize)/2, - bsize, bsize); - } - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) { - wCoreConfigure(fwin->language_button, 6 + bsize, (theight-bsize)/2, - bsize, bsize); - } -#endif - - if (fwin->right_button) { - wCoreConfigure(fwin->right_button, width-bsize-3, - (theight-bsize)/2, bsize, bsize); - } - } - updateTitlebar(fwin); - } else { - /* we had a titlebar, but now we don't need it anymore */ - for (i=0; i < (fwin->flags.single_texture ? 1 : 3); i++) { - FREE_PIXMAP(fwin->title_back[i]); - if (wPreferences.new_style) { - FREE_PIXMAP(fwin->lbutton_back[i]); - FREE_PIXMAP(fwin->rbutton_back[i]); -#ifdef XKB_BUTTON_HINT - FREE_PIXMAP(fwin->languagebutton_back[i]); -#endif - } - } - if (fwin->left_button) - wCoreDestroy(fwin->left_button); - fwin->left_button = NULL; - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - wCoreDestroy(fwin->language_button); - fwin->language_button = NULL; -#endif - - if (fwin->right_button) - wCoreDestroy(fwin->right_button); - fwin->right_button = NULL; - - wCoreDestroy(fwin->titlebar); - fwin->titlebar = NULL; - - fwin->top_width = 0; - } - } else { - /* if we didn't have a titlebar and are being requested for - * one, create it */ - if (flags & WFF_TITLEBAR) { - fwin->top_width = theight; - - fwin->flags.titlebar = 1; - fwin->titlebar = wCoreCreate(fwin->core, 0, 0, width+1, theight); - - if (flags & WFF_LEFT_BUTTON) { - fwin->flags.left_button = 1; - if (wPreferences.new_style) { - fwin->left_button = wCoreCreate(fwin->core, 0, 0, - bsize, bsize); - if (width < theight*4) { - fwin->flags.lbutton_dont_fit = 1; - } else { - XMapRaised(dpy, fwin->left_button->window); - } - } else { - fwin->left_button = - wCoreCreate(fwin->titlebar, 3, (theight-bsize)/2, - bsize, bsize); - - XSetWindowBackground(dpy, fwin->left_button->window, - scr->widget_texture->normal.pixel); - - if (width < theight*3) { - fwin->flags.lbutton_dont_fit = 1; - } else { - XMapRaised(dpy, fwin->left_button->window); - } - } - } - -#ifdef XKB_BUTTON_HINT - if (flags & WFF_LANGUAGE_BUTTON) { - fwin->flags.language_button = 1; - if (wPreferences.new_style) { - fwin->language_button = wCoreCreate(fwin->core, - bsize, 0, bsize, bsize); - - if (width < theight*4) { - fwin->flags.languagebutton_dont_fit = 1; - } else { - XMapRaised(dpy, fwin->language_button->window); - } - } else { - fwin->language_button = - wCoreCreate(fwin->titlebar, bsize + 6, (theight-bsize)/2, - bsize, bsize); - - XSetWindowBackground(dpy, fwin->language_button->window, - scr->widget_texture->normal.pixel); - - if (width < theight*3) { - fwin->flags.languagebutton_dont_fit = 1; - } else { - XMapRaised(dpy, fwin->language_button->window); - } - } - } -#endif - - if (flags & WFF_RIGHT_BUTTON) { - fwin->flags.right_button = 1; - if (wPreferences.new_style) { - fwin->right_button = - wCoreCreate(fwin->core, width-bsize+1, 0, - bsize, bsize); - } else { - fwin->right_button = - wCoreCreate(fwin->titlebar, width-bsize-3, - (theight-bsize)/2, bsize, bsize); - XSetWindowBackground(dpy, fwin->right_button->window, - scr->widget_texture->normal.pixel); - } - - if (width < theight*2) { - fwin->flags.rbutton_dont_fit = 1; - } else { - XMapRaised(dpy, fwin->right_button->window); - } - } - - if (wPreferences.new_style) - updateTitlebar(fwin); - - XMapRaised(dpy, fwin->titlebar->window); - - fwin->flags.need_texture_remake = 1; - } - } - checkTitleSize(fwin); - - if (flags & WFF_RESIZEBAR) { - fwin->bottom_width = RESIZEBAR_HEIGHT; - - if (!fwin->resizebar) { - fwin->flags.resizebar = 1; - fwin->resizebar = wCoreCreate(fwin->core, 0, - height + fwin->top_width, - width, RESIZEBAR_HEIGHT); - fwin->resizebar_corner_width = RESIZEBAR_CORNER_WIDTH; - if (width < RESIZEBAR_CORNER_WIDTH*2 + RESIZEBAR_MIN_WIDTH) { - fwin->resizebar_corner_width = (width - RESIZEBAR_MIN_WIDTH)/2; - if (fwin->resizebar_corner_width < 0) - fwin->resizebar_corner_width = 0; - } - - XMapWindow(dpy, fwin->resizebar->window); - XLowerWindow(dpy, fwin->resizebar->window); - - fwin->flags.need_texture_remake = 1; - } else { - if (height+fwin->top_width+fwin->bottom_width != fwin->core->height) { - wCoreConfigure(fwin->resizebar, 0, height + fwin->top_width, - width, RESIZEBAR_HEIGHT); - } - } - } else { - fwin->bottom_width = 0; - - if (fwin->resizebar) { - fwin->bottom_width = 0; - wCoreDestroy(fwin->resizebar); - fwin->resizebar = NULL; - } - } - - if (height + fwin->top_width + fwin->bottom_width != fwin->core->height - && !(flags & WFF_IS_SHADED)) { - wFrameWindowResize(fwin, width, - height + fwin->top_width + fwin->bottom_width); - } - - - if (flags & WFF_BORDER) { - XSetWindowBorderWidth(dpy, fwin->core->window, FRAME_BORDER_WIDTH); - } else { - XSetWindowBorderWidth(dpy, fwin->core->window, 0); - } - - /* setup object descriptors */ - - if (fwin->titlebar) { - fwin->titlebar->descriptor.handle_expose = handleExpose; - fwin->titlebar->descriptor.parent = fwin; - fwin->titlebar->descriptor.parent_type = WCLASS_FRAME; - fwin->titlebar->descriptor.handle_mousedown = titlebarMouseDown; - } - - if (fwin->resizebar) { - fwin->resizebar->descriptor.handle_expose = handleExpose; - fwin->resizebar->descriptor.parent = fwin; - fwin->resizebar->descriptor.parent_type = WCLASS_FRAME; - fwin->resizebar->descriptor.handle_mousedown = resizebarMouseDown; - } - - if (fwin->left_button) { - fwin->left_button->descriptor.handle_expose = handleButtonExpose; - fwin->left_button->descriptor.parent = fwin; - fwin->left_button->descriptor.parent_type = WCLASS_FRAME; - fwin->left_button->descriptor.handle_mousedown = buttonMouseDown; - } - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) { - fwin->language_button->descriptor.handle_expose = handleButtonExpose; - fwin->language_button->descriptor.parent = fwin; - fwin->language_button->descriptor.parent_type = WCLASS_FRAME; - fwin->language_button->descriptor.handle_mousedown = buttonMouseDown; - } -#endif - - - if (fwin->right_button) { - fwin->right_button->descriptor.parent = fwin; - fwin->right_button->descriptor.parent_type = WCLASS_FRAME; - fwin->right_button->descriptor.handle_expose = handleButtonExpose; - fwin->right_button->descriptor.handle_mousedown = buttonMouseDown; - } - - checkTitleSize(fwin); -} - - - -void -wFrameWindowDestroy(WFrameWindow *fwin) -{ - int i; - - if (fwin->left_button) - wCoreDestroy(fwin->left_button); - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - wCoreDestroy(fwin->language_button); -#endif - - if (fwin->right_button) - wCoreDestroy(fwin->right_button); - - if (fwin->resizebar) - wCoreDestroy(fwin->resizebar); - - if (fwin->titlebar) - wCoreDestroy(fwin->titlebar); - - RemoveFromStackList(fwin->core); - - wCoreDestroy(fwin->core); - - if (fwin->title) - wfree(fwin->title); - - for (i=0; i < (fwin->flags.single_texture ? 1 : 3); i++) { - FREE_PIXMAP(fwin->title_back[i]); - if (wPreferences.new_style) { - FREE_PIXMAP(fwin->lbutton_back[i]); -#ifdef XKB_BUTTON_HINT - FREE_PIXMAP(fwin->languagebutton_back[i]); -#endif - FREE_PIXMAP(fwin->rbutton_back[i]); - } - } - - wfree(fwin); -} - - -void -wFrameWindowChangeState(WFrameWindow *fwin, int state) -{ - if (fwin->flags.state==state) - return; - - fwin->flags.state = state; - fwin->flags.need_texture_change = 1; - - wFrameWindowPaint(fwin); -} - - -static void -updateTitlebar(WFrameWindow *fwin) -{ - int x, w; - int theight; - - theight = WMFontHeight(*fwin->font) + (*fwin->title_clearance + TITLEBAR_EXTEND_SPACE) * 2; - - x = 0; - w = fwin->core->width + 1; - - if (wPreferences.new_style) { - if (fwin->flags.hide_left_button || !fwin->left_button - || fwin->flags.lbutton_dont_fit) { - x = 0; -#ifdef XKB_BUTTON_HINT - if(fwin->language_button) - wCoreConfigure(fwin->language_button, 0, 0, - fwin->language_button->width, - fwin->language_button->width); -#endif - } else { -#ifdef XKB_BUTTON_HINT - if(fwin->language_button) - wCoreConfigure(fwin->language_button, fwin->left_button->width, 0, - fwin->language_button->width, - fwin->language_button->width); -#endif - x = fwin->left_button->width; - w -= fwin->left_button->width; - } -#ifdef XKB_BUTTON_HINT - if (fwin->flags.hide_language_button || !fwin->language_button - || fwin->flags.languagebutton_dont_fit) { - } else { - x += fwin->language_button->width; - w -= fwin->language_button->width; - } -#endif - } -#ifdef XKB_BUTTON_HINT - else { - int bsize = theight - 7; - if (fwin->flags.hide_left_button || !fwin->left_button - || fwin->flags.lbutton_dont_fit) { - if(fwin->language_button) - wCoreConfigure(fwin->language_button, 3, (theight-bsize)/2, - fwin->language_button->width, - fwin->language_button->width); - } - else { - if(fwin->language_button) - wCoreConfigure(fwin->language_button, - 6 + fwin->left_button->width, (theight-bsize)/2, - fwin->language_button->width, - fwin->language_button->width); - } - } -#endif - - if (wPreferences.new_style) { - if (!fwin->flags.hide_right_button && fwin->right_button - && !fwin->flags.rbutton_dont_fit) { - w -= fwin->right_button->width; - } - } - - if (wPreferences.new_style || fwin->titlebar->width!=w) - fwin->flags.need_texture_remake = 1; - - wCoreConfigure(fwin->titlebar, x, 0, w, theight); -} - - -void -wFrameWindowHideButton(WFrameWindow *fwin, int flags) -{ - if ((flags & WFF_RIGHT_BUTTON) && fwin->right_button) { - XUnmapWindow(dpy, fwin->right_button->window); - fwin->flags.hide_right_button = 1; - } - - if ((flags & WFF_LEFT_BUTTON) && fwin->left_button) { - XUnmapWindow(dpy, fwin->left_button->window); - fwin->flags.hide_left_button = 1; - } - -#ifdef XKB_BUTTON_HINT - if ((flags & WFF_LANGUAGE_BUTTON) && fwin->language_button) { - XUnmapWindow(dpy, fwin->language_button->window); - fwin->flags.hide_language_button = 1; - } -#endif - - if (fwin->titlebar) { - if (wPreferences.new_style) { - updateTitlebar(fwin); - } else { -#ifdef XKB_BUTTON_HINT - updateTitlebar(fwin); -#else - XClearWindow(dpy, fwin->titlebar->window); - wFrameWindowPaint(fwin); -#endif - } - checkTitleSize(fwin); - } -} - - -void -wFrameWindowShowButton(WFrameWindow *fwin, int flags) -{ - if ((flags & WFF_RIGHT_BUTTON) && fwin->right_button - && fwin->flags.hide_right_button) { - - if (!fwin->flags.rbutton_dont_fit) - XMapWindow(dpy, fwin->right_button->window); - - fwin->flags.hide_right_button = 0; - } - -#ifdef XKB_BUTTON_HINT - if ((flags & WFF_LANGUAGE_BUTTON) && fwin->language_button - && fwin->flags.hide_language_button) { - - if (!fwin->flags.languagebutton_dont_fit) - XMapWindow(dpy, fwin->language_button->window); - - fwin->flags.hide_language_button = 0; - } -#endif - - if ((flags & WFF_LEFT_BUTTON) && fwin->left_button - && fwin->flags.hide_left_button) { - - if (!fwin->flags.lbutton_dont_fit) - XMapWindow(dpy, fwin->left_button->window); - - fwin->flags.hide_left_button = 0; - } - - - if (fwin->titlebar) { - if (wPreferences.new_style) { - updateTitlebar(fwin); - } else { - XClearWindow(dpy, fwin->titlebar->window); - wFrameWindowPaint(fwin); - } - checkTitleSize(fwin); - } -} - - -static void -#ifdef XKB_BUTTON_HINT -renderTexture(WScreen *scr, WTexture *texture, int width, int height, - int bwidth, int bheight, int left, int language, int right, - Pixmap *title, Pixmap *lbutton, Pixmap *languagebutton, Pixmap *rbutton) -#else -renderTexture(WScreen *scr, WTexture *texture, int width, int height, - int bwidth, int bheight, int left, int right, - Pixmap *title, Pixmap *lbutton, Pixmap *rbutton) -#endif -{ - RImage *img; - RImage *limg, *rimg, *mimg; -#ifdef XKB_BUTTON_HINT - RImage *timg; -#endif - int x, w; - - *title = None; - *lbutton = None; - *rbutton = None; -#ifdef XKB_BUTTON_HINT - *languagebutton = None; -#endif - - img = wTextureRenderImage(texture, width, height, WREL_FLAT); - if (!img) { - wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode)); - return; - } - - if (wPreferences.new_style) { - if (left) { - limg = RGetSubImage(img, 0, 0, bwidth, bheight); - } else - limg = NULL; - - x = 0; - w = img->width; - -#ifdef XKB_BUTTON_HINT - if (language) { - timg = RGetSubImage(img, bwidth * left, 0, bwidth, bheight); - } else - timg = NULL; -#endif - - if (limg) { - RBevelImage(limg, RBEV_RAISED2); - if (!RConvertImage(scr->rcontext, limg, lbutton)) { - wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); - } - x += limg->width; - w -= limg->width; - RReleaseImage(limg); - } - -#ifdef XKB_BUTTON_HINT - if (timg) { - RBevelImage(timg, RBEV_RAISED2); - if (!RConvertImage(scr->rcontext, timg, languagebutton)) { - wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); - } - x += timg->width; - w -= timg->width; - RReleaseImage(timg); - } -#endif - - if (right) { - rimg = RGetSubImage(img, width - bwidth, 0, bwidth, bheight); - } else - rimg = NULL; - - if (rimg) { - RBevelImage(rimg, RBEV_RAISED2); - if (!RConvertImage(scr->rcontext, rimg, rbutton)) { - wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); - } - w -= rimg->width; - RReleaseImage(rimg); - } - - if (w!=width) { - mimg = RGetSubImage(img, x, 0, w, img->height); - RBevelImage(mimg, RBEV_RAISED2); - - if (!RConvertImage(scr->rcontext, mimg, title)) { - wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); - } - RReleaseImage(mimg); - } else { - RBevelImage(img, RBEV_RAISED2); - - if (!RConvertImage(scr->rcontext, img, title)) { - wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); - } - } - } else { - RBevelImage(img, RBEV_RAISED2); - - if (!RConvertImage(scr->rcontext, img, title)) { - wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); - } - } - - RReleaseImage(img); -} - - -static void -renderResizebarTexture(WScreen *scr, WTexture *texture, int width, int height, - int cwidth, Pixmap *pmap) -{ - RImage *img; - RColor light; - RColor dark; - - *pmap = None; - - img = wTextureRenderImage(texture, width, height, WREL_FLAT); - if (!img) { - wwarning(_("could not render texture: %s"), - RMessageForError(RErrorCode)); - return; - } - - light.alpha = 0; - light.red = light.green = light.blue = 80; - - dark.alpha = 0; - dark.red = dark.green = dark.blue = 40; - - ROperateLine(img, RSubtractOperation, 0, 0, width-1, 0, &dark); - ROperateLine(img, RAddOperation, 0, 1, width-1, 1, &light); - - ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height-1, &dark); - ROperateLine(img, RAddOperation, cwidth+1, 2, cwidth+1, height-1, &light); - - if (width > 1) - ROperateLine(img, RSubtractOperation, width-cwidth-2, 2, - width-cwidth-2, height-1, &dark); - ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1, - height-1, &light); - -#ifdef SHADOW_RESIZEBAR - ROperateLine(img, RAddOperation, 0, 1, 0, height-1, &light); - ROperateLine(img, RSubtractOperation, width-1, 1, width-1, height-1, - &dark); - ROperateLine(img, RSubtractOperation, 0, height-1, width-1, height-1, - &dark); -#endif /* SHADOW_RESIZEBAR */ - - - if (!RConvertImage(scr->rcontext, img, pmap)) { - wwarning(_("error rendering image: %s"), RMessageForError(RErrorCode)); - } - - RReleaseImage(img); -} - - - -static void -updateTexture(WFrameWindow *fwin) -{ - int i; - unsigned long pixel; - - i = fwin->flags.state; - if (fwin->titlebar) { - if (fwin->title_texture[i]->any.type!=WTEX_SOLID) { - XSetWindowBackgroundPixmap(dpy, fwin->titlebar->window, - fwin->title_back[i]); - if (wPreferences.new_style) { - if (fwin->left_button && fwin->lbutton_back[i]) - XSetWindowBackgroundPixmap(dpy, fwin->left_button->window, - fwin->lbutton_back[i]); - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button && fwin->languagebutton_back[i]) { - XSetWindowBackgroundPixmap(dpy, fwin->language_button->window, - fwin->languagebutton_back[i]); - } -#endif - - if (fwin->right_button && fwin->rbutton_back[i]) - XSetWindowBackgroundPixmap(dpy, fwin->right_button->window, - fwin->rbutton_back[i]); - } - } else { - pixel = fwin->title_texture[i]->solid.normal.pixel; - XSetWindowBackground(dpy, fwin->titlebar->window, pixel); - if (wPreferences.new_style) { - if (fwin->left_button) - XSetWindowBackground(dpy, fwin->left_button->window, - pixel); -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - XSetWindowBackground(dpy, fwin->language_button->window, - pixel); -#endif - if (fwin->right_button) - XSetWindowBackground(dpy, fwin->right_button->window, - pixel); - } - } - XClearWindow(dpy, fwin->titlebar->window); - - if (fwin->left_button) { - XClearWindow(dpy, fwin->left_button->window); - handleButtonExpose(&fwin->left_button->descriptor, NULL); - } -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) { - XClearWindow(dpy, fwin->language_button->window); - handleButtonExpose(&fwin->language_button->descriptor, NULL); - } -#endif - if (fwin->right_button) { - XClearWindow(dpy, fwin->right_button->window); - handleButtonExpose(&fwin->right_button->descriptor, NULL); - } - } -} - - - -static void -remakeTexture(WFrameWindow *fwin, int state) -{ - Pixmap pmap, lpmap, rpmap; -#ifdef XKB_BUTTON_HINT - Pixmap tpmap; -#endif - - if (fwin->title_texture[state] && fwin->titlebar) { - FREE_PIXMAP(fwin->title_back[state]); - if (wPreferences.new_style) { - FREE_PIXMAP(fwin->lbutton_back[state]); - FREE_PIXMAP(fwin->rbutton_back[state]); -#ifdef XKB_BUTTON_HINT - FREE_PIXMAP(fwin->languagebutton_back[state]); -#endif - } - - if (fwin->title_texture[state]->any.type!=WTEX_SOLID) { - int left, right; - int width; -#ifdef XKB_BUTTON_HINT - int language; -#endif - - /* eventually surrounded by if new_style */ - left = fwin->left_button && !fwin->flags.hide_left_button - && !fwin->flags.lbutton_dont_fit; -#ifdef XKB_BUTTON_HINT - language = fwin->language_button && !fwin->flags.hide_language_button - && !fwin->flags.languagebutton_dont_fit; -#endif - right = fwin->right_button && !fwin->flags.hide_right_button - && !fwin->flags.rbutton_dont_fit; - - width = fwin->core->width+1; - -#ifdef XKB_BUTTON_HINT - renderTexture(fwin->screen_ptr, fwin->title_texture[state], - width, fwin->titlebar->height, - fwin->titlebar->height, fwin->titlebar->height, - left, language, right, &pmap, &lpmap, &tpmap, &rpmap); -#else - renderTexture(fwin->screen_ptr, fwin->title_texture[state], - width, fwin->titlebar->height, - fwin->titlebar->height, fwin->titlebar->height, - left, right, &pmap, &lpmap, &rpmap); -#endif - - fwin->title_back[state] = pmap; - if (wPreferences.new_style) { - fwin->lbutton_back[state] = lpmap; - fwin->rbutton_back[state] = rpmap; -#ifdef XKB_BUTTON_HINT - fwin->languagebutton_back[state] = tpmap; -#endif - } - } - } - if (fwin->resizebar_texture && fwin->resizebar_texture[0] - && fwin->resizebar && state == 0) { - - FREE_PIXMAP(fwin->resizebar_back[0]); - - if (fwin->resizebar_texture[0]->any.type!=WTEX_SOLID) { - - renderResizebarTexture(fwin->screen_ptr, - fwin->resizebar_texture[0], - fwin->resizebar->width, - fwin->resizebar->height, - fwin->resizebar_corner_width, - &pmap); - - fwin->resizebar_back[0] = pmap; - } - - /* this part should be in updateTexture() */ - if (fwin->resizebar_texture[0]->any.type!=WTEX_SOLID) { - XSetWindowBackgroundPixmap(dpy, fwin->resizebar->window, - fwin->resizebar_back[0]); - } else { - XSetWindowBackground(dpy, fwin->resizebar->window, - fwin->resizebar_texture[0]->solid.normal.pixel); - } - XClearWindow(dpy, fwin->resizebar->window); - } -} - - -void -wFrameWindowPaint(WFrameWindow *fwin) -{ - WScreen *scr = fwin->screen_ptr; - int state; - - state = fwin->flags.state; - - if (fwin->flags.is_client_window_frame) - fwin->flags.justification = wPreferences.title_justification; - - if (fwin->flags.need_texture_remake) { - int i; - - fwin->flags.need_texture_remake = 0; - fwin->flags.need_texture_change = 0; - - if (fwin->flags.single_texture) { - remakeTexture(fwin, 0); - updateTexture(fwin); - } else { - /* first render the texture for the current state... */ - remakeTexture(fwin, state); - /* ... and paint it */ - updateTexture(fwin); - - for (i=0; i < 3; i++) { - if (i != state) { - remakeTexture(fwin, i); - } - } - } - } - - if (fwin->flags.need_texture_change) { - fwin->flags.need_texture_change = 0; - - updateTexture(fwin); - } - - if (fwin->titlebar && !fwin->flags.repaint_only_resizebar - && fwin->title_texture[state]->any.type==WTEX_SOLID) { - wDrawBevel(fwin->titlebar->window, fwin->titlebar->width, - fwin->titlebar->height, - (WTexSolid*)fwin->title_texture[state], - WREL_RAISED); - } - - if (fwin->resizebar && !fwin->flags.repaint_only_titlebar - && fwin->resizebar_texture[0]->any.type == WTEX_SOLID) { - Window win; - int w, h; - int cw; - GC light_gc, dim_gc; - WTexSolid *texture = (WTexSolid*)fwin->resizebar_texture[0]; - - w = fwin->resizebar->width; - h = fwin->resizebar->height; - cw = fwin->resizebar_corner_width; - light_gc = texture->light_gc; - dim_gc = texture->dim_gc; - win = fwin->resizebar->window; - - XDrawLine(dpy, win, dim_gc, 0, 0, w, 0); - XDrawLine(dpy, win, light_gc, 0, 1, w, 1); - - XDrawLine(dpy, win, dim_gc, cw, 2, cw, h); - XDrawLine(dpy, win, light_gc, cw+1, 2, cw+1, h); - - XDrawLine(dpy, win, dim_gc, w-cw-2, 2, w-cw-2, h); - XDrawLine(dpy, win, light_gc, w-cw-1, 2, w-cw-1, h); - -#ifdef SHADOW_RESIZEBAR - XDrawLine(dpy, win, light_gc, 0, 1, 0, h-1); - XDrawLine(dpy, win, dim_gc, w-1, 2, w-1, h-1); - XDrawLine(dpy, win, dim_gc, 1, h-1, cw, h-1); - XDrawLine(dpy, win, dim_gc, cw+2, h-1, w-cw-2, h-1); - XDrawLine(dpy, win, dim_gc, w-cw, h-1, w-1, h-1); -#endif /* SHADOW_RESIZEBAR */ - } - - - if (fwin->titlebar && !fwin->flags.repaint_only_resizebar) { - int x, y, w, h; - int lofs = 6, rofs = 6; - int titlelen; - int allButtons = 1; - - - if (!wPreferences.new_style) { - if (fwin->left_button && !fwin->flags.hide_left_button - && !fwin->flags.lbutton_dont_fit) - lofs += fwin->left_button->width + 3; - else - allButtons = 0; - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button && !fwin->flags.hide_language_button - && !fwin->flags.languagebutton_dont_fit) - lofs += fwin->language_button->width; - else - allButtons = 0; -#endif - - if (fwin->right_button && !fwin->flags.hide_right_button - && !fwin->flags.rbutton_dont_fit) - rofs += fwin->right_button->width + 3; - else - allButtons = 0; - } - -#ifdef XKB_BUTTON_HINT - fwin->languagebutton_image = - scr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode]; -#endif - - if (fwin->title) { - Drawable buf; - char *title; - - 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; - break; - - case WTJ_RIGHT: - x = fwin->titlebar->width - w - rofs; - break; - - default: - if (!allButtons) - x = lofs + (fwin->titlebar->width - w - lofs - rofs) / 2; - else - x = (fwin->titlebar->width - w) / 2; - break; - } - - y = *fwin->title_clearance + TITLEBAR_EXTEND_SPACE; - h = WMFontHeight(*fwin->font); - - /* We use a w+2 buffer to have an extra pixel on the left and - * another one on the right. This is because for some odd reason, - * sometimes when using AA fonts (when libfreetype2 is compiled - * with bytecode interpreter turned off), some fonts are drawn - * starting from x = -1 not from 0 as requested. Observed with - * capital A letter on the bold 'trebuchet ms' font. -Dan - */ - buf = XCreatePixmap(dpy, fwin->titlebar->window, w+2, h, - scr->w_depth); - - XSetClipMask(dpy, scr->copy_gc, None); - - if (fwin->title_texture[state]->any.type!=WTEX_SOLID) { - XCopyArea(dpy, fwin->title_back[state], buf, scr->copy_gc, - x-1, y, w+2, h, 0, 0); - } else { - XSetForeground(dpy, scr->copy_gc, - fwin->title_texture[state]->solid.normal.pixel); - XFillRectangle(dpy, buf, scr->copy_gc, 0, 0, w+2, h); - } - - /*XDrawRectangle(dpy, buf, WMColorGC(scr->white),1,0,w,h-1);*/ - WMDrawString(scr->wmscreen, buf, fwin->title_color[state], - *fwin->font, 1, 0, title, titlelen); - - XCopyArea(dpy, buf, fwin->titlebar->window, scr->copy_gc, - 0, 0, w+2, h, x-1, y); - - XFreePixmap(dpy, buf); - - wfree(title); - } - - if (fwin->left_button) - handleButtonExpose(&fwin->left_button->descriptor, NULL); - if (fwin->right_button) - handleButtonExpose(&fwin->right_button->descriptor, NULL); -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - handleButtonExpose(&fwin->language_button->descriptor, NULL); -#endif - } -} - - -static void -reconfigure(WFrameWindow *fwin, int x, int y, int width, int height, - Bool dontMove) -{ - int k = (wPreferences.new_style ? 4 : 3); - int resizedHorizontally = 0; - - if (dontMove) - XResizeWindow(dpy, fwin->core->window, width, height); - else - XMoveResizeWindow(dpy, fwin->core->window, x, y, width, height); - - /* - if (fwin->core->height != height && fwin->resizebar) - XMoveWindow(dpy, fwin->resizebar->window, 0, - height - fwin->resizebar->height); - */ - if (fwin->core->width != width) { - fwin->flags.need_texture_remake = 1; - resizedHorizontally = 1; - } - - fwin->core->width = width; - fwin->core->height = height; - - if (fwin->titlebar && resizedHorizontally) { - /* Check if the titlebar is wide enough to hold the buttons. - * Temporarily remove them if can't - */ - if (fwin->left_button) { - if (width < fwin->top_width*k && !fwin->flags.lbutton_dont_fit) { - - if (!fwin->flags.hide_left_button) { - XUnmapWindow(dpy, fwin->left_button->window); - } - fwin->flags.lbutton_dont_fit = 1; - } else if (width >= fwin->top_width*k && fwin->flags.lbutton_dont_fit) { - - if (!fwin->flags.hide_left_button) { - XMapWindow(dpy, fwin->left_button->window); - } - fwin->flags.lbutton_dont_fit = 0; - } - } - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) { - if (width < fwin->top_width*k && !fwin->flags.languagebutton_dont_fit) { - - if (!fwin->flags.hide_language_button) { - XUnmapWindow(dpy, fwin->language_button->window); - } - fwin->flags.languagebutton_dont_fit = 1; - } else if (width >= fwin->top_width*k && fwin->flags.languagebutton_dont_fit) { - - if (!fwin->flags.hide_language_button) { - XMapWindow(dpy, fwin->language_button->window); - } - fwin->flags.languagebutton_dont_fit = 0; - } - } -#endif - - if (fwin->right_button) { - if (width < fwin->top_width*2 && !fwin->flags.rbutton_dont_fit) { - - if (!fwin->flags.hide_right_button) { - XUnmapWindow(dpy, fwin->right_button->window); - } - fwin->flags.rbutton_dont_fit = 1; - } else if (width >= fwin->top_width*2 && fwin->flags.rbutton_dont_fit) { - - if (!fwin->flags.hide_right_button) { - XMapWindow(dpy, fwin->right_button->window); - } - fwin->flags.rbutton_dont_fit = 0; - } - } - - if (wPreferences.new_style) { - if (fwin->right_button) - XMoveWindow(dpy, fwin->right_button->window, - width - fwin->right_button->width + 1, 0); - } else { - if (fwin->right_button) - XMoveWindow(dpy, fwin->right_button->window, - width - fwin->right_button->width - 3, - (fwin->titlebar->height - fwin->right_button->height)/2); - } - updateTitlebar(fwin); - checkTitleSize(fwin); - } - - if (fwin->resizebar) { - wCoreConfigure(fwin->resizebar, 0, - fwin->core->height - fwin->resizebar->height, - fwin->core->width, fwin->resizebar->height); - - fwin->resizebar_corner_width = RESIZEBAR_CORNER_WIDTH; - if (fwin->core->width < RESIZEBAR_CORNER_WIDTH*2 + RESIZEBAR_MIN_WIDTH) { - fwin->resizebar_corner_width = fwin->core->width/2; - } - } -} - -void -wFrameWindowConfigure(WFrameWindow *fwin, int x, int y, int width, int height) -{ - reconfigure(fwin, x, y, width, height, False); -} - -void -wFrameWindowResize(WFrameWindow *fwin, int width, int height) -{ - reconfigure(fwin, 0, 0, width, height, True); -} - - - -int -wFrameWindowChangeTitle(WFrameWindow *fwin, char *new_title) -{ - /* check if the title is the same as before */ - if (fwin->title) { - if (new_title && (strcmp(fwin->title, new_title) == 0)) { - return 0; - } - } else { - if (!new_title) - return 0; - } - - if (fwin->title) - wfree(fwin->title); - - fwin->title = wstrdup(new_title); - - if (fwin->titlebar) { - XClearWindow(dpy, fwin->titlebar->window); - - wFrameWindowPaint(fwin); - } - checkTitleSize(fwin); - - return 1; -} - - -#ifdef OLWM_HINTS -void -wFrameWindowUpdatePushButton(WFrameWindow *fwin, Bool pushed) -{ - fwin->flags.right_button_pushed_in = pushed; - - paintButton(fwin->right_button, fwin->title_texture[fwin->flags.state], - WMColorPixel(fwin->title_color[fwin->flags.state]), - fwin->rbutton_image, pushed); -} -#endif /* OLWM_HINTS */ - - -#ifdef XKB_BUTTON_HINT -void -wFrameWindowUpdateLanguageButton(WFrameWindow *fwin) -{ - paintButton(fwin->language_button, fwin->title_texture[fwin->flags.state], - WMColorPixel(fwin->title_color[fwin->flags.state]), - fwin->languagebutton_image, True); -} -#endif /* XKB_BUTTON_HINT */ - - -/*********************************************************************/ - -static void -handleExpose(WObjDescriptor *desc, XEvent *event) -{ - WFrameWindow *fwin = (WFrameWindow*)desc->parent; - - - if (fwin->titlebar && fwin->titlebar->window == event->xexpose.window) - fwin->flags.repaint_only_titlebar = 1; - if (fwin->resizebar && fwin->resizebar->window == event->xexpose.window) - fwin->flags.repaint_only_resizebar = 1; - wFrameWindowPaint(fwin); - fwin->flags.repaint_only_titlebar = 0; - fwin->flags.repaint_only_resizebar = 0; -} - - -static void -checkTitleSize(WFrameWindow *fwin) -{ - int width; - - if (!fwin->title) { - fwin->flags.incomplete_title = 0; - return; - } - - if (!fwin->titlebar) { - fwin->flags.incomplete_title = 1; - return; - } else { - width = fwin->titlebar->width - 6 - 6; - } - - if (!wPreferences.new_style) { - if (fwin->left_button && !fwin->flags.hide_left_button - && !fwin->flags.lbutton_dont_fit) - width -= fwin->left_button->width + 3; - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button && !fwin->flags.hide_language_button - && !fwin->flags.languagebutton_dont_fit) - width -= fwin->language_button->width + 3; -#endif - - if (fwin->right_button && !fwin->flags.hide_right_button - && !fwin->flags.rbutton_dont_fit) - width -= fwin->right_button->width + 3; - } - if (WMWidthOfString(*fwin->font, fwin->title, strlen(fwin->title)) > width) { - fwin->flags.incomplete_title = 1; - } else { - fwin->flags.incomplete_title = 0; - } -} - - -static void -paintButton(WCoreWindow *button, WTexture *texture, unsigned long color, - WPixmap *image, int pushed) -{ - WScreen *scr = button->screen_ptr; - GC copy_gc = scr->copy_gc; - int x=0, y=0, d=0; - int left=0, width=0; - - /* setup stuff according to the state */ - if (pushed) { - if (image) { - if (image->width>=image->height*2) { - /* the image contains 2 pictures: the second is for the - * pushed state */ - width = image->width/2; - left = image->width/2; - } else { - width = image->width; - } - } - XSetClipMask(dpy, copy_gc, None); - XSetForeground(dpy, copy_gc, scr->white_pixel); - d=1; - if (wPreferences.new_style) { - XFillRectangle(dpy, button->window, copy_gc, 0, 0, - button->width-1, button->height-1); - XSetForeground(dpy, copy_gc, scr->black_pixel); - XDrawRectangle(dpy, button->window, copy_gc, 0, 0, - button->width-1, button->height-1); - } else { - XFillRectangle(dpy, button->window, copy_gc, 0, 0, - button->width, button->height); - XSetForeground(dpy, copy_gc, scr->black_pixel); - XDrawRectangle(dpy, button->window, copy_gc, 0, 0, - button->width, button->height); - } - } else { - XClearWindow(dpy, button->window); - - if (image) { - if (image->width>=image->height*2) - width = image->width/2; - else - width = image->width; - } - d=0; - - if (wPreferences.new_style) { - if (texture->any.type==WTEX_SOLID || pushed) { - wDrawBevel(button->window, button->width, button->height, - (WTexSolid*)texture, WREL_RAISED); - } - } else { - wDrawBevel(button->window, button->width, button->height, - scr->widget_texture, WREL_RAISED); - } - } - - if (image) { - /* display image */ - XSetClipMask(dpy, copy_gc, image->mask); - x = (button->width - width)/2 + d; - y = (button->height - image->height)/2 + d; - XSetClipOrigin(dpy, copy_gc, x-left, y); - if (!wPreferences.new_style) { - XSetForeground(dpy, copy_gc, scr->black_pixel); - if (!pushed) { - if (image->depth==1) - XCopyPlane(dpy, image->image, button->window, copy_gc, - left, 0, width, image->height, x, y, 1); - else - XCopyArea(dpy, image->image, button->window, copy_gc, - left, 0, width, image->height, x, y); - } else { - XSetForeground(dpy, copy_gc, scr->dark_pixel); - XFillRectangle(dpy, button->window, copy_gc, 0, 0, - button->width, button->height); - } - } else { - if (pushed) { - XSetForeground(dpy, copy_gc, scr->black_pixel); - } else { - XSetForeground(dpy, copy_gc, color); - XSetBackground(dpy, copy_gc, texture->any.color.pixel); - } - XFillRectangle(dpy, button->window, copy_gc, 0, 0, - button->width, button->height); - } - } -} - - -static void -handleButtonExpose(WObjDescriptor *desc, XEvent *event) -{ - WFrameWindow *fwin = (WFrameWindow*)desc->parent; - WCoreWindow *button = (WCoreWindow*)desc->self; - -#ifdef XKB_BUTTON_HINT - if (button == fwin->language_button) { - if (wPreferences.modelock){ - paintButton(button, fwin->title_texture[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], - WMColorPixel(fwin->title_color[fwin->flags.state]), - fwin->lbutton_image, False); - } else { - Bool pushed = False; - -#ifdef OLWM_HINTS - if (fwin->flags.right_button_pushed_in) - pushed = True; -#endif - /* emulate the olwm pushpin in the "out" state */ - paintButton(button, fwin->title_texture[fwin->flags.state], - WMColorPixel(fwin->title_color[fwin->flags.state]), - fwin->rbutton_image, pushed); - } -} - - -static void -titlebarMouseDown(WObjDescriptor *desc, XEvent *event) -{ - WFrameWindow *fwin = desc->parent; - WCoreWindow *titlebar = desc->self; - - if (IsDoubleClick(fwin->core->screen_ptr, event)) { - if (fwin->on_dblclick_titlebar) { - (*fwin->on_dblclick_titlebar)(titlebar, fwin->child, event); - } - } else { - if (fwin->on_mousedown_titlebar) { - (*fwin->on_mousedown_titlebar)(titlebar, fwin->child, event); - } - } -} - - -static void -resizebarMouseDown(WObjDescriptor *desc, XEvent *event) -{ - WFrameWindow *fwin = desc->parent; - WCoreWindow *resizebar = desc->self; - - if (fwin->on_mousedown_resizebar) - (*fwin->on_mousedown_resizebar)(resizebar, fwin->child, event); -} - - -static void -buttonMouseDown(WObjDescriptor *desc, XEvent *event) -{ - WFrameWindow *fwin = desc->parent; - WCoreWindow *button = desc->self; - WPixmap *image; - XEvent ev; - int done=0, execute=1; - WTexture *texture; - unsigned long pixel; - int clickButton = event->xbutton.button; - - if (IsDoubleClick(fwin->core->screen_ptr, event)) { - if (button == fwin->right_button && fwin->on_dblclick_right) { - (*fwin->on_dblclick_right)(button, fwin->child, event); - } - return; - } - - if (button == fwin->left_button) { - image = fwin->lbutton_image; - } else { - image = fwin->rbutton_image; - } -#ifdef XKB_BUTTON_HINT - if (button == fwin->language_button) { - if (!wPreferences.modelock) - return; - image = fwin->languagebutton_image; - } -#endif - - pixel = WMColorPixel(fwin->title_color[fwin->flags.state]); - texture = fwin->title_texture[fwin->flags.state]; - paintButton(button, texture, pixel, image, True); - - while (!done) { - WMMaskEvent(dpy, LeaveWindowMask|EnterWindowMask|ButtonReleaseMask - |ButtonPressMask|ExposureMask, &ev); - switch (ev.type) { - case LeaveNotify: - execute = 0; - paintButton(button, texture, pixel, image, False); - break; - - case EnterNotify: - execute = 1; - paintButton(button, texture, pixel, image, True); - break; - - case ButtonPress: - break; - - case ButtonRelease: - if (ev.xbutton.button == clickButton) - done = 1; - break; - - default: - WMHandleEvent(&ev); - } - } - paintButton(button, texture, pixel, image, False); - - if (execute) { - if (button == fwin->left_button) { - if (fwin->on_click_left) - (*fwin->on_click_left)(button, fwin->child, &ev); - } else if (button == fwin->right_button) { - if (fwin->on_click_right) - (*fwin->on_click_right)(button, fwin->child, &ev); - } -#ifdef XKB_BUTTON_HINT - else if (button == fwin->language_button) { - if (fwin->on_click_language) - (*fwin->on_click_language)(button, fwin->child, &ev); - } -#endif - - } -} - +/* + * Window Maker window manager + * + * Copyright (c) 1997-2003 Alfredo K. Kojima + * + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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, + * USA. + */ + +#include "wconfig.h" + +#include +#include +#ifdef KEEP_XKB_LOCK_STATUS +#include +#endif /* KEEP_XKB_LOCK_STATUS */ + +#include +#include + +#include + +#include "WindowMaker.h" +#include "GNUstep.h" +#include "texture.h" +#include "screen.h" +#include "wcore.h" +#include "framewin.h" +#include "stacking.h" +#include "funcs.h" + +#define DBLCLICK_TIME wPreferences.dblclick_time + +extern WPreferences wPreferences; + +static void handleExpose(WObjDescriptor *desc, XEvent *event); +static void handleButtonExpose(WObjDescriptor *desc, XEvent *event); + +static void buttonMouseDown(WObjDescriptor *desc, XEvent *event); +static void titlebarMouseDown(WObjDescriptor *desc, XEvent *event); +static void resizebarMouseDown(WObjDescriptor *desc, XEvent *event); + +static void checkTitleSize(WFrameWindow *fwin); + + +static void paintButton(WCoreWindow *button, WTexture *texture, + unsigned long color, WPixmap *image, int pushed); + +static void updateTitlebar(WFrameWindow *fwin); + + +WFrameWindow* +wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y, + int width, int height, int *clearance, int flags, + WTexture **title_texture, WTexture **resize_texture, + WMColor **color, WMFont **font) +{ + WFrameWindow *fwin; + + fwin = wmalloc(sizeof(WFrameWindow)); + memset(fwin, 0, sizeof(WFrameWindow)); + + fwin->screen_ptr = scr; + + fwin->flags.single_texture = (flags & WFF_SINGLE_STATE) ? 1 : 0; + + fwin->title_texture = title_texture; + fwin->resizebar_texture = resize_texture; + fwin->title_color = color; + fwin->title_clearance = clearance; + fwin->font = font; +#ifdef KEEP_XKB_LOCK_STATUS + fwin->languagemode = XkbGroup1Index; + fwin->last_languagemode = XkbGroup2Index; +#endif + + fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, + (flags & WFF_BORDER) + ? FRAME_BORDER_WIDTH : 0); + if (wPreferences.use_saveunders) { + unsigned long vmask; + XSetWindowAttributes attribs; + + vmask = CWSaveUnder; + attribs.save_under = True; + XChangeWindowAttributes(dpy, fwin->core->window, vmask, &attribs); + } + + /* setup stacking information */ + fwin->core->stacking = wmalloc(sizeof(WStacking)); + fwin->core->stacking->above = NULL; + fwin->core->stacking->under = NULL; + fwin->core->stacking->child_of = NULL; + fwin->core->stacking->window_level = wlevel; + + AddToStackList(fwin->core); + + wFrameWindowUpdateBorders(fwin, flags); + + return fwin; +} + + + +void +wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) +{ + int theight; + int bsize; + int width, height; + int i; + WScreen *scr = fwin->screen_ptr; + + width = fwin->core->width; + if (flags & WFF_IS_SHADED) + height = -1; + else + height = fwin->core->height - fwin->top_width - fwin->bottom_width; + + if (flags & WFF_TITLEBAR) + theight = WMFontHeight(*fwin->font) + (*fwin->title_clearance + TITLEBAR_EXTEND_SPACE) * 2; + else + theight = 0; + + if (wPreferences.new_style) { + bsize = theight; + } else { + bsize = theight - 7; + } + + if (fwin->titlebar) { + /* if we had a titlebar and is requesting for one, + * check if the size has changed and resize it */ + if (flags & WFF_TITLEBAR) { + fwin->top_width = theight; + + fwin->flags.need_texture_remake = 1; + + if (wPreferences.new_style) { + if (fwin->left_button) { + wCoreConfigure(fwin->left_button, 0, 0, bsize, bsize); + } +#ifdef XKB_BUTTON_HINT + if (fwin->language_button) + if (fwin->flags.hide_left_button || !fwin->left_button + || fwin->flags.lbutton_dont_fit) { + wCoreConfigure(fwin->language_button, 0, 0, bsize, bsize); + } else { + wCoreConfigure(fwin->language_button, bsize, 0, bsize, bsize); + } +#endif + + + if (fwin->right_button) { + wCoreConfigure(fwin->right_button, width-bsize+1, + 0, bsize, bsize); + } + } else { /* !new_style */ + if (fwin->left_button) { + wCoreConfigure(fwin->left_button, 3, (theight-bsize)/2, + bsize, bsize); + } + +#ifdef XKB_BUTTON_HINT + if (fwin->language_button) { + wCoreConfigure(fwin->language_button, 6 + bsize, (theight-bsize)/2, + bsize, bsize); + } +#endif + + if (fwin->right_button) { + wCoreConfigure(fwin->right_button, width-bsize-3, + (theight-bsize)/2, bsize, bsize); + } + } + updateTitlebar(fwin); + } else { + /* we had a titlebar, but now we don't need it anymore */ + for (i=0; i < (fwin->flags.single_texture ? 1 : 3); i++) { + FREE_PIXMAP(fwin->title_back[i]); + if (wPreferences.new_style) { + FREE_PIXMAP(fwin->lbutton_back[i]); + FREE_PIXMAP(fwin->rbutton_back[i]); +#ifdef XKB_BUTTON_HINT + FREE_PIXMAP(fwin->languagebutton_back[i]); +#endif + } + } + if (fwin->left_button) + wCoreDestroy(fwin->left_button); + fwin->left_button = NULL; + +#ifdef XKB_BUTTON_HINT + if (fwin->language_button) + wCoreDestroy(fwin->language_button); + fwin->language_button = NULL; +#endif + + if (fwin->right_button) + wCoreDestroy(fwin->right_button); + fwin->right_button = NULL; + + wCoreDestroy(fwin->titlebar); + fwin->titlebar = NULL; + + fwin->top_width = 0; + } + } else { + /* if we didn't have a titlebar and are being requested for + * one, create it */ + if (flags & WFF_TITLEBAR) { + fwin->top_width = theight; + + fwin->flags.titlebar = 1; + fwin->titlebar = wCoreCreate(fwin->core, 0, 0, width+1, theight); + + if (flags & WFF_LEFT_BUTTON) { + fwin->flags.left_button = 1; + if (wPreferences.new_style) { + fwin->left_button = wCoreCreate(fwin->core, 0, 0, + bsize, bsize); + if (width < theight*4) { + fwin->flags.lbutton_dont_fit = 1; + } else { + XMapRaised(dpy, fwin->left_button->window); + } + } else { + fwin->left_button = + wCoreCreate(fwin->titlebar, 3, (theight-bsize)/2, + bsize, bsize); + + XSetWindowBackground(dpy, fwin->left_button->window, + scr->widget_texture->normal.pixel); + + if (width < theight*3) { + fwin->flags.lbutton_dont_fit = 1; + } else { + XMapRaised(dpy, fwin->left_button->window); + } + } + } + +#ifdef XKB_BUTTON_HINT + if (flags & WFF_LANGUAGE_BUTTON) { + fwin->flags.language_button = 1; + if (wPreferences.new_style) { + fwin->language_button = wCoreCreate(fwin->core, + bsize, 0, bsize, bsize); + + if (width < theight*4) { + fwin->flags.languagebutton_dont_fit = 1; + } else { + XMapRaised(dpy, fwin->language_button->window); + } + } else { + fwin->language_button = + wCoreCreate(fwin->titlebar, bsize + 6, (theight-bsize)/2, + bsize, bsize); + + XSetWindowBackground(dpy, fwin->language_button->window, + scr->widget_texture->normal.pixel); + + if (width < theight*3) { + fwin->flags.languagebutton_dont_fit = 1; + } else { + XMapRaised(dpy, fwin->language_button->window); + } + } + } +#endif + + if (flags & WFF_RIGHT_BUTTON) { + fwin->flags.right_button = 1; + if (wPreferences.new_style) { + fwin->right_button = + wCoreCreate(fwin->core, width-bsize+1, 0, + bsize, bsize); + } else { + fwin->right_button = + wCoreCreate(fwin->titlebar, width-bsize-3, + (theight-bsize)/2, bsize, bsize); + XSetWindowBackground(dpy, fwin->right_button->window, + scr->widget_texture->normal.pixel); + } + + if (width < theight*2) { + fwin->flags.rbutton_dont_fit = 1; + } else { + XMapRaised(dpy, fwin->right_button->window); + } + } + + if (wPreferences.new_style) + updateTitlebar(fwin); + + XMapRaised(dpy, fwin->titlebar->window); + + fwin->flags.need_texture_remake = 1; + } + } + checkTitleSize(fwin); + + if (flags & WFF_RESIZEBAR) { + fwin->bottom_width = RESIZEBAR_HEIGHT; + + if (!fwin->resizebar) { + fwin->flags.resizebar = 1; + fwin->resizebar = wCoreCreate(fwin->core, 0, + height + fwin->top_width, + width, RESIZEBAR_HEIGHT); + fwin->resizebar_corner_width = RESIZEBAR_CORNER_WIDTH; + if (width < RESIZEBAR_CORNER_WIDTH*2 + RESIZEBAR_MIN_WIDTH) { + fwin->resizebar_corner_width = (width - RESIZEBAR_MIN_WIDTH)/2; + if (fwin->resizebar_corner_width < 0) + fwin->resizebar_corner_width = 0; + } + + XMapWindow(dpy, fwin->resizebar->window); + XLowerWindow(dpy, fwin->resizebar->window); + + fwin->flags.need_texture_remake = 1; + } else { + if (height+fwin->top_width+fwin->bottom_width != fwin->core->height) { + wCoreConfigure(fwin->resizebar, 0, height + fwin->top_width, + width, RESIZEBAR_HEIGHT); + } + } + } else { + fwin->bottom_width = 0; + + if (fwin->resizebar) { + fwin->bottom_width = 0; + wCoreDestroy(fwin->resizebar); + fwin->resizebar = NULL; + } + } + + if (height + fwin->top_width + fwin->bottom_width != fwin->core->height + && !(flags & WFF_IS_SHADED)) { + wFrameWindowResize(fwin, width, + height + fwin->top_width + fwin->bottom_width); + } + + + if (flags & WFF_BORDER) { + XSetWindowBorderWidth(dpy, fwin->core->window, FRAME_BORDER_WIDTH); + } else { + XSetWindowBorderWidth(dpy, fwin->core->window, 0); + } + + /* setup object descriptors */ + + if (fwin->titlebar) { + fwin->titlebar->descriptor.handle_expose = handleExpose; + fwin->titlebar->descriptor.parent = fwin; + fwin->titlebar->descriptor.parent_type = WCLASS_FRAME; + fwin->titlebar->descriptor.handle_mousedown = titlebarMouseDown; + } + + if (fwin->resizebar) { + fwin->resizebar->descriptor.handle_expose = handleExpose; + fwin->resizebar->descriptor.parent = fwin; + fwin->resizebar->descriptor.parent_type = WCLASS_FRAME; + fwin->resizebar->descriptor.handle_mousedown = resizebarMouseDown; + } + + if (fwin->left_button) { + fwin->left_button->descriptor.handle_expose = handleButtonExpose; + fwin->left_button->descriptor.parent = fwin; + fwin->left_button->descriptor.parent_type = WCLASS_FRAME; + fwin->left_button->descriptor.handle_mousedown = buttonMouseDown; + } + +#ifdef XKB_BUTTON_HINT + if (fwin->language_button) { + fwin->language_button->descriptor.handle_expose = handleButtonExpose; + fwin->language_button->descriptor.parent = fwin; + fwin->language_button->descriptor.parent_type = WCLASS_FRAME; + fwin->language_button->descriptor.handle_mousedown = buttonMouseDown; + } +#endif + + + if (fwin->right_button) { + fwin->right_button->descriptor.parent = fwin; + fwin->right_button->descriptor.parent_type = WCLASS_FRAME; + fwin->right_button->descriptor.handle_expose = handleButtonExpose; + fwin->right_button->descriptor.handle_mousedown = buttonMouseDown; + } + + checkTitleSize(fwin); +} + + + +void +wFrameWindowDestroy(WFrameWindow *fwin) +{ + int i; + + if (fwin->left_button) + wCoreDestroy(fwin->left_button); + +#ifdef XKB_BUTTON_HINT + if (fwin->language_button) + wCoreDestroy(fwin->language_button); +#endif + + if (fwin->right_button) + wCoreDestroy(fwin->right_button); + + if (fwin->resizebar) + wCoreDestroy(fwin->resizebar); + + if (fwin->titlebar) + wCoreDestroy(fwin->titlebar); + + RemoveFromStackList(fwin->core); + + wCoreDestroy(fwin->core); + + if (fwin->title) + wfree(fwin->title); + + for (i=0; i < (fwin->flags.single_texture ? 1 : 3); i++) { + FREE_PIXMAP(fwin->title_back[i]); + if (wPreferences.new_style) { + FREE_PIXMAP(fwin->lbutton_back[i]); +#ifdef XKB_BUTTON_HINT + FREE_PIXMAP(fwin->languagebutton_back[i]); +#endif + FREE_PIXMAP(fwin->rbutton_back[i]); + } + } + + wfree(fwin); +} + + +void +wFrameWindowChangeState(WFrameWindow *fwin, int state) +{ + if (fwin->flags.state==state) + return; + + fwin->flags.state = state; + fwin->flags.need_texture_change = 1; + + wFrameWindowPaint(fwin); +} + + +static void +updateTitlebar(WFrameWindow *fwin) +{ + int x, w; + int theight; + + theight = WMFontHeight(*fwin->font) + (*fwin->title_clearance + TITLEBAR_EXTEND_SPACE) * 2; + + x = 0; + w = fwin->core->width + 1; + + if (wPreferences.new_style) { + if (fwin->flags.hide_left_button || !fwin->left_button + || fwin->flags.lbutton_dont_fit) { + x = 0; +#ifdef XKB_BUTTON_HINT + if(fwin->language_button) + wCoreConfigure(fwin->language_button, 0, 0, + fwin->language_button->width, + fwin->language_button->width); +#endif + } else { +#ifdef XKB_BUTTON_HINT + if(fwin->language_button) + wCoreConfigure(fwin->language_button, fwin->left_button->width, 0, + fwin->language_button->width, + fwin->language_button->width); +#endif + x = fwin->left_button->width; + w -= fwin->left_button->width; + } +#ifdef XKB_BUTTON_HINT + if (fwin->flags.hide_language_button || !fwin->language_button + || fwin->flags.languagebutton_dont_fit) { + } else { + x += fwin->language_button->width; + w -= fwin->language_button->width; + } +#endif + } +#ifdef XKB_BUTTON_HINT + else { + int bsize = theight - 7; + if (fwin->flags.hide_left_button || !fwin->left_button + || fwin->flags.lbutton_dont_fit) { + if(fwin->language_button) + wCoreConfigure(fwin->language_button, 3, (theight-bsize)/2, + fwin->language_button->width, + fwin->language_button->width); + } + else { + if(fwin->language_button) + wCoreConfigure(fwin->language_button, + 6 + fwin->left_button->width, (theight-bsize)/2, + fwin->language_button->width, + fwin->language_button->width); + } + } +#endif + + if (wPreferences.new_style) { + if (!fwin->flags.hide_right_button && fwin->right_button + && !fwin->flags.rbutton_dont_fit) { + w -= fwin->right_button->width; + } + } + + if (wPreferences.new_style || fwin->titlebar->width!=w) + fwin->flags.need_texture_remake = 1; + + wCoreConfigure(fwin->titlebar, x, 0, w, theight); +} + + +void +wFrameWindowHideButton(WFrameWindow *fwin, int flags) +{ + if ((flags & WFF_RIGHT_BUTTON) && fwin->right_button) { + XUnmapWindow(dpy, fwin->right_button->window); + fwin->flags.hide_right_button = 1; + } + + if ((flags & WFF_LEFT_BUTTON) && fwin->left_button) { + XUnmapWindow(dpy, fwin->left_button->window); + fwin->flags.hide_left_button = 1; + } + +#ifdef XKB_BUTTON_HINT + if ((flags & WFF_LANGUAGE_BUTTON) && fwin->language_button) { + XUnmapWindow(dpy, fwin->language_button->window); + fwin->flags.hide_language_button = 1; + } +#endif + + if (fwin->titlebar) { + if (wPreferences.new_style) { + updateTitlebar(fwin); + } else { +#ifdef XKB_BUTTON_HINT + updateTitlebar(fwin); +#else + XClearWindow(dpy, fwin->titlebar->window); + wFrameWindowPaint(fwin); +#endif + } + checkTitleSize(fwin); + } +} + + +void +wFrameWindowShowButton(WFrameWindow *fwin, int flags) +{ + if ((flags & WFF_RIGHT_BUTTON) && fwin->right_button + && fwin->flags.hide_right_button) { + + if (!fwin->flags.rbutton_dont_fit) + XMapWindow(dpy, fwin->right_button->window); + + fwin->flags.hide_right_button = 0; + } + +#ifdef XKB_BUTTON_HINT + if ((flags & WFF_LANGUAGE_BUTTON) && fwin->language_button + && fwin->flags.hide_language_button) { + + if (!fwin->flags.languagebutton_dont_fit) + XMapWindow(dpy, fwin->language_button->window); + + fwin->flags.hide_language_button = 0; + } +#endif + + if ((flags & WFF_LEFT_BUTTON) && fwin->left_button + && fwin->flags.hide_left_button) { + + if (!fwin->flags.lbutton_dont_fit) + XMapWindow(dpy, fwin->left_button->window); + + fwin->flags.hide_left_button = 0; + } + + + if (fwin->titlebar) { + if (wPreferences.new_style) { + updateTitlebar(fwin); + } else { + XClearWindow(dpy, fwin->titlebar->window); + wFrameWindowPaint(fwin); + } + checkTitleSize(fwin); + } +} + + +static void +#ifdef XKB_BUTTON_HINT +renderTexture(WScreen *scr, WTexture *texture, int width, int height, + int bwidth, int bheight, int left, int language, int right, + Pixmap *title, Pixmap *lbutton, Pixmap *languagebutton, Pixmap *rbutton) +#else +renderTexture(WScreen *scr, WTexture *texture, int width, int height, + int bwidth, int bheight, int left, int right, + Pixmap *title, Pixmap *lbutton, Pixmap *rbutton) +#endif +{ + RImage *img; + RImage *limg, *rimg, *mimg; +#ifdef XKB_BUTTON_HINT + RImage *timg; +#endif + int x, w; + + *title = None; + *lbutton = None; + *rbutton = None; +#ifdef XKB_BUTTON_HINT + *languagebutton = None; +#endif + + img = wTextureRenderImage(texture, width, height, WREL_FLAT); + if (!img) { + wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode)); + return; + } + + if (wPreferences.new_style) { + if (left) { + limg = RGetSubImage(img, 0, 0, bwidth, bheight); + } else + limg = NULL; + + x = 0; + w = img->width; + +#ifdef XKB_BUTTON_HINT + if (language) { + timg = RGetSubImage(img, bwidth * left, 0, bwidth, bheight); + } else + timg = NULL; +#endif + + if (limg) { + RBevelImage(limg, RBEV_RAISED2); + if (!RConvertImage(scr->rcontext, limg, lbutton)) { + wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); + } + x += limg->width; + w -= limg->width; + RReleaseImage(limg); + } + +#ifdef XKB_BUTTON_HINT + if (timg) { + RBevelImage(timg, RBEV_RAISED2); + if (!RConvertImage(scr->rcontext, timg, languagebutton)) { + wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); + } + x += timg->width; + w -= timg->width; + RReleaseImage(timg); + } +#endif + + if (right) { + rimg = RGetSubImage(img, width - bwidth, 0, bwidth, bheight); + } else + rimg = NULL; + + if (rimg) { + RBevelImage(rimg, RBEV_RAISED2); + if (!RConvertImage(scr->rcontext, rimg, rbutton)) { + wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); + } + w -= rimg->width; + RReleaseImage(rimg); + } + + if (w!=width) { + mimg = RGetSubImage(img, x, 0, w, img->height); + RBevelImage(mimg, RBEV_RAISED2); + + if (!RConvertImage(scr->rcontext, mimg, title)) { + wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); + } + RReleaseImage(mimg); + } else { + RBevelImage(img, RBEV_RAISED2); + + if (!RConvertImage(scr->rcontext, img, title)) { + wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); + } + } + } else { + RBevelImage(img, RBEV_RAISED2); + + if (!RConvertImage(scr->rcontext, img, title)) { + wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); + } + } + + RReleaseImage(img); +} + + +static void +renderResizebarTexture(WScreen *scr, WTexture *texture, int width, int height, + int cwidth, Pixmap *pmap) +{ + RImage *img; + RColor light; + RColor dark; + + *pmap = None; + + img = wTextureRenderImage(texture, width, height, WREL_FLAT); + if (!img) { + wwarning(_("could not render texture: %s"), + RMessageForError(RErrorCode)); + return; + } + + light.alpha = 0; + light.red = light.green = light.blue = 80; + + dark.alpha = 0; + dark.red = dark.green = dark.blue = 40; + + ROperateLine(img, RSubtractOperation, 0, 0, width-1, 0, &dark); + ROperateLine(img, RAddOperation, 0, 1, width-1, 1, &light); + + ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height-1, &dark); + ROperateLine(img, RAddOperation, cwidth+1, 2, cwidth+1, height-1, &light); + + if (width > 1) + ROperateLine(img, RSubtractOperation, width-cwidth-2, 2, + width-cwidth-2, height-1, &dark); + ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1, + height-1, &light); + +#ifdef SHADOW_RESIZEBAR + ROperateLine(img, RAddOperation, 0, 1, 0, height-1, &light); + ROperateLine(img, RSubtractOperation, width-1, 1, width-1, height-1, + &dark); + ROperateLine(img, RSubtractOperation, 0, height-1, width-1, height-1, + &dark); +#endif /* SHADOW_RESIZEBAR */ + + + if (!RConvertImage(scr->rcontext, img, pmap)) { + wwarning(_("error rendering image: %s"), RMessageForError(RErrorCode)); + } + + RReleaseImage(img); +} + + + +static void +updateTexture(WFrameWindow *fwin) +{ + int i; + unsigned long pixel; + + i = fwin->flags.state; + if (fwin->titlebar) { + if (fwin->title_texture[i]->any.type!=WTEX_SOLID) { + XSetWindowBackgroundPixmap(dpy, fwin->titlebar->window, + fwin->title_back[i]); + if (wPreferences.new_style) { + if (fwin->left_button && fwin->lbutton_back[i]) + XSetWindowBackgroundPixmap(dpy, fwin->left_button->window, + fwin->lbutton_back[i]); + +#ifdef XKB_BUTTON_HINT + if (fwin->language_button && fwin->languagebutton_back[i]) { + XSetWindowBackgroundPixmap(dpy, fwin->language_button->window, + fwin->languagebutton_back[i]); + } +#endif + + if (fwin->right_button && fwin->rbutton_back[i]) + XSetWindowBackgroundPixmap(dpy, fwin->right_button->window, + fwin->rbutton_back[i]); + } + } else { + pixel = fwin->title_texture[i]->solid.normal.pixel; + XSetWindowBackground(dpy, fwin->titlebar->window, pixel); + if (wPreferences.new_style) { + if (fwin->left_button) + XSetWindowBackground(dpy, fwin->left_button->window, + pixel); +#ifdef XKB_BUTTON_HINT + if (fwin->language_button) + XSetWindowBackground(dpy, fwin->language_button->window, + pixel); +#endif + if (fwin->right_button) + XSetWindowBackground(dpy, fwin->right_button->window, + pixel); + } + } + XClearWindow(dpy, fwin->titlebar->window); + + if (fwin->left_button) { + XClearWindow(dpy, fwin->left_button->window); + handleButtonExpose(&fwin->left_button->descriptor, NULL); + } +#ifdef XKB_BUTTON_HINT + if (fwin->language_button) { + XClearWindow(dpy, fwin->language_button->window); + handleButtonExpose(&fwin->language_button->descriptor, NULL); + } +#endif + if (fwin->right_button) { + XClearWindow(dpy, fwin->right_button->window); + handleButtonExpose(&fwin->right_button->descriptor, NULL); + } + } +} + + + +static void +remakeTexture(WFrameWindow *fwin, int state) +{ + Pixmap pmap, lpmap, rpmap; +#ifdef XKB_BUTTON_HINT + Pixmap tpmap; +#endif + + if (fwin->title_texture[state] && fwin->titlebar) { + FREE_PIXMAP(fwin->title_back[state]); + if (wPreferences.new_style) { + FREE_PIXMAP(fwin->lbutton_back[state]); + FREE_PIXMAP(fwin->rbutton_back[state]); +#ifdef XKB_BUTTON_HINT + FREE_PIXMAP(fwin->languagebutton_back[state]); +#endif + } + + if (fwin->title_texture[state]->any.type!=WTEX_SOLID) { + int left, right; + int width; +#ifdef XKB_BUTTON_HINT + int language; +#endif + + /* eventually surrounded by if new_style */ + left = fwin->left_button && !fwin->flags.hide_left_button + && !fwin->flags.lbutton_dont_fit; +#ifdef XKB_BUTTON_HINT + language = fwin->language_button && !fwin->flags.hide_language_button + && !fwin->flags.languagebutton_dont_fit; +#endif + right = fwin->right_button && !fwin->flags.hide_right_button + && !fwin->flags.rbutton_dont_fit; + + width = fwin->core->width+1; + +#ifdef XKB_BUTTON_HINT + renderTexture(fwin->screen_ptr, fwin->title_texture[state], + width, fwin->titlebar->height, + fwin->titlebar->height, fwin->titlebar->height, + left, language, right, &pmap, &lpmap, &tpmap, &rpmap); +#else + renderTexture(fwin->screen_ptr, fwin->title_texture[state], + width, fwin->titlebar->height, + fwin->titlebar->height, fwin->titlebar->height, + left, right, &pmap, &lpmap, &rpmap); +#endif + + fwin->title_back[state] = pmap; + if (wPreferences.new_style) { + fwin->lbutton_back[state] = lpmap; + fwin->rbutton_back[state] = rpmap; +#ifdef XKB_BUTTON_HINT + fwin->languagebutton_back[state] = tpmap; +#endif + } + } + } + if (fwin->resizebar_texture && fwin->resizebar_texture[0] + && fwin->resizebar && state == 0) { + + FREE_PIXMAP(fwin->resizebar_back[0]); + + if (fwin->resizebar_texture[0]->any.type!=WTEX_SOLID) { + + renderResizebarTexture(fwin->screen_ptr, + fwin->resizebar_texture[0], + fwin->resizebar->width, + fwin->resizebar->height, + fwin->resizebar_corner_width, + &pmap); + + fwin->resizebar_back[0] = pmap; + } + + /* this part should be in updateTexture() */ + if (fwin->resizebar_texture[0]->any.type!=WTEX_SOLID) { + XSetWindowBackgroundPixmap(dpy, fwin->resizebar->window, + fwin->resizebar_back[0]); + } else { + XSetWindowBackground(dpy, fwin->resizebar->window, + fwin->resizebar_texture[0]->solid.normal.pixel); + } + XClearWindow(dpy, fwin->resizebar->window); + } +} + + +void +wFrameWindowPaint(WFrameWindow *fwin) +{ + WScreen *scr = fwin->screen_ptr; + int state; + + state = fwin->flags.state; + + if (fwin->flags.is_client_window_frame) + fwin->flags.justification = wPreferences.title_justification; + + if (fwin->flags.need_texture_remake) { + int i; + + fwin->flags.need_texture_remake = 0; + fwin->flags.need_texture_change = 0; + + if (fwin->flags.single_texture) { + remakeTexture(fwin, 0); + updateTexture(fwin); + } else { + /* first render the texture for the current state... */ + remakeTexture(fwin, state); + /* ... and paint it */ + updateTexture(fwin); + + for (i=0; i < 3; i++) { + if (i != state) { + remakeTexture(fwin, i); + } + } + } + } + + if (fwin->flags.need_texture_change) { + fwin->flags.need_texture_change = 0; + + updateTexture(fwin); + } + + if (fwin->titlebar && !fwin->flags.repaint_only_resizebar + && fwin->title_texture[state]->any.type==WTEX_SOLID) { + wDrawBevel(fwin->titlebar->window, fwin->titlebar->width, + fwin->titlebar->height, + (WTexSolid*)fwin->title_texture[state], + WREL_RAISED); + } + + if (fwin->resizebar && !fwin->flags.repaint_only_titlebar + && fwin->resizebar_texture[0]->any.type == WTEX_SOLID) { + Window win; + int w, h; + int cw; + GC light_gc, dim_gc; + WTexSolid *texture = (WTexSolid*)fwin->resizebar_texture[0]; + + w = fwin->resizebar->width; + h = fwin->resizebar->height; + cw = fwin->resizebar_corner_width; + light_gc = texture->light_gc; + dim_gc = texture->dim_gc; + win = fwin->resizebar->window; + + XDrawLine(dpy, win, dim_gc, 0, 0, w, 0); + XDrawLine(dpy, win, light_gc, 0, 1, w, 1); + + XDrawLine(dpy, win, dim_gc, cw, 2, cw, h); + XDrawLine(dpy, win, light_gc, cw+1, 2, cw+1, h); + + XDrawLine(dpy, win, dim_gc, w-cw-2, 2, w-cw-2, h); + XDrawLine(dpy, win, light_gc, w-cw-1, 2, w-cw-1, h); + +#ifdef SHADOW_RESIZEBAR + XDrawLine(dpy, win, light_gc, 0, 1, 0, h-1); + XDrawLine(dpy, win, dim_gc, w-1, 2, w-1, h-1); + XDrawLine(dpy, win, dim_gc, 1, h-1, cw, h-1); + XDrawLine(dpy, win, dim_gc, cw+2, h-1, w-cw-2, h-1); + XDrawLine(dpy, win, dim_gc, w-cw, h-1, w-1, h-1); +#endif /* SHADOW_RESIZEBAR */ + } + + + if (fwin->titlebar && !fwin->flags.repaint_only_resizebar) { + int x, y, w, h; + int lofs = 6, rofs = 6; + int titlelen; + int allButtons = 1; + + + if (!wPreferences.new_style) { + if (fwin->left_button && !fwin->flags.hide_left_button + && !fwin->flags.lbutton_dont_fit) + lofs += fwin->left_button->width + 3; + else + allButtons = 0; + +#ifdef XKB_BUTTON_HINT + if (fwin->language_button && !fwin->flags.hide_language_button + && !fwin->flags.languagebutton_dont_fit) + lofs += fwin->language_button->width; + else + allButtons = 0; +#endif + + if (fwin->right_button && !fwin->flags.hide_right_button + && !fwin->flags.rbutton_dont_fit) + rofs += fwin->right_button->width + 3; + else + allButtons = 0; + } + +#ifdef XKB_BUTTON_HINT + fwin->languagebutton_image = + scr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode]; +#endif + + if (fwin->title) { + Drawable buf; + char *title; + + 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; + break; + + case WTJ_RIGHT: + x = fwin->titlebar->width - w - rofs; + break; + + default: + if (!allButtons) + x = lofs + (fwin->titlebar->width - w - lofs - rofs) / 2; + else + x = (fwin->titlebar->width - w) / 2; + break; + } + + y = *fwin->title_clearance + TITLEBAR_EXTEND_SPACE; + h = WMFontHeight(*fwin->font); + + /* We use a w+2 buffer to have an extra pixel on the left and + * another one on the right. This is because for some odd reason, + * sometimes when using AA fonts (when libfreetype2 is compiled + * with bytecode interpreter turned off), some fonts are drawn + * starting from x = -1 not from 0 as requested. Observed with + * capital A letter on the bold 'trebuchet ms' font. -Dan + */ + buf = XCreatePixmap(dpy, fwin->titlebar->window, w+2, h, + scr->w_depth); + + XSetClipMask(dpy, scr->copy_gc, None); + + if (fwin->title_texture[state]->any.type!=WTEX_SOLID) { + XCopyArea(dpy, fwin->title_back[state], buf, scr->copy_gc, + x-1, y, w+2, h, 0, 0); + } else { + XSetForeground(dpy, scr->copy_gc, + fwin->title_texture[state]->solid.normal.pixel); + XFillRectangle(dpy, buf, scr->copy_gc, 0, 0, w+2, h); + } + + /*XDrawRectangle(dpy, buf, WMColorGC(scr->white),1,0,w,h-1);*/ + WMDrawString(scr->wmscreen, buf, fwin->title_color[state], + *fwin->font, 1, 0, title, titlelen); + + XCopyArea(dpy, buf, fwin->titlebar->window, scr->copy_gc, + 0, 0, w+2, h, x-1, y); + + XFreePixmap(dpy, buf); + + wfree(title); + } + + if (fwin->left_button) + handleButtonExpose(&fwin->left_button->descriptor, NULL); + if (fwin->right_button) + handleButtonExpose(&fwin->right_button->descriptor, NULL); +#ifdef XKB_BUTTON_HINT + if (fwin->language_button) + handleButtonExpose(&fwin->language_button->descriptor, NULL); +#endif + } +} + + +static void +reconfigure(WFrameWindow *fwin, int x, int y, int width, int height, + Bool dontMove) +{ + int k = (wPreferences.new_style ? 4 : 3); + int resizedHorizontally = 0; + + if (dontMove) + XResizeWindow(dpy, fwin->core->window, width, height); + else + XMoveResizeWindow(dpy, fwin->core->window, x, y, width, height); + + /* + if (fwin->core->height != height && fwin->resizebar) + XMoveWindow(dpy, fwin->resizebar->window, 0, + height - fwin->resizebar->height); + */ + if (fwin->core->width != width) { + fwin->flags.need_texture_remake = 1; + resizedHorizontally = 1; + } + + fwin->core->width = width; + fwin->core->height = height; + + if (fwin->titlebar && resizedHorizontally) { + /* Check if the titlebar is wide enough to hold the buttons. + * Temporarily remove them if can't + */ + if (fwin->left_button) { + if (width < fwin->top_width*k && !fwin->flags.lbutton_dont_fit) { + + if (!fwin->flags.hide_left_button) { + XUnmapWindow(dpy, fwin->left_button->window); + } + fwin->flags.lbutton_dont_fit = 1; + } else if (width >= fwin->top_width*k && fwin->flags.lbutton_dont_fit) { + + if (!fwin->flags.hide_left_button) { + XMapWindow(dpy, fwin->left_button->window); + } + fwin->flags.lbutton_dont_fit = 0; + } + } + +#ifdef XKB_BUTTON_HINT + if (fwin->language_button) { + if (width < fwin->top_width*k && !fwin->flags.languagebutton_dont_fit) { + + if (!fwin->flags.hide_language_button) { + XUnmapWindow(dpy, fwin->language_button->window); + } + fwin->flags.languagebutton_dont_fit = 1; + } else if (width >= fwin->top_width*k && fwin->flags.languagebutton_dont_fit) { + + if (!fwin->flags.hide_language_button) { + XMapWindow(dpy, fwin->language_button->window); + } + fwin->flags.languagebutton_dont_fit = 0; + } + } +#endif + + if (fwin->right_button) { + if (width < fwin->top_width*2 && !fwin->flags.rbutton_dont_fit) { + + if (!fwin->flags.hide_right_button) { + XUnmapWindow(dpy, fwin->right_button->window); + } + fwin->flags.rbutton_dont_fit = 1; + } else if (width >= fwin->top_width*2 && fwin->flags.rbutton_dont_fit) { + + if (!fwin->flags.hide_right_button) { + XMapWindow(dpy, fwin->right_button->window); + } + fwin->flags.rbutton_dont_fit = 0; + } + } + + if (wPreferences.new_style) { + if (fwin->right_button) + XMoveWindow(dpy, fwin->right_button->window, + width - fwin->right_button->width + 1, 0); + } else { + if (fwin->right_button) + XMoveWindow(dpy, fwin->right_button->window, + width - fwin->right_button->width - 3, + (fwin->titlebar->height - fwin->right_button->height)/2); + } + updateTitlebar(fwin); + checkTitleSize(fwin); + } + + if (fwin->resizebar) { + wCoreConfigure(fwin->resizebar, 0, + fwin->core->height - fwin->resizebar->height, + fwin->core->width, fwin->resizebar->height); + + fwin->resizebar_corner_width = RESIZEBAR_CORNER_WIDTH; + if (fwin->core->width < RESIZEBAR_CORNER_WIDTH*2 + RESIZEBAR_MIN_WIDTH) { + fwin->resizebar_corner_width = fwin->core->width/2; + } + } +} + +void +wFrameWindowConfigure(WFrameWindow *fwin, int x, int y, int width, int height) +{ + reconfigure(fwin, x, y, width, height, False); +} + +void +wFrameWindowResize(WFrameWindow *fwin, int width, int height) +{ + reconfigure(fwin, 0, 0, width, height, True); +} + + + +int +wFrameWindowChangeTitle(WFrameWindow *fwin, char *new_title) +{ + /* check if the title is the same as before */ + if (fwin->title) { + if (new_title && (strcmp(fwin->title, new_title) == 0)) { + return 0; + } + } else { + if (!new_title) + return 0; + } + + if (fwin->title) + wfree(fwin->title); + + fwin->title = wstrdup(new_title); + + if (fwin->titlebar) { + XClearWindow(dpy, fwin->titlebar->window); + + wFrameWindowPaint(fwin); + } + checkTitleSize(fwin); + + return 1; +} + + +#ifdef OLWM_HINTS +void +wFrameWindowUpdatePushButton(WFrameWindow *fwin, Bool pushed) +{ + fwin->flags.right_button_pushed_in = pushed; + + paintButton(fwin->right_button, fwin->title_texture[fwin->flags.state], + WMColorPixel(fwin->title_color[fwin->flags.state]), + fwin->rbutton_image, pushed); +} +#endif /* OLWM_HINTS */ + + +#ifdef XKB_BUTTON_HINT +void +wFrameWindowUpdateLanguageButton(WFrameWindow *fwin) +{ + paintButton(fwin->language_button, fwin->title_texture[fwin->flags.state], + WMColorPixel(fwin->title_color[fwin->flags.state]), + fwin->languagebutton_image, True); +} +#endif /* XKB_BUTTON_HINT */ + + +/*********************************************************************/ + +static void +handleExpose(WObjDescriptor *desc, XEvent *event) +{ + WFrameWindow *fwin = (WFrameWindow*)desc->parent; + + + if (fwin->titlebar && fwin->titlebar->window == event->xexpose.window) + fwin->flags.repaint_only_titlebar = 1; + if (fwin->resizebar && fwin->resizebar->window == event->xexpose.window) + fwin->flags.repaint_only_resizebar = 1; + wFrameWindowPaint(fwin); + fwin->flags.repaint_only_titlebar = 0; + fwin->flags.repaint_only_resizebar = 0; +} + + +static void +checkTitleSize(WFrameWindow *fwin) +{ + int width; + + if (!fwin->title) { + fwin->flags.incomplete_title = 0; + return; + } + + if (!fwin->titlebar) { + fwin->flags.incomplete_title = 1; + return; + } else { + width = fwin->titlebar->width - 6 - 6; + } + + if (!wPreferences.new_style) { + if (fwin->left_button && !fwin->flags.hide_left_button + && !fwin->flags.lbutton_dont_fit) + width -= fwin->left_button->width + 3; + +#ifdef XKB_BUTTON_HINT + if (fwin->language_button && !fwin->flags.hide_language_button + && !fwin->flags.languagebutton_dont_fit) + width -= fwin->language_button->width + 3; +#endif + + if (fwin->right_button && !fwin->flags.hide_right_button + && !fwin->flags.rbutton_dont_fit) + width -= fwin->right_button->width + 3; + } + if (WMWidthOfString(*fwin->font, fwin->title, strlen(fwin->title)) > width) { + fwin->flags.incomplete_title = 1; + } else { + fwin->flags.incomplete_title = 0; + } +} + + +static void +paintButton(WCoreWindow *button, WTexture *texture, unsigned long color, + WPixmap *image, int pushed) +{ + WScreen *scr = button->screen_ptr; + GC copy_gc = scr->copy_gc; + int x=0, y=0, d=0; + int left=0, width=0; + + /* setup stuff according to the state */ + if (pushed) { + if (image) { + if (image->width>=image->height*2) { + /* the image contains 2 pictures: the second is for the + * pushed state */ + width = image->width/2; + left = image->width/2; + } else { + width = image->width; + } + } + XSetClipMask(dpy, copy_gc, None); + XSetForeground(dpy, copy_gc, scr->white_pixel); + d=1; + if (wPreferences.new_style) { + XFillRectangle(dpy, button->window, copy_gc, 0, 0, + button->width-1, button->height-1); + XSetForeground(dpy, copy_gc, scr->black_pixel); + XDrawRectangle(dpy, button->window, copy_gc, 0, 0, + button->width-1, button->height-1); + } else { + XFillRectangle(dpy, button->window, copy_gc, 0, 0, + button->width, button->height); + XSetForeground(dpy, copy_gc, scr->black_pixel); + XDrawRectangle(dpy, button->window, copy_gc, 0, 0, + button->width, button->height); + } + } else { + XClearWindow(dpy, button->window); + + if (image) { + if (image->width>=image->height*2) + width = image->width/2; + else + width = image->width; + } + d=0; + + if (wPreferences.new_style) { + if (texture->any.type==WTEX_SOLID || pushed) { + wDrawBevel(button->window, button->width, button->height, + (WTexSolid*)texture, WREL_RAISED); + } + } else { + wDrawBevel(button->window, button->width, button->height, + scr->widget_texture, WREL_RAISED); + } + } + + if (image) { + /* display image */ + XSetClipMask(dpy, copy_gc, image->mask); + x = (button->width - width)/2 + d; + y = (button->height - image->height)/2 + d; + XSetClipOrigin(dpy, copy_gc, x-left, y); + if (!wPreferences.new_style) { + XSetForeground(dpy, copy_gc, scr->black_pixel); + if (!pushed) { + if (image->depth==1) + XCopyPlane(dpy, image->image, button->window, copy_gc, + left, 0, width, image->height, x, y, 1); + else + XCopyArea(dpy, image->image, button->window, copy_gc, + left, 0, width, image->height, x, y); + } else { + XSetForeground(dpy, copy_gc, scr->dark_pixel); + XFillRectangle(dpy, button->window, copy_gc, 0, 0, + button->width, button->height); + } + } else { + if (pushed) { + XSetForeground(dpy, copy_gc, scr->black_pixel); + } else { + XSetForeground(dpy, copy_gc, color); + XSetBackground(dpy, copy_gc, texture->any.color.pixel); + } + XFillRectangle(dpy, button->window, copy_gc, 0, 0, + button->width, button->height); + } + } +} + + +static void +handleButtonExpose(WObjDescriptor *desc, XEvent *event) +{ + WFrameWindow *fwin = (WFrameWindow*)desc->parent; + WCoreWindow *button = (WCoreWindow*)desc->self; + +#ifdef XKB_BUTTON_HINT + if (button == fwin->language_button) { + if (wPreferences.modelock){ + paintButton(button, fwin->title_texture[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], + WMColorPixel(fwin->title_color[fwin->flags.state]), + fwin->lbutton_image, False); + } else { + Bool pushed = False; + +#ifdef OLWM_HINTS + if (fwin->flags.right_button_pushed_in) + pushed = True; +#endif + /* emulate the olwm pushpin in the "out" state */ + paintButton(button, fwin->title_texture[fwin->flags.state], + WMColorPixel(fwin->title_color[fwin->flags.state]), + fwin->rbutton_image, pushed); + } +} + + +static void +titlebarMouseDown(WObjDescriptor *desc, XEvent *event) +{ + WFrameWindow *fwin = desc->parent; + WCoreWindow *titlebar = desc->self; + + if (IsDoubleClick(fwin->core->screen_ptr, event)) { + if (fwin->on_dblclick_titlebar) { + (*fwin->on_dblclick_titlebar)(titlebar, fwin->child, event); + } + } else { + if (fwin->on_mousedown_titlebar) { + (*fwin->on_mousedown_titlebar)(titlebar, fwin->child, event); + } + } +} + + +static void +resizebarMouseDown(WObjDescriptor *desc, XEvent *event) +{ + WFrameWindow *fwin = desc->parent; + WCoreWindow *resizebar = desc->self; + + if (fwin->on_mousedown_resizebar) + (*fwin->on_mousedown_resizebar)(resizebar, fwin->child, event); +} + + +static void +buttonMouseDown(WObjDescriptor *desc, XEvent *event) +{ + WFrameWindow *fwin = desc->parent; + WCoreWindow *button = desc->self; + WPixmap *image; + XEvent ev; + int done=0, execute=1; + WTexture *texture; + unsigned long pixel; + int clickButton = event->xbutton.button; + + if (IsDoubleClick(fwin->core->screen_ptr, event)) { + if (button == fwin->right_button && fwin->on_dblclick_right) { + (*fwin->on_dblclick_right)(button, fwin->child, event); + } + return; + } + + if (button == fwin->left_button) { + image = fwin->lbutton_image; + } else { + image = fwin->rbutton_image; + } +#ifdef XKB_BUTTON_HINT + if (button == fwin->language_button) { + if (!wPreferences.modelock) + return; + image = fwin->languagebutton_image; + } +#endif + + pixel = WMColorPixel(fwin->title_color[fwin->flags.state]); + texture = fwin->title_texture[fwin->flags.state]; + paintButton(button, texture, pixel, image, True); + + while (!done) { + WMMaskEvent(dpy, LeaveWindowMask|EnterWindowMask|ButtonReleaseMask + |ButtonPressMask|ExposureMask, &ev); + switch (ev.type) { + case LeaveNotify: + execute = 0; + paintButton(button, texture, pixel, image, False); + break; + + case EnterNotify: + execute = 1; + paintButton(button, texture, pixel, image, True); + break; + + case ButtonPress: + break; + + case ButtonRelease: + if (ev.xbutton.button == clickButton) + done = 1; + break; + + default: + WMHandleEvent(&ev); + } + } + paintButton(button, texture, pixel, image, False); + + if (execute) { + if (button == fwin->left_button) { + if (fwin->on_click_left) + (*fwin->on_click_left)(button, fwin->child, &ev); + } else if (button == fwin->right_button) { + if (fwin->on_click_right) + (*fwin->on_click_right)(button, fwin->child, &ev); + } +#ifdef XKB_BUTTON_HINT + else if (button == fwin->language_button) { + if (fwin->on_click_language) + (*fwin->on_click_language)(button, fwin->child, &ev); + } +#endif + + } +} + diff --git a/src/framewin.h b/src/framewin.h index 7945283c..88887a90 100644 --- a/src/framewin.h +++ b/src/framewin.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -45,9 +45,9 @@ typedef struct WFrameWindow { WScreen *screen_ptr; /* pointer to the screen structure */ - + WCoreWindow *core; - + WCoreWindow *titlebar; /* the titlebar */ WCoreWindow *left_button; /* miniaturize button */ #ifdef XKB_BUTTON_HINT @@ -78,7 +78,7 @@ typedef struct WFrameWindow { #ifdef XKB_BUTTON_HINT WPixmap *languagebutton_image; #endif - + union WTexture **title_texture; union WTexture **resizebar_texture; WMColor **title_color; @@ -93,70 +93,70 @@ typedef struct WFrameWindow { /* thing that uses this frame. passed as data to callbacks */ void *child; - + /* callbacks */ void (*on_click_left)(WCoreWindow *sender, void *data, XEvent *event); #ifdef XKB_BUTTON_HINT void (*on_click_language)(WCoreWindow *sender, void *data, XEvent *event); #endif - + void (*on_click_right)(WCoreWindow *sender, void *data, XEvent *event); void (*on_dblclick_right)(WCoreWindow *sender, void *data, XEvent *event); - + void (*on_mousedown_titlebar)(WCoreWindow *sender, void *data, XEvent *event); void (*on_dblclick_titlebar)(WCoreWindow *sender, void *data, XEvent *event); void (*on_mousedown_resizebar)(WCoreWindow *sender, void *data, XEvent *event); - + struct { - unsigned int state:2; /* 3 possible states */ - unsigned int justification:2; - unsigned int titlebar:1; - unsigned int resizebar:1; - unsigned int left_button:1; - unsigned int right_button:1; + unsigned int state:2; /* 3 possible states */ + unsigned int justification:2; + unsigned int titlebar:1; + unsigned int resizebar:1; + unsigned int left_button:1; + unsigned int right_button:1; #ifdef XKB_BUTTON_HINT - unsigned int language_button:1; + unsigned int language_button:1; #endif - unsigned int need_texture_remake:1; + unsigned int need_texture_remake:1; + + unsigned int single_texture:1; - unsigned int single_texture:1; - - unsigned int hide_left_button:1; - unsigned int hide_right_button:1; + unsigned int hide_left_button:1; + unsigned int hide_right_button:1; #ifdef XKB_BUTTON_HINT - unsigned int hide_language_button:1; + unsigned int hide_language_button:1; #endif - - unsigned int need_texture_change:1; - - unsigned int lbutton_dont_fit:1; - unsigned int rbutton_dont_fit:1; + + unsigned int need_texture_change:1; + + unsigned int lbutton_dont_fit:1; + unsigned int rbutton_dont_fit:1; #ifdef XKB_BUTTON_HINT - unsigned int languagebutton_dont_fit:1; + unsigned int languagebutton_dont_fit:1; #endif - unsigned int repaint_only_titlebar:1; - unsigned int repaint_only_resizebar:1; + unsigned int repaint_only_titlebar:1; + unsigned int repaint_only_resizebar:1; + + unsigned int is_client_window_frame:1; - unsigned int is_client_window_frame:1; - - unsigned int incomplete_title:1; + unsigned int incomplete_title:1; #ifdef OLWM_HINTS - unsigned int right_button_pushed_in:1; + unsigned int right_button_pushed_in:1; #endif } flags; } WFrameWindow; WFrameWindow* -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, - WMColor **color, WMFont **font); +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, + WMColor **color, WMFont **font); void wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags); diff --git a/src/funcs.h b/src/funcs.h index 86dc4cc5..6395a41d 100644 --- a/src/funcs.h +++ b/src/funcs.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -86,7 +86,7 @@ Pixmap LoadIcon(WScreen *scr, char *path, char *mask, int title_height); void PlaceIcon(WScreen *scr, int *x_ret, int *y_ret, int head); int calcIntersectionArea(int x1, int y1, int w1, int h1, - int x2, int y2, int w2, int h2); + int x2, int y2, int w2, int h2); void PlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, unsigned int width, unsigned int height); @@ -135,14 +135,14 @@ Bool UpdateDomainFile(WDDomain *domain); #ifdef NUMLOCK_HACK void wHackedGrabKey(int keycode, unsigned int modifiers, - Window grab_window, Bool owner_events, int pointer_mode, - int keyboard_mode); + Window grab_window, Bool owner_events, int pointer_mode, + int keyboard_mode); #endif -void wHackedGrabButton(unsigned int button, unsigned int modifiers, - Window grab_window, Bool owner_events, - unsigned int event_mask, int pointer_mode, - int keyboard_mode, Window confine_to, Cursor cursor); +void wHackedGrabButton(unsigned int button, unsigned int modifiers, + Window grab_window, Bool owner_events, + unsigned int event_mask, int pointer_mode, + int keyboard_mode, Window confine_to, Cursor cursor); void ExecExitScript(); diff --git a/src/geomview.c b/src/geomview.c index c179fffd..5a46b024 100644 --- a/src/geomview.c +++ b/src/geomview.c @@ -8,22 +8,22 @@ typedef struct W_GeometryView { W_Class widgetClass; WMView *view; - + WMColor *black; WMColor *gray; WMFont *font; - + WMSize textSize; - + union { - struct { - int x, y; - } pos; - struct { - unsigned width, height; - } size; + struct { + int x, y; + } pos; + struct { + unsigned width, height; + } size; } data; - + unsigned showPosition:1; } WGeometryView; @@ -39,33 +39,33 @@ WCreateGeometryView(WMScreen *scr) WGeometryView *gview; char buffer[64]; static W_Class widgetClass = 0; - + if (!widgetClass) { - widgetClass = W_RegisterUserWidget(); + widgetClass = W_RegisterUserWidget(); } - + gview = malloc(sizeof(WGeometryView)); if (!gview) { - return NULL; + return NULL; } memset(gview, 0, sizeof(WGeometryView)); - + gview->widgetClass = widgetClass; gview->view = W_CreateTopView(scr); if (!gview->view) { - wfree(gview); + wfree(gview); - return NULL; + return NULL; } gview->view->self = gview; gview->font = WMSystemFontOfSize(scr, 12); if (!gview->font) { - W_DestroyView(gview->view); - wfree(gview); + W_DestroyView(gview->view); + wfree(gview); - return NULL; + return NULL; } gview->black = WMBlackColor(scr); @@ -75,12 +75,12 @@ WCreateGeometryView(WMScreen *scr) snprintf(buffer, sizeof(buffer), "%+05i, %+05i", 0, 0); - gview->textSize.width = WMWidthOfString(gview->font, buffer, - strlen(buffer)); + gview->textSize.width = WMWidthOfString(gview->font, buffer, + strlen(buffer)); gview->textSize.height = WMFontHeight(gview->font); - + W_ResizeView(gview->view, gview->textSize.width+8, - gview->textSize.height+6); + gview->textSize.height+6); return gview; } @@ -92,19 +92,19 @@ WSetGeometryViewShownPosition(WGeometryView *gview, int x, int y) gview->showPosition = 1; gview->data.pos.x = x; gview->data.pos.y = y; - + paint(gview); } void WSetGeometryViewShownSize(WGeometryView *gview, - unsigned width, unsigned height) + unsigned width, unsigned height) { gview->showPosition = 0; gview->data.size.width = width; gview->data.size.height = height; - + paint(gview); } @@ -116,23 +116,23 @@ paint(WGeometryView *gview) char buffer[64]; if (gview->showPosition) { - snprintf(buffer, sizeof(buffer), "%+5i , %+5i ", - gview->data.pos.x, gview->data.pos.y); + snprintf(buffer, sizeof(buffer), "%+5i , %+5i ", + gview->data.pos.x, gview->data.pos.y); } else { - snprintf(buffer, sizeof(buffer), "%+5i x %+5i ", - gview->data.size.width, gview->data.size.height); + snprintf(buffer, sizeof(buffer), "%+5i x %+5i ", + gview->data.size.width, gview->data.size.height); } WMDrawImageString(W_VIEW_SCREEN(gview->view), - W_VIEW_DRAWABLE(gview->view), - gview->black, gview->gray, gview->font, - (W_VIEW_WIDTH(gview->view)-gview->textSize.width)/2, - (W_VIEW_HEIGHT(gview->view)-gview->textSize.height)/2, - buffer, strlen(buffer)); + W_VIEW_DRAWABLE(gview->view), + gview->black, gview->gray, gview->font, + (W_VIEW_WIDTH(gview->view)-gview->textSize.width)/2, + (W_VIEW_HEIGHT(gview->view)-gview->textSize.height)/2, + buffer, strlen(buffer)); W_DrawRelief(W_VIEW_SCREEN(gview->view), W_VIEW_DRAWABLE(gview->view), - 0, 0, W_VIEW_WIDTH(gview->view), W_VIEW_HEIGHT(gview->view), - WRRaised); + 0, 0, W_VIEW_WIDTH(gview->view), W_VIEW_HEIGHT(gview->view), + WRRaised); } @@ -141,12 +141,12 @@ static void handleEvents(XEvent *event, void *clientData) { WGeometryView *gview = (WGeometryView*)clientData; - + switch (event->type) { - case Expose: - paint(gview); - break; - + case Expose: + paint(gview); + break; + } } diff --git a/src/geomview.h b/src/geomview.h index 9dc74119..ac51afca 100644 --- a/src/geomview.h +++ b/src/geomview.h @@ -8,7 +8,7 @@ WGeometryView *WCreateGeometryView(WMScreen *scr); void WSetGeometryViewShownPosition(WGeometryView *gview, int x, int y); void WSetGeometryViewShownSize(WGeometryView *gview, - unsigned width, unsigned height); + unsigned width, unsigned height); diff --git a/src/gnome.c b/src/gnome.c index b97b295e..0d15cc25 100644 --- a/src/gnome.c +++ b/src/gnome.c @@ -1,9 +1,9 @@ /* gnome.c-- support for the GNOME Hints - * + * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,14 +16,14 @@ * * 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. */ /* * According to the author of this thing, it should not be taken seriously. * IMHO, there are lot's of weirdnesses and it's quite unelegant. I'd - * rather not support it, but here it goes anyway. + * rather not support it, but here it goes anyway. */ #include "wconfig.h" @@ -116,35 +116,35 @@ wGNOMEInitStuff(WScreen *scr) if (!_XA_WIN_SUPPORTING_WM_CHECK) { - _XA_WIN_SUPPORTING_WM_CHECK = - XInternAtom(dpy, "_WIN_SUPPORTING_WM_CHECK", False); + _XA_WIN_SUPPORTING_WM_CHECK = + XInternAtom(dpy, "_WIN_SUPPORTING_WM_CHECK", False); - _XA_WIN_PROTOCOLS = XInternAtom(dpy, "_WIN_PROTOCOLS", False); + _XA_WIN_PROTOCOLS = XInternAtom(dpy, "_WIN_PROTOCOLS", False); - _XA_WIN_LAYER = XInternAtom(dpy, "_WIN_LAYER", False); + _XA_WIN_LAYER = XInternAtom(dpy, "_WIN_LAYER", False); - _XA_WIN_STATE = XInternAtom(dpy, "_WIN_STATE", False); + _XA_WIN_STATE = XInternAtom(dpy, "_WIN_STATE", False); - _XA_WIN_HINTS = XInternAtom(dpy, "_WIN_HINTS", False); + _XA_WIN_HINTS = XInternAtom(dpy, "_WIN_HINTS", False); - _XA_WIN_APP_STATE = XInternAtom(dpy, "_WIN_APP_STATE", False); + _XA_WIN_APP_STATE = XInternAtom(dpy, "_WIN_APP_STATE", False); - _XA_WIN_EXPANDED_SIZE = XInternAtom(dpy, "_WIN_EXPANDED_SIZE", False); + _XA_WIN_EXPANDED_SIZE = XInternAtom(dpy, "_WIN_EXPANDED_SIZE", False); - _XA_WIN_ICONS = XInternAtom(dpy, "_WIN_ICONS", False); + _XA_WIN_ICONS = XInternAtom(dpy, "_WIN_ICONS", False); - _XA_WIN_WORKSPACE = XInternAtom(dpy, "_WIN_WORKSPACE", False); + _XA_WIN_WORKSPACE = XInternAtom(dpy, "_WIN_WORKSPACE", False); - _XA_WIN_WORKSPACE_COUNT = - XInternAtom(dpy, "_WIN_WORKSPACE_COUNT", False); + _XA_WIN_WORKSPACE_COUNT = + XInternAtom(dpy, "_WIN_WORKSPACE_COUNT", False); - _XA_WIN_WORKSPACE_NAMES = - XInternAtom(dpy, "_WIN_WORKSPACE_NAMES", False); + _XA_WIN_WORKSPACE_NAMES = + XInternAtom(dpy, "_WIN_WORKSPACE_NAMES", False); - _XA_WIN_CLIENT_LIST = XInternAtom(dpy, "_WIN_CLIENT_LIST", False); + _XA_WIN_CLIENT_LIST = XInternAtom(dpy, "_WIN_CLIENT_LIST", False); - _XA_WIN_DESKTOP_BUTTON_PROXY = - XInternAtom(dpy, "_WIN_DESKTOP_BUTTON_PROXY", False); + _XA_WIN_DESKTOP_BUTTON_PROXY = + XInternAtom(dpy, "_WIN_DESKTOP_BUTTON_PROXY", False); } /* I'd rather use the ICCCM 2.0 mechanisms, but @@ -154,23 +154,23 @@ wGNOMEInitStuff(WScreen *scr) /* setup the "We're compliant, you idiot!" hint */ /* why XA_CARDINAL instead of XA_WINDOW? */ - XChangeProperty(dpy, scr->root_win, _XA_WIN_SUPPORTING_WM_CHECK, - XA_CARDINAL, 32, PropModeReplace, - (unsigned char*)&scr->no_focus_win, 1); + XChangeProperty(dpy, scr->root_win, _XA_WIN_SUPPORTING_WM_CHECK, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char*)&scr->no_focus_win, 1); + + XChangeProperty(dpy, scr->no_focus_win, _XA_WIN_SUPPORTING_WM_CHECK, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char*)&scr->no_focus_win, 1); - XChangeProperty(dpy, scr->no_focus_win, _XA_WIN_SUPPORTING_WM_CHECK, - XA_CARDINAL, 32, PropModeReplace, - (unsigned char*)&scr->no_focus_win, 1); - /* setup the "desktop button proxy" thing */ XChangeProperty(dpy, scr->root_win, _XA_WIN_DESKTOP_BUTTON_PROXY, - XA_CARDINAL, 32, PropModeReplace, - (unsigned char*)&scr->no_focus_win, 1); + XA_CARDINAL, 32, PropModeReplace, + (unsigned char*)&scr->no_focus_win, 1); XChangeProperty(dpy, scr->no_focus_win, _XA_WIN_DESKTOP_BUTTON_PROXY, - XA_CARDINAL, 32, PropModeReplace, - (unsigned char*)&scr->no_focus_win, 1); - + XA_CARDINAL, 32, PropModeReplace, + (unsigned char*)&scr->no_focus_win, 1); + /* setup the list of supported protocols */ count = 0; @@ -186,7 +186,7 @@ wGNOMEInitStuff(WScreen *scr) supportedStuff[count++] = _XA_WIN_CLIENT_LIST; XChangeProperty(dpy, scr->root_win, _XA_WIN_PROTOCOLS, XA_ATOM, 32, - PropModeReplace, (unsigned char*)supportedStuff, count); + PropModeReplace, (unsigned char*)supportedStuff, count); XFlush(dpy); @@ -214,8 +214,8 @@ wGNOMEUpdateClientListHint(WScreen *scr) windows = malloc(sizeof(Window)*scr->window_count); if (!windows) { - wwarning(_("out of memory while updating GNOME hints")); - return; + wwarning(_("out of memory while updating GNOME hints")); + return; } count = 0; @@ -224,14 +224,14 @@ wGNOMEUpdateClientListHint(WScreen *scr) if (!wwin->flags.internal_window && !wwin->client_flags.skip_window_list) { - windows[count++] = wwin->client_win; - } + windows[count++] = wwin->client_win; + } - wwin = wwin->prev; + wwin = wwin->prev; } XChangeProperty(dpy, scr->root_win, _XA_WIN_CLIENT_LIST, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *)windows, count); + PropModeReplace, (unsigned char *)windows, count); wfree(windows); XFlush(dpy); @@ -246,7 +246,7 @@ wGNOMEUpdateWorkspaceHints(WScreen *scr) val = scr->workspace_count; XChangeProperty(dpy, scr->root_win, _XA_WIN_WORKSPACE_COUNT, XA_CARDINAL, - 32, PropModeReplace, (unsigned char*)&val, 1); + 32, PropModeReplace, (unsigned char*)&val, 1); wGNOMEUpdateWorkspaceNamesHint(scr); } @@ -260,13 +260,13 @@ wGNOMEUpdateWorkspaceNamesHint(WScreen *scr) int i; for (i = 0; i < scr->workspace_count; i++) { - wsNames[i] = scr->workspaces[i]->name; + wsNames[i] = scr->workspaces[i]->name; } if (XStringListToTextProperty(wsNames, scr->workspace_count, &textProp)) { - XSetTextProperty(dpy, scr->root_win, &textProp, - _XA_WIN_WORKSPACE_NAMES); - XFree(textProp.value); + XSetTextProperty(dpy, scr->root_win, &textProp, + _XA_WIN_WORKSPACE_NAMES); + XFree(textProp.value); } } @@ -279,7 +279,7 @@ wGNOMEUpdateCurrentWorkspaceHint(WScreen *scr) val = scr->current_workspace; XChangeProperty(dpy, scr->root_win, _XA_WIN_WORKSPACE, XA_CARDINAL, - 32, PropModeReplace, (unsigned char*)&val, 1); + 32, PropModeReplace, (unsigned char*)&val, 1); } @@ -289,22 +289,22 @@ getWindowLevel(int layer) int level; if (layer <= WIN_LAYER_DESKTOP) - level = WMDesktopLevel; + level = WMDesktopLevel; else if (layer <= WIN_LAYER_BELOW) - level = WMSunkenLevel; + level = WMSunkenLevel; else if (layer <= WIN_LAYER_NORMAL) - level = WMNormalLevel; + level = WMNormalLevel; else if (layer <= WIN_LAYER_ONTOP) - level = WMFloatingLevel; + level = WMFloatingLevel; else if (layer <= WIN_LAYER_DOCK) - level = WMDockLevel; + level = WMDockLevel; else if (layer <= WIN_LAYER_ABOVE_DOCK) - level = WMSubmenuLevel; + level = WMSubmenuLevel; else if (layer <= WIN_LAYER_MENU) - level = WMMainMenuLevel; - else - level = WMOuterSpaceLevel; - + level = WMMainMenuLevel; + else + level = WMOuterSpaceLevel; + return level; } @@ -320,103 +320,103 @@ wGNOMECheckClientHints(WWindow *wwin, int *layer, int *workspace) Bool hasHints = False; /* hints */ - + if (XGetWindowProperty(dpy, wwin->client_win, _XA_WIN_HINTS, 0, 1, False, - /* should be XA_INTEGER, but spec is broken */ - XA_CARDINAL, &type_ret, &fmt_ret, &nitems_ret, - &bytes_after_ret, - (unsigned char**)&data)==Success && data) { - flags = *data; - - XFree(data); - - if (flags & (WIN_HINTS_SKIP_FOCUS|WIN_HINTS_SKIP_WINLIST - |WIN_HINTS_SKIP_TASKBAR)) { - wwin->client_flags.skip_window_list = 1; - } - - /* client reserved area, for the panel */ - if (flags & (WIN_HINTS_DO_NOT_COVER)) { - WReservedArea *area; - - area = malloc(sizeof(WReservedArea)); - if (!area) { - wwarning(_("out of memory while updating GNOME hints")); - } else { - XWindowAttributes wattribs; - - XGetWindowAttributes(dpy, wwin->client_win, &wattribs); - wClientGetNormalHints(wwin, &wattribs, False, - &area->area.x1, &area->area.y1, - &area->area.x2, &area->area.y2); - area->area.x2 = area->area.x2 + area->area.x1; - area->area.y2 = area->area.y2 + area->area.y1; - - area->window = wwin->client_win; - } - area->next = wwin->screen_ptr->reservedAreas; - wwin->screen_ptr->reservedAreas = area; - - wScreenUpdateUsableArea(wwin->screen_ptr); - } - - hasHints = True; + /* should be XA_INTEGER, but spec is broken */ + XA_CARDINAL, &type_ret, &fmt_ret, &nitems_ret, + &bytes_after_ret, + (unsigned char**)&data)==Success && data) { + flags = *data; + + XFree(data); + + if (flags & (WIN_HINTS_SKIP_FOCUS|WIN_HINTS_SKIP_WINLIST + |WIN_HINTS_SKIP_TASKBAR)) { + wwin->client_flags.skip_window_list = 1; + } + + /* client reserved area, for the panel */ + if (flags & (WIN_HINTS_DO_NOT_COVER)) { + WReservedArea *area; + + area = malloc(sizeof(WReservedArea)); + if (!area) { + wwarning(_("out of memory while updating GNOME hints")); + } else { + XWindowAttributes wattribs; + + XGetWindowAttributes(dpy, wwin->client_win, &wattribs); + wClientGetNormalHints(wwin, &wattribs, False, + &area->area.x1, &area->area.y1, + &area->area.x2, &area->area.y2); + area->area.x2 = area->area.x2 + area->area.x1; + area->area.y2 = area->area.y2 + area->area.y1; + + area->window = wwin->client_win; + } + area->next = wwin->screen_ptr->reservedAreas; + wwin->screen_ptr->reservedAreas = area; + + wScreenUpdateUsableArea(wwin->screen_ptr); + } + + hasHints = True; } /* layer */ if (XGetWindowProperty(dpy, wwin->client_win, _XA_WIN_LAYER, 0, 1, False, - XA_CARDINAL, &type_ret, &fmt_ret, &nitems_ret, - &bytes_after_ret, - (unsigned char**)&data)==Success && data) { - val = *data; + XA_CARDINAL, &type_ret, &fmt_ret, &nitems_ret, + &bytes_after_ret, + (unsigned char**)&data)==Success && data) { + val = *data; - XFree(data); + XFree(data); - *layer = getWindowLevel(val); - hasHints = True; + *layer = getWindowLevel(val); + hasHints = True; } - + /* workspace */ - if (XGetWindowProperty(dpy, wwin->client_win, _XA_WIN_WORKSPACE, 0, 1, - False, XA_CARDINAL, &type_ret, &fmt_ret, - &nitems_ret, &bytes_after_ret, - (unsigned char**)&data)==Success && data) { - val = *data; + if (XGetWindowProperty(dpy, wwin->client_win, _XA_WIN_WORKSPACE, 0, 1, + False, XA_CARDINAL, &type_ret, &fmt_ret, + &nitems_ret, &bytes_after_ret, + (unsigned char**)&data)==Success && data) { + val = *data; - XFree(data); + XFree(data); - if (val > 0) - *workspace = val; - hasHints = True; + if (val > 0) + *workspace = val; + hasHints = True; } /* reserved area */ - if (XGetWindowProperty(dpy, wwin->client_win, _XA_WIN_EXPANDED_SIZE, 0, 1, - False, XA_CARDINAL, &type_ret, &fmt_ret, - &nitems_ret, &bytes_after_ret, - (unsigned char**)&data)==Success && data) { - WReservedArea *area; - - area = malloc(sizeof(WReservedArea)); - if (!area) { - wwarning(_("out of memory while updating GNOME hints")); - } else { - area->area.x1 = data[0]; - area->area.y1 = data[1]; - area->area.x2 = data[2] - data[0]; - area->area.y2 = data[3] - data[1]; - XFree(data); - - area->window = wwin->client_win; - } - - area->next = wwin->screen_ptr->reservedAreas; - wwin->screen_ptr->reservedAreas = area; + if (XGetWindowProperty(dpy, wwin->client_win, _XA_WIN_EXPANDED_SIZE, 0, 1, + False, XA_CARDINAL, &type_ret, &fmt_ret, + &nitems_ret, &bytes_after_ret, + (unsigned char**)&data)==Success && data) { + WReservedArea *area; + + area = malloc(sizeof(WReservedArea)); + if (!area) { + wwarning(_("out of memory while updating GNOME hints")); + } else { + area->area.x1 = data[0]; + area->area.y1 = data[1]; + area->area.x2 = data[2] - data[0]; + area->area.y2 = data[3] - data[1]; + XFree(data); + + area->window = wwin->client_win; + } + + area->next = wwin->screen_ptr->reservedAreas; + wwin->screen_ptr->reservedAreas = area; wScreenUpdateUsableArea(wwin->screen_ptr); - hasHints = True; + hasHints = True; } - + return hasHints; } @@ -433,21 +433,21 @@ wGNOMEGetUsableArea(WScreen *scr, int head, WArea *area) area->x1 = area->y1 = area->x2 = area->y2 = 0; for(cur = scr->reservedAreas ; cur ; cur = cur->next) { - WWindow * wwin = wWindowFor(cur->window); - if (wWindowTouchesHead(wwin, head)) { - if(cur->area.x1 > area->x1) - area->x1 = cur->area.x1; - if(cur->area.y1 > area->y1) - area->y1 = cur->area.y1; - if(cur->area.x2 > area->x2) - area->x2 = cur->area.x2; - if(cur->area.y2 > area->y2) - area->y2 = cur->area.y2; - } + WWindow * wwin = wWindowFor(cur->window); + if (wWindowTouchesHead(wwin, head)) { + if(cur->area.x1 > area->x1) + area->x1 = cur->area.x1; + if(cur->area.y1 > area->y1) + area->y1 = cur->area.y1; + if(cur->area.x2 > area->x2) + area->x2 = cur->area.x2; + if(cur->area.y2 > area->y2) + area->y2 = cur->area.y2; + } } if (area->x1==0 && area->x2==0 && - area->y1==0 && area->y2==0) return False; + area->y1==0 && area->y2==0) return False; rect = wGetRectForHead(scr, head); @@ -470,30 +470,30 @@ wGNOMECheckInitialClientState(WWindow *wwin) long flags, *data = 0; if (XGetWindowProperty(dpy, wwin->client_win, _XA_WIN_STATE, 0, 1, False, - XA_CARDINAL, &type_ret, &fmt_ret, &nitems_ret, - &bytes_after_ret, - (unsigned char**)&data)!=Success || !data) - return False; + XA_CARDINAL, &type_ret, &fmt_ret, &nitems_ret, + &bytes_after_ret, + (unsigned char**)&data)!=Success || !data) + return False; flags = *data; XFree(data); if (flags & WIN_STATE_STICKY) - wwin->client_flags.omnipresent = 1; + wwin->client_flags.omnipresent = 1; if (flags & (WIN_STATE_MAXIMIZED_VERT|WIN_STATE_MAXIMIZED_HORIZ)) { - if (flags & WIN_STATE_MAXIMIZED_VERT) - wwin->flags.maximized |= MAX_VERTICAL; + if (flags & WIN_STATE_MAXIMIZED_VERT) + wwin->flags.maximized |= MAX_VERTICAL; - if (flags & WIN_STATE_MAXIMIZED_HORIZ) - wwin->flags.maximized |= MAX_HORIZONTAL; + if (flags & WIN_STATE_MAXIMIZED_HORIZ) + wwin->flags.maximized |= MAX_HORIZONTAL; } if (flags & WIN_STATE_SHADED) - wwin->flags.shaded = 1; - + wwin->flags.shaded = 1; + return True; } @@ -505,43 +505,43 @@ wGNOMEUpdateClientStateHint(WWindow *wwin, Bool changedWorkspace) long flags = 0; if (changedWorkspace) { - val = wwin->frame->workspace; + val = wwin->frame->workspace; - XChangeProperty(dpy, wwin->client_win, _XA_WIN_WORKSPACE, XA_CARDINAL, - 32, PropModeReplace, (unsigned char*)&val, 1); + XChangeProperty(dpy, wwin->client_win, _XA_WIN_WORKSPACE, XA_CARDINAL, + 32, PropModeReplace, (unsigned char*)&val, 1); - if (val != wwin->screen_ptr->current_workspace) - flags |= WIN_STATE_HID_WORKSPACE; + if (val != wwin->screen_ptr->current_workspace) + flags |= WIN_STATE_HID_WORKSPACE; } if (IS_OMNIPRESENT(wwin)) - flags |= WIN_STATE_STICKY; + flags |= WIN_STATE_STICKY; if (wwin->flags.miniaturized) - flags |= WIN_STATE_MINIMIZED; + flags |= WIN_STATE_MINIMIZED; if (wwin->flags.maximized & MAX_VERTICAL) - flags |= WIN_STATE_MAXIMIZED_VERT; + flags |= WIN_STATE_MAXIMIZED_VERT; if (wwin->flags.maximized & MAX_HORIZONTAL) - flags |= WIN_STATE_MAXIMIZED_HORIZ; + flags |= WIN_STATE_MAXIMIZED_HORIZ; if (wwin->flags.shaded) - flags |= WIN_STATE_SHADED; + flags |= WIN_STATE_SHADED; if (wwin->transient_for != None) { - WWindow *owner = wWindowFor(wwin->transient_for); + WWindow *owner = wWindowFor(wwin->transient_for); - if (owner && !owner->flags.mapped) - flags |= WIN_STATE_HID_TRANSIENT; + if (owner && !owner->flags.mapped) + flags |= WIN_STATE_HID_TRANSIENT; } /* ? */ if (wwin->flags.hidden) - flags |= WIN_STATE_HIDDEN; + flags |= WIN_STATE_HIDDEN; XChangeProperty(dpy, wwin->client_win, _XA_WIN_STATE, XA_CARDINAL, - 32, PropModeReplace, (unsigned char*)&flags, 1); + 32, PropModeReplace, (unsigned char*)&flags, 1); } @@ -554,85 +554,85 @@ wGNOMEProcessClientMessage(XClientMessageEvent *event) scr = wScreenForWindow(event->window); if (scr) { - /* generic client messages */ - if (event->message_type == _XA_WIN_WORKSPACE) { - wWorkspaceChange(scr, event->data.l[0]); - } else { - done = False; - } - - if (done) - return True; + /* generic client messages */ + if (event->message_type == _XA_WIN_WORKSPACE) { + wWorkspaceChange(scr, event->data.l[0]); + } else { + done = False; + } + + if (done) + return True; } - /* window specific client messages */ + /* window specific client messages */ wwin = wWindowFor(event->window); if (!wwin) - return False; - + return False; + if (event->message_type == _XA_WIN_LAYER) { - int level = getWindowLevel(event->data.l[0]); + int level = getWindowLevel(event->data.l[0]); - if (WINDOW_LEVEL(wwin) != level) { - ChangeStackingLevel(wwin->frame->core, level); - } + if (WINDOW_LEVEL(wwin) != level) { + ChangeStackingLevel(wwin->frame->core, level); + } } else if (event->message_type == _XA_WIN_STATE) { - int flags, mask; - int maximize = 0; - - mask = event->data.l[0]; - flags = event->data.l[1]; - - if (mask & WIN_STATE_STICKY) { - if ((flags & WIN_STATE_STICKY) != WFLAGP(wwin, omnipresent)) { - wWindowSetOmnipresent(wwin, (flags & WIN_STATE_STICKY)!=0); - } - } - - if (mask & WIN_STATE_MAXIMIZED_VERT) { - if (flags & WIN_STATE_MAXIMIZED_VERT) - maximize = MAX_VERTICAL; - else - maximize = 0; - } else { - maximize = wwin->flags.maximized & MAX_VERTICAL; - } - - if (mask & WIN_STATE_MAXIMIZED_HORIZ) { - if (flags & WIN_STATE_MAXIMIZED_HORIZ) - maximize |= MAX_HORIZONTAL; - else - maximize |= 0; - } else { - maximize |= wwin->flags.maximized & MAX_HORIZONTAL; - } - - if (maximize != wwin->flags.maximized) { - if (maximize) { - wMaximizeWindow(wwin, maximize); + int flags, mask; + int maximize = 0; + + mask = event->data.l[0]; + flags = event->data.l[1]; + + if (mask & WIN_STATE_STICKY) { + if ((flags & WIN_STATE_STICKY) != WFLAGP(wwin, omnipresent)) { + wWindowSetOmnipresent(wwin, (flags & WIN_STATE_STICKY)!=0); + } + } + + if (mask & WIN_STATE_MAXIMIZED_VERT) { + if (flags & WIN_STATE_MAXIMIZED_VERT) + maximize = MAX_VERTICAL; + else + maximize = 0; + } else { + maximize = wwin->flags.maximized & MAX_VERTICAL; + } + + if (mask & WIN_STATE_MAXIMIZED_HORIZ) { + if (flags & WIN_STATE_MAXIMIZED_HORIZ) + maximize |= MAX_HORIZONTAL; + else + maximize |= 0; + } else { + maximize |= wwin->flags.maximized & MAX_HORIZONTAL; + } + + if (maximize != wwin->flags.maximized) { + if (maximize) { + wMaximizeWindow(wwin, maximize); } else { - wUnmaximizeWindow(wwin); + wUnmaximizeWindow(wwin); + } + } + + if (mask & WIN_STATE_SHADED) { + if ((flags & WIN_STATE_SHADED) != wwin->flags.shaded) { + if (wwin->flags.shaded) + wUnshadeWindow(wwin); + else + wShadeWindow(wwin); } - } - - if (mask & WIN_STATE_SHADED) { - if ((flags & WIN_STATE_SHADED) != wwin->flags.shaded) { - if (wwin->flags.shaded) - wUnshadeWindow(wwin); - else - wShadeWindow(wwin); - } - } + } } else if (event->message_type == _XA_WIN_WORKSPACE) { - if (event->data.l[0] != wwin->frame->workspace) { - wWindowChangeWorkspace(wwin, event->data.l[0]); - } + if (event->data.l[0] != wwin->frame->workspace) { + wWindowChangeWorkspace(wwin, event->data.l[0]); + } } else { - done = False; + done = False; } - + return done; } @@ -641,7 +641,7 @@ Bool wGNOMEProxyizeButtonEvent(WScreen *scr, XEvent *event) { if (event->type == ButtonPress) - XUngrabPointer(dpy, CurrentTime); + XUngrabPointer(dpy, CurrentTime); XSendEvent(dpy, scr->no_focus_win, False, SubstructureNotifyMask, event); return True; @@ -655,32 +655,32 @@ wGNOMERemoveClient(WWindow *wwin) WReservedArea *area; wGNOMEUpdateClientListHint(wwin->screen_ptr); - + area = wwin->screen_ptr->reservedAreas; if (area) { - if (area->window == wwin->client_win) { - wwin->screen_ptr->reservedAreas = area->next; - wfree(area); - flag = 1; - } else { - while (area->next && area->next->window != wwin->client_win) - area = area->next; - - if (area->next) { - WReservedArea *next; - - next = area->next->next; - wfree(area->next); - area->next = next; - - flag = 1; - } - } + if (area->window == wwin->client_win) { + wwin->screen_ptr->reservedAreas = area->next; + wfree(area); + flag = 1; + } else { + while (area->next && area->next->window != wwin->client_win) + area = area->next; + + if (area->next) { + WReservedArea *next; + + next = area->next->next; + wfree(area->next); + area->next = next; + + flag = 1; + } + } } if (flag) { - wScreenUpdateUsableArea(wwin->screen_ptr); + wScreenUpdateUsableArea(wwin->screen_ptr); } } @@ -694,15 +694,15 @@ observer(void *self, WMNotification *notif) const char *name = WMGetNotificationName(notif); if (strcmp(name, WMNManaged) == 0 && wwin) { - wGNOMEUpdateClientStateHint(wwin, True); - - wGNOMEUpdateClientListHint(wwin->screen_ptr); + wGNOMEUpdateClientStateHint(wwin, True); + + wGNOMEUpdateClientListHint(wwin->screen_ptr); } else if (strcmp(name, WMNUnmanaged) == 0 && wwin) { - wGNOMERemoveClient(wwin); + wGNOMERemoveClient(wwin); } else if (strcmp(name, WMNChangedWorkspace) == 0 && wwin) { - wGNOMEUpdateClientStateHint(wwin, True); + wGNOMEUpdateClientStateHint(wwin, True); } else if (strcmp(name, WMNChangedState) == 0 && wwin) { - wGNOMEUpdateClientStateHint(wwin, False); + wGNOMEUpdateClientStateHint(wwin, False); } } @@ -712,15 +712,15 @@ wsobserver(void *self, WMNotification *notif) { WScreen *scr = (WScreen*)WMGetNotificationObject(notif); const char *name = WMGetNotificationName(notif); - + if (strcmp(name, WMNWorkspaceCreated) == 0) { - wGNOMEUpdateWorkspaceHints(scr); + wGNOMEUpdateWorkspaceHints(scr); } else if (strcmp(name, WMNWorkspaceDestroyed) == 0) { - wGNOMEUpdateWorkspaceHints(scr); + wGNOMEUpdateWorkspaceHints(scr); } else if (strcmp(name, WMNWorkspaceNameChanged) == 0) { - wGNOMEUpdateWorkspaceNamesHint(scr); + wGNOMEUpdateWorkspaceNamesHint(scr); } else if (strcmp(name, WMNWorkspaceChanged) == 0) { - wGNOMEUpdateCurrentWorkspaceHint(scr); + wGNOMEUpdateCurrentWorkspaceHint(scr); } else if (strcmp(name, WMNResetStacking) == 0) { } @@ -728,3 +728,4 @@ wsobserver(void *self, WMNotification *notif) #endif /* GNOME_STUFF */ + diff --git a/src/gnome.h b/src/gnome.h index 947c00d1..e681625c 100644 --- a/src/gnome.h +++ b/src/gnome.h @@ -1,9 +1,9 @@ /* gnome.h-- stuff for support for gnome hints - * + * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ diff --git a/src/icon.c b/src/icon.c index 86efbb03..92fec5b3 100644 --- a/src/icon.c +++ b/src/icon.c @@ -1,9 +1,9 @@ /* icon.c - window icon and dock and appicon parent - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -66,22 +66,22 @@ appearanceObserver(void *self, WMNotification *notif) int flags = (int)WMGetNotificationClientData(notif); if (flags & WTextureSettings) { - icon->force_paint = 1; + icon->force_paint = 1; } if (flags & WFontSettings) { - icon->force_paint = 1; + icon->force_paint = 1; } /* - if (flags & WColorSettings) { - } + if (flags & WColorSettings) { + } */ wIconPaint(icon); - /* so that the appicon expose handlers will paint the appicon specific + /* so that the appicon expose handlers will paint the appicon specific * stuff */ - XClearArea(dpy, icon->core->window, 0, 0, icon->core->width, - icon->core->height, True); + XClearArea(dpy, icon->core->window, 0, 0, icon->core->width, + icon->core->height, True); } @@ -106,7 +106,7 @@ getSize(Drawable d, unsigned int *w, unsigned int *h, unsigned int *dep) Window rjunk; int xjunk, yjunk; unsigned int bjunk; - + XGetGeometry(dpy, d, &rjunk, &xjunk, &yjunk, w, h, &bjunk, dep); } @@ -119,30 +119,30 @@ wIconCreate(WWindow *wwin) char *file; unsigned long vmask = 0; XSetWindowAttributes attribs; - + icon = wmalloc(sizeof(WIcon)); memset(icon, 0, sizeof(WIcon)); icon->core = wCoreCreateTopLevel(scr, wwin->icon_x, wwin->icon_y, - wPreferences.icon_size, - wPreferences.icon_size, 0); - + wPreferences.icon_size, + wPreferences.icon_size, 0); + if (wPreferences.use_saveunders) { - vmask |= CWSaveUnder; - attribs.save_under = True; + vmask |= CWSaveUnder; + attribs.save_under = True; } /* a white border for selecting it */ vmask |= CWBorderPixel; attribs.border_pixel = scr->white_pixel; - + XChangeWindowAttributes(dpy, icon->core->window, vmask, &attribs); - + /* will be overriden if this is an application icon */ icon->core->descriptor.handle_mousedown = miniwindowMouseDown; icon->core->descriptor.handle_expose = miniwindowExpose; icon->core->descriptor.parent_type = WCLASS_MINIWINDOW; icon->core->descriptor.parent = icon; - + icon->core->stacking = wmalloc(sizeof(WStacking)); icon->core->stacking->above = NULL; icon->core->stacking->under = NULL; @@ -151,15 +151,15 @@ wIconCreate(WWindow *wwin) icon->owner = wwin; if (wwin->wm_hints && (wwin->wm_hints->flags & IconWindowHint)) { - if (wwin->client_win == wwin->main_window) { - WApplication *wapp; - /* do not let miniwindow steal app-icon's icon window */ - wapp = wApplicationOf(wwin->client_win); - if (!wapp || wapp->app_icon==NULL) - icon->icon_win = wwin->wm_hints->icon_window; - } else { - icon->icon_win = wwin->wm_hints->icon_window; - } + if (wwin->client_win == wwin->main_window) { + WApplication *wapp; + /* do not let miniwindow steal app-icon's icon window */ + wapp = wApplicationOf(wwin->client_win); + if (!wapp || wapp->app_icon==NULL) + icon->icon_win = wwin->wm_hints->icon_window; + } else { + icon->icon_win = wwin->wm_hints->icon_window; + } } #ifdef NO_MINIWINDOW_TITLES icon->show_title = 0; @@ -168,13 +168,13 @@ wIconCreate(WWindow *wwin) #endif #ifdef NETWM_HINTS if (!icon->image && !WFLAGP(wwin, always_user_icon)) - icon->image = RRetainImage(wwin->net_icon_image); + icon->image = RRetainImage(wwin->net_icon_image); if (!icon->image) #endif - icon->image = wDefaultGetImage(scr, wwin->wm_instance, wwin->wm_class); + icon->image = wDefaultGetImage(scr, wwin->wm_instance, wwin->wm_class); file = wDefaultGetIconFile(scr, wwin->wm_instance, wwin->wm_class, - False); + False); if (file) { icon->file = wstrdup(file); } @@ -182,15 +182,15 @@ wIconCreate(WWindow *wwin) wGetIconName(dpy, wwin->client_win, &icon->icon_name); icon->tile_type = TILE_NORMAL; - + wIconUpdate(icon); - + XFlush(dpy); - WMAddNotificationObserver(appearanceObserver, icon, - WNIconAppearanceSettingsChanged, icon); - WMAddNotificationObserver(tileObserver, icon, - WNIconTileSettingsChanged, icon); + WMAddNotificationObserver(appearanceObserver, icon, + WNIconAppearanceSettingsChanged, icon); + WMAddNotificationObserver(tileObserver, icon, + WNIconTileSettingsChanged, icon); return icon; } @@ -204,16 +204,16 @@ wIconCreateWithIconFile(WScreen *scr, char *iconfile, int tile) icon = wmalloc(sizeof(WIcon)); memset(icon, 0, sizeof(WIcon)); - icon->core = wCoreCreateTopLevel(scr, 0, 0, wPreferences.icon_size, - wPreferences.icon_size, 0); + icon->core = wCoreCreateTopLevel(scr, 0, 0, wPreferences.icon_size, + wPreferences.icon_size, 0); if (wPreferences.use_saveunders) { - vmask = CWSaveUnder; - attribs.save_under = True; + vmask = CWSaveUnder; + attribs.save_under = True; } /* a white border for selecting it */ vmask |= CWBorderPixel; attribs.border_pixel = scr->white_pixel; - + XChangeWindowAttributes(dpy, icon->core->window, vmask, &attribs); /* will be overriden if this is a application icon */ @@ -229,24 +229,24 @@ wIconCreateWithIconFile(WScreen *scr, char *iconfile, int tile) icon->core->stacking->child_of = NULL; if (iconfile) { - icon->image = RLoadImage(scr->rcontext, iconfile, 0); - if (!icon->image) { - wwarning(_("error loading image file \"%s\""), iconfile, RMessageForError(RErrorCode)); - } - - icon->image = wIconValidateIconSize(scr, icon->image); - - icon->file = wstrdup(iconfile); + icon->image = RLoadImage(scr->rcontext, iconfile, 0); + if (!icon->image) { + wwarning(_("error loading image file \"%s\""), iconfile, RMessageForError(RErrorCode)); + } + + icon->image = wIconValidateIconSize(scr, icon->image); + + icon->file = wstrdup(iconfile); } - + icon->tile_type = tile; - + wIconUpdate(icon); - WMAddNotificationObserver(appearanceObserver, icon, - WNIconAppearanceSettingsChanged, icon); - WMAddNotificationObserver(tileObserver, icon, - WNIconTileSettingsChanged, icon); + WMAddNotificationObserver(appearanceObserver, icon, + WNIconAppearanceSettingsChanged, icon); + WMAddNotificationObserver(tileObserver, icon, + WNIconTileSettingsChanged, icon); return icon; } @@ -262,29 +262,29 @@ wIconDestroy(WIcon *icon) WMRemoveNotificationObserver(icon); if (icon->handlerID) - WMDeleteTimerHandler(icon->handlerID); + WMDeleteTimerHandler(icon->handlerID); if (icon->icon_win) { - int x=0, y=0; - - if (icon->owner) { - x = icon->owner->icon_x; - y = icon->owner->icon_y; - } - XUnmapWindow(dpy, icon->icon_win); - XReparentWindow(dpy, icon->icon_win, scr->root_win, x, y); + int x=0, y=0; + + if (icon->owner) { + x = icon->owner->icon_x; + y = icon->owner->icon_y; + } + XUnmapWindow(dpy, icon->icon_win); + XReparentWindow(dpy, icon->icon_win, scr->root_win, x, y); } if (icon->icon_name) - XFree(icon->icon_name); + XFree(icon->icon_name); if (icon->pixmap) - XFreePixmap(dpy, icon->pixmap); + XFreePixmap(dpy, icon->pixmap); if (icon->file) wfree(icon->file); if (icon->image!=NULL) - RReleaseImage(icon->image); + RReleaseImage(icon->image); wCoreDestroy(icon->core); wfree(icon); @@ -296,13 +296,13 @@ static void drawIconTitle(WScreen *scr, Pixmap pixmap, int height) { XFillRectangle(dpy, pixmap, scr->icon_title_texture->normal_gc, - 0, 0, wPreferences.icon_size, height+1); + 0, 0, wPreferences.icon_size, height+1); XDrawLine(dpy, pixmap, scr->icon_title_texture->light_gc, 0, 0, - wPreferences.icon_size, 0); + wPreferences.icon_size, 0); XDrawLine(dpy, pixmap, scr->icon_title_texture->light_gc, 0, 0, - 0, height+1); - XDrawLine(dpy, pixmap, scr->icon_title_texture->dim_gc, - wPreferences.icon_size-1, 0, wPreferences.icon_size-1, height+1); + 0, height+1); + XDrawLine(dpy, pixmap, scr->icon_title_texture->dim_gc, + wPreferences.icon_size-1, 0, wPreferences.icon_size-1, height+1); } @@ -314,31 +314,31 @@ makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int tileType) int x, y, sx, sy; unsigned w, h; int theight = WMFontHeight(scr->icon_title_font); - + if (tileType == TILE_NORMAL) - tile = RCloneImage(scr->icon_tile); + tile = RCloneImage(scr->icon_tile); else { - assert(scr->clip_tile); - tile = RCloneImage(scr->clip_tile); + assert(scr->clip_tile); + tile = RCloneImage(scr->clip_tile); } if (icon) { - w = (icon->width > wPreferences.icon_size) - ? wPreferences.icon_size : icon->width; - x = (wPreferences.icon_size - w) / 2; - sx = (icon->width - w)/2; - - if (!titled) { - h = (icon->height > wPreferences.icon_size) - ? wPreferences.icon_size : icon->height; - y = (wPreferences.icon_size - h) / 2; - sy = (icon->height - h)/2; - } else { - h = (icon->height+theight > wPreferences.icon_size - ? wPreferences.icon_size-theight : icon->height); - y = theight+((int)wPreferences.icon_size-theight-h)/2; - sy = (icon->height - h)/2; - } - RCombineArea(tile, icon, sx, sy, w, h, x, y); + w = (icon->width > wPreferences.icon_size) + ? wPreferences.icon_size : icon->width; + x = (wPreferences.icon_size - w) / 2; + sx = (icon->width - w)/2; + + if (!titled) { + h = (icon->height > wPreferences.icon_size) + ? wPreferences.icon_size : icon->height; + y = (wPreferences.icon_size - h) / 2; + sy = (icon->height - h)/2; + } else { + h = (icon->height+theight > wPreferences.icon_size + ? wPreferences.icon_size-theight : icon->height); + y = theight+((int)wPreferences.icon_size-theight-h)/2; + sy = (icon->height - h)/2; + } + RCombineArea(tile, icon, sx, sy, w, h, x, y); } if (shadowed) { @@ -352,12 +352,12 @@ makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int tileType) } if (!RConvertImage(scr->rcontext, tile, &pixmap)) { - wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); + wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); } RReleaseImage(tile); if (titled) - drawIconTitle(scr, pixmap, theight); + drawIconTitle(scr, pixmap, theight); return pixmap; } @@ -369,10 +369,10 @@ wIconChangeTitle(WIcon *icon, char *new_title) int changed; changed = (new_title==NULL && icon->icon_name!=NULL) - || (new_title!=NULL && icon->icon_name==NULL); + || (new_title!=NULL && icon->icon_name==NULL); if (icon->icon_name!=NULL) - XFree(icon->icon_name); + XFree(icon->icon_name); icon->icon_name = new_title; @@ -386,7 +386,7 @@ void wIconChangeImage(WIcon *icon, RImage *new_image) { assert(icon != NULL); - + if (icon->image) RReleaseImage(icon->image); @@ -401,32 +401,32 @@ wIconValidateIconSize(WScreen *scr, RImage *icon) { RImage *tmp; int w, h; - + if (!icon) - return NULL; + return NULL; #ifndef DONT_SCALE_ICONS if (wPreferences.icon_size != 64) { - w = wPreferences.icon_size * icon->width / 64; - h = wPreferences.icon_size * icon->height / 64; + w = wPreferences.icon_size * icon->width / 64; + h = wPreferences.icon_size * icon->height / 64; - tmp = RScaleImage(icon, w, h); - RReleaseImage(icon); - icon = tmp; + tmp = RScaleImage(icon, w, h); + RReleaseImage(icon); + icon = tmp; } #endif #if 0 if (icon->width > wPreferences.icon_size || icon->height > wPreferences.icon_size) { - if (icon->width > icon->height) { - w = wPreferences.icon_size - 4; - h = w*icon->height/icon->width; - } else { - h = wPreferences.icon_size - 4; - w = h*icon->width/icon->height; - } - tmp = RScaleImage(icon, w, h); - RReleaseImage(icon); - icon = tmp; + if (icon->width > icon->height) { + w = wPreferences.icon_size - 4; + h = w*icon->height/icon->width; + } else { + h = wPreferences.icon_size - 4; + w = h*icon->width/icon->height; + } + tmp = RScaleImage(icon, w, h); + RReleaseImage(icon); + icon = tmp; } #endif @@ -443,22 +443,22 @@ wIconChangeImageFile(WIcon *icon, char *file) int error = 0; if (!file) { - wIconChangeImage(icon, NULL); - return True; + wIconChangeImage(icon, NULL); + return True; } path = FindImage(wPreferences.icon_path, file); if (path && (image = RLoadImage(scr->rcontext, path, 0))) { - image = wIconValidateIconSize(icon->core->screen_ptr, image); + image = wIconValidateIconSize(icon->core->screen_ptr, image); - wIconChangeImage(icon, image); + wIconChangeImage(icon, image); } else { - error = 1; + error = 1; } if (path) - wfree(path); + wfree(path); return !error; } @@ -471,21 +471,21 @@ getnameforicon(WWindow *wwin) char *prefix, *suffix; char *path; int len; - + if (wwin->wm_class && wwin->wm_instance) { - int len = strlen(wwin->wm_class)+strlen(wwin->wm_instance)+2; - suffix = wmalloc(len); - snprintf(suffix, len, "%s.%s", wwin->wm_instance, wwin->wm_class); + int len = strlen(wwin->wm_class)+strlen(wwin->wm_instance)+2; + suffix = wmalloc(len); + snprintf(suffix, len, "%s.%s", wwin->wm_instance, wwin->wm_class); } else if (wwin->wm_class) { - int len = strlen(wwin->wm_class)+1; - suffix = wmalloc(len); - snprintf(suffix, len, "%s", wwin->wm_class); + int len = strlen(wwin->wm_class)+1; + suffix = wmalloc(len); + snprintf(suffix, len, "%s", wwin->wm_class); } else if (wwin->wm_instance) { - int len = strlen(wwin->wm_instance)+1; - suffix = wmalloc(len); - snprintf(suffix, len, "%s", wwin->wm_instance); + int len = strlen(wwin->wm_instance)+1; + suffix = wmalloc(len); + snprintf(suffix, len, "%s", wwin->wm_instance); } else { - return NULL; + return NULL; } prefix = wusergnusteppath(); @@ -494,21 +494,21 @@ getnameforicon(WWindow *wwin) snprintf(path, len, "%s/.AppInfo", prefix); if (access(path, F_OK)!=0) { - if (mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR)) { - wsyserror(_("could not create directory %s"), path); - wfree(path); - wfree(suffix); - return NULL; - } + if (mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR)) { + wsyserror(_("could not create directory %s"), path); + wfree(path); + wfree(suffix); + return NULL; + } } strcat(path, "/WindowMaker"); if (access(path, F_OK)!=0) { - if (mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR)!=0) { - wsyserror(_("could not create directory %s"), path); - wfree(path); - wfree(suffix); - return NULL; - } + if (mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR)!=0) { + wsyserror(_("could not create directory %s"), path); + wfree(path); + wfree(suffix); + return NULL; + } } strcat(path, "/"); @@ -525,7 +525,7 @@ getnameforicon(WWindow *wwin) * Stores the client supplied icon at ~/GNUstep/.AppInfo/WindowMaker * and returns the path for that icon. Returns NULL if there is no * client supplied icon or on failure. - * + * * Side effects: * New directories might be created. */ @@ -537,25 +537,25 @@ wIconStore(WIcon *icon) WWindow *wwin = icon->owner; if (!wwin || !wwin->wm_hints || !(wwin->wm_hints->flags & IconPixmapHint) - || wwin->wm_hints->icon_pixmap == None) - return NULL; + || wwin->wm_hints->icon_pixmap == None) + return NULL; path = getnameforicon(wwin); if (!path) - return NULL; + return NULL; image = RCreateImageFromDrawable(icon->core->screen_ptr->rcontext, - wwin->wm_hints->icon_pixmap, - (wwin->wm_hints->flags & IconMaskHint) - ? wwin->wm_hints->icon_mask : None); + wwin->wm_hints->icon_pixmap, + (wwin->wm_hints->flags & IconMaskHint) + ? wwin->wm_hints->icon_mask : None); if (!image) { - wfree(path); - return NULL; + wfree(path); + return NULL; } if (!RSaveImage(image, path, "XPM")) { - wfree(path); - path = NULL; + wfree(path); + path = NULL; } RReleaseImage(image); @@ -564,11 +564,10 @@ wIconStore(WIcon *icon) /* -void -wIconChangeIconWindow(WIcon *icon, Window new_window); +void wIconChangeIconWindow(WIcon *icon, Window new_window); */ -static void +static void cycleColor(void *data) { WIcon *icon = (WIcon*)data; @@ -580,7 +579,7 @@ cycleColor(void *data) XChangeGC(dpy, scr->icon_select_gc, GCDashOffset, &gcv); XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0, - icon->core->width-1, icon->core->height-1); + icon->core->width-1, icon->core->height-1); icon->handlerID = WMAddTimerHandler(COLOR_CYCLE_DELAY, cycleColor, icon); } @@ -589,9 +588,9 @@ void wIconSetHighlited(WIcon *icon, Bool flag) { if (icon->highlighted == flag) { - return; + return; } - + icon->highlighted = flag; wIconPaint(icon); } @@ -606,7 +605,7 @@ wIconSelect(WIcon *icon) if (icon->selected) { icon->step = 0; - if (!wPreferences.dont_blink) + if (!wPreferences.dont_blink) icon->handlerID = WMAddTimerHandler(10, cycleColor, icon); else XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0, @@ -616,8 +615,8 @@ wIconSelect(WIcon *icon) WMDeleteTimerHandler(icon->handlerID); icon->handlerID = NULL; } - XClearArea(dpy, icon->core->window, 0, 0, icon->core->width, - icon->core->height, True); + XClearArea(dpy, icon->core->window, 0, 0, icon->core->width, + icon->core->height, True); } } @@ -632,180 +631,180 @@ wIconUpdate(WIcon *icon) assert(scr->icon_tile!=NULL); if (icon->pixmap!=None) - XFreePixmap(dpy, icon->pixmap); + XFreePixmap(dpy, icon->pixmap); icon->pixmap = None; - - + + if (wwin && (WFLAGP(wwin, always_user_icon) #ifdef NETWM_HINTS - || wwin->net_icon_image + || wwin->net_icon_image #endif - )) - goto user_icon; - + )) + goto user_icon; + /* use client specified icon window */ if (icon->icon_win!=None) { - XWindowAttributes attr; - int resize=0; - int width, height, depth; - int theight; - Pixmap pixmap; - - getSize(icon->icon_win, &width, &height, &depth); - - if (width > wPreferences.icon_size) { - resize = 1; - width = wPreferences.icon_size; - } - if (height > wPreferences.icon_size) { - resize = 1; - height = wPreferences.icon_size; - } - if (icon->show_title - && (height+title_height < wPreferences.icon_size)) { - pixmap = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size, - wPreferences.icon_size, scr->w_depth); - XSetClipMask(dpy, scr->copy_gc, None); - XCopyArea(dpy, scr->icon_tile_pixmap, pixmap, scr->copy_gc, 0, 0, - wPreferences.icon_size, wPreferences.icon_size, 0, 0); - drawIconTitle(scr, pixmap, title_height); - theight = title_height; - } else { - pixmap = None; - theight = 0; - XSetWindowBackgroundPixmap(dpy, icon->core->window, - scr->icon_tile_pixmap); - } - - XSetWindowBorderWidth(dpy, icon->icon_win, 0); - XReparentWindow(dpy, icon->icon_win, icon->core->window, - (wPreferences.icon_size-width)/2, - theight+(wPreferences.icon_size-height-theight)/2); - if (resize) - XResizeWindow(dpy, icon->icon_win, width, height); - - XMapWindow(dpy, icon->icon_win); - - XAddToSaveSet(dpy, icon->icon_win); - - icon->pixmap = pixmap; - - if (XGetWindowAttributes(dpy, icon->icon_win, &attr)) { - if (attr.all_event_masks & ButtonPressMask) { - wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True, - ButtonPressMask, GrabModeSync, GrabModeAsync, - None, wCursor[WCUR_ARROW]); - } - } + XWindowAttributes attr; + int resize=0; + int width, height, depth; + int theight; + Pixmap pixmap; + + getSize(icon->icon_win, &width, &height, &depth); + + if (width > wPreferences.icon_size) { + resize = 1; + width = wPreferences.icon_size; + } + if (height > wPreferences.icon_size) { + resize = 1; + height = wPreferences.icon_size; + } + if (icon->show_title + && (height+title_height < wPreferences.icon_size)) { + pixmap = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size, + wPreferences.icon_size, scr->w_depth); + XSetClipMask(dpy, scr->copy_gc, None); + XCopyArea(dpy, scr->icon_tile_pixmap, pixmap, scr->copy_gc, 0, 0, + wPreferences.icon_size, wPreferences.icon_size, 0, 0); + drawIconTitle(scr, pixmap, title_height); + theight = title_height; + } else { + pixmap = None; + theight = 0; + XSetWindowBackgroundPixmap(dpy, icon->core->window, + scr->icon_tile_pixmap); + } + + XSetWindowBorderWidth(dpy, icon->icon_win, 0); + XReparentWindow(dpy, icon->icon_win, icon->core->window, + (wPreferences.icon_size-width)/2, + theight+(wPreferences.icon_size-height-theight)/2); + if (resize) + XResizeWindow(dpy, icon->icon_win, width, height); + + XMapWindow(dpy, icon->icon_win); + + XAddToSaveSet(dpy, icon->icon_win); + + icon->pixmap = pixmap; + + if (XGetWindowAttributes(dpy, icon->icon_win, &attr)) { + if (attr.all_event_masks & ButtonPressMask) { + wHackedGrabButton(Button1, MOD_MASK, icon->core->window, True, + ButtonPressMask, GrabModeSync, GrabModeAsync, + None, wCursor[WCUR_ARROW]); + } + } } else if (wwin && wwin->wm_hints - && (wwin->wm_hints->flags & IconPixmapHint)) { - int x, y; - unsigned int w, h; - Window jw; - int ji, dotitle; - unsigned int ju, d; - Pixmap pixmap; - - if (!XGetGeometry(dpy, wwin->wm_hints->icon_pixmap, &jw, - &ji, &ji, &w, &h, &ju, &d)) { - icon->owner->wm_hints->flags &= ~IconPixmapHint; - goto user_icon; - } - - pixmap = XCreatePixmap(dpy, icon->core->window, wPreferences.icon_size, - wPreferences.icon_size, scr->w_depth); - XSetClipMask(dpy, scr->copy_gc, None); - XCopyArea(dpy, scr->icon_tile_pixmap, pixmap, scr->copy_gc, 0, 0, - wPreferences.icon_size, wPreferences.icon_size, 0, 0); - - if (w > wPreferences.icon_size) - w = wPreferences.icon_size; - x = (wPreferences.icon_size-w)/2; - - if (icon->show_title && (title_height < wPreferences.icon_size)) { - drawIconTitle(scr, pixmap, title_height); - dotitle = 1; - - if (h > wPreferences.icon_size - title_height - 2) { - h = wPreferences.icon_size - title_height - 2; - y = title_height + 1; - } else { - y = (wPreferences.icon_size-h-title_height)/2+title_height + 1; - } - } else { - dotitle = 0; - if (w > wPreferences.icon_size) - w = wPreferences.icon_size; - y = (wPreferences.icon_size-h)/2; - } - - if (wwin->wm_hints->flags & IconMaskHint) - XSetClipMask(dpy, scr->copy_gc, wwin->wm_hints->icon_mask); - - XSetClipOrigin(dpy, scr->copy_gc, x, y); - - if (d != scr->w_depth) { - XSetForeground(dpy, scr->copy_gc, scr->black_pixel); - XSetBackground(dpy, scr->copy_gc, scr->white_pixel); - XCopyPlane(dpy, wwin->wm_hints->icon_pixmap, pixmap, scr->copy_gc, - 0, 0, w, h, x, y, 1); - } else { - XCopyArea(dpy, wwin->wm_hints->icon_pixmap, pixmap, scr->copy_gc, - 0, 0, w, h, x, y); - } - - XSetClipOrigin(dpy, scr->copy_gc, 0, 0); - - icon->pixmap = pixmap; + && (wwin->wm_hints->flags & IconPixmapHint)) { + int x, y; + unsigned int w, h; + Window jw; + int ji, dotitle; + unsigned int ju, d; + Pixmap pixmap; + + if (!XGetGeometry(dpy, wwin->wm_hints->icon_pixmap, &jw, + &ji, &ji, &w, &h, &ju, &d)) { + icon->owner->wm_hints->flags &= ~IconPixmapHint; + goto user_icon; + } + + pixmap = XCreatePixmap(dpy, icon->core->window, wPreferences.icon_size, + wPreferences.icon_size, scr->w_depth); + XSetClipMask(dpy, scr->copy_gc, None); + XCopyArea(dpy, scr->icon_tile_pixmap, pixmap, scr->copy_gc, 0, 0, + wPreferences.icon_size, wPreferences.icon_size, 0, 0); + + if (w > wPreferences.icon_size) + w = wPreferences.icon_size; + x = (wPreferences.icon_size-w)/2; + + if (icon->show_title && (title_height < wPreferences.icon_size)) { + drawIconTitle(scr, pixmap, title_height); + dotitle = 1; + + if (h > wPreferences.icon_size - title_height - 2) { + h = wPreferences.icon_size - title_height - 2; + y = title_height + 1; + } else { + y = (wPreferences.icon_size-h-title_height)/2+title_height + 1; + } + } else { + dotitle = 0; + if (w > wPreferences.icon_size) + w = wPreferences.icon_size; + y = (wPreferences.icon_size-h)/2; + } + + if (wwin->wm_hints->flags & IconMaskHint) + XSetClipMask(dpy, scr->copy_gc, wwin->wm_hints->icon_mask); + + XSetClipOrigin(dpy, scr->copy_gc, x, y); + + if (d != scr->w_depth) { + XSetForeground(dpy, scr->copy_gc, scr->black_pixel); + XSetBackground(dpy, scr->copy_gc, scr->white_pixel); + XCopyPlane(dpy, wwin->wm_hints->icon_pixmap, pixmap, scr->copy_gc, + 0, 0, w, h, x, y, 1); + } else { + XCopyArea(dpy, wwin->wm_hints->icon_pixmap, pixmap, scr->copy_gc, + 0, 0, w, h, x, y); + } + + XSetClipOrigin(dpy, scr->copy_gc, 0, 0); + + icon->pixmap = pixmap; } else { - user_icon: - - if (icon->image) { - icon->pixmap = makeIcon(scr, icon->image, icon->show_title, - icon->shadowed, icon->tile_type); - } else { - /* make default icons */ - - if (!scr->def_icon_pixmap) { - RImage *image = NULL; - char *path; - char *file; - - file = wDefaultGetIconFile(scr, NULL, NULL, False); - if (file) { - path = FindImage(wPreferences.icon_path, file); - if (!path) { - wwarning(_("could not find default icon \"%s\""),file); - goto make_icons; - } - - image = RLoadImage(scr->rcontext, path, 0); - if (!image) { - wwarning(_("could not load default icon \"%s\":%s"), - file, RMessageForError(RErrorCode)); - } - wfree(path); - } - make_icons: - - image = wIconValidateIconSize(scr, image); - scr->def_icon_pixmap = makeIcon(scr, image, False, False, - icon->tile_type); - scr->def_ticon_pixmap = makeIcon(scr, image, True, False, - icon->tile_type); - if (image) - RReleaseImage(image); - } - - if (icon->show_title) { - XSetWindowBackgroundPixmap(dpy, icon->core->window, - scr->def_ticon_pixmap); - } else { - XSetWindowBackgroundPixmap(dpy, icon->core->window, - scr->def_icon_pixmap); - } - icon->pixmap = None; - } + user_icon: + + if (icon->image) { + icon->pixmap = makeIcon(scr, icon->image, icon->show_title, + icon->shadowed, icon->tile_type); + } else { + /* make default icons */ + + if (!scr->def_icon_pixmap) { + RImage *image = NULL; + char *path; + char *file; + + file = wDefaultGetIconFile(scr, NULL, NULL, False); + if (file) { + path = FindImage(wPreferences.icon_path, file); + if (!path) { + wwarning(_("could not find default icon \"%s\""),file); + goto make_icons; + } + + image = RLoadImage(scr->rcontext, path, 0); + if (!image) { + wwarning(_("could not load default icon \"%s\":%s"), + file, RMessageForError(RErrorCode)); + } + wfree(path); + } + make_icons: + + image = wIconValidateIconSize(scr, image); + scr->def_icon_pixmap = makeIcon(scr, image, False, False, + icon->tile_type); + scr->def_ticon_pixmap = makeIcon(scr, image, True, False, + icon->tile_type); + if (image) + RReleaseImage(image); + } + + if (icon->show_title) { + XSetWindowBackgroundPixmap(dpy, icon->core->window, + scr->def_ticon_pixmap); + } else { + XSetWindowBackgroundPixmap(dpy, icon->core->window, + scr->def_icon_pixmap); + } + icon->pixmap = None; + } } if (icon->pixmap != None) { XSetWindowBackgroundPixmap(dpy, icon->core->window, icon->pixmap); @@ -834,26 +833,26 @@ wIconPaint(WIcon *icon) /* draw the icon title */ if (icon->show_title && icon->icon_name!=NULL) { - int l; - int w; + int l; + int w; - tmp = ShrinkString(scr->icon_title_font, icon->icon_name, - wPreferences.icon_size-4); - w = WMWidthOfString(scr->icon_title_font, tmp, l=strlen(tmp)); + tmp = ShrinkString(scr->icon_title_font, icon->icon_name, + wPreferences.icon_size-4); + w = WMWidthOfString(scr->icon_title_font, tmp, l=strlen(tmp)); - if (w > icon->core->width - 4) - x = (icon->core->width - 4) - w; - else - x = (icon->core->width - w)/2; + if (w > icon->core->width - 4) + x = (icon->core->width - 4) - w; + else + x = (icon->core->width - w)/2; - WMDrawString(scr->wmscreen, icon->core->window, scr->icon_title_color, - scr->icon_title_font, x, 1, tmp, l); - wfree(tmp); + WMDrawString(scr->wmscreen, icon->core->window, scr->icon_title_color, + scr->icon_title_font, x, 1, tmp, l); + wfree(tmp); } if (icon->selected) - XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0, - icon->core->width-1, icon->core->height-1); + XDrawRectangle(dpy, icon->core->window, scr->icon_select_gc, 0, 0, + icon->core->width-1, icon->core->height-1); } @@ -877,7 +876,7 @@ miniwindowDblClick(WObjDescriptor *desc, XEvent *event) } -static void +static void miniwindowMouseDown(WObjDescriptor *desc, XEvent *event) { WIcon *icon = desc->parent; @@ -889,95 +888,95 @@ miniwindowMouseDown(WObjDescriptor *desc, XEvent *event) int clickButton=event->xbutton.button; if (WCHECK_STATE(WSTATE_MODAL)) - return; + return; if (IsDoubleClick(icon->core->screen_ptr, event)) { - miniwindowDblClick(desc, event); - return; + miniwindowDblClick(desc, event); + return; } - + #ifdef DEBUG puts("Moving miniwindow"); #endif - if (event->xbutton.button == Button1) { - if (event->xbutton.state & MOD_MASK) - wLowerFrame(icon->core); - else - wRaiseFrame(icon->core); + if (event->xbutton.button == Button1) { + if (event->xbutton.state & MOD_MASK) + wLowerFrame(icon->core); + else + wRaiseFrame(icon->core); if (event->xbutton.state & ShiftMask) { wIconSelect(icon); wSelectWindow(icon->owner, !wwin->flags.selected); } } else if (event->xbutton.button == Button3) { - WObjDescriptor *desc; + WObjDescriptor *desc; - OpenMiniwindowMenu(wwin, event->xbutton.x_root, - event->xbutton.y_root); + OpenMiniwindowMenu(wwin, event->xbutton.x_root, + event->xbutton.y_root); - /* allow drag select of menu */ - desc = &wwin->screen_ptr->window_menu->menu->descriptor; - event->xbutton.send_event = True; - (*desc->handle_mousedown)(desc, event); + /* allow drag select of menu */ + desc = &wwin->screen_ptr->window_menu->menu->descriptor; + event->xbutton.send_event = True; + (*desc->handle_mousedown)(desc, event); - return; + return; } if (XGrabPointer(dpy, icon->core->window, False, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, - GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { + |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, + GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { #ifdef DEBUG0 - wwarning("pointer grab failed for icon move"); + wwarning("pointer grab failed for icon move"); #endif } while(1) { - WMMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask - |ButtonMotionMask|ExposureMask, &ev); - switch (ev.type) { - case Expose: - WMHandleEvent(&ev); - break; - - case MotionNotify: - if (!grabbed) { - if (abs(dx-ev.xmotion.x)>=MOVE_THRESHOLD - || abs(dy-ev.xmotion.y)>=MOVE_THRESHOLD) { - XChangeActivePointerGrab(dpy, ButtonMotionMask - |ButtonReleaseMask|ButtonPressMask, - wCursor[WCUR_MOVE], CurrentTime); - grabbed=1; - } else { - break; - } - } - x = ev.xmotion.x_root - dx; - y = ev.xmotion.y_root - dy; - XMoveWindow(dpy, icon->core->window, x, y); - break; - - case ButtonPress: - break; - - case ButtonRelease: - if (ev.xbutton.button != clickButton) - break; - - if (wwin->icon_x!=x || wwin->icon_y!=y) - wwin->flags.icon_moved = 1; - - XMoveWindow(dpy, icon->core->window, x, y); - - wwin->icon_x = x; - wwin->icon_y = y; + WMMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask + |ButtonMotionMask|ExposureMask, &ev); + switch (ev.type) { + case Expose: + WMHandleEvent(&ev); + break; + + case MotionNotify: + if (!grabbed) { + if (abs(dx-ev.xmotion.x)>=MOVE_THRESHOLD + || abs(dy-ev.xmotion.y)>=MOVE_THRESHOLD) { + XChangeActivePointerGrab(dpy, ButtonMotionMask + |ButtonReleaseMask|ButtonPressMask, + wCursor[WCUR_MOVE], CurrentTime); + grabbed=1; + } else { + break; + } + } + x = ev.xmotion.x_root - dx; + y = ev.xmotion.y_root - dy; + XMoveWindow(dpy, icon->core->window, x, y); + break; + + case ButtonPress: + break; + + case ButtonRelease: + if (ev.xbutton.button != clickButton) + break; + + if (wwin->icon_x!=x || wwin->icon_y!=y) + wwin->flags.icon_moved = 1; + + XMoveWindow(dpy, icon->core->window, x, y); + + wwin->icon_x = x; + wwin->icon_y = y; #ifdef DEBUG - puts("End miniwindow move"); + puts("End miniwindow move"); #endif - XUngrabPointer(dpy, CurrentTime); + XUngrabPointer(dpy, CurrentTime); - if (wPreferences.auto_arrange_icons) - wArrangeIcons(wwin->screen_ptr, True); - return; - - } + if (wPreferences.auto_arrange_icons) + wArrangeIcons(wwin->screen_ptr, True); + return; + + } } } diff --git a/src/icon.h b/src/icon.h index 0645c742..b54091f4 100644 --- a/src/icon.h +++ b/src/icon.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -53,9 +53,9 @@ typedef struct WIcon { unsigned int highlighted:1; Pixmap pixmap; - + WMHandlerID handlerID; /* timer handler ID for cycling select - * color */ + * color */ } WIcon; WIcon *wIconCreateWithIconFile(WScreen *scr, char *iconfile, int tile); diff --git a/src/keybind.h b/src/keybind.h index 90004e1d..4165b484 100644 --- a/src/keybind.h +++ b/src/keybind.h @@ -2,7 +2,7 @@ * Window Maker window manager * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ diff --git a/src/kwm.c b/src/kwm.c index ec63ea9a..8490349e 100644 --- a/src/kwm.c +++ b/src/kwm.c @@ -1,9 +1,9 @@ /* kwm.c-- stuff for support for kwm hints * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,24 +16,24 @@ * * 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. */ /* - * + * * Supported stuff: * ================ - * + * * kfm icon selection from krootbgwm - * + * * kwm.h function/method Notes *---------------------------------------------------------------------------- - * setUnsavedDataHint() currently, only gives visual clue that + * setUnsavedDataHint() currently, only gives visual clue that * there is unsaved data (broken X close button) - * setSticky() + * setSticky() * setIcon() std X thing... - * setDecoration() + * setDecoration() * logout() * refreshScreen() * setWmCommand() std X thing @@ -41,7 +41,7 @@ * setKWMModule() * * isKWMInitialized() not trustworthy - * activeWindow() dunno it's use, but since it's easy to + * activeWindow() dunno it's use, but since it's easy to * implement it won't hurt to support * switchToDesktop() * (set/get)WindowRegion() @@ -52,13 +52,13 @@ * sendKWMCommand() also does the message relay thing * desktop() * geometryRestore() - * isIconified() - * isMaximized() + * isIconified() + * isMaximized() * isSticky() * moveToDesktop() WARNING: evil mechanism * setGeometryRestore() WARNING: evil mechanism * setMaximize() woo hoo! wanna race? - * setIconify() BAH!: why reinvent the f'ing wheel!? + * setIconify() BAH!: why reinvent the f'ing wheel!? * its even broken!!! * move() std X thing * setGeometry() std X thing @@ -73,10 +73,10 @@ * setKWMDockModule() maybe we can make the Dock behave as the KDE * dock, but must figure where to show the windows * setDockWindow() - * + * * Unsupported stuff (superfluous/not-essential/nonsense): * ======================================================= - * + * * darkenScreen() * setMiniIcon() * configureWm() @@ -86,11 +86,11 @@ * title() * titleWithState() * geometry() kde lib code makes it unnecessary - * - * + * + * * Extensions to KDE: * ================== - * + * * These are clientmessage-type messages specific to Window Maker: * wmaker:info - show info panel * wmaker:legal - show legal panel @@ -146,7 +146,7 @@ #include "kwm.h" /*#define DEBUG1 -*/ + */ /******* Global ******/ extern Time LastFocusChange; @@ -181,7 +181,7 @@ static Atom _XA_KWM_MODULE_WIN_ACTIVATE = 0; static Atom _XA_KWM_MODULE_WIN_ICON_CHANGE = 0; static Atom _XA_KWM_MODULE_DOCKWIN_ADD = 0; static Atom _XA_KWM_MODULE_DOCKWIN_REMOVE = 0; - + static Atom _XA_KWM_WIN_UNSAVED_DATA = 0; static Atom _XA_KWM_WIN_DECORATION = 0; static Atom _XA_KWM_WIN_DESKTOP = 0; @@ -223,11 +223,11 @@ static KWMModuleList *KWMDockWindows = NULL; /* window decoration types */ enum { - KWMnoDecoration = 0, - KWMnormalDecoration = 1, + KWMnoDecoration = 0, + KWMnormalDecoration = 1, KWMtinyDecoration = 2, KWMnoFocus = 256, - KWMstandaloneMenuBar = 512, + KWMstandaloneMenuBar = 512, KWMdesktopIcon = 1024, KWMstaysOnTop = 2048 }; @@ -249,7 +249,7 @@ getSimpleHint(Window win, Atom atom, long *retval) data = (long*)PropGetCheckProperty(win, atom, atom, 32, 1, NULL); if (!data) - return False; + return False; *retval = *data; @@ -265,7 +265,7 @@ setSimpleHint(Window win, Atom atom, long value) { assert(atom!=0); XChangeProperty(dpy, win, atom, atom, - 32, PropModeReplace, (unsigned char*)&value, 1); + 32, PropModeReplace, (unsigned char*)&value, 1); } @@ -286,7 +286,7 @@ sendClientMessage(WScreen *scr, Window window, Atom atom, long value) event.xclient.data.l[1] = LastTimestamp; if (scr && scr->root_win == window) - mask = SubstructureRedirectMask; + mask = SubstructureRedirectMask; XSendEvent(dpy, window, False, mask, &event); } @@ -308,10 +308,10 @@ sendTextMessage(WScreen *scr, Window window, Atom atom, char *text) event.xclient.format = 8; for (i=0; i<20 && text[i]; i++) - event.xclient.data.b[i] = text[i]; + event.xclient.data.b[i] = text[i]; if (scr && scr->root_win == window) - mask = SubstructureRedirectMask; + mask = SubstructureRedirectMask; XSendEvent(dpy, window, False, mask, &event); } @@ -325,7 +325,7 @@ getAreaHint(Window win, Atom atom, WArea *area) data = (long*)PropGetCheckProperty(win, atom, atom, 32, 4, NULL); if (!data) - return False; + return False; area->x1 = data[0]; area->y1 = data[1]; @@ -348,8 +348,8 @@ setAreaHint(Window win, Atom atom, WArea area) value[1] = area.y1; value[2] = area.x2 - area.x1; value[3] = area.y2 - area.y1; - XChangeProperty(dpy, win, atom, atom, 32, PropModeReplace, - (unsigned char*)&value, 4); + XChangeProperty(dpy, win, atom, atom, 32, PropModeReplace, + (unsigned char*)&value, 4); } @@ -362,8 +362,8 @@ addModule(WScreen *scr, Window window) node = malloc(sizeof(KWMModuleList)); if (!node) { - wwarning("out of memory while registering KDE module"); - return; + wwarning("out of memory while registering KDE module"); + return; } node->next = KWMModules; @@ -373,27 +373,27 @@ addModule(WScreen *scr, Window window) sendClientMessage(scr, window, _XA_KWM_MODULE_INIT, 0); if (getSimpleHint(window, _XA_KWM_MODULE, &val) && val==2) { - if (scr->kwm_dock != None) { - setSimpleHint(window, _XA_KWM_MODULE, 1); - } else { - KWMModuleList *ptr; - - scr->kwm_dock = window; - - for (ptr = KWMDockWindows; ptr!=NULL; ptr = ptr->next) { - sendClientMessage(scr, scr->kwm_dock, _XA_KWM_MODULE_DOCKWIN_ADD, - ptr->window); - } - } + if (scr->kwm_dock != None) { + setSimpleHint(window, _XA_KWM_MODULE, 1); + } else { + KWMModuleList *ptr; + + scr->kwm_dock = window; + + for (ptr = KWMDockWindows; ptr!=NULL; ptr = ptr->next) { + sendClientMessage(scr, scr->kwm_dock, _XA_KWM_MODULE_DOCKWIN_ADD, + ptr->window); + } + } } /* send list of windows */ for (ptr = scr->focused_window; ptr!=NULL; ptr = ptr->prev) { - if (!ptr->flags.kwm_hidden_for_modules - && !WFLAGP(ptr, skip_window_list)) { - sendClientMessage(scr, window, _XA_KWM_MODULE_WIN_ADD, - ptr->client_win); - } + if (!ptr->flags.kwm_hidden_for_modules + && !WFLAGP(ptr, skip_window_list)) { + sendClientMessage(scr, window, _XA_KWM_MODULE_WIN_ADD, + ptr->client_win); + } } /* send window stacking order */ @@ -401,8 +401,8 @@ addModule(WScreen *scr, Window window) /* send focused window */ if (scr->focused_window && scr->focused_window->flags.focused) { - sendClientMessage(scr, window, _XA_KWM_MODULE_WIN_ACTIVATE, - scr->focused_window->client_win); + sendClientMessage(scr, window, _XA_KWM_MODULE_WIN_ACTIVATE, + scr->focused_window->client_win); } /* tell who we are */ @@ -424,40 +424,40 @@ removeModule(WScreen *scr, Window window) KWMModuleList *next; if (!KWMModules) { - return; + return; } if (KWMModules->window == window) { - next = KWMModules->next; + next = KWMModules->next; #ifdef DEBUG1 - printf("REMOVING MODULE %s\n", KWMModules->title); - if (KWMModules->title) - XFree(KWMModules->title); + printf("REMOVING MODULE %s\n", KWMModules->title); + if (KWMModules->title) + XFree(KWMModules->title); #endif - wfree(KWMModules); - KWMModules = next; + wfree(KWMModules); + KWMModules = next; } else { - KWMModuleList *ptr; + KWMModuleList *ptr; - ptr = KWMModules; - while (ptr->next) { - if (ptr->next->window == window) { - next = ptr->next->next; + ptr = KWMModules; + while (ptr->next) { + if (ptr->next->window == window) { + next = ptr->next->next; #ifdef DEBUG1 - printf("REMOVING MODULE %s\n", ptr->next->title); - if (ptr->next->title) - XFree(ptr->next->title); + printf("REMOVING MODULE %s\n", ptr->next->title); + if (ptr->next->title) + XFree(ptr->next->title); #endif - wfree(ptr->next); - ptr->next->next = next; - break; - } - ptr->next = ptr->next->next; - } + wfree(ptr->next); + ptr->next->next = next; + break; + } + ptr->next = ptr->next->next; + } } if (scr->kwm_dock == window) - scr->kwm_dock = None; + scr->kwm_dock = None; } @@ -468,24 +468,24 @@ addDockWindow(WScreen *scr, Window window) KWMModuleList *ptr; for (ptr = KWMDockWindows; ptr != NULL; ptr = ptr->next) { - if (ptr->window == window) - break; + if (ptr->window == window) + break; } if (!ptr) { - KWMModuleList *node; - - node = malloc(sizeof(KWMModuleList)); - if (!node) { - wwarning("out of memory while processing KDE dock window"); - return; - } - node->next = KWMDockWindows; - KWMDockWindows = node; - node->window = window; - XSelectInput(dpy, window, StructureNotifyMask); - - sendClientMessage(scr, scr->kwm_dock, _XA_KWM_MODULE_DOCKWIN_ADD, - window); + KWMModuleList *node; + + node = malloc(sizeof(KWMModuleList)); + if (!node) { + wwarning("out of memory while processing KDE dock window"); + return; + } + node->next = KWMDockWindows; + KWMDockWindows = node; + node->window = window; + XSelectInput(dpy, window, StructureNotifyMask); + + sendClientMessage(scr, scr->kwm_dock, _XA_KWM_MODULE_DOCKWIN_ADD, + window); } } @@ -494,33 +494,33 @@ static void removeDockWindow(WScreen *scr, Window window) { if (!KWMDockWindows) - return; + return; if (KWMDockWindows->window == window) { - KWMModuleList *next; + KWMModuleList *next; - sendClientMessage(scr, scr->kwm_dock, _XA_KWM_MODULE_DOCKWIN_REMOVE, - window); + sendClientMessage(scr, scr->kwm_dock, _XA_KWM_MODULE_DOCKWIN_REMOVE, + window); - next = KWMDockWindows->next; - wfree(KWMDockWindows); - KWMDockWindows = next; + next = KWMDockWindows->next; + wfree(KWMDockWindows); + KWMDockWindows = next; } else { - KWMModuleList *ptr, *next; - - ptr = KWMDockWindows; - while (ptr->next) { - if (ptr->next->window == window) { - sendClientMessage(scr, scr->kwm_dock, - _XA_KWM_MODULE_DOCKWIN_REMOVE, window); - next = ptr->next->next; - wfree(ptr->next); - ptr->next = next; - return; - } - ptr = ptr->next; - } + KWMModuleList *ptr, *next; + + ptr = KWMDockWindows; + while (ptr->next) { + if (ptr->next->window == window) { + sendClientMessage(scr, scr->kwm_dock, + _XA_KWM_MODULE_DOCKWIN_REMOVE, window); + next = ptr->next->next; + wfree(ptr->next); + ptr->next = next; + return; + } + ptr = ptr->next; + } } } @@ -533,12 +533,12 @@ sendToModules(WScreen *scr, Atom atom, WWindow *wwin, long data) long mask; if (wwin) { - if (wwin->flags.kwm_hidden_for_modules - || WFLAGP(wwin, skip_window_list)) - return; - data = wwin->client_win; + if (wwin->flags.kwm_hidden_for_modules + || WFLAGP(wwin, skip_window_list)) + return; + data = wwin->client_win; } -#ifdef DEBUG1 +#ifdef DEBUG1 printf("notifying %s\n",XGetAtomName(dpy, atom)); #endif memset(&event, 0, sizeof(XEvent)); @@ -549,12 +549,12 @@ sendToModules(WScreen *scr, Atom atom, WWindow *wwin, long data) mask = 0; if (scr && scr->root_win == data) - mask = SubstructureRedirectMask; + mask = SubstructureRedirectMask; for (ptr = KWMModules; ptr!=NULL; ptr = ptr->next) { - event.xclient.window = ptr->window; - event.xclient.data.l[0] = data; - XSendEvent(dpy, ptr->window, False, mask, &event); + event.xclient.window = ptr->window; + event.xclient.data.l[0] = data; + XSendEvent(dpy, ptr->window, False, mask, &event); } } @@ -563,74 +563,74 @@ void wKWMInitStuff(WScreen *scr) { if (!_XA_KWM_WIN_STICKY) { - _XA_KWM_WIN_UNSAVED_DATA = XInternAtom(dpy, "KWM_WIN_UNSAVED_DATA", - False); + _XA_KWM_WIN_UNSAVED_DATA = XInternAtom(dpy, "KWM_WIN_UNSAVED_DATA", + False); + + _XA_KWM_WIN_DECORATION = XInternAtom(dpy, "KWM_WIN_DECORATION", False); + + _XA_KWM_WIN_DESKTOP = XInternAtom(dpy, "KWM_WIN_DESKTOP", False); - _XA_KWM_WIN_DECORATION = XInternAtom(dpy, "KWM_WIN_DECORATION", False); + _XA_KWM_WIN_GEOMETRY_RESTORE = XInternAtom(dpy, + "KWM_WIN_GEOMETRY_RESTORE", + False); - _XA_KWM_WIN_DESKTOP = XInternAtom(dpy, "KWM_WIN_DESKTOP", False); + _XA_KWM_WIN_STICKY = XInternAtom(dpy, "KWM_WIN_STICKY", False); - _XA_KWM_WIN_GEOMETRY_RESTORE = XInternAtom(dpy, - "KWM_WIN_GEOMETRY_RESTORE", - False); + _XA_KWM_WIN_ICONIFIED = XInternAtom(dpy, "KWM_WIN_ICONIFIED", False); - _XA_KWM_WIN_STICKY = XInternAtom(dpy, "KWM_WIN_STICKY", False); + _XA_KWM_WIN_MAXIMIZED = XInternAtom(dpy, "KWM_WIN_MAXIMIZED", False); - _XA_KWM_WIN_ICONIFIED = XInternAtom(dpy, "KWM_WIN_ICONIFIED", False); + _XA_KWM_WIN_ICON_GEOMETRY = XInternAtom(dpy, "KWM_WIN_ICON_GEOMETRY", + False); - _XA_KWM_WIN_MAXIMIZED = XInternAtom(dpy, "KWM_WIN_MAXIMIZED", False); + _XA_KWM_COMMAND = XInternAtom(dpy, "KWM_COMMAND", False); - _XA_KWM_WIN_ICON_GEOMETRY = XInternAtom(dpy, "KWM_WIN_ICON_GEOMETRY", - False); + _XA_KWM_ACTIVE_WINDOW = XInternAtom(dpy, "KWM_ACTIVE_WINDOW", False); - _XA_KWM_COMMAND = XInternAtom(dpy, "KWM_COMMAND", False); + _XA_KWM_ACTIVATE_WINDOW = XInternAtom(dpy, "KWM_ACTIVATE_WINDOW", + False); - _XA_KWM_ACTIVE_WINDOW = XInternAtom(dpy, "KWM_ACTIVE_WINDOW", False); + _XA_KWM_DO_NOT_MANAGE = XInternAtom(dpy, "KWM_DO_NOT_MANAGE", False); - _XA_KWM_ACTIVATE_WINDOW = XInternAtom(dpy, "KWM_ACTIVATE_WINDOW", - False); + _XA_KWM_CURRENT_DESKTOP = XInternAtom(dpy, "KWM_CURRENT_DESKTOP", + False); - _XA_KWM_DO_NOT_MANAGE = XInternAtom(dpy, "KWM_DO_NOT_MANAGE", False); - - _XA_KWM_CURRENT_DESKTOP = XInternAtom(dpy, "KWM_CURRENT_DESKTOP", - False); + _XA_KWM_NUMBER_OF_DESKTOPS = XInternAtom(dpy, "KWM_NUMBER_OF_DESKTOPS", + False); - _XA_KWM_NUMBER_OF_DESKTOPS = XInternAtom(dpy, "KWM_NUMBER_OF_DESKTOPS", - False); + _XA_KWM_DOCKWINDOW = XInternAtom(dpy, "KWM_DOCKWINDOW", False); - _XA_KWM_DOCKWINDOW = XInternAtom(dpy, "KWM_DOCKWINDOW", False); + _XA_KWM_RUNNING = XInternAtom(dpy, "KWM_RUNNING", False); - _XA_KWM_RUNNING = XInternAtom(dpy, "KWM_RUNNING", False); + _XA_KWM_MODULE = XInternAtom(dpy, "KWM_MODULE", False); - _XA_KWM_MODULE = XInternAtom(dpy, "KWM_MODULE", False); + _XA_KWM_MODULE_INIT = XInternAtom(dpy, "KWM_MODULE_INIT", False); + _XA_KWM_MODULE_INITIALIZED = XInternAtom(dpy, "KWM_MODULE_INITIALIZED", False); - _XA_KWM_MODULE_INIT = XInternAtom(dpy, "KWM_MODULE_INIT", False); - _XA_KWM_MODULE_INITIALIZED = XInternAtom(dpy, "KWM_MODULE_INITIALIZED", False); + /* dunno what these do, but Matthias' patch contains it... */ + _XA_KWM_MODULE_DESKTOP_CHANGE = XInternAtom(dpy, "KWM_MODULE_DESKTOP_CHANGE", False); + _XA_KWM_MODULE_DESKTOP_NAME_CHANGE = XInternAtom(dpy, "KWM_MODULE_DESKTOP_NAME_CHANGE", False); + _XA_KWM_MODULE_DESKTOP_NUMBER_CHANGE = XInternAtom(dpy, "KWM_MODULE_DESKTOP_NUMBER_CHANGE", False); - /* dunno what these do, but Matthias' patch contains it... */ - _XA_KWM_MODULE_DESKTOP_CHANGE = XInternAtom(dpy, "KWM_MODULE_DESKTOP_CHANGE", False); - _XA_KWM_MODULE_DESKTOP_NAME_CHANGE = XInternAtom(dpy, "KWM_MODULE_DESKTOP_NAME_CHANGE", False); - _XA_KWM_MODULE_DESKTOP_NUMBER_CHANGE = XInternAtom(dpy, "KWM_MODULE_DESKTOP_NUMBER_CHANGE", False); + _XA_KWM_MODULE_WIN_ADD = XInternAtom(dpy, "KWM_MODULE_WIN_ADD", False); + _XA_KWM_MODULE_WIN_REMOVE = XInternAtom(dpy, "KWM_MODULE_WIN_REMOVE", False); + _XA_KWM_MODULE_WIN_CHANGE = XInternAtom(dpy, "KWM_MODULE_WIN_CHANGE", False); + _XA_KWM_MODULE_WIN_RAISE = XInternAtom(dpy, "KWM_MODULE_WIN_RAISE", False); + _XA_KWM_MODULE_WIN_LOWER = XInternAtom(dpy, "KWM_MODULE_WIN_LOWER", False); + _XA_KWM_MODULE_WIN_ACTIVATE = XInternAtom(dpy, "KWM_MODULE_WIN_ACTIVATE", False); + _XA_KWM_MODULE_WIN_ICON_CHANGE = XInternAtom(dpy, "KWM_MODULE_WIN_ICON_CHANGE", False); + _XA_KWM_MODULE_DOCKWIN_ADD = XInternAtom(dpy, "KWM_MODULE_DOCKWIN_ADD", False); + _XA_KWM_MODULE_DOCKWIN_REMOVE = XInternAtom(dpy, "KWM_MODULE_DOCKWIN_REMOVE", False); - _XA_KWM_MODULE_WIN_ADD = XInternAtom(dpy, "KWM_MODULE_WIN_ADD", False); - _XA_KWM_MODULE_WIN_REMOVE = XInternAtom(dpy, "KWM_MODULE_WIN_REMOVE", False); - _XA_KWM_MODULE_WIN_CHANGE = XInternAtom(dpy, "KWM_MODULE_WIN_CHANGE", False); - _XA_KWM_MODULE_WIN_RAISE = XInternAtom(dpy, "KWM_MODULE_WIN_RAISE", False); - _XA_KWM_MODULE_WIN_LOWER = XInternAtom(dpy, "KWM_MODULE_WIN_LOWER", False); - _XA_KWM_MODULE_WIN_ACTIVATE = XInternAtom(dpy, "KWM_MODULE_WIN_ACTIVATE", False); - _XA_KWM_MODULE_WIN_ICON_CHANGE = XInternAtom(dpy, "KWM_MODULE_WIN_ICON_CHANGE", False); - _XA_KWM_MODULE_DOCKWIN_ADD = XInternAtom(dpy, "KWM_MODULE_DOCKWIN_ADD", False); - _XA_KWM_MODULE_DOCKWIN_REMOVE = XInternAtom(dpy, "KWM_MODULE_DOCKWIN_REMOVE", False); - - memset(_XA_KWM_WINDOW_REGION_, 0, sizeof(_XA_KWM_WINDOW_REGION_)); + memset(_XA_KWM_WINDOW_REGION_, 0, sizeof(_XA_KWM_WINDOW_REGION_)); - memset(_XA_KWM_DESKTOP_NAME_, 0, sizeof(_XA_KWM_DESKTOP_NAME_)); + memset(_XA_KWM_DESKTOP_NAME_, 0, sizeof(_XA_KWM_DESKTOP_NAME_)); } #define SETSTR(hint, str) {\ - static Atom a = 0; if (!a) a = XInternAtom(dpy, #hint, False);\ - XChangeProperty(dpy, scr->root_win, a, XA_STRING, 8, PropModeReplace,\ - (unsigned char*)str, strlen(str));} + static Atom a = 0; if (!a) a = XInternAtom(dpy, #hint, False);\ + XChangeProperty(dpy, scr->root_win, a, XA_STRING, 8, PropModeReplace,\ + (unsigned char*)str, strlen(str));} SETSTR(KWM_STRING_MAXIMIZE, _("Maximize")); SETSTR(KWM_STRING_UNMAXIMIZE, _("Unmaximize")); @@ -644,9 +644,9 @@ wKWMInitStuff(WScreen *scr) SETSTR(KWM_STRING_TODESKTOP, _("Move To")); SETSTR(KWM_STRING_ONTOCURRENTDESKTOP, _("Bring Here")); #undef SETSTR - + /* catch any notifications from any objects */ - + WMAddNotificationObserver(observer, scr, WMNManaged, NULL); WMAddNotificationObserver(observer, scr, WMNUnmanaged, NULL); WMAddNotificationObserver(observer, scr, WMNChangedWorkspace, NULL); @@ -659,8 +659,8 @@ wKWMInitStuff(WScreen *scr) WMAddNotificationObserver(wsobserver, scr, WMNWorkspaceDestroyed, NULL); WMAddNotificationObserver(wsobserver, scr, WMNWorkspaceChanged, NULL); WMAddNotificationObserver(wsobserver, scr, WMNWorkspaceNameChanged, NULL); - - WMAddNotificationObserver(wsobserver, scr, WMNResetStacking, NULL); + + WMAddNotificationObserver(wsobserver, scr, WMNResetStacking, NULL); } @@ -671,14 +671,14 @@ wKWMSendStacking(WScreen *scr, Window module) WCoreWindow *core; WM_ITERATE_BAG(scr->stacking_list, core, i) { - for (; core != NULL; core = core->stacking->under) { - WWindow *wwin; - - wwin = wWindowFor(core->window); - if (wwin) - sendClientMessage(scr, module, _XA_KWM_MODULE_WIN_RAISE, - wwin->client_win); - } + for (; core != NULL; core = core->stacking->under) { + WWindow *wwin; + + wwin = wWindowFor(core->window); + if (wwin) + sendClientMessage(scr, module, _XA_KWM_MODULE_WIN_RAISE, + wwin->client_win); + } } } @@ -689,9 +689,9 @@ wKWMBroadcastStacking(WScreen *scr) KWMModuleList *ptr = KWMModules; while (ptr) { - wKWMSendStacking(scr, ptr->window); + wKWMSendStacking(scr, ptr->window); - ptr = ptr->next; + ptr = ptr->next; } } @@ -709,18 +709,18 @@ wKWMGetWorkspaceName(WScreen *scr, int workspace) assert(workspace >= 0 && workspace < MAX_WORKSPACES); if (_XA_KWM_DESKTOP_NAME_[workspace]==0) { - snprintf(buffer, sizeof(buffer), "KWM_DESKTOP_NAME_%d", workspace + 1); + snprintf(buffer, sizeof(buffer), "KWM_DESKTOP_NAME_%d", workspace + 1); - _XA_KWM_DESKTOP_NAME_[workspace] = XInternAtom(dpy, buffer, False); + _XA_KWM_DESKTOP_NAME_[workspace] = XInternAtom(dpy, buffer, False); } - + /* What do these people have against correctly using property types? */ - if (XGetWindowProperty(dpy, scr->root_win, - _XA_KWM_DESKTOP_NAME_[workspace], 0, 128, False, - XA_STRING, - &type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret, - (unsigned char**)&data)!=Success || !data) - return NULL; + if (XGetWindowProperty(dpy, scr->root_win, + _XA_KWM_DESKTOP_NAME_[workspace], 0, 128, False, + XA_STRING, + &type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret, + (unsigned char**)&data)!=Success || !data) + return NULL; tmp = wstrdup(data); XFree(data); @@ -744,9 +744,9 @@ wKWMShutdown(WScreen *scr, Bool closeModules) XDeleteProperty(dpy, scr->root_win, _XA_KWM_RUNNING); if (closeModules) { - for (ptr = KWMModules; ptr != NULL; ptr = ptr->next) { - XKillClient(dpy, ptr->window); - } + for (ptr = KWMModules; ptr != NULL; ptr = ptr->next) { + XKillClient(dpy, ptr->window); + } } } @@ -757,49 +757,49 @@ wKWMCheckClientHints(WWindow *wwin, int *layer, int *workspace) long val; Bool hasHint = False; - if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_UNSAVED_DATA, &val) - && val) { + if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_UNSAVED_DATA, &val) + && val) { - wwin->client_flags.broken_close = 1; - hasHint = True; + wwin->client_flags.broken_close = 1; + hasHint = True; } else - if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_DECORATION, &val)) { - if (val & KWMnoFocus) { - wwin->client_flags.no_focusable = 1; - } - switch (val & ~KWMnoFocus) { - case KWMnoDecoration: - wwin->client_flags.no_titlebar = 1; - wwin->client_flags.no_resizebar = 1; - break; - case KWMtinyDecoration: - wwin->client_flags.no_resizebar = 1; - break; - case KWMstandaloneMenuBar: - wwin->client_flags.no_titlebar = 1; - wwin->client_flags.no_resizebar = 1; - wwin->client_flags.no_resizable = 1; - wwin->client_flags.skip_window_list = 1; - wwin->client_flags.no_hide_others = 1; - wwin->flags.kwm_menubar = 1; - *layer = WMMainMenuLevel; - break; - case KWMdesktopIcon: - *layer = WMDesktopLevel; - break; - case KWMstaysOnTop: - *layer = WMFloatingLevel; - break; - case KWMnormalDecoration: - default: - break; - } - hasHint = True; - } else - if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_DESKTOP, &val)) { - *workspace = val - 1; - hasHint = True; - } + if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_DECORATION, &val)) { + if (val & KWMnoFocus) { + wwin->client_flags.no_focusable = 1; + } + switch (val & ~KWMnoFocus) { + case KWMnoDecoration: + wwin->client_flags.no_titlebar = 1; + wwin->client_flags.no_resizebar = 1; + break; + case KWMtinyDecoration: + wwin->client_flags.no_resizebar = 1; + break; + case KWMstandaloneMenuBar: + wwin->client_flags.no_titlebar = 1; + wwin->client_flags.no_resizebar = 1; + wwin->client_flags.no_resizable = 1; + wwin->client_flags.skip_window_list = 1; + wwin->client_flags.no_hide_others = 1; + wwin->flags.kwm_menubar = 1; + *layer = WMMainMenuLevel; + break; + case KWMdesktopIcon: + *layer = WMDesktopLevel; + break; + case KWMstaysOnTop: + *layer = WMFloatingLevel; + break; + case KWMnormalDecoration: + default: + break; + } + hasHint = True; + } else + if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_DESKTOP, &val)) { + *workspace = val - 1; + hasHint = True; + } return hasHint; } @@ -814,35 +814,35 @@ wKWMCheckClientInitialState(WWindow *wwin) if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_STICKY, &val) && val) { - wwin->client_flags.omnipresent = 1; - hasHint = True; - } else - if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_ICONIFIED, &val) && val) { - - wwin->flags.miniaturized = 1; - hasHint = True; - } else - if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_MAXIMIZED, &val)) { - if (val == 2) - wwin->flags.maximized = MAX_VERTICAL; - else if (val == 1) - wwin->flags.maximized = MAX_HORIZONTAL; - else if (val == 3) - wwin->flags.maximized = MAX_VERTICAL|MAX_HORIZONTAL; - hasHint = True; + wwin->client_flags.omnipresent = 1; + hasHint = True; } else - if (getAreaHint(wwin->client_win, _XA_KWM_WIN_GEOMETRY_RESTORE, &area) - && (wwin->old_geometry.x != area.x1 - || wwin->old_geometry.y != area.y1 - || wwin->old_geometry.width != area.x2 - area.x1 - || wwin->old_geometry.height != area.y2 - area.y1)) { - - wwin->old_geometry.x = area.x1; - wwin->old_geometry.y = area.y1; - wwin->old_geometry.width = area.x2 - area.x1; - wwin->old_geometry.height = area.y2 - area.y1; - hasHint = True; - } + if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_ICONIFIED, &val) && val) { + + wwin->flags.miniaturized = 1; + hasHint = True; + } else + if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_MAXIMIZED, &val)) { + if (val == 2) + wwin->flags.maximized = MAX_VERTICAL; + else if (val == 1) + wwin->flags.maximized = MAX_HORIZONTAL; + else if (val == 3) + wwin->flags.maximized = MAX_VERTICAL|MAX_HORIZONTAL; + hasHint = True; + } else + if (getAreaHint(wwin->client_win, _XA_KWM_WIN_GEOMETRY_RESTORE, &area) + && (wwin->old_geometry.x != area.x1 + || wwin->old_geometry.y != area.y1 + || wwin->old_geometry.width != area.x2 - area.x1 + || wwin->old_geometry.height != area.y2 - area.y1)) { + + wwin->old_geometry.x = area.x1; + wwin->old_geometry.y = area.y1; + wwin->old_geometry.width = area.x2 - area.x1; + wwin->old_geometry.height = area.y2 - area.y1; + hasHint = True; + } return hasHint; } @@ -857,165 +857,165 @@ wKWMCheckClientHintChange(WWindow *wwin, XPropertyEvent *event) if (!wwin->frame) { - return False; + return False; } - + if (event->atom == _XA_KWM_WIN_UNSAVED_DATA) { #ifdef DEBUG1 - printf("got KDE unsaved data change\n"); + printf("got KDE unsaved data change\n"); #endif - flag = getSimpleHint(wwin->client_win, _XA_KWM_WIN_UNSAVED_DATA, - &value) && value; + flag = getSimpleHint(wwin->client_win, _XA_KWM_WIN_UNSAVED_DATA, + &value) && value; - if (flag != wwin->client_flags.broken_close) { - wwin->client_flags.broken_close = flag; - if (wwin->frame) - wWindowUpdateButtonImages(wwin); - } + if (flag != wwin->client_flags.broken_close) { + wwin->client_flags.broken_close = flag; + if (wwin->frame) + wWindowUpdateButtonImages(wwin); + } } else if (event->atom == _XA_KWM_WIN_STICKY) { #ifdef DEBUG1 - printf("got KDE sticky change\n"); + printf("got KDE sticky change\n"); #endif - flag = !getSimpleHint(wwin->client_win, _XA_KWM_WIN_STICKY, - &value) || value; + flag = !getSimpleHint(wwin->client_win, _XA_KWM_WIN_STICKY, + &value) || value; - if (flag != wwin->client_flags.omnipresent) { + if (flag != wwin->client_flags.omnipresent) { - wWindowSetOmnipresent(wwin, flag); - } + wWindowSetOmnipresent(wwin, flag); + } } else if (event->atom == _XA_KWM_WIN_MAXIMIZED) { - int bla = 0; + int bla = 0; #ifdef DEBUG1 - printf("got KDE maximize change\n"); + printf("got KDE maximize change\n"); #endif - flag = getSimpleHint(wwin->client_win, _XA_KWM_WIN_MAXIMIZED, &value); - - if (flag) { - if (value == 3) - bla = MAX_VERTICAL|MAX_HORIZONTAL; - else if (value == 2) - bla = MAX_VERTICAL; - else if (value == 1) - bla = MAX_HORIZONTAL; - } - - if (bla != wwin->flags.maximized) { - if (bla != 0) - wMaximizeWindow(wwin, bla); - else - wUnmaximizeWindow(wwin); - } + flag = getSimpleHint(wwin->client_win, _XA_KWM_WIN_MAXIMIZED, &value); + + if (flag) { + if (value == 3) + bla = MAX_VERTICAL|MAX_HORIZONTAL; + else if (value == 2) + bla = MAX_VERTICAL; + else if (value == 1) + bla = MAX_HORIZONTAL; + } + + if (bla != wwin->flags.maximized) { + if (bla != 0) + wMaximizeWindow(wwin, bla); + else + wUnmaximizeWindow(wwin); + } } else if (event->atom == _XA_KWM_WIN_ICONIFIED) { #ifdef DEBUG1 - printf("got KDE iconify change\n"); + printf("got KDE iconify change\n"); #endif - flag = !getSimpleHint(wwin->client_win, _XA_KWM_WIN_ICONIFIED, - &value) || value; + flag = !getSimpleHint(wwin->client_win, _XA_KWM_WIN_ICONIFIED, + &value) || value; - if (flag != wwin->flags.miniaturized) { + if (flag != wwin->flags.miniaturized) { - if (flag) - wIconifyWindow(wwin); - else - wDeiconifyWindow(wwin); - } + if (flag) + wIconifyWindow(wwin); + else + wDeiconifyWindow(wwin); + } } else if (event->atom == _XA_KWM_WIN_DECORATION) { - Bool refresh = False; - int oldnofocus; + Bool refresh = False; + int oldnofocus; #ifdef DEBUG1 - printf("got KDE decoration change\n"); + printf("got KDE decoration change\n"); #endif - oldnofocus = wwin->client_flags.no_focusable; - - if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_DECORATION, &value)) { - wwin->client_flags.no_focusable = (value & KWMnoFocus)!=0; - - switch (value & ~KWMnoFocus) { - case KWMnoDecoration: - if (!WFLAGP(wwin, no_titlebar) || !WFLAGP(wwin, no_resizebar)) - refresh = True; - - wwin->client_flags.no_titlebar = 1; - wwin->client_flags.no_resizebar = 1; - break; - - case KWMtinyDecoration: - if (WFLAGP(wwin, no_titlebar) || !WFLAGP(wwin, no_resizebar)) - refresh = True; - - wwin->client_flags.no_titlebar = 0; - wwin->client_flags.no_resizebar = 1; - break; - - case KWMnormalDecoration: - default: - if (WFLAGP(wwin, no_titlebar) || WFLAGP(wwin, no_resizebar)) - refresh = True; - - wwin->client_flags.no_titlebar = 0; - wwin->client_flags.no_resizebar = 0; - break; - } - } else { - if (WFLAGP(wwin, no_titlebar) || WFLAGP(wwin, no_resizebar)) - refresh = True; - wwin->client_flags.no_focusable = (value & KWMnoFocus)!=0; - wwin->client_flags.no_titlebar = 0; - wwin->client_flags.no_resizebar = 0; - } - - if (refresh) - wWindowConfigureBorders(wwin); - - if (wwin->client_flags.no_focusable && !oldnofocus) { - - sendToModules(wwin->screen_ptr, _XA_KWM_MODULE_WIN_REMOVE, - wwin, 0); - wwin->flags.kwm_hidden_for_modules = 1; - - } else if (!wwin->client_flags.no_focusable && oldnofocus) { - - if (wwin->flags.kwm_hidden_for_modules) { - sendToModules(wwin->screen_ptr, _XA_KWM_MODULE_WIN_ADD, - wwin, 0); - wwin->flags.kwm_hidden_for_modules = 0; - } - } + oldnofocus = wwin->client_flags.no_focusable; + + if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_DECORATION, &value)) { + wwin->client_flags.no_focusable = (value & KWMnoFocus)!=0; + + switch (value & ~KWMnoFocus) { + case KWMnoDecoration: + if (!WFLAGP(wwin, no_titlebar) || !WFLAGP(wwin, no_resizebar)) + refresh = True; + + wwin->client_flags.no_titlebar = 1; + wwin->client_flags.no_resizebar = 1; + break; + + case KWMtinyDecoration: + if (WFLAGP(wwin, no_titlebar) || !WFLAGP(wwin, no_resizebar)) + refresh = True; + + wwin->client_flags.no_titlebar = 0; + wwin->client_flags.no_resizebar = 1; + break; + + case KWMnormalDecoration: + default: + if (WFLAGP(wwin, no_titlebar) || WFLAGP(wwin, no_resizebar)) + refresh = True; + + wwin->client_flags.no_titlebar = 0; + wwin->client_flags.no_resizebar = 0; + break; + } + } else { + if (WFLAGP(wwin, no_titlebar) || WFLAGP(wwin, no_resizebar)) + refresh = True; + wwin->client_flags.no_focusable = (value & KWMnoFocus)!=0; + wwin->client_flags.no_titlebar = 0; + wwin->client_flags.no_resizebar = 0; + } + + if (refresh) + wWindowConfigureBorders(wwin); + + if (wwin->client_flags.no_focusable && !oldnofocus) { + + sendToModules(wwin->screen_ptr, _XA_KWM_MODULE_WIN_REMOVE, + wwin, 0); + wwin->flags.kwm_hidden_for_modules = 1; + + } else if (!wwin->client_flags.no_focusable && oldnofocus) { + + if (wwin->flags.kwm_hidden_for_modules) { + sendToModules(wwin->screen_ptr, _XA_KWM_MODULE_WIN_ADD, + wwin, 0); + wwin->flags.kwm_hidden_for_modules = 0; + } + } } else if (event->atom == _XA_KWM_WIN_DESKTOP && wwin->frame) { #ifdef DEBUG1 - printf("got KDE workspace change for %s\n", wwin->frame->title); + printf("got KDE workspace change for %s\n", wwin->frame->title); #endif - if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_DESKTOP, &value) - && value-1 != wwin->frame->workspace) { - wWindowChangeWorkspace(wwin, value-1); - } + if (getSimpleHint(wwin->client_win, _XA_KWM_WIN_DESKTOP, &value) + && value-1 != wwin->frame->workspace) { + wWindowChangeWorkspace(wwin, value-1); + } } else if (event->atom == _XA_KWM_WIN_GEOMETRY_RESTORE) { - WArea area; + WArea area; #ifdef DEBUG1 - printf("got KDE geometry restore change\n"); + printf("got KDE geometry restore change\n"); #endif - if (getAreaHint(wwin->client_win, _XA_KWM_WIN_GEOMETRY_RESTORE, &area) - && (wwin->old_geometry.x != area.x1 - || wwin->old_geometry.y != area.y1 - || wwin->old_geometry.width != area.x2 - area.x1 - || wwin->old_geometry.height != area.y2 - area.y1)) { - - wwin->old_geometry.x = area.x1; - wwin->old_geometry.y = area.y1; - wwin->old_geometry.width = area.x2 - area.x1; - wwin->old_geometry.height = area.y2 - area.y1; - } + if (getAreaHint(wwin->client_win, _XA_KWM_WIN_GEOMETRY_RESTORE, &area) + && (wwin->old_geometry.x != area.x1 + || wwin->old_geometry.y != area.y1 + || wwin->old_geometry.width != area.x2 - area.x1 + || wwin->old_geometry.height != area.y2 - area.y1)) { + + wwin->old_geometry.x = area.x1; + wwin->old_geometry.y = area.y1; + wwin->old_geometry.width = area.x2 - area.x1; + wwin->old_geometry.height = area.y2 - area.y1; + } } else { - processed = False; + processed = False; } return processed; @@ -1030,7 +1030,7 @@ performWindowCommand(WScreen *scr, char *command) wwin = scr->focused_window; if (!wwin || !wwin->flags.focused || !wwin->flags.mapped) { - wwin = NULL; + wwin = NULL; } CloseWindowMenu(scr); @@ -1038,61 +1038,61 @@ performWindowCommand(WScreen *scr, char *command) if (strcmp(command, "winMove")==0 || strcmp(command, "winResize")==0) { - if (wwin) - wKeyboardMoveResizeWindow(wwin); + if (wwin) + wKeyboardMoveResizeWindow(wwin); } else if (strcmp(command, "winMaximize")==0) { - if (wwin) - wMaximizeWindow(wwin, MAX_VERTICAL|MAX_HORIZONTAL); - + if (wwin) + wMaximizeWindow(wwin, MAX_VERTICAL|MAX_HORIZONTAL); + } else if (strcmp(command, "winRestore")==0) { - if (wwin && wwin->flags.maximized) - wUnmaximizeWindow(wwin); + if (wwin && wwin->flags.maximized) + wUnmaximizeWindow(wwin); } else if (strcmp(command, "winIconify")==0) { - if (wwin && !WFLAGP(wwin, no_miniaturizable)) { - if (wwin->protocols.MINIATURIZE_WINDOW) - wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, - LastTimestamp); - else { - wIconifyWindow(wwin); - } - } + if (wwin && !WFLAGP(wwin, no_miniaturizable)) { + if (wwin->protocols.MINIATURIZE_WINDOW) + wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, + LastTimestamp); + else { + wIconifyWindow(wwin); + } + } } else if (strcmp(command, "winClose")==0) { - if (wwin && !WFLAGP(wwin, no_closable)) { - if (wwin->protocols.DELETE_WINDOW) - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); - } + if (wwin && !WFLAGP(wwin, no_closable)) { + if (wwin->protocols.DELETE_WINDOW) + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + } } else if (strcmp(command, "winSticky")==0) { - if (wwin) { - wWindowSetOmnipresent(wwin, !wwin->client_flags.omnipresent); - } + if (wwin) { + wWindowSetOmnipresent(wwin, !wwin->client_flags.omnipresent); + } } else if (strcmp(command, "winShade")==0) { - if (wwin && !WFLAGP(wwin, no_shadeable)) { - if (wwin->flags.shaded) - wUnshadeWindow(wwin); - else - wShadeWindow(wwin); - } + if (wwin && !WFLAGP(wwin, no_shadeable)) { + if (wwin->flags.shaded) + wUnshadeWindow(wwin); + else + wShadeWindow(wwin); + } } else if (strcmp(command, "winOperation")==0) { - if (wwin) - OpenWindowMenu(wwin, wwin->frame_x, - wwin->frame_y+wwin->frame->top_width, True); - + if (wwin) + OpenWindowMenu(wwin, wwin->frame_x, + wwin->frame_y+wwin->frame->top_width, True); + } else { - return False; + return False; } return True; @@ -1103,87 +1103,87 @@ static void performCommand(WScreen *scr, char *command, XClientMessageEvent *event) { assert(scr != NULL); - + if (strcmp(command, "commandLine")==0 - || strcmp(command, "execute")==0) { - char *cmd; - - cmd = ExpandOptions(scr, _("%a(Run Command,Type the command to run:)")); - if (cmd) { - ExecuteShellCommand(scr, cmd); - wfree(cmd); - } + || strcmp(command, "execute")==0) { + char *cmd; + + cmd = ExpandOptions(scr, _("%a(Run Command,Type the command to run:)")); + if (cmd) { + ExecuteShellCommand(scr, cmd); + wfree(cmd); + } } else if (strcmp(command, "logout")==0) { - Shutdown(WSLogoutMode); + Shutdown(WSLogoutMode); } else if (strcmp(command, "refreshScreen")==0) { - wRefreshDesktop(scr); + wRefreshDesktop(scr); } else if (strncmp(command, "go:", 3)==0) { - Shutdown(WSRestartPreparationMode); - Restart(&command[3], False); - Restart(NULL, True); + Shutdown(WSRestartPreparationMode); + Restart(&command[3], False); + Restart(NULL, True); } else if (strcmp(command, "desktop+1")==0) { - wWorkspaceRelativeChange(scr, 1); + wWorkspaceRelativeChange(scr, 1); } else if (strcmp(command, "desktop-1")==0) { - wWorkspaceRelativeChange(scr, -1); + wWorkspaceRelativeChange(scr, -1); } else if (strcmp(command, "desktop+2")==0) { - wWorkspaceRelativeChange(scr, 2); + wWorkspaceRelativeChange(scr, 2); } else if (strcmp(command, "desktop-2")==0) { - wWorkspaceRelativeChange(scr, -2); + wWorkspaceRelativeChange(scr, -2); } else if (strcmp(command, "desktop%%2")==0) { - if (scr->current_workspace % 2 == 1) - wWorkspaceRelativeChange(scr, 1); - else - wWorkspaceRelativeChange(scr, -1); + if (scr->current_workspace % 2 == 1) + wWorkspaceRelativeChange(scr, 1); + else + wWorkspaceRelativeChange(scr, -1); } else if (strncmp(command, "desktop", 7)==0) { - int ws; + int ws; - ws = atoi(&command[7]); - wWorkspaceChange(scr, ws); + ws = atoi(&command[7]); + wWorkspaceChange(scr, ws); - /* wmaker specific stuff */ + /* wmaker specific stuff */ } else if (strcmp(command, "wmaker:info")==0) { - wShowInfoPanel(scr); + wShowInfoPanel(scr); } else if (strcmp(command, "wmaker:legal")==0) { - wShowLegalPanel(scr); + wShowLegalPanel(scr); } else if (strcmp(command, "wmaker:arrangeIcons")==0) { - wArrangeIcons(scr, True); + wArrangeIcons(scr, True); } else if (strcmp(command, "wmaker:showAll")==0) { - wShowAllWindows(scr); + wShowAllWindows(scr); } else if (strcmp(command, "wmaker:hideOthers")==0) { - wHideOtherApplications(scr->focused_window); + wHideOtherApplications(scr->focused_window); } else if (strcmp(command, "wmaker:restart")==0) { - Shutdown(WSRestartPreparationMode); - Restart(NULL, True); + Shutdown(WSRestartPreparationMode); + Restart(NULL, True); } else if (strcmp(command, "wmaker:exit")==0) { - Shutdown(WSExitMode); + Shutdown(WSExitMode); #ifdef UNSUPPORTED_STUFF } else if (strcmp(command, "moduleRaised")==0) { /* useless */ @@ -1194,22 +1194,22 @@ performCommand(WScreen *scr, char *command, XClientMessageEvent *event) } else if (strcmp(command, "darkenScreen")==0) { /* breaks consistency */ #endif } else if (!performWindowCommand(scr, command)) { - KWMModuleList *module; - long mask = 0; - XEvent ev; - /* do message relay thing */ - - ev.xclient = *event; - for (module = KWMModules; module != NULL; module = module->next) { - - ev.xclient.window = module->window; - if (module->window == scr->root_win) - mask = SubstructureRedirectMask; - else - mask = 0; - - XSendEvent(dpy, module->window, False, mask, &ev); - } + KWMModuleList *module; + long mask = 0; + XEvent ev; + /* do message relay thing */ + + ev.xclient = *event; + for (module = KWMModules; module != NULL; module = module->next) { + + ev.xclient.window = module->window; + if (module->window == scr->root_win) + mask = SubstructureRedirectMask; + else + mask = 0; + + XSendEvent(dpy, module->window, False, mask, &ev); + } } } @@ -1223,73 +1223,73 @@ wKWMProcessClientMessage(XClientMessageEvent *event) printf("CLIENT MESS %s\n", XGetAtomName(dpy, event->message_type)); #endif if (event->message_type == _XA_KWM_COMMAND && event->format==8) { - char buffer[24]; - int i; + char buffer[24]; + int i; - scr = wScreenForRootWindow(event->window); + scr = wScreenForRootWindow(event->window); - for (i=0; i<20; i++) { - buffer[i] = event->data.b[i]; - } - buffer[i] = 0; + for (i=0; i<20; i++) { + buffer[i] = event->data.b[i]; + } + buffer[i] = 0; #ifdef DEBUG1 - printf("got KDE command %s\n", buffer); + printf("got KDE command %s\n", buffer); #endif - performCommand(scr, buffer, event); + performCommand(scr, buffer, event); } else if (event->message_type == _XA_KWM_ACTIVATE_WINDOW) { - WWindow *wwin; + WWindow *wwin; #ifdef DEBUG1 - printf("got KDE activate internal\n"); + printf("got KDE activate internal\n"); #endif - wwin = wWindowFor(event->data.l[0]); + wwin = wWindowFor(event->data.l[0]); - if (wwin) - wSetFocusTo(wwin->screen_ptr, wwin); + if (wwin) + wSetFocusTo(wwin->screen_ptr, wwin); - } else if (event->message_type == _XA_KWM_DO_NOT_MANAGE - && event->format == 8) { - KWMDoNotManageList *node; - int i; + } else if (event->message_type == _XA_KWM_DO_NOT_MANAGE + && event->format == 8) { + KWMDoNotManageList *node; + int i; #ifdef DEBUG1 - printf("got KDE dont manage\n"); + printf("got KDE dont manage\n"); #endif - node = malloc(sizeof(KWMDoNotManageList)); - if (!node) { - wwarning("out of memory processing KWM_DO_NOT_MANAGE message"); - } - for (i=0; i<20 && event->data.b[i]; i++) - node->title[i] = event->data.b[i]; - node->title[i] = 0; + node = malloc(sizeof(KWMDoNotManageList)); + if (!node) { + wwarning("out of memory processing KWM_DO_NOT_MANAGE message"); + } + for (i=0; i<20 && event->data.b[i]; i++) + node->title[i] = event->data.b[i]; + node->title[i] = 0; - node->next = KWMDoNotManageCrap; - KWMDoNotManageCrap = node; + node->next = KWMDoNotManageCrap; + KWMDoNotManageCrap = node; } else if (event->message_type == _XA_KWM_MODULE) { - long val; - Window modwin = event->data.l[0]; + long val; + Window modwin = event->data.l[0]; - scr = wScreenForRootWindow(event->window); + scr = wScreenForRootWindow(event->window); - if (getSimpleHint(modwin, _XA_KWM_MODULE, &val) && val) { + if (getSimpleHint(modwin, _XA_KWM_MODULE, &val) && val) { #ifdef DEBUG1 - puts("got KDE module startup"); + puts("got KDE module startup"); #endif - addModule(scr, modwin); - } else { + addModule(scr, modwin); + } else { #ifdef DEBUG1 - puts("got KDE module finish"); + puts("got KDE module finish"); #endif - removeModule(scr, modwin); - } + removeModule(scr, modwin); + } } else { - processed = False; + processed = False; } - + return processed; } @@ -1301,9 +1301,9 @@ wKWMCheckModule(WScreen *scr, Window window) if (getSimpleHint(window, _XA_KWM_MODULE, &val) && val) { #ifdef DEBUG1 - puts("got KDE module startup"); + puts("got KDE module startup"); #endif - addModule(scr, window); + addModule(scr, window); } } @@ -1315,100 +1315,100 @@ wKWMCheckRootHintChange(WScreen *scr, XPropertyEvent *event) long value; if (event->atom == _XA_KWM_CURRENT_DESKTOP) { - if (getSimpleHint(scr->root_win, _XA_KWM_CURRENT_DESKTOP, &value)) { + if (getSimpleHint(scr->root_win, _XA_KWM_CURRENT_DESKTOP, &value)) { #ifdef DEBUG1 - printf("got KDE workspace switch to %li\n", value); + printf("got KDE workspace switch to %li\n", value); #endif - if (value-1 != scr->current_workspace) { - wWorkspaceChange(scr, value-1); - } - } + if (value-1 != scr->current_workspace) { + wWorkspaceChange(scr, value-1); + } + } } else if (event->atom == _XA_KWM_NUMBER_OF_DESKTOPS) { #ifdef DEBUG1 - printf("got KDE workspace number change\n"); + printf("got KDE workspace number change\n"); #endif - if (getSimpleHint(scr->root_win, _XA_KWM_NUMBER_OF_DESKTOPS, &value)) { + if (getSimpleHint(scr->root_win, _XA_KWM_NUMBER_OF_DESKTOPS, &value)) { - /* increasing is easy... */ - if (value > scr->workspace_count) { - scr->flags.kwm_syncing_count = 1; + /* increasing is easy... */ + if (value > scr->workspace_count) { + scr->flags.kwm_syncing_count = 1; - wWorkspaceMake(scr, value - scr->workspace_count); + wWorkspaceMake(scr, value - scr->workspace_count); - scr->flags.kwm_syncing_count = 0; + scr->flags.kwm_syncing_count = 0; - } else if (value < scr->workspace_count) { - int i; - Bool rebuild = False; + } else if (value < scr->workspace_count) { + int i; + Bool rebuild = False; - scr->flags.kwm_syncing_count = 1; + scr->flags.kwm_syncing_count = 1; - /* decrease all we can do */ - for (i = scr->workspace_count; i >= value; i--) { - if (!wWorkspaceDelete(scr, i)) { - rebuild = True; - break; - } - } + /* decrease all we can do */ + for (i = scr->workspace_count; i >= value; i--) { + if (!wWorkspaceDelete(scr, i)) { + rebuild = True; + break; + } + } - scr->flags.kwm_syncing_count = 0; + scr->flags.kwm_syncing_count = 0; - /* someone destroyed a workspace that can't be destroyed. - * Reset the hints to reflect our internal state. - */ - if (rebuild) { - wKWMUpdateWorkspaceCountHint(scr); - } - } - } + /* someone destroyed a workspace that can't be destroyed. + * Reset the hints to reflect our internal state. + */ + if (rebuild) { + wKWMUpdateWorkspaceCountHint(scr); + } + } + } } else { - int i; + int i; - processed = False; + processed = False; - for (i = 0; i < MAX_WORKSPACES && i < scr->workspace_count; i++) { - if (event->atom == _XA_KWM_DESKTOP_NAME_[i]) { - char *name; + for (i = 0; i < MAX_WORKSPACES && i < scr->workspace_count; i++) { + if (event->atom == _XA_KWM_DESKTOP_NAME_[i]) { + char *name; - name = wKWMGetWorkspaceName(scr, i); + name = wKWMGetWorkspaceName(scr, i); #ifdef DEBUG1 - printf("got KDE workspace name change to %s\n", name); + printf("got KDE workspace name change to %s\n", name); #endif - if (name && strncmp(name, scr->workspaces[i]->name, - MAX_WORKSPACENAME_WIDTH)!=0) { - scr->flags.kwm_syncing_name = 1; - wWorkspaceRename(scr, i, name); - scr->flags.kwm_syncing_name = 0; - } - if (name) - XFree(name); - processed = True; - break; - } else if (event->atom == _XA_KWM_WINDOW_REGION_[i]) { + if (name && strncmp(name, scr->workspaces[i]->name, + MAX_WORKSPACENAME_WIDTH)!=0) { + scr->flags.kwm_syncing_name = 1; + wWorkspaceRename(scr, i, name); + scr->flags.kwm_syncing_name = 0; + } + if (name) + XFree(name); + processed = True; + break; + } else if (event->atom == _XA_KWM_WINDOW_REGION_[i]) { #if 0 - WArea area; - - if (getAreaHint(scr->root_win, event->atom, &area)) { - - if (scr->totalUsableArea.x1 != area.x1 - || scr->totalUsableArea.y1 != area.y1 - || scr->totalUsableArea.x2 != area.x2 - || scr->totalUsableArea.y2 != area.y2) { - wScreenUpdateUsableArea(scr); - } - } + WArea area; + + if (getAreaHint(scr->root_win, event->atom, &area)) { + + if (scr->totalUsableArea.x1 != area.x1 + || scr->totalUsableArea.y1 != area.y1 + || scr->totalUsableArea.x2 != area.x2 + || scr->totalUsableArea.y2 != area.y2) { + wScreenUpdateUsableArea(scr); + } + } #else - if (i == scr->current_workspace % MAX_WORKSPACES) - wScreenUpdateUsableArea(scr); + if (i == scr->current_workspace % MAX_WORKSPACES) + wScreenUpdateUsableArea(scr); #endif - processed = True; - break; - } - } + processed = True; + break; + } + } } return processed; @@ -1422,44 +1422,44 @@ wKWMManageableClient(WScreen *scr, Window win, char *title) long val; if (getSimpleHint(win, _XA_KWM_DOCKWINDOW, &val) && val) { - addDockWindow(scr, win); - return False; + addDockWindow(scr, win); + return False; } - + ptr = KWMDoNotManageCrap; /* * TODO: support for glob patterns or regexes */ if (ptr && strncmp(ptr->title, title, strlen(ptr->title))==0) { - next = ptr->next; - wfree(ptr); - KWMDoNotManageCrap = next; + next = ptr->next; + wfree(ptr); + KWMDoNotManageCrap = next; #ifdef DEBUG1 - printf("window %s not managed per KDE request\n", title); + printf("window %s not managed per KDE request\n", title); #endif - sendToModules(scr, _XA_KWM_MODULE_WIN_ADD, NULL, win); - sendToModules(scr, _XA_KWM_MODULE_WIN_REMOVE, NULL, win); + sendToModules(scr, _XA_KWM_MODULE_WIN_ADD, NULL, win); + sendToModules(scr, _XA_KWM_MODULE_WIN_REMOVE, NULL, win); - return False; + return False; } else if (ptr) { - while (ptr->next) { - if (strncmp(ptr->next->title, title, strlen(ptr->next->title))==0) { + while (ptr->next) { + if (strncmp(ptr->next->title, title, strlen(ptr->next->title))==0) { #ifdef DEBUG1 - printf("window %s not managed per KDE request\n", title); + printf("window %s not managed per KDE request\n", title); #endif - next = ptr->next->next; - wfree(ptr->next); - ptr->next = next; + next = ptr->next->next; + wfree(ptr->next); + ptr->next = next; - sendToModules(scr, _XA_KWM_MODULE_WIN_ADD, NULL, win); - sendToModules(scr, _XA_KWM_MODULE_WIN_REMOVE, NULL, win); + sendToModules(scr, _XA_KWM_MODULE_WIN_ADD, NULL, win); + sendToModules(scr, _XA_KWM_MODULE_WIN_REMOVE, NULL, win); - return False; - } + return False; + } - ptr = ptr->next; - } + ptr = ptr->next; + } } return True; @@ -1470,10 +1470,10 @@ void wKWMUpdateCurrentWorkspaceHint(WScreen *scr) { setSimpleHint(scr->root_win, _XA_KWM_CURRENT_DESKTOP, - scr->current_workspace+1); + scr->current_workspace+1); sendToModules(scr, _XA_KWM_MODULE_DESKTOP_CHANGE, NULL, - scr->current_workspace+1); + scr->current_workspace+1); } @@ -1484,26 +1484,26 @@ wKWMUpdateActiveWindowHint(WScreen *scr) WWindow *wwin, *tmp; if (!scr->focused_window || !scr->focused_window->flags.focused) - val = None; + val = None; else { - val = (long)(scr->focused_window->client_win); - - /* raise the menubar thing */ - wwin = scr->focused_window; - tmp = wwin->prev; - while (tmp) { - if (tmp->flags.kwm_menubar - && tmp->transient_for == wwin->client_win) { - wRaiseFrame(tmp->frame->core); - break; - } - tmp = tmp->prev; - } + val = (long)(scr->focused_window->client_win); + + /* raise the menubar thing */ + wwin = scr->focused_window; + tmp = wwin->prev; + while (tmp) { + if (tmp->flags.kwm_menubar + && tmp->transient_for == wwin->client_win) { + wRaiseFrame(tmp->frame->core); + break; + } + tmp = tmp->prev; + } } - + XChangeProperty(dpy, scr->root_win, _XA_KWM_ACTIVE_WINDOW, - _XA_KWM_ACTIVE_WINDOW, 32, PropModeReplace, - (unsigned char*)&val, 1); + _XA_KWM_ACTIVE_WINDOW, 32, PropModeReplace, + (unsigned char*)&val, 1); XFlush(dpy); } @@ -1512,13 +1512,13 @@ void wKWMUpdateWorkspaceCountHint(WScreen *scr) { if (scr->flags.kwm_syncing_count) - return; + return; setSimpleHint(scr->root_win, _XA_KWM_NUMBER_OF_DESKTOPS, - scr->workspace_count); + scr->workspace_count); sendToModules(scr, _XA_KWM_MODULE_DESKTOP_NUMBER_CHANGE, NULL, - scr->workspace_count); + scr->workspace_count); } @@ -1528,12 +1528,12 @@ wKWMCheckDestroy(XDestroyWindowEvent *event) WScreen *scr; if (event->event == event->window) { - return; + return; } scr = wScreenSearchForRootWindow(event->event); if (!scr) { - return; + return; } removeModule(scr, event->window); @@ -1549,15 +1549,15 @@ wKWMUpdateWorkspaceNameHint(WScreen *scr, int workspace) assert(workspace >= 0 && workspace < MAX_WORKSPACES); if (_XA_KWM_DESKTOP_NAME_[workspace]==0) { - snprintf(buffer, sizeof(buffer), "KWM_DESKTOP_NAME_%d", workspace + 1); + snprintf(buffer, sizeof(buffer), "KWM_DESKTOP_NAME_%d", workspace + 1); - _XA_KWM_DESKTOP_NAME_[workspace] = XInternAtom(dpy, buffer, False); + _XA_KWM_DESKTOP_NAME_[workspace] = XInternAtom(dpy, buffer, False); } XChangeProperty(dpy, scr->root_win, _XA_KWM_DESKTOP_NAME_[workspace], - XA_STRING, 8, PropModeReplace, - (unsigned char*)scr->workspaces[workspace]->name, - strlen(scr->workspaces[workspace]->name)+1); + XA_STRING, 8, PropModeReplace, + (unsigned char*)scr->workspaces[workspace]->name, + strlen(scr->workspaces[workspace]->name)+1); sendToModules(scr, _XA_KWM_MODULE_DESKTOP_NAME_CHANGE, NULL, workspace+1); } @@ -1569,10 +1569,10 @@ wKWMUpdateClientWorkspace(WWindow *wwin) { #ifdef DEBUG1 printf("updating workspace of %s to %i\n", - wwin->frame->title, wwin->frame->workspace+1); + wwin->frame->title, wwin->frame->workspace+1); #endif - setSimpleHint(wwin->client_win, _XA_KWM_WIN_DESKTOP, - wwin->frame->workspace+1); + setSimpleHint(wwin->client_win, _XA_KWM_WIN_DESKTOP, + wwin->frame->workspace+1); } @@ -1580,12 +1580,12 @@ void wKWMUpdateClientGeometryRestore(WWindow *wwin) { WArea rect; - + rect.x1 = wwin->old_geometry.x; rect.y1 = wwin->old_geometry.y; rect.x2 = wwin->old_geometry.x + wwin->old_geometry.width; rect.y2 = wwin->old_geometry.y + wwin->old_geometry.height; - + setAreaHint(wwin->client_win, _XA_KWM_WIN_GEOMETRY_RESTORE, rect); } @@ -1594,23 +1594,23 @@ void wKWMUpdateClientStateHint(WWindow *wwin, WKWMStateFlag flags) { if (flags & KWMIconifiedFlag) { - setSimpleHint(wwin->client_win, _XA_KWM_WIN_ICONIFIED, - wwin->flags.miniaturized /*|| wwin->flags.shaded - || wwin->flags.hidden*/); + setSimpleHint(wwin->client_win, _XA_KWM_WIN_ICONIFIED, + wwin->flags.miniaturized /*|| wwin->flags.shaded + || wwin->flags.hidden*/); } if (flags & KWMStickyFlag) { - setSimpleHint(wwin->client_win, _XA_KWM_WIN_STICKY, - IS_OMNIPRESENT(wwin)); + setSimpleHint(wwin->client_win, _XA_KWM_WIN_STICKY, + IS_OMNIPRESENT(wwin)); } if (flags & KWMMaximizedFlag) { - int value = 0; + int value = 0; - if (wwin->flags.maximized & MAX_VERTICAL) - value |= 2; - if (wwin->flags.maximized & MAX_HORIZONTAL) - value |= 1; + if (wwin->flags.maximized & MAX_VERTICAL) + value |= 2; + if (wwin->flags.maximized & MAX_HORIZONTAL) + value |= 1; - setSimpleHint(wwin->client_win, _XA_KWM_WIN_MAXIMIZED, value); + setSimpleHint(wwin->client_win, _XA_KWM_WIN_MAXIMIZED, value); } } @@ -1623,20 +1623,20 @@ wKWMGetUsableArea(WScreen *scr, int head, WArea *area) int region = scr->current_workspace % MAX_WORKSPACES; if (_XA_KWM_WINDOW_REGION_[region]==0) { - snprintf(buffer, sizeof(buffer), "KWM_WINDOW_REGION_%d", 1+region); + snprintf(buffer, sizeof(buffer), "KWM_WINDOW_REGION_%d", 1+region); - _XA_KWM_WINDOW_REGION_[region] = XInternAtom(dpy, buffer, False); + _XA_KWM_WINDOW_REGION_[region] = XInternAtom(dpy, buffer, False); } ok = getAreaHint(scr->root_win, _XA_KWM_WINDOW_REGION_[region], area); if (ok) { - WMRect rect = wGetRectForHead(scr, head); + WMRect rect = wGetRectForHead(scr, head); - area->x1 = WMAX(area->x1, rect.pos.x); - area->x2 = WMIN(area->x2, rect.pos.x + rect.size.width); - area->y1 = WMAX(area->y1, rect.pos.y); - area->y2 = WMIN(area->y2, rect.pos.y + rect.size.height); + area->x1 = WMAX(area->x1, rect.pos.x); + area->x2 = WMIN(area->x2, rect.pos.x + rect.size.width); + area->y1 = WMAX(area->y1, rect.pos.y); + area->y2 = WMIN(area->y2, rect.pos.y + rect.size.height); } return ok; @@ -1660,15 +1660,15 @@ wKWMSetUsableAreaHint(WScreen *scr, int workspace) * the next time the area changes, we won't know what should * be the new final area. This protocol isn't worth a shit :/ */ -/* - * According to Matthias Ettrich: - * Indeed, there's no protocol to deal with the area yet in case several - * clients want to influence it. It is sufficent, though, if it is clear - * that one process is responsable for the area. For KDE this is kpanel, but - * I see that there might be a conflict with the docking area of windowmaker - * itself. - * - */ + /* + * According to Matthias Ettrich: + * Indeed, there's no protocol to deal with the area yet in case several + * clients want to influence it. It is sufficent, though, if it is clear + * that one process is responsable for the area. For KDE this is kpanel, but + * I see that there might be a conflict with the docking area of windowmaker + * itself. + * + */ #ifdef notdef char buffer[64]; @@ -1676,13 +1676,13 @@ wKWMSetUsableAreaHint(WScreen *scr, int workspace) assert(workspace >= 0 && workspace < MAX_WORKSPACES); if (_XA_KWM_WINDOW_REGION_[workspace]==0) { - snprintf(buffer, sizeof(buffer), "KWM_WINDOW_REGION_%d", workspace+1); + snprintf(buffer, sizeof(buffer), "KWM_WINDOW_REGION_%d", workspace+1); - _XA_KWM_WINDOW_REGION_[workspace] = XInternAtom(dpy, buffer, False); + _XA_KWM_WINDOW_REGION_[workspace] = XInternAtom(dpy, buffer, False); } setAreaHint(scr->root_win, _XA_KWM_WINDOW_REGION_[workspace], - scr->totalUsableArea); + scr->totalUsableArea); #endif } #endif /* not_used */ @@ -1693,35 +1693,35 @@ wKWMSendEventMessage(WWindow *wwin, WKWMEventMessage message) Atom msg; if (wwin && (wwin->flags.internal_window - || wwin->flags.kwm_hidden_for_modules - || !wwin->flags.kwm_managed - || WFLAGP(wwin, skip_window_list))) - return; + || wwin->flags.kwm_hidden_for_modules + || !wwin->flags.kwm_managed + || WFLAGP(wwin, skip_window_list))) + return; switch (message) { - case WKWMAddWindow: - msg = _XA_KWM_MODULE_WIN_ADD; - break; - case WKWMRemoveWindow: - msg = _XA_KWM_MODULE_WIN_REMOVE; - break; - case WKWMFocusWindow: - msg = _XA_KWM_MODULE_WIN_ACTIVATE; - break; - case WKWMRaiseWindow: - msg = _XA_KWM_MODULE_WIN_RAISE; - break; - case WKWMLowerWindow: - msg = _XA_KWM_MODULE_WIN_LOWER; - break; - case WKWMChangedClient: - msg = _XA_KWM_MODULE_WIN_CHANGE; - break; - case WKWMIconChange: - msg = _XA_KWM_MODULE_WIN_ICON_CHANGE; - break; - default: - return; + case WKWMAddWindow: + msg = _XA_KWM_MODULE_WIN_ADD; + break; + case WKWMRemoveWindow: + msg = _XA_KWM_MODULE_WIN_REMOVE; + break; + case WKWMFocusWindow: + msg = _XA_KWM_MODULE_WIN_ACTIVATE; + break; + case WKWMRaiseWindow: + msg = _XA_KWM_MODULE_WIN_RAISE; + break; + case WKWMLowerWindow: + msg = _XA_KWM_MODULE_WIN_LOWER; + break; + case WKWMChangedClient: + msg = _XA_KWM_MODULE_WIN_CHANGE; + break; + case WKWMIconChange: + msg = _XA_KWM_MODULE_WIN_ICON_CHANGE; + break; + default: + return; } sendToModules(wwin ? wwin->screen_ptr : NULL, msg, wwin, 0); @@ -1756,17 +1756,17 @@ connectKFM(WScreen *scr) ptr = strchr(buffer, ':'); if (ptr) - *ptr = '_'; + *ptr = '_'; ptr = strrchr(buffer, '.'); if (ptr) - *ptr = 0; + *ptr = 0; { - char b[32]; - - snprintf(b, sizeof(b), ".%i", scr->screen); - - buffer = wstrappend(buffer, b); + char b[32]; + + snprintf(b, sizeof(b), ".%i", scr->screen); + + buffer = wstrappend(buffer, b); } path = wstrappend(path, buffer); wfree(buffer); @@ -1775,44 +1775,44 @@ connectKFM(WScreen *scr) f = fopen(path, "rb"); wfree(path); if (!f) - return -1; + return -1; *buf = 0; fgets(buf, sizeof(buf), f); buf[sizeof(buf)] = 0; pid = atoi(buf); if (pid <= 0) - return -1; + return -1; if (kill(pid, 0) != 0) - return -1; + return -1; *buf = 0; fgets(buf, sizeof(buf), f); - buf[sizeof(buf)] = 0; + buf[sizeof(buf)] = 0; fclose(f); sock = socket(AF_UNIX, SOCK_STREAM, 0); if (sock < 0) - return -1; + return -1; addr.sun_family = AF_UNIX; strcpy(addr.sun_path, buf); if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) { - close(sock); - return -1; + close(sock); + return -1; } path = wstrconcat(wgethomedir(), "/.kde/share/apps/kfm/magic"); f = fopen(path, "rb"); wfree(path); if (!f) { - return -1; + return -1; } ptr = fgets(buf, sizeof(buf), f); fclose(f); if (!ptr) { - return -1; + return -1; } puts(buffer); @@ -1835,20 +1835,19 @@ wKWMSelectRootRegion(WScreen *scr, int x, int y, int w, int h, Bool control) puts("CONNECTING"); sock = connectKFM(scr); if (sock < 0) - return; + return; puts("SENDING DATA"); - + sprintf(buffer, "selectRootIcons %i %i %i %i %c", x, y, w, h, control); writeSocket(sock, buffer); - + close(sock); #endif } - - -static void observer(void *self, WMNotification *notif) +static void +observer(void *self, WMNotification *notif) { WScreen *scr = (WScreen*)self; WWindow *wwin = (WWindow*)WMGetNotificationObject(notif); @@ -1856,99 +1855,101 @@ static void observer(void *self, WMNotification *notif) void *data = WMGetNotificationClientData(notif); if (strcmp(name, WMNManaged) == 0 && wwin) { - wKWMUpdateClientWorkspace(wwin); - wKWMUpdateClientStateHint(wwin, KWMAllFlags); - - wwin->flags.kwm_managed = 1; + wKWMUpdateClientWorkspace(wwin); + wKWMUpdateClientStateHint(wwin, KWMAllFlags); + + wwin->flags.kwm_managed = 1; + + wKWMSendEventMessage(wwin, WKWMAddWindow); - wKWMSendEventMessage(wwin, WKWMAddWindow); - } else if (strcmp(name, WMNUnmanaged) == 0 && wwin) { - wwin->frame->workspace = -1; - - wKWMUpdateClientWorkspace(wwin); - - wKWMSendEventMessage(wwin, WKWMRemoveWindow); - + wwin->frame->workspace = -1; + + wKWMUpdateClientWorkspace(wwin); + + wKWMSendEventMessage(wwin, WKWMRemoveWindow); + } else if (strcmp(name, WMNChangedWorkspace) == 0 && wwin) { - wKWMUpdateClientWorkspace(wwin); - wKWMSendEventMessage(wwin, WKWMChangedClient); - + wKWMUpdateClientWorkspace(wwin); + wKWMSendEventMessage(wwin, WKWMChangedClient); + } else if (strcmp(name, WMNChangedFocus) == 0) { - wKWMUpdateActiveWindowHint(scr); - wKWMSendEventMessage(wwin, WKWMFocusWindow); - + wKWMUpdateActiveWindowHint(scr); + wKWMSendEventMessage(wwin, WKWMFocusWindow); + } else if (strcmp(name, WMNChangedName) == 0) { - wKWMSendEventMessage(wwin, WKWMChangedClient); + wKWMSendEventMessage(wwin, WKWMChangedClient); } else if (strcmp(name, WMNChangedState) == 0) { - char *detail = (char*)data; - - if (strcmp(detail, "shade") == 0) { - wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); - wKWMSendEventMessage(wwin, WKWMChangedClient); - } else if (strcmp(detail, "omnipresent") == 0) { - wKWMUpdateClientStateHint(wwin, KWMStickyFlag); - wKWMSendEventMessage(wwin, WKWMChangedClient); - } else if (strcmp(detail, "maximize") == 0) { - wKWMUpdateClientStateHint(wwin, KWMMaximizedFlag); - wKWMSendEventMessage(wwin, WKWMChangedClient); - } else if (strcmp(detail, "iconify-transient") == 0) { - if (wwin->flags.miniaturized) { - wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); - wKWMSendEventMessage(wwin, WKWMRemoveWindow); - wwin->flags.kwm_hidden_for_modules = 1; - } else { - wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); - if (wwin->flags.kwm_hidden_for_modules) { - wKWMSendEventMessage(wwin, WKWMAddWindow); - wwin->flags.kwm_hidden_for_modules = 0; - } - } - } else if (strcmp(detail, "iconify") == 0) { - wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); - wKWMSendEventMessage(wwin, WKWMChangedClient); - } else if (strcmp(detail, "hide") == 0) { - wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); - wKWMSendEventMessage(wwin, WKWMChangedClient); - } + char *detail = (char*)data; + + if (strcmp(detail, "shade") == 0) { + wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); + wKWMSendEventMessage(wwin, WKWMChangedClient); + } else if (strcmp(detail, "omnipresent") == 0) { + wKWMUpdateClientStateHint(wwin, KWMStickyFlag); + wKWMSendEventMessage(wwin, WKWMChangedClient); + } else if (strcmp(detail, "maximize") == 0) { + wKWMUpdateClientStateHint(wwin, KWMMaximizedFlag); + wKWMSendEventMessage(wwin, WKWMChangedClient); + } else if (strcmp(detail, "iconify-transient") == 0) { + if (wwin->flags.miniaturized) { + wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); + wKWMSendEventMessage(wwin, WKWMRemoveWindow); + wwin->flags.kwm_hidden_for_modules = 1; + } else { + wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); + if (wwin->flags.kwm_hidden_for_modules) { + wKWMSendEventMessage(wwin, WKWMAddWindow); + wwin->flags.kwm_hidden_for_modules = 0; + } + } + } else if (strcmp(detail, "iconify") == 0) { + wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); + wKWMSendEventMessage(wwin, WKWMChangedClient); + } else if (strcmp(detail, "hide") == 0) { + wKWMUpdateClientStateHint(wwin, KWMIconifiedFlag); + wKWMSendEventMessage(wwin, WKWMChangedClient); + } } else if (strcmp(name, WMNChangedStacking) == 0 && wwin) { - if (data == NULL) - wKWMBroadcastStacking(wwin->screen_ptr); - else if (strcmp(data, "lower") == 0) - wKWMSendEventMessage(wwin, WKWMLowerWindow); - else if (strcmp(data, "raise") == 0) - wKWMSendEventMessage(wwin, WKWMRaiseWindow); + if (data == NULL) + wKWMBroadcastStacking(wwin->screen_ptr); + else if (strcmp(data, "lower") == 0) + wKWMSendEventMessage(wwin, WKWMLowerWindow); + else if (strcmp(data, "raise") == 0) + wKWMSendEventMessage(wwin, WKWMRaiseWindow); } } -static void wsobserver(void *self, WMNotification *notif) +static void +wsobserver(void *self, WMNotification *notif) { WScreen *scr = (WScreen*)WMGetNotificationObject(notif); const char *name = WMGetNotificationName(notif); void *data = WMGetNotificationClientData(notif); if (strcmp(name, WMNWorkspaceCreated) == 0) { - if (!scr->flags.kwm_syncing_count) { - wKWMUpdateWorkspaceCountHint(scr); - wKWMUpdateWorkspaceNameHint(scr, (int)data); - } + if (!scr->flags.kwm_syncing_count) { + wKWMUpdateWorkspaceCountHint(scr); + wKWMUpdateWorkspaceNameHint(scr, (int)data); + } #ifdef not_used - wKWMSetUsableAreaHint(scr, scr->workspace_count-1); + wKWMSetUsableAreaHint(scr, scr->workspace_count-1); #endif } else if (strcmp(name, WMNWorkspaceDestroyed) == 0) { - wKWMUpdateWorkspaceCountHint(scr); + wKWMUpdateWorkspaceCountHint(scr); } else if (strcmp(name, WMNWorkspaceNameChanged) == 0) { - wKWMUpdateWorkspaceNameHint(scr, (int)data); + wKWMUpdateWorkspaceNameHint(scr, (int)data); } else if (strcmp(name, WMNWorkspaceChanged) == 0) { - wKWMUpdateCurrentWorkspaceHint(scr); + wKWMUpdateCurrentWorkspaceHint(scr); } else if (strcmp(name, WMNResetStacking) == 0) { - wKWMBroadcastStacking(scr); + wKWMBroadcastStacking(scr); } } #endif /* KWM_HINTS */ + diff --git a/src/kwm.h b/src/kwm.h index 3aa6c7dc..2687e117 100644 --- a/src/kwm.h +++ b/src/kwm.h @@ -1,9 +1,9 @@ /* kde.h-- stuff for support for kde hints - * + * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -25,19 +25,19 @@ typedef enum { KWMStickyFlag = (1<<0), - KWMMaximizedFlag = (1<<1), - KWMIconifiedFlag = (1<<2), - KWMAllFlags = 7 + KWMMaximizedFlag = (1<<1), + KWMIconifiedFlag = (1<<2), + KWMAllFlags = 7 } WKWMStateFlag; typedef enum { WKWMAddWindow, - WKWMRemoveWindow, - WKWMFocusWindow, - WKWMRaiseWindow, - WKWMLowerWindow, - WKWMChangedClient, - WKWMIconChange + WKWMRemoveWindow, + WKWMFocusWindow, + WKWMRaiseWindow, + WKWMLowerWindow, + WKWMChangedClient, + WKWMIconChange } WKWMEventMessage; @@ -95,8 +95,8 @@ char *wKWMGetWorkspaceName(WScreen *scr, int workspace); Bool wKWMGetIconGeometry(WWindow *wwin, WArea *area); -void wKWMSelectRootRegion(WScreen *scr, int x, int y, int w, int h, - Bool control); +void wKWMSelectRootRegion(WScreen *scr, int x, int y, int w, int h, + Bool control); #endif diff --git a/src/main.c b/src/main.c index 9f6a23d5..938d2bb0 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -189,7 +189,7 @@ Exit(int status) wSessionDisconnectManager(); #endif if (dpy) - XCloseDisplay(dpy); + XCloseDisplay(dpy); exit(status); } @@ -203,20 +203,20 @@ Restart(char *manager, Bool abortOnFailure) int i; if (manager && manager[0]!=0) { - prog = argv[0] = strtok(manager, " "); - for (i=1; iscreen); - strcat(tmp, buf); - putenv(tmp); + int len = strlen(DisplayName)+64; + tmp = wmalloc(len); + snprintf(tmp, len, "DISPLAY=%s", XDisplayName(DisplayName)); + ptr = strchr(strchr(tmp, ':'), '.'); + if (ptr) + *ptr = 0; + snprintf(buf, sizeof(buf), ".%i", scr->screen); + strcat(tmp, buf); + putenv(tmp); } tmp = wmalloc(60); - snprintf(tmp, 60, "WRASTER_COLOR_RESOLUTION%i=%i", scr->screen, - scr->rcontext->attribs->colors_per_channel); + snprintf(tmp, 60, "WRASTER_COLOR_RESOLUTION%i=%i", scr->screen, + scr->rcontext->attribs->colors_per_channel); putenv(tmp); } @@ -267,16 +267,16 @@ static void shellCommandHandler(pid_t pid, unsigned char status, _tuple *data) { if (status == 127) { - char *buffer; + char *buffer; - buffer = wstrconcat(_("Could not execute command: "), data->command); + buffer = wstrconcat(_("Could not execute command: "), data->command); - wMessageDialog(data->scr, _("Error"), buffer, _("OK"), NULL, NULL); - wfree(buffer); + wMessageDialog(data->scr, _("Error"), buffer, _("OK"), NULL, NULL); + wfree(buffer); } else if (status != 127) { - /* - printf("%s: %i\n", data->command, status); - */ + /* + printf("%s: %i\n", data->command, status); + */ } wfree(data->command); @@ -294,35 +294,35 @@ ExecuteShellCommand(WScreen *scr, char *command) * This have a problem: if the shell is tcsh (not sure about others) * and ~/.tcshrc have /bin/stty erase ^H somewhere on it, the shell * will block and the command will not be executed. - if (!shell) { - shell = getenv("SHELL"); - if (!shell) - shell = "/bin/sh"; - } + if (!shell) { + shell = getenv("SHELL"); + if (!shell) + shell = "/bin/sh"; + } */ shell = "/bin/sh"; pid = fork(); - + if (pid==0) { - SetupEnvironment(scr); + SetupEnvironment(scr); #ifdef HAVE_SETSID setsid(); #endif - execl(shell, shell, "-c", command, NULL); - wsyserror("could not execute %s -c %s", shell, command); - Exit(-1); + execl(shell, shell, "-c", command, NULL); + wsyserror("could not execute %s -c %s", shell, command); + Exit(-1); } else if (pid < 0) { - wsyserror("cannot fork a new process"); + wsyserror("cannot fork a new process"); } else { - _tuple *data = wmalloc(sizeof(_tuple)); - - data->scr = scr; - data->command = wstrdup(command); + _tuple *data = wmalloc(sizeof(_tuple)); + + data->scr = scr; + data->command = wstrdup(command); - wAddDeathHandler(pid, (WDeathHandler*)shellCommandHandler, data); + wAddDeathHandler(pid, (WDeathHandler*)shellCommandHandler, data); } } @@ -341,69 +341,69 @@ StartLogShell(WScreen *scr) int out_fd[2]; int err_fd[2]; pid_t pid; - + SetupEnvironment(scr); - + if (pipe(in_fd) < 0) { - wsyserror("could not create pipe for log shell\n"); - return; + wsyserror("could not create pipe for log shell\n"); + return; } if (pipe(out_fd) < 0) { - wsyserror("could not create pipe for log shell\n"); - close(in_fd[0]); - close(in_fd[1]); - return; + wsyserror("could not create pipe for log shell\n"); + close(in_fd[0]); + close(in_fd[1]); + return; } if (pipe(err_fd) < 0) { - wsyserror("could not create pipe for log shell\n"); - close(out_fd[0]); - close(out_fd[1]); - close(in_fd[0]); - close(in_fd[1]); - return; + wsyserror("could not create pipe for log shell\n"); + close(out_fd[0]); + close(out_fd[1]); + close(in_fd[0]); + close(in_fd[1]); + return; } pid = fork(); if (pid < 0) { - wsyserror("could not fork a new process for log shell\n"); - return; - } else if (pid == 0) { - close(in_fd[0]); - close(out_fd[1]); - close(err_fd[1]); - - close(0); - close(1); - close(2); - - if (dup2(in_fd[1], 0) < 0) { - wsyserror("could not redirect stdin for log shell\n"); - exit(1); - } - if (dup2(out_fd[1], 1) < 0) { - wsyserror("could not redirect stdout for log shell\n"); - exit(1); - } - if (dup2(err_fd[1], 2) < 0) { - wsyserror("could not redirect stderr for log shell\n"); - exit(1); - } - - close(in_fd[1]); - close(out_fd[1]); - close(err_fd[1]); - - execl("/bin/sh", "/bin/sh", "-c", wPreferences.logger_shell, NULL); - wsyserror("could not execute %s\n", wPreferences.logger_shell); - exit(1); + wsyserror("could not fork a new process for log shell\n"); + return; + } else if (pid == 0) { + close(in_fd[0]); + close(out_fd[1]); + close(err_fd[1]); + + close(0); + close(1); + close(2); + + if (dup2(in_fd[1], 0) < 0) { + wsyserror("could not redirect stdin for log shell\n"); + exit(1); + } + if (dup2(out_fd[1], 1) < 0) { + wsyserror("could not redirect stdout for log shell\n"); + exit(1); + } + if (dup2(err_fd[1], 2) < 0) { + wsyserror("could not redirect stderr for log shell\n"); + exit(1); + } + + close(in_fd[1]); + close(out_fd[1]); + close(err_fd[1]); + + execl("/bin/sh", "/bin/sh", "-c", wPreferences.logger_shell, NULL); + wsyserror("could not execute %s\n", wPreferences.logger_shell); + exit(1); } else { - close(in_fd[1]); - close(out_fd[0]); - close(err_fd[0]); - - LogStdIn = in_fd[1]; - LogStdOut = out_fd[0]; - LogStdErr = err_fd[0]; + close(in_fd[1]); + close(out_fd[0]); + close(err_fd[0]); + + LogStdIn = in_fd[1]; + LogStdOut = out_fd[0]; + LogStdErr = err_fd[0]; } } @@ -412,8 +412,8 @@ StartLogShell(WScreen *scr) *--------------------------------------------------------------------- * wAbort-- * Do a major cleanup and exit the program - * - *---------------------------------------------------------------------- + * + *---------------------------------------------------------------------- */ void wAbort(Bool dumpCore) @@ -422,15 +422,15 @@ wAbort(Bool dumpCore) WScreen *scr; for (i=0; i1) { - for (i=1; i=argc) { - wwarning(_("too few arguments for %s"), argv[i-1]); - exit(0); - } - Locale = argv[i]; - } else if (strcmp(argv[i], "-display")==0 - || strcmp(argv[i], "--display")==0) { - i++; - if (i>=argc) { - wwarning(_("too few arguments for %s"), argv[i-1]); - exit(0); - } - DisplayName = argv[i]; - } else if (strcmp(argv[i], "-visualid")==0 - || strcmp(argv[i], "--visual-id")==0) { - i++; - if (i>=argc) { - wwarning(_("too few arguments for %s"), argv[i-1]); - exit(0); - } - if (sscanf(argv[i], "%i", &wVisualID)!=1) { - wwarning(_("bad value for visualid: \"%s\""), argv[i]); - exit(0); - } - } else if (strcmp(argv[i], "-static")==0 - || strcmp(argv[i], "--static")==0) { - - wPreferences.flags.noupdates = 1; - } else if (strcmp(argv[i], "-nopolling")==0 - || strcmp(argv[i], "--no-polling")==0) { - - wPreferences.flags.nopolling = 1; + } else if (strcmp(argv[i], "-locale")==0 + || strcmp(argv[i], "--locale")==0) { + i++; + if (i>=argc) { + wwarning(_("too few arguments for %s"), argv[i-1]); + exit(0); + } + Locale = argv[i]; + } else if (strcmp(argv[i], "-display")==0 + || strcmp(argv[i], "--display")==0) { + i++; + if (i>=argc) { + wwarning(_("too few arguments for %s"), argv[i-1]); + exit(0); + } + DisplayName = argv[i]; + } else if (strcmp(argv[i], "-visualid")==0 + || strcmp(argv[i], "--visual-id")==0) { + i++; + if (i>=argc) { + wwarning(_("too few arguments for %s"), argv[i-1]); + exit(0); + } + if (sscanf(argv[i], "%i", &wVisualID)!=1) { + wwarning(_("bad value for visualid: \"%s\""), argv[i]); + exit(0); + } + } else if (strcmp(argv[i], "-static")==0 + || strcmp(argv[i], "--static")==0) { + + wPreferences.flags.noupdates = 1; + } else if (strcmp(argv[i], "-nopolling")==0 + || strcmp(argv[i], "--no-polling")==0) { + + wPreferences.flags.nopolling = 1; #ifdef XSMP_ENABLED - } else if (strcmp(argv[i], "-clientid")==0 - || strcmp(argv[i], "-restore")==0) { - i++; - if (i>=argc) { - wwarning(_("too few arguments for %s"), argv[i-1]); - exit(0); - } + } else if (strcmp(argv[i], "-clientid")==0 + || strcmp(argv[i], "-restore")==0) { + i++; + if (i>=argc) { + wwarning(_("too few arguments for %s"), argv[i-1]); + exit(0); + } #endif - } else if (strcmp(argv[i], "--help")==0) { - print_help(); - exit(0); - } else { - printf(_("%s: invalid argument '%s'\n"), argv[0], argv[i]); - printf(_("Try '%s --help' for more information\n"), argv[0]); - exit(1); - } - } + } else if (strcmp(argv[i], "--help")==0) { + print_help(); + exit(0); + } else { + printf(_("%s: invalid argument '%s'\n"), argv[0], argv[i]); + printf(_("Try '%s --help' for more information\n"), argv[0]); + exit(1); + } + } } - + if (!wPreferences.flags.noupdates) { - /* check existence of Defaults DB directory */ - check_defaults(); + /* check existence of Defaults DB directory */ + check_defaults(); } @@ -734,7 +734,7 @@ main(int argc, char **argv) setlocale(LC_ALL, ""); - if (!Locale || strcmp(Locale, "C")==0 || strcmp(Locale, "POSIX")==0) + if (!Locale || strcmp(Locale, "C")==0 || strcmp(Locale, "POSIX")==0) Locale = NULL; #ifdef I18N if (getenv("NLSPATH")) @@ -744,50 +744,50 @@ main(int argc, char **argv) textdomain("WindowMaker"); if (!XSupportsLocale()) { - wwarning(_("X server does not support locale")); + wwarning(_("X server does not support locale")); } if (XSetLocaleModifiers("") == NULL) { - wwarning(_("cannot set locale modifiers")); + wwarning(_("cannot set locale modifiers")); } #endif if (Locale) { - char *ptr; + char *ptr; - Locale = wstrdup(Locale); - ptr = strchr(Locale, '.'); - if (ptr) - *ptr = 0; + Locale = wstrdup(Locale); + ptr = strchr(Locale, '.'); + if (ptr) + *ptr = 0; } /* open display */ dpy = XOpenDisplay(DisplayName); if (dpy == NULL) { - wfatal(_("could not open display \"%s\""), XDisplayName(DisplayName)); - exit(1); + wfatal(_("could not open display \"%s\""), XDisplayName(DisplayName)); + exit(1); } if (fcntl(ConnectionNumber(dpy), F_SETFD, FD_CLOEXEC) < 0) { - wsyserror("error setting close-on-exec flag for X connection"); - exit(1); + wsyserror("error setting close-on-exec flag for X connection"); + exit(1); } /* check if the user specified a complete display name (with screen). * If so, only manage the specified screen */ if (DisplayName) - str = strchr(DisplayName, ':'); + str = strchr(DisplayName, ':'); else - str = NULL; + str = NULL; if (str && sscanf(str, ":%i.%i", &d, &s)==2) - multiHead = False; + multiHead = False; DisplayName = XDisplayName(DisplayName); { - int len = strlen(DisplayName)+64; - str = wmalloc(len); - snprintf(str, len, "DISPLAY=%s", DisplayName); + int len = strlen(DisplayName)+64; + str = wmalloc(len); + snprintf(str, len, "DISPLAY=%s", DisplayName); } putenv(str); @@ -801,14 +801,15 @@ main(int argc, char **argv) #ifdef XSMP_ENABLED wSessionConnectManager(argv, argc); #endif - + StartUp(!multiHead); - + if (wScreenCount==1) - multiHead = False; + multiHead = False; execInitScript(); EventLoop(); return -1; } + diff --git a/src/menu.c b/src/menu.c index 18496093..02968a36 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2260,7 +2260,7 @@ byebye: ((WMenu*)desc->parent)->flags.inside_handler = 0; #ifdef VIRTUAL_DESKTOP - wWorkspaceRaiseEdge(scr); + wWorkspaceRaiseEdge(scr); #endif } diff --git a/src/menu.h b/src/menu.h index 29d55af4..c9a72dfa 100644 --- a/src/menu.h +++ b/src/menu.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -42,11 +42,11 @@ typedef struct WMenuEntry { WMPropList *instances; /* allowed instances */ #endif /* USER_MENU */ struct { - unsigned int enabled:1; /* entry is selectable */ - unsigned int indicator:1; /* left indicator */ - unsigned int indicator_on:1; - unsigned int indicator_type:3; - unsigned int editable:1; + unsigned int enabled:1; /* entry is selectable */ + unsigned int indicator:1; /* left indicator */ + unsigned int indicator_on:1; + unsigned int indicator_type:3; + unsigned int editable:1; } flags; } WMenuEntry; @@ -56,8 +56,8 @@ typedef struct WMenu { struct WMenu *brother; time_t timestamp; /* for the root menu. Last time - * menu was reloaded */ - + * menu was reloaded */ + /* decorations */ struct WFrameWindow *frame; WCoreWindow *menu; /* the window menu */ @@ -65,41 +65,41 @@ typedef struct WMenu { int frame_x, frame_y; /* position of the frame in root*/ WMenuEntry **entries; /* array of entries. This is shared - * by the menu and it's "brother" */ + * by the menu and it's "brother" */ short alloced_entries; /* number of entries allocated in - * entry array */ + * entry array */ struct WMenu **cascades; /* array of cascades */ short cascade_no; - + short entry_no; /* number of entries */ short selected_entry; - + short entry_height; /* height of each entry */ WMHandlerID timer; /* timer for the autoscroll */ - - void *jump_back; /* jump back data */ - + + void *jump_back; /* jump back data */ + /* to be called when some entry is edited */ void (*on_edit)(struct WMenu *menu, struct WMenuEntry *entry); /* to be called when destroyed */ void (*on_destroy)(struct WMenu *menu); struct { - unsigned int titled:1; - unsigned int realized:1; /* whether the window was configured */ - unsigned int app_menu:1; /* this is a application or root menu */ - unsigned int mapped:1; /* if menu is already mapped on screen*/ - unsigned int buttoned:1; /* if the close button is visible - * (menu was torn off) */ - unsigned int open_to_left:1; /* direction to open submenus */ - unsigned int lowered:1; - - unsigned int brother:1; /* if this is a copy of the menu*/ - unsigned int editing:1; - unsigned int jump_back_pending:1; - - unsigned int inside_handler:1; + unsigned int titled:1; + unsigned int realized:1; /* whether the window was configured */ + unsigned int app_menu:1; /* this is a application or root menu */ + unsigned int mapped:1; /* if menu is already mapped on screen*/ + unsigned int buttoned:1; /* if the close button is visible + * (menu was torn off) */ + unsigned int open_to_left:1; /* direction to open submenus */ + unsigned int lowered:1; + + unsigned int brother:1; /* if this is a copy of the menu*/ + unsigned int editing:1; + unsigned int jump_back_pending:1; + + unsigned int inside_handler:1; } flags; } WMenu; @@ -107,16 +107,16 @@ typedef struct WMenu { void wMenuPaint(WMenu *menu); void wMenuDestroy(WMenu *menu, int recurse); void wMenuRealize(WMenu *menu); -WMenuEntry *wMenuInsertCascade(WMenu *menu, int index, char *text, - WMenu *cascade); -WMenuEntry *wMenuInsertCallback(WMenu *menu, int index, char *text, - void (*callback)(WMenu *menu, WMenuEntry *entry), - void *clientdata); +WMenuEntry *wMenuInsertCascade(WMenu *menu, int index, char *text, + WMenu *cascade); +WMenuEntry *wMenuInsertCallback(WMenu *menu, int index, char *text, + void (*callback)(WMenu *menu, WMenuEntry *entry), + void *clientdata); void wMenuEntrySetCascade(WMenu *menu, WMenuEntry *entry, WMenu *cascade); #define wMenuAddCallback(menu, text, callback, data) \ - wMenuInsertCallback(menu, -1, text, callback, data) + wMenuInsertCallback(menu, -1, text, callback, data) void wMenuRemoveItem(WMenu *menu, int index); diff --git a/src/menureader.c b/src/menureader.c index 56ff7872..6aa3cf6d 100644 --- a/src/menureader.c +++ b/src/menureader.c @@ -1,9 +1,9 @@ /* menureader.c- root menu definition readers - * + * * Window Maker window manager - * + * * Copyright (c) 2000-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -39,11 +39,11 @@ typedef struct PLMenuReaderData { WMPropList *pl; int curIndex; - + WMPropList **submenu; int *curSubIndex; int submenuDepth; - + } PLMenuReaderData; @@ -51,13 +51,13 @@ typedef struct TextMenuReaderData { WRootMenuReader *reader; FILE *file; - + } TextMenuReaderData; typedef struct PipeMenuReaderData { WRootMenuReader *reader; - + } PipeMenuReaderData; @@ -70,9 +70,9 @@ typedef struct DirMenuReaderData { } DirMenuReaderData; /* -typedef struct GNOMEMenuReaderData { -} GNOMEMenuReaderData; -*/ + typedef struct GNOMEMenuReaderData { + } GNOMEMenuReaderData; + */ @@ -81,10 +81,10 @@ typedef struct GNOMEMenuReaderData { static WRootMenuData *pl_openMenu(WMPropList *pl); static Bool pl_hasMoreData(WRootMenuData *data); static Bool pl_nextCommand(WRootMenuData *data, - char **title, - char **command, - char **parameter, - char **shortcut); + char **title, + char **command, + char **parameter, + char **shortcut); static void pl_closeMenuFile(WRootMenuData *data); @@ -92,20 +92,20 @@ static void pl_closeMenuFile(WRootMenuData *data); static WRootMenuData *text_openMenuFile(char *path); static Bool text_hasMoreData(WRootMenuData *data); static Bool text_nextCommand(WRootMenuData *data, - char **title, - char **command, - char **parameter, - char **shortcut); + char **title, + char **command, + char **parameter, + char **shortcut); static void text_closeMenuFile(WRootMenuData *data); static WRootMenuData *dir_openMenuFile(char *path); static Bool dir_hasMoreData(WRootMenuData *data); static Bool dir_nextCommand(WRootMenuData *data, - char **title, - char **command, - char **parameter, - char **shortcut); + char **title, + char **command, + char **parameter, + char **shortcut); static void dir_closeMenuFile(WRootMenuData *data); @@ -114,27 +114,27 @@ static void dir_closeMenuFile(WRootMenuData *data); static WRootMenuReader PLMenuReader = { - pl_hasMoreData, - pl_nextCommand, - pl_closeMenuFile + pl_hasMoreData, + pl_nextCommand, + pl_closeMenuFile }; static WRootMenuReader TextMenuReader = { - text_hasMoreData, - text_nextCommand, - text_closeMenuFile + text_hasMoreData, + text_nextCommand, + text_closeMenuFile }; static WRootMenuReader DirMenuReaderData = { - dir_hasMoreData, - dir_nextCommand, - dir_closeMenuFile + dir_hasMoreData, + dir_nextCommand, + dir_closeMenuFile }; /* -WRootMenuReader GNOMEMenuReaderData = { -}; -*/ + WRootMenuReader GNOMEMenuReaderData = { + }; + */ @@ -148,7 +148,8 @@ static char linebuf[LINESIZE]; /* ---------- proplist ---------- */ -static WRootMenuData *pl_openMenuFile(WMPropList *pl) +static WRootMenuData* +pl_openMenuFile(WMPropList *pl) { PLRootMenuData *data = wmalloc(sizeof(PLRootMenuData)); @@ -165,29 +166,29 @@ static WRootMenuData *pl_openMenuFile(WMPropList *pl) } -static Bool pl_hasMoreData(WRootMenuData *data) +static Bool +pl_hasMoreData(WRootMenuData *data) { } -static Bool pl_nextCommand(WRootMenuData *data, - char **title, - char **command, - char **parameter, - char **shortcut) +static Bool +pl_nextCommand(WRootMenuData *data, char **title, char **command, + char **parameter, char **shortcut) { } -static void pl_closeMenuFile(WRootMenuData *data) +static void +pl_closeMenuFile(WRootMenuData *data) { if (data->submenu) - wfree(data->submenu); + wfree(data->submenu); if (data->curSubIndex) - wfree(data->curSubIndex); + wfree(data->curSubIndex); WMReleasePropList(data->pl); - + wfree(data); } @@ -195,36 +196,37 @@ static void pl_closeMenuFile(WRootMenuData *data) /* ---------- text ---------- */ -static WRootMenuData *text_openMenuFile(char *path) +static WRootMenuData* +text_openMenuFile(char *path) { TextMenuReaderData *data; - + data = wmalloc(sizeof(TextMenuReaderData)); data->reader = TextMenuReader; - + data->file = fopen(path, "rb"); if (!data->file) { - return NULL; + return NULL; } } -static Bool text_hasMoreData(WRootMenuData *data) +static Bool +text_hasMoreData(WRootMenuData *data) { } -static Bool text_nextCommand(WRootMenuData *data, - char **title, - char **command, - char **parameter, - char **shortcut) +static Bool +text_nextCommand(WRootMenuData *data, char **title, char **command, + char **parameter, char **shortcut) { } -static void text_closeMenuFile(WRootMenuData *data) +static void +text_closeMenuFile(WRootMenuData *data) { } @@ -232,7 +234,8 @@ static void text_closeMenuFile(WRootMenuData *data) /* ---------- directory ---------- */ -static WRootMenuData *dir_openMenuFile(char *paths, time_t *timestamp) +static WRootMenuData* +dir_openMenuFile(char *paths, time_t *timestamp) { DirMenuReaderData *data; char **dirs; @@ -245,119 +248,117 @@ static WRootMenuData *dir_openMenuFile(char *paths, time_t *timestamp) wtokensplit(paths, &dirs, &dirN); if (dirN == 0) { - return NULL; + return NULL; } for (c = 0, i = 0; i < dirN; i++) { - char *tmp; - - if (strcmp(dirs[i], "-noext")==0) { - i++; - continue; - } - - tmp = wexpandpath(dirs[i]); - wfree(dirs[i]); - dirs[i] = tmp; - - if (stat(dirs[i], &stat_buf)<0) { - wsyserror(_("%s:could not stat menu"), dirs[i]); - wfree(dirs[i]); - dirs[i] = NULL; - } else { - c++; - checksum += stat_buf.st_mtime; - } + char *tmp; + + if (strcmp(dirs[i], "-noext")==0) { + i++; + continue; + } + + tmp = wexpandpath(dirs[i]); + wfree(dirs[i]); + dirs[i] = tmp; + + if (stat(dirs[i], &stat_buf)<0) { + wsyserror(_("%s:could not stat menu"), dirs[i]); + wfree(dirs[i]); + dirs[i] = NULL; + } else { + c++; + checksum += stat_buf.st_mtime; + } } if (*timestamp == checksum && *timestamp != 0) { - return NULL; + return NULL; } if (c == 0) { - for (i = 0; i < dirN; i++) { - if (dirs[i]) - wfree(dirs[i]); - } - wfree(dirs); - - return NULL; + for (i = 0; i < dirN; i++) { + if (dirs[i]) + wfree(dirs[i]); + } + wfree(dirs); + + return NULL; } - + data = wmalloc(sizeof(DirMenuReaderData)); data->reader = DirMenuReader; - - - + + + } -static Bool dir_hasMoreData(WRootMenuData *data) +static Bool +dir_hasMoreData(WRootMenuData *data) { } -static Bool dir_nextCommand(WRootMenuData *data, - char **title, - char **command, - char **parameter, - char **shortcut) +static Bool +dir_nextCommand(WRootMenuData *data, char **title, char **command, + char **parameter, char **shortcut) { } -static void dir_closeMenuFile(WRootMenuData *data) +static void +dir_closeMenuFile(WRootMenuData *data) { } - - - -WRootMenuData *OpenMenu(char *path, time_t *menuTime) +WRootMenuData* +OpenMenu(char *path, time_t *menuTime) { proplist pl; struct stat stat_buf; WRootMenuData *data; - + /* check whether it's a piped menu */ if (*path == '|') { - /* piped menus have the following semantics for menuTime: - * if it's 0, then it wasnt loaded yet - * if it's 1, it was already loaded, so do not reload - * (would be too slow) - * now, menuTime will only be set to 1 if the pipe command is - * specified as ||command instead of |command - * in other words ||command means force the submenu to always refresh - */ - if (*menuTime == 0) { - data = pipe_openMenu(path); - } - if (path[1] != '|') { - *menuTime = 1; - } - return data; + /* piped menus have the following semantics for menuTime: + * if it's 0, then it wasnt loaded yet + * if it's 1, it was already loaded, so do not reload + * (would be too slow) + * now, menuTime will only be set to 1 if the pipe command is + * specified as ||command instead of |command + * in other words ||command means force the submenu to always refresh + */ + if (*menuTime == 0) { + data = pipe_openMenu(path); + } + if (path[1] != '|') { + *menuTime = 1; + } + return data; } if (stat(path, &stat_buf) < 0) { - wsyserror(_("could not stat() menu file '%s'")); - return NULL; + wsyserror(_("could not stat() menu file '%s'")); + return NULL; } - + /* check whether it's a directory */ if (S_ISDIR(stat_buf.st_mode)) { - return dir_openMenuFile(path, menuTime); + return dir_openMenuFile(path, menuTime); } if (*menuTime >= stat_buf.st_mtime && *menuTime != 0) { - /* no changes in the menu file */ - return NULL; + /* no changes in the menu file */ + return NULL; } /* then check whether it's a proplist menu */ pl = WMReadPropListFromFile(path); if (pl && WMIsPLArray(pl)) { - *menuTime = stat_buf.st_mtime; - return pl_openMenu(pl); + *menuTime = stat_buf.st_mtime; + return pl_openMenu(pl); } *menuTime = stat_buf.st_mtime; @@ -366,97 +367,95 @@ WRootMenuData *OpenMenu(char *path, time_t *menuTime) } - -WRootMenuData *ReopenRootMenu(time_t *checkTime, - char **menuPath, - time_t *menuTimestamp) +WRootMenuData* +ReopenRootMenu(time_t *checkTime, char **menuPath, time_t *menuTimestamp) { proplist pl; struct stat stat_buf; char *path; - + if (stat(path, &stat_buf) < 0) { - wsyserror(_("could not stat() menu file '%s'")); - return NULL; + wsyserror(_("could not stat() menu file '%s'")); + return NULL; } if (*menuTime >= stat_buf.st_mtime && *checkTime != 0) { - /* no changes in WMRootMenu, see if the contents changed */ - if (*menuPath != NULL) { - return OpenMenu(*menuPath, menuTimestamp); - } else { - return NULL; - } + /* no changes in WMRootMenu, see if the contents changed */ + if (*menuPath != NULL) { + return OpenMenu(*menuPath, menuTimestamp); + } else { + return NULL; + } } *checkTime = stat_buf.st_mtime; pl = WMReadPropListFromFile(path); if (!pl) { - wwarning(_("could not load domain %s from user defaults database"), - "WMRootMenu"); - return NULL; + wwarning(_("could not load domain %s from user defaults database"), + "WMRootMenu"); + return NULL; } if (WMIsPLString(pl)) { - char *tmp; - char *path; - Bool menu_is_default = False; - - tmp = wexpandpath(WMGetFromPLString(pl)); - - path = getLocalizedMenuFile(tmp); - - if (!path) { - path = wfindfile(DEF_CONFIG_PATHS, tmp); - } - - if (!path) { - wwarning(_("could not find menu file '%s' referenced in WMRootMenu"), - tmp); - path = wfindfile(DEF_CONFIG_PATHS, DEF_MENU_FILE); - menu_is_default = True; - } - - if (!path) { - wwarning(_("could not find any usable menu files. Please check '%s'"), - tmp); - wfree(tmp); - return NULL; - } - - wfree(tmp); - - if (*menuPath) { - if (strcmp(*menuPath, path) != 0) { - *menuTimestamp = 0; - wfree(*menuPath); - *menuPath = path; - - if (menu_is_default) { - wwarning(_("using default menu file \"%s\" as the menu referenced in WMRootMenu could not be found "), - path); - } - } else { - /* the menu path didn't change, but the - * pointed file might have changed, so we don't return - */ - } - } else { - *menuPath = path; - } - - return OpenMenu(*menuPath, menuTimestamp); + char *tmp; + char *path; + Bool menu_is_default = False; + + tmp = wexpandpath(WMGetFromPLString(pl)); + + path = getLocalizedMenuFile(tmp); + + if (!path) { + path = wfindfile(DEF_CONFIG_PATHS, tmp); + } + + if (!path) { + wwarning(_("could not find menu file '%s' referenced in WMRootMenu"), + tmp); + path = wfindfile(DEF_CONFIG_PATHS, DEF_MENU_FILE); + menu_is_default = True; + } + + if (!path) { + wwarning(_("could not find any usable menu files. Please check '%s'"), + tmp); + wfree(tmp); + return NULL; + } + + wfree(tmp); + + if (*menuPath) { + if (strcmp(*menuPath, path) != 0) { + *menuTimestamp = 0; + wfree(*menuPath); + *menuPath = path; + + if (menu_is_default) { + wwarning(_("using default menu file \"%s\" as the menu referenced in WMRootMenu could not be found "), + path); + } + } else { + /* the menu path didn't change, but the + * pointed file might have changed, so we don't return + */ + } + } else { + *menuPath = path; + } + + return OpenMenu(*menuPath, menuTimestamp); } else if (WMIsPLArray(pl)) { - *menuTimestamp = stat_buf.st_mtime; + *menuTimestamp = stat_buf.st_mtime; - return pl_openMenu(pl); + return pl_openMenu(pl); } else { - wwarning(_("invalid content in menu file '%s'.\nIt should either be a property list menu or the path to the file, enclosed in \"."), - path); - return NULL; + wwarning(_("invalid content in menu file '%s'.\nIt should either be a property list menu or the path to the file, enclosed in \"."), + path); + return NULL; } } diff --git a/src/misc.c b/src/misc.c index 17dc4917..63ef2ba5 100644 --- a/src/misc.c +++ b/src/misc.c @@ -66,8 +66,8 @@ static void putdef(char *line, char *name, char *value) { if (!value) { - wwarning(_("could not define value for %s for cpp"), name); - return; + wwarning(_("could not define value for %s for cpp"), name); + return; } strcat(line, name); strcat(line, value); @@ -92,18 +92,18 @@ username() tmp = getlogin(); if (!tmp) { - struct passwd *user; - - user = getpwuid(getuid()); - if (!user) { - wsyserror(_("could not get password entry for UID %i"), getuid()); - return NULL; - } - if (!user->pw_name) { - return NULL; - } else { - return user->pw_name; - } + struct passwd *user; + + user = getpwuid(getuid()); + if (!user) { + wsyserror(_("could not get password entry for UID %i"), getuid()); + return NULL; + } + if (!user->pw_name) { + return NULL; + } else { + return user->pw_name; + } } return tmp; } @@ -120,21 +120,21 @@ MakeCPPArgs(char *path) *line = 0; i=1; if ((buf=getenv("HOSTNAME"))!=NULL) { - if (buf[0]=='(') { - wwarning(_("your machine is misconfigured. HOSTNAME is set to %s"), - buf); - } else - putdef(line, " -DHOST=", buf); + if (buf[0]=='(') { + wwarning(_("your machine is misconfigured. HOSTNAME is set to %s"), + buf); + } else + putdef(line, " -DHOST=", buf); } else if ((buf=getenv("HOST"))!=NULL) { - if (buf[0]=='(') { - wwarning(_("your machine is misconfigured. HOST is set to %s"), - buf); - } else - putdef(line, " -DHOST=", buf); + if (buf[0]=='(') { + wwarning(_("your machine is misconfigured. HOST is set to %s"), + buf); + } else + putdef(line, " -DHOST=", buf); } buf = username(); if (buf) - putdef(line, " -DUSER=", buf); + putdef(line, " -DUSER=", buf); putidef(line, " -DUID=", getuid()); buf = XDisplayName(DisplayString(dpy)); putdef(line, " -DDISPLAY=", buf); @@ -147,22 +147,22 @@ MakeCPPArgs(char *path) putidef(line, " -DSCR_WIDTH=", WidthOfScreen(DefaultScreenOfDisplay(dpy))); putidef(line, " -DSCR_HEIGHT=", - HeightOfScreen(DefaultScreenOfDisplay(dpy))); + HeightOfScreen(DefaultScreenOfDisplay(dpy))); /* put the dir where the menu is being read from to the * search path */ if (path) { - tmp = wstrdup(path); - buf = strchr(tmp+1, ' '); - if (buf) { - *buf = 0; - } - buf = strrchr(tmp, '/'); - if (buf) { - *buf = 0; /* trunc filename */ - putdef(line, " -I", tmp); - } - wfree(tmp); + tmp = wstrdup(path); + buf = strchr(tmp+1, ' '); + if (buf) { + *buf = 0; + } + buf = strrchr(tmp, '/'); + if (buf) { + *buf = 0; /* trunc filename */ + putdef(line, " -I", tmp); + } + wfree(tmp); } @@ -171,20 +171,20 @@ MakeCPPArgs(char *path) buf = strtok(buffer, ":"); do { - char fullpath[MAXLINE]; + char fullpath[MAXLINE]; - if (buf[0]!='~') { - strcpy(fullpath, buf); - } else { - char * wgethomedir(); - /* home is statically allocated. Don't free it! */ - char *home = wgethomedir(); + if (buf[0]!='~') { + strcpy(fullpath, buf); + } else { + char * wgethomedir(); + /* home is statically allocated. Don't free it! */ + char *home = wgethomedir(); - strcpy(fullpath, home); - strcat(fullpath, &(buf[1])); - } + strcpy(fullpath, home); + strcat(fullpath, &(buf[1])); + } - putdef(line, " -I", fullpath); + putdef(line, " -I", fullpath); } while ((buf = strtok(NULL, ":"))!=NULL); @@ -212,18 +212,18 @@ isBelow(WWindow *win1, WWindow *win2) tmp = win1->frame->core->stacking->under; while (tmp) { - if (tmp == win2->frame->core) - return True; - tmp = tmp->stacking->under; + if (tmp == win2->frame->core) + return True; + tmp = tmp->stacking->under; } for (i=win1->frame->core->stacking->window_level-1; i>=0; i--) { - tmp = win1->screen_ptr->stacking_list[i]; - while (tmp) { - if (tmp == win2->frame->core) - return True; - tmp = tmp->stacking->under; - } + tmp = win1->screen_ptr->stacking_list[i]; + while (tmp) { + if (tmp == win2->frame->core) + return True; + tmp = tmp->stacking->under; + } } return True; } @@ -246,32 +246,32 @@ char **winname; int num; if (XGetWMName(dpy, win, &text_prop)) { - if (text_prop.value && text_prop.nitems > 0) { - if (text_prop.encoding == XA_STRING) { - *winname = wstrdup((char *)text_prop.value); - XFree(text_prop.value); - } else { - text_prop.nitems = strlen((char *)text_prop.value); - if (XmbTextPropertyToTextList(dpy, &text_prop, &list, &num) >= - Success && num > 0 && *list) { - XFree(text_prop.value); - *winname = wstrdup(*list); - XFreeStringList(list); - } else { - *winname = wstrdup((char *)text_prop.value); - XFree(text_prop.value); - } - } - } else { - /* the title is set, but it was set to none */ - *winname = wstrdup(""); - } - return True; + if (text_prop.value && text_prop.nitems > 0) { + if (text_prop.encoding == XA_STRING) { + *winname = wstrdup((char *)text_prop.value); + XFree(text_prop.value); + } else { + text_prop.nitems = strlen((char *)text_prop.value); + if (XmbTextPropertyToTextList(dpy, &text_prop, &list, &num) >= + Success && num > 0 && *list) { + XFree(text_prop.value); + *winname = wstrdup(*list); + XFreeStringList(list); + } else { + *winname = wstrdup((char *)text_prop.value); + XFree(text_prop.value); + } + } + } else { + /* the title is set, but it was set to none */ + *winname = wstrdup(""); + } + return True; } else { - /* the hint is probably not set */ - *winname = NULL; + /* the hint is probably not set */ + *winname = NULL; - return False; + return False; } } @@ -291,20 +291,20 @@ char **iconname; int num; if (XGetWMIconName(dpy, win, &text_prop) != 0 && text_prop.value - && text_prop.nitems > 0) { - if (text_prop.encoding == XA_STRING) - *iconname = (char *)text_prop.value; - else { - text_prop.nitems = strlen((char *)text_prop.value); - if (XmbTextPropertyToTextList(dpy, &text_prop, &list, &num) >= - Success && num > 0 && *list) { - XFree(text_prop.value); - *iconname = wstrdup(*list); - XFreeStringList(list); - } else - *iconname = (char *)text_prop.value; - } - return True; + && text_prop.nitems > 0) { + if (text_prop.encoding == XA_STRING) + *iconname = (char *)text_prop.value; + else { + text_prop.nitems = strlen((char *)text_prop.value); + if (XmbTextPropertyToTextList(dpy, &text_prop, &list, &num) >= + Success && num > 0 && *list) { + XFree(text_prop.value); + *iconname = wstrdup(*list); + XFreeStringList(list); + } else + *iconname = (char *)text_prop.value; + } + return True; } *iconname = NULL; return False; @@ -319,14 +319,14 @@ eatExpose() /* compress all expose events into a single one */ if (XCheckMaskEvent(dpy, ExposureMask, &event)) { - /* ignore other exposure events for this window */ - while (XCheckWindowEvent(dpy, event.xexpose.window, ExposureMask, - &foo)); - /* eat exposes for other windows */ - eatExpose(); - - event.xexpose.count = 0; - XPutBackEvent(dpy, &event); + /* ignore other exposure events for this window */ + while (XCheckWindowEvent(dpy, event.xexpose.window, ExposureMask, + &foo)); + /* eat exposes for other windows */ + eatExpose(); + + event.xexpose.count = 0; + XPutBackEvent(dpy, &event); } } @@ -340,15 +340,15 @@ SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y) /* animation parameters */ static struct { - int delay; - int steps; - int slowdown; + int delay; + int steps; + int slowdown; } apars[5] = { - {ICON_SLIDE_DELAY_UF, ICON_SLIDE_STEPS_UF, ICON_SLIDE_SLOWDOWN_UF}, - {ICON_SLIDE_DELAY_F, ICON_SLIDE_STEPS_F, ICON_SLIDE_SLOWDOWN_F}, - {ICON_SLIDE_DELAY_M, ICON_SLIDE_STEPS_M, ICON_SLIDE_SLOWDOWN_M}, - {ICON_SLIDE_DELAY_S, ICON_SLIDE_STEPS_S, ICON_SLIDE_SLOWDOWN_S}, - {ICON_SLIDE_DELAY_US, ICON_SLIDE_STEPS_US, ICON_SLIDE_SLOWDOWN_US}}; + {ICON_SLIDE_DELAY_UF, ICON_SLIDE_STEPS_UF, ICON_SLIDE_SLOWDOWN_UF}, + {ICON_SLIDE_DELAY_F, ICON_SLIDE_STEPS_F, ICON_SLIDE_SLOWDOWN_F}, + {ICON_SLIDE_DELAY_M, ICON_SLIDE_STEPS_M, ICON_SLIDE_SLOWDOWN_M}, + {ICON_SLIDE_DELAY_S, ICON_SLIDE_STEPS_S, ICON_SLIDE_SLOWDOWN_S}, + {ICON_SLIDE_DELAY_US, ICON_SLIDE_STEPS_US, ICON_SLIDE_SLOWDOWN_US}}; @@ -378,7 +378,7 @@ SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y) } while (x != to_x || y != to_y) { - x += px; + x += px; y += py; if ((px<0 && (int)x < to_x) || (px>0 && (int)x > to_x)) x = (float)to_x; @@ -408,8 +408,8 @@ SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y) } else { wusleep(10); } - if (time(NULL) - time0 > MAX_ANIMATION_TIME) - break; + if (time(NULL) - time0 > MAX_ANIMATION_TIME) + break; } XMoveWindow(dpy, win, to_x, to_y); @@ -429,37 +429,37 @@ ShrinkString(WMFont *font, char *string, int width) int p1, p2, t; if (wPreferences.multi_byte_text) - return wstrdup(string); + return wstrdup(string); p = strlen(string); w = WMWidthOfString(font, string, p); text = wmalloc(strlen(string)+8); strcpy(text, string); if (w<=width) - return text; + return text; pos = strchr(text, ' '); if (!pos) - pos = strchr(text, ':'); + pos = strchr(text, ':'); if (pos) { - *pos = 0; - p = strlen(text); - w1 = WMWidthOfString(font, text, p); - if (w1 > width) { - w1 = 0; - p = 0; - *pos = ' '; - *text = 0; - } else { - *pos = 0; - width -= w1; - p++; - } - string += p; - p=strlen(string); + *pos = 0; + p = strlen(text); + w1 = WMWidthOfString(font, text, p); + if (w1 > width) { + w1 = 0; + p = 0; + *pos = ' '; + *text = 0; + } else { + *pos = 0; + width -= w1; + p++; + } + string += p; + p=strlen(string); } else { - *text=0; + *text=0; } strcat(text, "..."); width -= WMWidthOfString(font, "...", 3); @@ -468,15 +468,15 @@ ShrinkString(WMFont *font, char *string, int width) p2=p; t = (p2-p1)/2; while (p2>p1 && p1!=t) { - w = WMWidthOfString(font, &string[p-t], t); - if (w>width) { - p2 = t; - t = p1+(p2-p1)/2; - } else if (wwidth) { + p2 = t; + t = p1+(p2-p1)/2; + } else if (w= 0) { - char *data; - int size; + char *data; + int size; - data = XFetchBuffer(dpy, &size, buffer); + data = XFetchBuffer(dpy, &size, buffer); - return data; + return data; } else { - char *data; - int bits; - Atom rtype; - unsigned long len, bytes; - WMHandlerID timer; - int timeout = 0; - XEvent ev; - static Atom clipboard = 0; - - if (!clipboard) - clipboard = XInternAtom(dpy, "CLIPBOARD", False); - - XDeleteProperty(dpy, screen->info_window, clipboard); - - XConvertSelection(dpy, selection, XA_STRING, - clipboard, screen->info_window, - CurrentTime); - - timer = WMAddTimerHandler(1000, timeoutHandler, &timeout); - - while (!XCheckTypedWindowEvent(dpy, screen->info_window, - SelectionNotify, &ev) && !timeout); - - if (!timeout) { - WMDeleteTimerHandler(timer); - } else { - wwarning("selection retrieval timed out"); - return NULL; - } - - /* nobody owns the selection or the current owner has - * nothing to do with what we need */ - if (ev.xselection.property == None) { - return NULL; - } - - if (XGetWindowProperty(dpy, screen->info_window, - clipboard, 0, 1024, - False, XA_STRING, &rtype, &bits, &len, - &bytes, (unsigned char**)&data)!=Success) { - return NULL; - } - if (rtype!=XA_STRING || bits!=8) { - wwarning("invalid data in text selection"); - if (data) - XFree(data); - return NULL; - } - return data; + char *data; + int bits; + Atom rtype; + unsigned long len, bytes; + WMHandlerID timer; + int timeout = 0; + XEvent ev; + static Atom clipboard = 0; + + if (!clipboard) + clipboard = XInternAtom(dpy, "CLIPBOARD", False); + + XDeleteProperty(dpy, screen->info_window, clipboard); + + XConvertSelection(dpy, selection, XA_STRING, + clipboard, screen->info_window, + CurrentTime); + + timer = WMAddTimerHandler(1000, timeoutHandler, &timeout); + + while (!XCheckTypedWindowEvent(dpy, screen->info_window, + SelectionNotify, &ev) && !timeout); + + if (!timeout) { + WMDeleteTimerHandler(timer); + } else { + wwarning("selection retrieval timed out"); + return NULL; + } + + /* nobody owns the selection or the current owner has + * nothing to do with what we need */ + if (ev.xselection.property == None) { + return NULL; + } + + if (XGetWindowProperty(dpy, screen->info_window, + clipboard, 0, 1024, + False, XA_STRING, &rtype, &bits, &len, + &bytes, (unsigned char**)&data)!=Success) { + return NULL; + } + if (rtype!=XA_STRING || bits!=8) { + wwarning("invalid data in text selection"); + if (data) + XFree(data); + return NULL; + } + return data; } } @@ -608,7 +608,7 @@ getselection(WScreen *scr) tmp = getTextSelection(scr, XA_PRIMARY); if (!tmp) - tmp = getTextSelection(scr, XA_CUT_BUFFER0); + tmp = getTextSelection(scr, XA_CUT_BUFFER0); return tmp; } @@ -637,60 +637,60 @@ getuserinput(WScreen *scr, char *line, int *ptr) state = _STARTING; j = 0; for (; line[*ptr]!=0 && state!=_DONE; (*ptr)++) { - switch (state) { - case _STARTING: - if (line[*ptr]=='(') { - state = _TITLE; - begin = *ptr+1; - } else { - state = _DONE; - } - break; - - case _TITLE: - if (j <= 0 && line[*ptr]==',') { - - j = 0; - if (*ptr > begin) { - strncpy(tbuffer, &line[begin], WMIN(*ptr-begin, BUFSIZE)); - tbuffer[WMIN(*ptr-begin, BUFSIZE)] = 0; - title = (char*)tbuffer; - } - begin = *ptr+1; - state = _PROMPT; - - } else if (j <= 0 && line[*ptr]==')') { - - if (*ptr > begin) { - strncpy(tbuffer, &line[begin], WMIN(*ptr-begin, BUFSIZE)); - tbuffer[WMIN(*ptr-begin, BUFSIZE)] = 0; - title = (char*)tbuffer; - } - state = _DONE; - - } else if (line[*ptr]=='(') { - j++; - } else if (line[*ptr]==')') { - j--; - } - - break; - - case _PROMPT: - if (line[*ptr]==')' && j==0) { - - if (*ptr-begin > 1) { - strncpy(pbuffer, &line[begin], WMIN(*ptr-begin, BUFSIZE)); - pbuffer[WMIN(*ptr-begin, BUFSIZE)] = 0; - prompt = (char*)pbuffer; - } - state = _DONE; - } else if (line[*ptr]=='(') - j++; - else if (line[*ptr]==')') - j--; - break; - } + switch (state) { + case _STARTING: + if (line[*ptr]=='(') { + state = _TITLE; + begin = *ptr+1; + } else { + state = _DONE; + } + break; + + case _TITLE: + if (j <= 0 && line[*ptr]==',') { + + j = 0; + if (*ptr > begin) { + strncpy(tbuffer, &line[begin], WMIN(*ptr-begin, BUFSIZE)); + tbuffer[WMIN(*ptr-begin, BUFSIZE)] = 0; + title = (char*)tbuffer; + } + begin = *ptr+1; + state = _PROMPT; + + } else if (j <= 0 && line[*ptr]==')') { + + if (*ptr > begin) { + strncpy(tbuffer, &line[begin], WMIN(*ptr-begin, BUFSIZE)); + tbuffer[WMIN(*ptr-begin, BUFSIZE)] = 0; + title = (char*)tbuffer; + } + state = _DONE; + + } else if (line[*ptr]=='(') { + j++; + } else if (line[*ptr]==')') { + j--; + } + + break; + + case _PROMPT: + if (line[*ptr]==')' && j==0) { + + if (*ptr-begin > 1) { + strncpy(pbuffer, &line[begin], WMIN(*ptr-begin, BUFSIZE)); + pbuffer[WMIN(*ptr-begin, BUFSIZE)] = 0; + prompt = (char*)pbuffer; + } + state = _DONE; + } else if (line[*ptr]=='(') + j++; + else if (line[*ptr]==')') + j--; + break; + } } (*ptr)--; #undef _STARTING @@ -699,9 +699,9 @@ getuserinput(WScreen *scr, char *line, int *ptr) #undef _DONE if (!wInputDialog(scr, title, prompt, &ret)) - return NULL; + return NULL; else - return ret; + return ret; } @@ -718,22 +718,22 @@ get_dnd_selection(WScreen *scr) result=XGetTextProperty(dpy, scr->root_win, &text_ret, _XA_DND_SELECTION); if (result==0 || text_ret.value==NULL || text_ret.encoding==None - || text_ret.format==0 || text_ret.nitems == 0) { - wwarning(_("unable to get dropped data from DND drop")); - return NULL; + || text_ret.format==0 || text_ret.nitems == 0) { + wwarning(_("unable to get dropped data from DND drop")); + return NULL; } XTextPropertyToStringList(&text_ret, &list, &count); if (!list || count<1) { - XFree(text_ret.value); - wwarning(_("error getting dropped data from DND drop")); - return NULL; + XFree(text_ret.value); + wwarning(_("error getting dropped data from DND drop")); + return NULL; } flat_string = wtokenjoin(list, count); if (!flat_string) { - wwarning(_("out of memory while getting data from DND drop")); + wwarning(_("out of memory while getting data from DND drop")); } XFreeStringList(list); @@ -778,171 +778,171 @@ ExpandOptions(WScreen *scr, char *cmdline) olen = len+1; out = malloc(olen); if (!out) { - wwarning(_("out of memory during expansion of \"%s\"")); - return NULL; + wwarning(_("out of memory during expansion of \"%s\"")); + return NULL; } *out = 0; ptr = 0; /* input line pointer */ optr = 0; /* output line pointer */ state = S_NORMAL; while (ptr < len) { - switch (state) { - case S_NORMAL: - switch (cmdline[ptr]) { - case '\\': - state = S_ESCAPE; - break; - case '%': - state = S_OPTION; - break; - default: - state = S_NORMAL; - out[optr++]=cmdline[ptr]; - break; - } - break; - case S_ESCAPE: - switch (cmdline[ptr]) { - case 'n': - out[optr++]=10; - break; - - case 'r': - out[optr++]=13; - break; - - case 't': - out[optr++]=9; - break; - - default: - out[optr++]=cmdline[ptr]; - } - state = S_NORMAL; - break; - case S_OPTION: - state = S_NORMAL; - switch (cmdline[ptr]) { - case 'w': - if (scr->focused_window - && scr->focused_window->flags.focused) { - snprintf(tmpbuf, sizeof(tmpbuf), "0x%x", - (unsigned int)scr->focused_window->client_win); - slen = strlen(tmpbuf); - olen += slen; - nout = realloc(out,olen); - if (!nout) { - wwarning(_("out of memory during expansion of \"%w\"")); - goto error; - } - out = nout; - strcat(out,tmpbuf); - optr+=slen; - } else { - out[optr++]=' '; - } - break; - - case 'W': - snprintf(tmpbuf, sizeof(tmpbuf), "0x%x", - (unsigned int)scr->current_workspace + 1); - slen = strlen(tmpbuf); - olen += slen; - nout = realloc(out,olen); - if (!nout) { - wwarning(_("out of memory during expansion of \"%W\"")); - goto error; - } - out = nout; - strcat(out,tmpbuf); - optr+=slen; - break; - - case 'a': - ptr++; - user_input = getuserinput(scr, cmdline, &ptr); - if (user_input) { - slen = strlen(user_input); - olen += slen; - nout = realloc(out,olen); - if (!nout) { - wwarning(_("out of memory during expansion of \"%a\"")); - goto error; - } - out = nout; - strcat(out,user_input); - optr+=slen; - } else { - /* Not an error, but user has Canceled the dialog box. - * This will make the command to not be performed. */ - goto error; - } - break; + switch (state) { + case S_NORMAL: + switch (cmdline[ptr]) { + case '\\': + state = S_ESCAPE; + break; + case '%': + state = S_OPTION; + break; + default: + state = S_NORMAL; + out[optr++]=cmdline[ptr]; + break; + } + break; + case S_ESCAPE: + switch (cmdline[ptr]) { + case 'n': + out[optr++]=10; + break; + + case 'r': + out[optr++]=13; + break; + + case 't': + out[optr++]=9; + break; + + default: + out[optr++]=cmdline[ptr]; + } + state = S_NORMAL; + break; + case S_OPTION: + state = S_NORMAL; + switch (cmdline[ptr]) { + case 'w': + if (scr->focused_window + && scr->focused_window->flags.focused) { + snprintf(tmpbuf, sizeof(tmpbuf), "0x%x", + (unsigned int)scr->focused_window->client_win); + slen = strlen(tmpbuf); + olen += slen; + nout = realloc(out,olen); + if (!nout) { + wwarning(_("out of memory during expansion of \"%w\"")); + goto error; + } + out = nout; + strcat(out,tmpbuf); + optr+=slen; + } else { + out[optr++]=' '; + } + break; + + case 'W': + snprintf(tmpbuf, sizeof(tmpbuf), "0x%x", + (unsigned int)scr->current_workspace + 1); + slen = strlen(tmpbuf); + olen += slen; + nout = realloc(out,olen); + if (!nout) { + wwarning(_("out of memory during expansion of \"%W\"")); + goto error; + } + out = nout; + strcat(out,tmpbuf); + optr+=slen; + break; + + case 'a': + ptr++; + user_input = getuserinput(scr, cmdline, &ptr); + if (user_input) { + slen = strlen(user_input); + olen += slen; + nout = realloc(out,olen); + if (!nout) { + wwarning(_("out of memory during expansion of \"%a\"")); + goto error; + } + out = nout; + strcat(out,user_input); + optr+=slen; + } else { + /* Not an error, but user has Canceled the dialog box. + * This will make the command to not be performed. */ + goto error; + } + break; #if defined(OFFIX_DND) || defined(XDND) - case 'd': + case 'd': #ifdef XDND - if(scr->xdestring) { - dropped_thing = wstrdup(scr->xdestring); - } + if(scr->xdestring) { + dropped_thing = wstrdup(scr->xdestring); + } #endif - if (!dropped_thing) { - dropped_thing = get_dnd_selection(scr); - } - if (!dropped_thing) { - scr->flags.dnd_data_convertion_status = 1; - goto error; - } - slen = strlen(dropped_thing); - olen += slen; - nout = realloc(out,olen); - if (!nout) { - wwarning(_("out of memory during expansion of \"%d\"")); - goto error; - } - out = nout; - strcat(out,dropped_thing); - optr+=slen; - break; + if (!dropped_thing) { + dropped_thing = get_dnd_selection(scr); + } + if (!dropped_thing) { + scr->flags.dnd_data_convertion_status = 1; + goto error; + } + slen = strlen(dropped_thing); + olen += slen; + nout = realloc(out,olen); + if (!nout) { + wwarning(_("out of memory during expansion of \"%d\"")); + goto error; + } + out = nout; + strcat(out,dropped_thing); + optr+=slen; + break; #endif /* OFFIX_DND */ - case 's': - if (!selection) { - selection = getselection(scr); - } - if (!selection) { - wwarning(_("selection not available")); - goto error; - } - slen = strlen(selection); - olen += slen; - nout = realloc(out,olen); - if (!nout) { - wwarning(_("out of memory during expansion of \"%s\"")); - goto error; - } - out = nout; - strcat(out,selection); - optr+=slen; - break; - - default: - out[optr++]='%'; - out[optr++]=cmdline[ptr]; - } - break; - } - out[optr]=0; - ptr++; + case 's': + if (!selection) { + selection = getselection(scr); + } + if (!selection) { + wwarning(_("selection not available")); + goto error; + } + slen = strlen(selection); + olen += slen; + nout = realloc(out,olen); + if (!nout) { + wwarning(_("out of memory during expansion of \"%s\"")); + goto error; + } + out = nout; + strcat(out,selection); + optr+=slen; + break; + + default: + out[optr++]='%'; + out[optr++]=cmdline[ptr]; + } + break; + } + out[optr]=0; + ptr++; } if (selection) - XFree(selection); + XFree(selection); return out; - error: +error: wfree(out); if (selection) - XFree(selection); + XFree(selection); return NULL; } @@ -955,14 +955,14 @@ ParseWindowName(WMPropList *value, char **winstance, char **wclass, char *where) *winstance = *wclass = NULL; if (!WMIsPLString(value)) { - wwarning(_("bad window name value in %s state info"), where); - return; + wwarning(_("bad window name value in %s state info"), where); + return; } name = WMGetFromPLString(value); if (!name || strlen(name)==0) { - wwarning(_("bad window name value in %s state info"), where); - return; + wwarning(_("bad window name value in %s state info"), where); + return; } UnescapeWM_CLASS(name, winstance, wclass); @@ -1002,7 +1002,7 @@ GetShortcutString(char *text) char *buffer = NULL; char *k; int modmask = 0; -/* KeySym ksym;*/ + /* KeySym ksym;*/ int control = 0; char *tmp; @@ -1010,51 +1010,51 @@ GetShortcutString(char *text) /* get modifiers */ while ((k = strchr(text, '+'))!=NULL) { - int mod; - - *k = 0; - mod = wXModifierFromKey(text); - if (mod<0) { - return wstrdup("bug"); - } - - modmask |= mod; - - if (strcasecmp(text, "Meta")==0) { - buffer = wstrappend(buffer, "M+"); - } else if (strcasecmp(text, "Alt")==0) { - buffer = wstrappend(buffer, "A+"); - } else if (strcasecmp(text, "Shift")==0) { - buffer = wstrappend(buffer, "Sh+"); - } else if (strcasecmp(text, "Mod1")==0) { - buffer = wstrappend(buffer, "M1+"); - } else if (strcasecmp(text, "Mod2")==0) { - buffer = wstrappend(buffer, "M2+"); - } else if (strcasecmp(text, "Mod3")==0) { - buffer = wstrappend(buffer, "M3+"); - } else if (strcasecmp(text, "Mod4")==0) { - buffer = wstrappend(buffer, "M4+"); - } else if (strcasecmp(text, "Mod5")==0) { - buffer = wstrappend(buffer, "M5+"); - } else if (strcasecmp(text, "Control")==0) { - control = 1; - } else { - buffer = wstrappend(buffer, text); - } - text = k+1; + int mod; + + *k = 0; + mod = wXModifierFromKey(text); + if (mod<0) { + return wstrdup("bug"); + } + + modmask |= mod; + + if (strcasecmp(text, "Meta")==0) { + buffer = wstrappend(buffer, "M+"); + } else if (strcasecmp(text, "Alt")==0) { + buffer = wstrappend(buffer, "A+"); + } else if (strcasecmp(text, "Shift")==0) { + buffer = wstrappend(buffer, "Sh+"); + } else if (strcasecmp(text, "Mod1")==0) { + buffer = wstrappend(buffer, "M1+"); + } else if (strcasecmp(text, "Mod2")==0) { + buffer = wstrappend(buffer, "M2+"); + } else if (strcasecmp(text, "Mod3")==0) { + buffer = wstrappend(buffer, "M3+"); + } else if (strcasecmp(text, "Mod4")==0) { + buffer = wstrappend(buffer, "M4+"); + } else if (strcasecmp(text, "Mod5")==0) { + buffer = wstrappend(buffer, "M5+"); + } else if (strcasecmp(text, "Control")==0) { + control = 1; + } else { + buffer = wstrappend(buffer, text); + } + text = k+1; } if (control) { - buffer = wstrappend(buffer, "^"); + buffer = wstrappend(buffer, "^"); } buffer = wstrappend(buffer, text); /* get key */ -/* ksym = XStringToKeysym(text); - tmp = keysymToString(ksym, modmask); - puts(tmp); - buffer = wstrappend(buffer, tmp); -*/ + /* ksym = XStringToKeysym(text); + tmp = keysymToString(ksym, modmask); + puts(tmp); + buffer = wstrappend(buffer, tmp); + */ wfree(tmp); return buffer; @@ -1069,49 +1069,49 @@ EscapeWM_CLASS(char *name, char *class) int i, j, l; if (!name && !class) - return NULL; + return NULL; if (name) { - l = strlen(name); - ename = wmalloc(l*2+1); - j = 0; - for (i=0; iflags.backimage_helper_launched) { - return; + return; } len = (msg ? strlen(msg) : 0) + (workspace >=0 ? 4 : 0) + 1 ; @@ -1191,16 +1191,16 @@ SendHelperMessage(WScreen *scr, char type, int workspace, char *msg) buffer[4] = type; i = 5; if (workspace >= 0) { - snprintf(buf, sizeof(buf), "%4i", workspace); - memcpy(&buffer[i], buf, 4); - i += 4; - buffer[i] = 0; + snprintf(buf, sizeof(buf), "%4i", workspace); + memcpy(&buffer[i], buf, 4); + i += 4; + buffer[i] = 0; } if (msg) - strcpy(&buffer[i], msg); + strcpy(&buffer[i], msg); if (write(scr->helper_fd, buffer, len+4) < 0) { - wsyserror(_("could not send message to background image helper")); + wsyserror(_("could not send message to background image helper")); } wfree(buffer); } @@ -1249,9 +1249,9 @@ StrConcatDot(char *a, char *b) char *str; if (!a) - a = ""; + a = ""; if (!b) - b = ""; + b = ""; len = strlen(a)+strlen(b)+4; str = wmalloc(len); diff --git a/src/motif.c b/src/motif.c index 7c993395..e495e976 100644 --- a/src/motif.c +++ b/src/motif.c @@ -1,9 +1,9 @@ /* motif.c-- stuff for support for mwm hints - * + * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -82,136 +82,136 @@ static Atom _XA_MOTIF_WM_HINTS; -static void +static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints) { - /* + /* * We will ignore all decoration hints that have an equivalent as * functions, because wmaker does not distinguish decoration hints */ - - if (mwm_hints->flags & MWM_HINTS_DECORATIONS) { -# ifdef DEBUG - fprintf(stderr,"has decor hints [ "); -# endif - WSETUFLAG(wwin, no_titlebar, 1); - WSETUFLAG(wwin, no_close_button, 1); - WSETUFLAG(wwin, no_miniaturize_button, 1); - WSETUFLAG(wwin, no_resizebar, 1); - - if (mwm_hints->decorations & MWM_DECOR_ALL) { -# ifdef DEBUG - fprintf(stderr,"ALL "); -# endif - WSETUFLAG(wwin, no_titlebar, 0); - WSETUFLAG(wwin, no_close_button, 0); - WSETUFLAG(wwin, no_closable, 0); - WSETUFLAG(wwin, no_miniaturize_button, 0); - WSETUFLAG(wwin, no_miniaturizable, 0); - WSETUFLAG(wwin, no_resizebar, 0); - WSETUFLAG(wwin, no_resizable, 0); - } -/* - if (mwm_hints->decorations & MWM_DECOR_BORDER) { -# ifdef DEBUG - fprintf(stderr,"(BORDER) "); -# endif - } - */ - if (mwm_hints->decorations & MWM_DECOR_RESIZEH) { + if (mwm_hints->flags & MWM_HINTS_DECORATIONS) { # ifdef DEBUG - fprintf(stderr,"RESIZEH "); + fprintf(stderr,"has decor hints [ "); # endif - WSETUFLAG(wwin, no_resizebar, 0); - } + WSETUFLAG(wwin, no_titlebar, 1); + WSETUFLAG(wwin, no_close_button, 1); + WSETUFLAG(wwin, no_miniaturize_button, 1); + WSETUFLAG(wwin, no_resizebar, 1); - if (mwm_hints->decorations & MWM_DECOR_TITLE) { + if (mwm_hints->decorations & MWM_DECOR_ALL) { # ifdef DEBUG - fprintf(stderr,"TITLE+close "); + fprintf(stderr,"ALL "); # endif - WSETUFLAG(wwin, no_titlebar, 0); - WSETUFLAG(wwin, no_close_button, 0); - WSETUFLAG(wwin, no_closable, 0); - } -/* - if (mwm_hints->decorations & MWM_DECOR_MENU) { + WSETUFLAG(wwin, no_titlebar, 0); + WSETUFLAG(wwin, no_close_button, 0); + WSETUFLAG(wwin, no_closable, 0); + WSETUFLAG(wwin, no_miniaturize_button, 0); + WSETUFLAG(wwin, no_miniaturizable, 0); + WSETUFLAG(wwin, no_resizebar, 0); + WSETUFLAG(wwin, no_resizable, 0); + } + /* + if (mwm_hints->decorations & MWM_DECOR_BORDER) { + # ifdef DEBUG + fprintf(stderr,"(BORDER) "); + # endif + } + */ + + if (mwm_hints->decorations & MWM_DECOR_RESIZEH) { # ifdef DEBUG - fprintf(stderr,"(MENU) "); + fprintf(stderr,"RESIZEH "); # endif - } - */ + WSETUFLAG(wwin, no_resizebar, 0); + } - if (mwm_hints->decorations & MWM_DECOR_MINIMIZE) { + if (mwm_hints->decorations & MWM_DECOR_TITLE) { # ifdef DEBUG - fprintf(stderr,"MINIMIZE "); + fprintf(stderr,"TITLE+close "); # endif - WSETUFLAG(wwin, no_miniaturize_button, 0); - WSETUFLAG(wwin, no_miniaturizable, 0); - } -/* - if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) { + WSETUFLAG(wwin, no_titlebar, 0); + WSETUFLAG(wwin, no_close_button, 0); + WSETUFLAG(wwin, no_closable, 0); + } + /* + if (mwm_hints->decorations & MWM_DECOR_MENU) { + # ifdef DEBUG + fprintf(stderr,"(MENU) "); + # endif + } + */ + + if (mwm_hints->decorations & MWM_DECOR_MINIMIZE) { # ifdef DEBUG - fprintf(stderr,"(MAXIMIZE) "); + fprintf(stderr,"MINIMIZE "); # endif - } - */ + WSETUFLAG(wwin, no_miniaturize_button, 0); + WSETUFLAG(wwin, no_miniaturizable, 0); + } + /* + if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) { + # ifdef DEBUG + fprintf(stderr,"(MAXIMIZE) "); + # endif + } + */ # ifdef DEBUG - fprintf(stderr,"]\n"); + fprintf(stderr,"]\n"); # endif } if (mwm_hints->flags & MWM_HINTS_FUNCTIONS) { # ifdef DEBUG - fprintf(stderr,"has function hints [ "); -# endif - WSETUFLAG(wwin, no_closable, 1); - WSETUFLAG(wwin, no_miniaturizable, 1); - WSETUFLAG(wwin, no_resizable, 1); - - if (mwm_hints->functions & MWM_FUNC_ALL) { -# ifdef DEBUG - fprintf(stderr,"ALL "); + fprintf(stderr,"has function hints [ "); # endif - WSETUFLAG(wwin, no_closable, 0); - WSETUFLAG(wwin, no_miniaturizable, 0); - WSETUFLAG(wwin, no_resizable, 0); - } - if (mwm_hints->functions & MWM_FUNC_RESIZE) { -# ifdef DEBUG - fprintf(stderr,"RESIZE "); + WSETUFLAG(wwin, no_closable, 1); + WSETUFLAG(wwin, no_miniaturizable, 1); + WSETUFLAG(wwin, no_resizable, 1); + + if (mwm_hints->functions & MWM_FUNC_ALL) { +# ifdef DEBUG + fprintf(stderr,"ALL "); # endif - WSETUFLAG(wwin, no_resizable, 0); - } - /* - if (mwm_hints->functions & MWM_FUNC_MOVE) { -# ifdef DEBUG - fprintf(stderr,"(MOVE) "); + WSETUFLAG(wwin, no_closable, 0); + WSETUFLAG(wwin, no_miniaturizable, 0); + WSETUFLAG(wwin, no_resizable, 0); + } + if (mwm_hints->functions & MWM_FUNC_RESIZE) { +# ifdef DEBUG + fprintf(stderr,"RESIZE "); # endif - } - */ - if (mwm_hints->functions & MWM_FUNC_MINIMIZE) { -# ifdef DEBUG - fprintf(stderr,"MINIMIZE "); + WSETUFLAG(wwin, no_resizable, 0); + } + /* + if (mwm_hints->functions & MWM_FUNC_MOVE) { + # ifdef DEBUG + fprintf(stderr,"(MOVE) "); + # endif + } + */ + if (mwm_hints->functions & MWM_FUNC_MINIMIZE) { +# ifdef DEBUG + fprintf(stderr,"MINIMIZE "); # endif - WSETUFLAG(wwin, no_miniaturizable, 0); - } - if (mwm_hints->functions & MWM_FUNC_MAXIMIZE) { -# ifdef DEBUG - fprintf(stderr,"MAXIMIZE "); - /* a window must be resizable to be maximizable */ - WSETUFLAG(wwin, no_resizable, 0); + WSETUFLAG(wwin, no_miniaturizable, 0); + } + if (mwm_hints->functions & MWM_FUNC_MAXIMIZE) { +# ifdef DEBUG + fprintf(stderr,"MAXIMIZE "); + /* a window must be resizable to be maximizable */ + WSETUFLAG(wwin, no_resizable, 0); # endif - } - if (mwm_hints->functions & MWM_FUNC_CLOSE) { -# ifdef DEBUG - fprintf(stderr,"CLOSE "); + } + if (mwm_hints->functions & MWM_FUNC_CLOSE) { +# ifdef DEBUG + fprintf(stderr,"CLOSE "); # endif - WSETUFLAG(wwin, no_closable, 0); - } -# ifdef DEBUG - fprintf(stderr,"]\n"); + WSETUFLAG(wwin, no_closable, 0); + } +# ifdef DEBUG + fprintf(stderr,"]\n"); # endif } } @@ -224,23 +224,23 @@ getMWMHints(Window window, MWMHints *mwmhints) int count; if (!_XA_MOTIF_WM_HINTS) { - _XA_MOTIF_WM_HINTS = XInternAtom(dpy, "_MOTIF_WM_HINTS", False); + _XA_MOTIF_WM_HINTS = XInternAtom(dpy, "_MOTIF_WM_HINTS", False); } data = (unsigned long*)PropGetCheckProperty(window, _XA_MOTIF_WM_HINTS, - _XA_MOTIF_WM_HINTS, 32, - 0, &count); + _XA_MOTIF_WM_HINTS, 32, + 0, &count); if (!data) - return 0; + return 0; if (count >= 4) { - mwmhints->flags = data[0]; - mwmhints->functions = data[1]; - mwmhints->decorations = data[2]; - mwmhints->inputMode = data[3]; - if (count > 5) - mwmhints->unknown = data[4]; + mwmhints->flags = data[0]; + mwmhints->functions = data[1]; + mwmhints->decorations = data[2]; + mwmhints->inputMode = data[3]; + if (count > 5) + mwmhints->unknown = data[4]; } XFree(data); @@ -252,12 +252,13 @@ void wMWMCheckClientHints(WWindow *wwin) { MWMHints hints; - + if (getMWMHints(wwin->client_win, &hints)) { - setupMWMHints(wwin, &hints); + setupMWMHints(wwin, &hints); } } #endif /* MWM_HINTS */ + diff --git a/src/motif.h b/src/motif.h index e0816f88..a2f8010c 100644 --- a/src/motif.h +++ b/src/motif.h @@ -1,9 +1,9 @@ /* motif.h-- stuff for support for mwm hints - * + * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ diff --git a/src/moveres.c b/src/moveres.c index eaf7bb3c..a1607681 100644 --- a/src/moveres.c +++ b/src/moveres.c @@ -144,7 +144,7 @@ moveGeometryDisplayCentered(WScreen *scr, int x, int y) y2 = y1 + rect.size.height; } } - + if (x < x1 + 1) x = x1 + 1; else if (x > (x2 - w)) @@ -400,7 +400,7 @@ cycleGeometryDisplay(WWindow *wwin, int x, int y, int w, int h, int dir) wPreferences.size_display++; wPreferences.size_display %= NUM_DISPLAYS; - if (wPreferences.size_display == WDIS_NEW + if (wPreferences.size_display == WDIS_NEW || wPreferences.size_display == WDIS_NONE) { WMUnmapWidget(scr->gview); } else { @@ -1028,7 +1028,7 @@ updateWindowPosition(WWindow *wwin, MoveData *data, Bool doResistance, /* window is the leftmost window: check against screen edge */ /* Add inter head resistance 1/2 (if needed) */ - head = wGetHeadForPointerLocation(scr); + head = wGetHeadForPointerLocation(scr); rect = wGetRectForHead(scr, head); l_edge = WMAX(scr->totalUsableArea[head].x1, rect.pos.x); @@ -1324,7 +1324,7 @@ wKeyboardMoveResizeWindow(WWindow *wwin) ctrlmode=done=off_x=off_y=0; if (modes == RESIZABLE_BIT) { - ctrlmode = 1; + ctrlmode = 1; } XSync(dpy, False); @@ -1392,15 +1392,15 @@ wKeyboardMoveResizeWindow(WWindow *wwin) } if (kspeed < _KS) kspeed = _KS; lastTime = event.xkey.time; - if (modes == (MOVABLE_BIT|RESIZABLE_BIT)) { - if ((event.xkey.state & ControlMask) && !wwin->flags.shaded) { - ctrlmode=1; - wUnselectWindows(scr); - } - else { - ctrlmode=0; - } - } + if (modes == (MOVABLE_BIT|RESIZABLE_BIT)) { + if ((event.xkey.state & ControlMask) && !wwin->flags.shaded) { + ctrlmode=1; + wUnselectWindows(scr); + } + else { + ctrlmode=0; + } + } if (event.xkey.keycode == shiftl || event.xkey.keycode == shiftr) { if (ctrlmode) cycleGeometryDisplay(wwin, src_x+off_x, src_y+off_y, ww, wh, 0); @@ -1554,7 +1554,7 @@ wKeyboardMoveResizeWindow(WWindow *wwin) showGeometry(wwin, src_x+off_x, src_y+off_y, src_x+off_x+ww, src_y+off_y+wh,0); } else if(!scr->selected_windows) showPosition(wwin, src_x+off_x, src_y+off_y); - + if (done) { scr->keymove_tick=0; @@ -1610,14 +1610,14 @@ wKeyboardMoveResizeWindow(WWindow *wwin) wSetFocusTo(scr, wwin); } - if (wPreferences.auto_arrange_icons && wXineramaHeads(scr)>1 && + if (wPreferences.auto_arrange_icons && wXineramaHeads(scr)>1 && head != wGetHeadForWindow(wwin)) { wArrangeIcons(scr, True); } #if defined(NETWM_HINTS) && defined(VIRTUAL_DESKTOP) - wWorkspaceResizeViewPort(scr, scr->current_workspace); + wWorkspaceResizeViewPort(scr, scr->current_workspace); #endif return 1; @@ -1912,7 +1912,7 @@ wMouseMoveWindow(WWindow *wwin, XEvent *ev) #if defined(NETWM_HINTS) && defined(VIRTUAL_DESKTOP) if (started) - wWorkspaceResizeViewPort(scr, scr->current_workspace); + wWorkspaceResizeViewPort(scr, scr->current_workspace); #endif return started; @@ -2432,3 +2432,4 @@ InteractivePlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, } } } + diff --git a/src/openlook.c b/src/openlook.c index 82726e0d..b9e6f3f8 100644 --- a/src/openlook.c +++ b/src/openlook.c @@ -1,10 +1,10 @@ /* * openlook.c - OPEN LOOK (tm) compatibility stuff - * + * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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. */ @@ -105,21 +105,21 @@ getWindowState(Window win, OLWindowState *state) unsigned long *data; if (!_XA_SUN_WINDOW_STATE) { - _XA_SUN_WINDOW_STATE = XInternAtom(dpy, "_SUN_WINDOW_STATE", False); + _XA_SUN_WINDOW_STATE = XInternAtom(dpy, "_SUN_WINDOW_STATE", False); } data = (unsigned long*)PropGetCheckProperty(win, _XA_SUN_WINDOW_STATE, - XA_INTEGER, 32, 2, NULL); + XA_INTEGER, 32, 2, NULL); if (!data) { - return False; + return False; } - + state->flags = data[0]; state->state = data[1]; XFree(data); - + return True; } #endif @@ -132,53 +132,53 @@ getWindowHints(Window window, OLHints *hints) static Atom _XA_OL_WIN_ATTR = 0; if (!_XA_OL_WIN_ATTR) { - _XA_OL_WIN_ATTR = XInternAtom(dpy, "_OL_WIN_ATTR", False); + _XA_OL_WIN_ATTR = XInternAtom(dpy, "_OL_WIN_ATTR", False); } - data = (long*)PropGetCheckProperty(window, _XA_OL_WIN_ATTR, - _XA_OL_WIN_ATTR, 32, 0, &count); + data = (long*)PropGetCheckProperty(window, _XA_OL_WIN_ATTR, + _XA_OL_WIN_ATTR, 32, 0, &count); if (!data) - return False; + return False; if (count == 3) { - /* old format */ + /* old format */ - hints->flags = OL_WINTYPE|OL_MENUTYPE|OL_PINSTATE; - hints->winType = data[0]; - hints->menuType = data[1]; - hints->pinInitState = data[2]; - hints->cancel = 0; + hints->flags = OL_WINTYPE|OL_MENUTYPE|OL_PINSTATE; + hints->winType = data[0]; + hints->menuType = data[1]; + hints->pinInitState = data[2]; + hints->cancel = 0; } else if (count == 5) { - /* new format */ + /* new format */ - hints->flags = data[0]; - hints->winType = data[1]; - hints->menuType = data[2]; - hints->pinInitState = data[3]; - hints->cancel = data[4]; + hints->flags = data[0]; + hints->winType = data[1]; + hints->menuType = data[2]; + hints->pinInitState = data[3]; + hints->cancel = data[4]; } else { - XFree(data); - return False; + XFree(data); + return False; } XFree(data); /* do backward compatibility stuff */ if (hints->flags & OL_PINSTATE) { - static Atom pinIn = 0, pinOut; - - if (!pinIn) { - pinIn = XInternAtom(dpy, "_OL_PIN_IN", False); - pinOut = XInternAtom(dpy, "_OL_PIN_OUT", False); - } - - if (hints->pinInitState == pinIn) - hints->pinInitState = OL_PIN_IN; - else if (hints->pinInitState == pinOut) - hints->pinInitState = OL_PIN_OUT; + static Atom pinIn = 0, pinOut; + + if (!pinIn) { + pinIn = XInternAtom(dpy, "_OL_PIN_IN", False); + pinOut = XInternAtom(dpy, "_OL_PIN_OUT", False); + } + + if (hints->pinInitState == pinIn) + hints->pinInitState = OL_PIN_IN; + else if (hints->pinInitState == pinOut) + hints->pinInitState = OL_PIN_OUT; } return True; @@ -194,60 +194,60 @@ applyDecorationHints(Window win, int *flags) static Atom _XA_OL_DECOR_ADD = 0; static Atom _XA_OL_DECOR_DEL = 0; static Atom _XA_CLOSE, _XA_FOOTER, _XA_RESIZE, _XA_HEADER, _XA_PIN, - _XA_ICONNAME; + _XA_ICONNAME; int count; int i; if (!_XA_OL_DECOR_DEL) { - _XA_OL_DECOR_ADD = XInternAtom(dpy, "_OL_DECOR_ADD", False); - _XA_OL_DECOR_DEL = XInternAtom(dpy, "_OL_DECOR_DEL", False); - - _XA_CLOSE = XInternAtom(dpy, "_OL_DECOR_CLOSE", False); - _XA_FOOTER = XInternAtom(dpy, "_OL_DECOR_FOOTER", False); - _XA_RESIZE = XInternAtom(dpy, "_OL_DECOR_RESIZE", False); - _XA_HEADER = XInternAtom(dpy, "_OL_DECOR_HEADER", False); - _XA_PIN = XInternAtom(dpy, "_OL_DECOR_PIN", False); - _XA_ICONNAME = XInternAtom(dpy, "_OL_DECOR_ICON_NAME", False); + _XA_OL_DECOR_ADD = XInternAtom(dpy, "_OL_DECOR_ADD", False); + _XA_OL_DECOR_DEL = XInternAtom(dpy, "_OL_DECOR_DEL", False); + + _XA_CLOSE = XInternAtom(dpy, "_OL_DECOR_CLOSE", False); + _XA_FOOTER = XInternAtom(dpy, "_OL_DECOR_FOOTER", False); + _XA_RESIZE = XInternAtom(dpy, "_OL_DECOR_RESIZE", False); + _XA_HEADER = XInternAtom(dpy, "_OL_DECOR_HEADER", False); + _XA_PIN = XInternAtom(dpy, "_OL_DECOR_PIN", False); + _XA_ICONNAME = XInternAtom(dpy, "_OL_DECOR_ICON_NAME", False); } - atoms = (Atom*)PropGetCheckProperty(win, _XA_OL_DECOR_ADD, XA_ATOM, 32, 0, - &count); + atoms = (Atom*)PropGetCheckProperty(win, _XA_OL_DECOR_ADD, XA_ATOM, 32, 0, + &count); if (atoms) { - for (i=0; i < count; i++) { - if (atoms[i] == _XA_CLOSE) - *flags |= OL_DECORATION_CLOSEBUTTON; - else if (atoms[i] == _XA_FOOTER) - *flags |= OL_DECORATION_FOOTER; - else if (atoms[i] == _XA_RESIZE) - *flags |= OL_DECORATION_RESIZEABLE; - else if (atoms[i] == _XA_HEADER) - *flags |= OL_DECORATION_HEADER; - else if (atoms[i] == _XA_PIN) - *flags |= OL_DECORATION_PUSHPIN; - else if (atoms[i] == _XA_ICONNAME) - *flags |= OL_DECORATION_ICONNAME; - } - XFree(atoms); + for (i=0; i < count; i++) { + if (atoms[i] == _XA_CLOSE) + *flags |= OL_DECORATION_CLOSEBUTTON; + else if (atoms[i] == _XA_FOOTER) + *flags |= OL_DECORATION_FOOTER; + else if (atoms[i] == _XA_RESIZE) + *flags |= OL_DECORATION_RESIZEABLE; + else if (atoms[i] == _XA_HEADER) + *flags |= OL_DECORATION_HEADER; + else if (atoms[i] == _XA_PIN) + *flags |= OL_DECORATION_PUSHPIN; + else if (atoms[i] == _XA_ICONNAME) + *flags |= OL_DECORATION_ICONNAME; + } + XFree(atoms); } - atoms = (Atom*)PropGetCheckProperty(win, _XA_OL_DECOR_DEL, XA_ATOM, 32, 0, - &count); + atoms = (Atom*)PropGetCheckProperty(win, _XA_OL_DECOR_DEL, XA_ATOM, 32, 0, + &count); if (atoms) { - for (i=0; i < count; i++) { - if (atoms[i] == _XA_CLOSE) - *flags &= ~OL_DECORATION_CLOSEBUTTON; - else if (atoms[i] == _XA_FOOTER) - *flags &= ~OL_DECORATION_FOOTER; - else if (atoms[i] == _XA_RESIZE) - *flags &= ~OL_DECORATION_RESIZEABLE; - else if (atoms[i] == _XA_HEADER) - *flags &= ~OL_DECORATION_HEADER; - else if (atoms[i] == _XA_PIN) - *flags &= ~OL_DECORATION_PUSHPIN; - else if (atoms[i] == _XA_ICONNAME) - *flags &= ~OL_DECORATION_ICONNAME; - } - XFree(atoms); + for (i=0; i < count; i++) { + if (atoms[i] == _XA_CLOSE) + *flags &= ~OL_DECORATION_CLOSEBUTTON; + else if (atoms[i] == _XA_FOOTER) + *flags &= ~OL_DECORATION_FOOTER; + else if (atoms[i] == _XA_RESIZE) + *flags &= ~OL_DECORATION_RESIZEABLE; + else if (atoms[i] == _XA_HEADER) + *flags &= ~OL_DECORATION_HEADER; + else if (atoms[i] == _XA_PIN) + *flags &= ~OL_DECORATION_PUSHPIN; + else if (atoms[i] == _XA_ICONNAME) + *flags &= ~OL_DECORATION_ICONNAME; + } + XFree(atoms); } } @@ -258,12 +258,12 @@ wOLWMInitStuff(WScreen *scr) static Atom _SUN_OL_WIN_ATTR_5; if (!_XA_SUN_WM_PROTOCOLS) { - _XA_SUN_WM_PROTOCOLS = XInternAtom(dpy, "_SUN_WM_PROTOCOLS", False); - _SUN_OL_WIN_ATTR_5 = XInternAtom(dpy, "_SUN_OL_WIN_ATTR_5", False); + _XA_SUN_WM_PROTOCOLS = XInternAtom(dpy, "_SUN_WM_PROTOCOLS", False); + _SUN_OL_WIN_ATTR_5 = XInternAtom(dpy, "_SUN_OL_WIN_ATTR_5", False); } XChangeProperty(dpy, scr->root_win, _XA_SUN_WM_PROTOCOLS, XA_ATOM, 32, - PropModeReplace, (unsigned char*)&_SUN_OL_WIN_ATTR_5, 1); + PropModeReplace, (unsigned char*)&_SUN_OL_WIN_ATTR_5, 1); } @@ -273,11 +273,11 @@ wOLWMChangePushpinState(WWindow *wwin, Bool state) static Atom pinState = 0; if (!pinState) { - pinState = XInternAtom(dpy, "_OL_PIN_STATE", False); + pinState = XInternAtom(dpy, "_OL_PIN_STATE", False); } XChangeProperty(dpy, wwin->client_win, pinState, XA_INTEGER, 32, - PropModeReplace, (unsigned char *)&state, 1); + PropModeReplace, (unsigned char *)&state, 1); } @@ -293,14 +293,14 @@ void wOLWMUpdateWindowState(WWindow *wwin) { if (wwin->ol_window_state.used) { - if (wwin->ol_window_state.semantic) { - if (wwin->ol_window_state.semantic_compose) - setComposeLed(True); - else - setComposeLed(False); - } + if (wwin->ol_window_state.semantic) { + if (wwin->ol_window_state.semantic_compose) + setComposeLed(True); + else + setComposeLed(False); + } } else { - setComposeLed(False); + setComposeLed(False); } } #endif /* unfinished */ @@ -316,89 +316,89 @@ wOLWMCheckClientHints(WWindow *wwin) Atom menuType; if (!WT_BASE) { - WT_BASE = XInternAtom(dpy, "_OL_WT_BASE", False); - WT_CMD = XInternAtom(dpy, "_OL_WT_CMD", False); - WT_NOTICE = XInternAtom(dpy, "_OL_WT_NOTICE", False); - WT_HELP = XInternAtom(dpy, "_OL_WT_HELP", False); - WT_OTHER = XInternAtom(dpy, "_OL_WT_OTHER", False); - - MT_FULL = XInternAtom(dpy, "_OL_MENU_FULL", False); - MT_LIMITED = XInternAtom(dpy, "_OL_MENU_LIMITED", False); - MT_NONE = XInternAtom(dpy, "_OL_NONE", False); + WT_BASE = XInternAtom(dpy, "_OL_WT_BASE", False); + WT_CMD = XInternAtom(dpy, "_OL_WT_CMD", False); + WT_NOTICE = XInternAtom(dpy, "_OL_WT_NOTICE", False); + WT_HELP = XInternAtom(dpy, "_OL_WT_HELP", False); + WT_OTHER = XInternAtom(dpy, "_OL_WT_OTHER", False); + + MT_FULL = XInternAtom(dpy, "_OL_MENU_FULL", False); + MT_LIMITED = XInternAtom(dpy, "_OL_MENU_LIMITED", False); + MT_NONE = XInternAtom(dpy, "_OL_NONE", False); } /* get attributes */ if (!getWindowHints(wwin->client_win, &hints) || - !(hints.flags & OL_WINTYPE)) { + !(hints.flags & OL_WINTYPE)) { - decoration = OL_DECORATION_CLOSEBUTTON|OL_DECORATION_RESIZEABLE - |OL_DECORATION_HEADER|OL_DECORATION_ICONNAME; + decoration = OL_DECORATION_CLOSEBUTTON|OL_DECORATION_RESIZEABLE + |OL_DECORATION_HEADER|OL_DECORATION_ICONNAME; - menuType = MT_FULL; + menuType = MT_FULL; } else { - if (hints.winType == WT_BASE) { + if (hints.winType == WT_BASE) { - decoration = OL_DECORATION_CLOSEBUTTON|OL_DECORATION_RESIZEABLE - |OL_DECORATION_HEADER|OL_DECORATION_ICONNAME; + decoration = OL_DECORATION_CLOSEBUTTON|OL_DECORATION_RESIZEABLE + |OL_DECORATION_HEADER|OL_DECORATION_ICONNAME; - menuType = MT_FULL; + menuType = MT_FULL; - } else if (hints.winType == WT_CMD) { + } else if (hints.winType == WT_CMD) { - decoration = OL_DECORATION_PUSHPIN|OL_DECORATION_RESIZEABLE - |OL_DECORATION_HEADER|OL_DECORATION_ICONNAME; + decoration = OL_DECORATION_PUSHPIN|OL_DECORATION_RESIZEABLE + |OL_DECORATION_HEADER|OL_DECORATION_ICONNAME; - menuType = MT_LIMITED; + menuType = MT_LIMITED; /* this is a transient-like window */ wwin->client_flags.olwm_transient = 1; - } else if (hints.winType == WT_NOTICE) { + } else if (hints.winType == WT_NOTICE) { + + decoration = OL_DECORATION_ICONNAME; + menuType = MT_NONE; - decoration = OL_DECORATION_ICONNAME; - menuType = MT_NONE; + } else if (hints.winType == WT_HELP) { - } else if (hints.winType == WT_HELP) { + decoration = OL_DECORATION_PUSHPIN|OL_DECORATION_HEADER + |OL_DECORATION_ICONNAME|OL_DECORATION_WARPTOPIN; + menuType = MT_LIMITED; - decoration = OL_DECORATION_PUSHPIN|OL_DECORATION_HEADER - |OL_DECORATION_ICONNAME|OL_DECORATION_WARPTOPIN; - menuType = MT_LIMITED; - - } else if (hints.winType == WT_OTHER) { + } else if (hints.winType == WT_OTHER) { - decoration = OL_DECORATION_ICONNAME; - menuType = MT_NONE; + decoration = OL_DECORATION_ICONNAME; + menuType = MT_NONE; - if (hints.flags & OL_MENUTYPE) { - menuType = hints.menuType; - } - } + if (hints.flags & OL_MENUTYPE) { + menuType = hints.menuType; + } + } - if (hints.flags & OL_PINSTATE) { - pinInitState = hints.pinInitState; - } else { - pinInitState = OL_PIN_OUT; - } + if (hints.flags & OL_PINSTATE) { + pinInitState = hints.pinInitState; + } else { + pinInitState = OL_PIN_OUT; + } } /* mask attributes with decoration hints */ applyDecorationHints(wwin->client_win, &decoration); if ((decoration & OL_DECORATION_CLOSEBUTTON) - && (decoration & OL_DECORATION_PUSHPIN)) - decoration &= ~OL_DECORATION_CLOSEBUTTON; + && (decoration & OL_DECORATION_PUSHPIN)) + decoration &= ~OL_DECORATION_CLOSEBUTTON; if (!(decoration & OL_DECORATION_PUSHPIN)) - decoration &= ~OL_DECORATION_WARPTOPIN; + decoration &= ~OL_DECORATION_WARPTOPIN; /* map the hints to our attributes */ if (menuType == MT_FULL) - wwin->flags.olwm_limit_menu = 0; + wwin->flags.olwm_limit_menu = 0; else - wwin->flags.olwm_limit_menu = 1; + wwin->flags.olwm_limit_menu = 1; /* * Emulate olwm pushpin. @@ -408,20 +408,20 @@ wOLWMCheckClientHints(WWindow *wwin) * into a normal close button. */ if ((decoration & OL_DECORATION_PUSHPIN) && pinInitState==OL_PIN_OUT) { - wwin->flags.olwm_push_pin_out = 1; + wwin->flags.olwm_push_pin_out = 1; - wOLWMChangePushpinState(wwin, False); + wOLWMChangePushpinState(wwin, False); } else { - wOLWMChangePushpinState(wwin, True); + wOLWMChangePushpinState(wwin, True); } if (!(decoration & OL_DECORATION_RESIZEABLE)) { - wwin->client_flags.no_resizable = 1; - wwin->client_flags.no_resizebar = 1; + wwin->client_flags.no_resizable = 1; + wwin->client_flags.no_resizebar = 1; } if (decoration & OL_DECORATION_WARPTOPIN) { - wwin->client_flags.olwm_warp_to_pin = 1; + wwin->client_flags.olwm_warp_to_pin = 1; } } diff --git a/src/openlook.h b/src/openlook.h index e6e94894..3e803875 100644 --- a/src/openlook.h +++ b/src/openlook.h @@ -1,10 +1,10 @@ /* * openlook.h - OPEN LOOK (tm) compatibility stuff - * + * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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. */ diff --git a/src/pixmap.c b/src/pixmap.c index eaa0253e..91a10e7d 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -34,19 +34,19 @@ /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * wPixmapCreateFromXPMData-- * Creates a WPixmap structure and initializes it with the supplied * XPM structure data. - * + * * Returns: * A WPixmap structure or NULL on failure. - * + * * Notes: * DEF_XPM_CLOSENESS specifies the XpmCloseness - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ -WPixmap * +WPixmap* wPixmapCreateFromXPMData(WScreen *scr, char **data) { RImage *image; @@ -54,54 +54,54 @@ wPixmapCreateFromXPMData(WScreen *scr, char **data) image = RGetImageFromXPMData(scr->rcontext, data); if (!image) - return NULL; + return NULL; pix = wmalloc(sizeof(WPixmap)); memset(pix, 0, sizeof(WPixmap)); RConvertImageMask(scr->rcontext, image, &pix->image, &pix->mask, 128); - + pix->width = image->width; pix->height = image->height; pix->depth = scr->w_depth; - + RReleaseImage(image); - + return pix; } /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * wPixmapCreateFromXBMData-- * Creates a WPixmap structure and initializes it with the supplied * XBM structure data, size and mask. - * + * * Returns: * A WPixmap structure or NULL on failure. - * - *---------------------------------------------------------------------- + * + *---------------------------------------------------------------------- */ -WPixmap * -wPixmapCreateFromXBMData(WScreen *scr, char *data, char *mask, - int width, int height, unsigned long fg, - unsigned long bg) +WPixmap* +wPixmapCreateFromXBMData(WScreen *scr, char *data, char *mask, + int width, int height, unsigned long fg, + unsigned long bg) { WPixmap *pix; - + pix = wmalloc(sizeof(WPixmap)); memset(pix, 0, sizeof(WPixmap)); - pix->image = XCreatePixmapFromBitmapData(dpy, scr->w_win, data, width, - height, fg, bg, scr->w_depth); + pix->image = XCreatePixmapFromBitmapData(dpy, scr->w_win, data, width, + height, fg, bg, scr->w_depth); if (pix->image==None) { - wfree(pix); - return NULL; + wfree(pix); + return NULL; } if (mask) { - pix->mask = XCreateBitmapFromData(dpy, scr->w_win, mask, width, - height); + pix->mask = XCreateBitmapFromData(dpy, scr->w_win, mask, width, + height); } else { - pix->mask = None; + pix->mask = None; } pix->width = width; pix->height = height; @@ -113,7 +113,7 @@ wPixmapCreateFromXBMData(WScreen *scr, char *data, char *mask, #ifdef unused WPixmap* wPixmapCreateFromBitmap(WScreen *scr, Pixmap bitmap, Pixmap mask, - unsigned long fg, unsigned long bg) + unsigned long fg, unsigned long bg) { WPixmap *pix; XImage *img, *img2; @@ -122,38 +122,38 @@ wPixmapCreateFromBitmap(WScreen *scr, Pixmap bitmap, Pixmap mask, Pixmap pixmap; unsigned int width, height, baz, d; - if (!XGetGeometry(dpy, bitmap, &foo, &bar, &bar, &width, &height, &baz, - &d) || d!=1) { - return NULL; + if (!XGetGeometry(dpy, bitmap, &foo, &bar, &bar, &width, &height, &baz, + &d) || d!=1) { + return NULL; } img = XGetImage(dpy, bitmap, 0, 0, width, height, AllPlanes, XYPixmap); if (!img) - return NULL; - + return NULL; + img2=XCreateImage(dpy, scr->w_visual, scr->w_depth, ZPixmap, - 0, NULL, width, height, 8, 0); + 0, NULL, width, height, 8, 0); if (!img2) { - XDestroyImage(img); - return NULL; + XDestroyImage(img); + return NULL; } - + pixmap = XCreatePixmap(dpy, scr->w_win, width, height, scr->w_depth); if (pixmap==None) { - XDestroyImage(img); - XDestroyImage(img2); - return NULL; + XDestroyImage(img); + XDestroyImage(img2); + return NULL; } img2->data = wmalloc(height * img2->bytes_per_line); - + for (y=0; ycopy_gc, None); XPutImage(dpy, pixmap, scr->copy_gc, img2, 0, 0, 0, 0, width, height); @@ -178,16 +178,16 @@ wPixmapCreate(WScreen *scr, Pixmap image, Pixmap mask) Window foo; int bar; unsigned int width, height, depth, baz; - + pix = wmalloc(sizeof(WPixmap)); memset(pix, 0, sizeof(WPixmap)); pix->image = image; pix->mask = mask; if (!XGetGeometry(dpy, image, &foo, &bar, &bar, &width, &height, &baz, - &depth)) { - wwarning("XGetGeometry() failed during wPixmapCreate()"); - wfree(pix); - return NULL; + &depth)) { + wwarning("XGetGeometry() failed during wPixmapCreate()"); + wfree(pix); + return NULL; } pix->width = width; pix->height = height; @@ -197,75 +197,76 @@ wPixmapCreate(WScreen *scr, Pixmap image, Pixmap mask) #if 0 /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * wPixmapLoadXBMFile-- * Creates a WPixmap structure and loads a XBM file into it with * an optional mask file. If a mask is not wanted, mask_path should be * NULL. - * + * * Returns: * A WPixmap structure or NULL on failure. - * + * * Notes: * If the mask bitmap is not successfully loaded the operation * continues as no mask was supplied. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ -WPixmap * +WPixmap* wPixmapLoadXBMFile(WScreen *scr, char *path, char *mask_path) { WPixmap *pix; int junk; if (!path) return NULL; - + pix = wmalloc(sizeof(WPixmap)); memset(pix, 0, sizeof(WPixmap)); - - if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&(pix->width), - (unsigned *)&(pix->height), - &(pix->image), &junk, &junk)!=BitmapSuccess) { - wfree(pix); - return NULL; + + if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&(pix->width), + (unsigned *)&(pix->height), + &(pix->image), &junk, &junk)!=BitmapSuccess) { + wfree(pix); + return NULL; } if (mask_path!=NULL) { - if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&junk, - (unsigned *)&junk, &(pix->mask), - &junk, &junk) !=BitmapSuccess) { - wwarning(_("could not load mask bitmap file \"%s\". Won't use mask"), - mask_path); - pix->mask = None; - } + if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&junk, + (unsigned *)&junk, &(pix->mask), + &junk, &junk) !=BitmapSuccess) { + wwarning(_("could not load mask bitmap file \"%s\". Won't use mask"), + mask_path); + pix->mask = None; + } } else { - pix->mask = None; + pix->mask = None; } pix->depth = 1; return pix; } -#endif +#endif /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * wPixmapDestroy-- * Destroys a WPixmap structure and the pixmap/mask it holds. - * + * * Returns: * None *---------------------------------------------------------------------- */ -void +void wPixmapDestroy(WPixmap *pix) { if (!pix->shared) { - if (pix->mask && !pix->client_owned_mask) { - XFreePixmap(dpy, pix->mask); - } + if (pix->mask && !pix->client_owned_mask) { + XFreePixmap(dpy, pix->mask); + } - if (pix->image && !pix->client_owned) { - XFreePixmap(dpy, pix->image); - } + if (pix->image && !pix->client_owned) { + XFreePixmap(dpy, pix->image); + } } wfree(pix); } + diff --git a/src/pixmap.h b/src/pixmap.h index ea839ca6..8b046752 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ #ifndef WMPIXMAP_H_ @@ -29,7 +29,7 @@ typedef struct WPixmap { int width, height; /* size of pixmap */ int depth; /* depth of pixmap */ unsigned int shared:1; /* if pixmaps should be kept - * when structure is freed */ + * when structure is freed */ unsigned int client_owned:1; unsigned int client_owned_mask:1; } WPixmap; @@ -39,9 +39,9 @@ WPixmap *wPixmapCreate(WScreen *scr, Pixmap image, Pixmap mask); WPixmap *wPixmapCreateFromXPMData(WScreen *scr, char **data); -WPixmap *wPixmapCreateFromXBMData(WScreen *scr, char *data, char *mask, - int width, int height, unsigned long fg, - unsigned long bg); +WPixmap *wPixmapCreateFromXBMData(WScreen *scr, char *data, char *mask, + int width, int height, unsigned long fg, + unsigned long bg); void wPixmapDestroy(WPixmap *pix); #endif diff --git a/src/placement.c b/src/placement.c index 47a1af6a..83da4e21 100644 --- a/src/placement.c +++ b/src/placement.c @@ -1,9 +1,9 @@ /* placement.c - window and icon placement on screen - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -46,27 +46,26 @@ extern WPreferences wPreferences; #define X_ORIGIN(scr) WMAX(usableArea.x1,\ - wPreferences.window_place_origin.x) + wPreferences.window_place_origin.x) #define Y_ORIGIN(scr) WMAX(usableArea.y1,\ - wPreferences.window_place_origin.y) + wPreferences.window_place_origin.y) /* * interactive window placement is in moveres.c */ -extern void -InteractivePlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, - unsigned width, unsigned height); +extern void InteractivePlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, + unsigned width, unsigned height); /* * Returns True if it is an icon and is in this workspace. */ static Bool -iconPosition(WCoreWindow *wcore, int sx1, int sy1, int sx2, int sy2, - int workspace, int *retX, int *retY) +iconPosition(WCoreWindow *wcore, int sx1, int sy1, int sx2, int sy2, + int workspace, int *retX, int *retY) { void *parent; int ok = 0; @@ -75,46 +74,46 @@ iconPosition(WCoreWindow *wcore, int sx1, int sy1, int sx2, int sy2, /* if it is an application icon */ if (wcore->descriptor.parent_type == WCLASS_APPICON - && !((WAppIcon*)parent)->docked) { - *retX = ((WAppIcon*)parent)->x_pos; - *retY = ((WAppIcon*)parent)->y_pos; + && !((WAppIcon*)parent)->docked) { + *retX = ((WAppIcon*)parent)->x_pos; + *retY = ((WAppIcon*)parent)->y_pos; - ok = 1; + ok = 1; } else if (wcore->descriptor.parent_type == WCLASS_MINIWINDOW && - (((WIcon*)parent)->owner->frame->workspace == workspace - || IS_OMNIPRESENT(((WIcon*)parent)->owner) - || wPreferences.sticky_icons) - && ((WIcon*)parent)->mapped) { + (((WIcon*)parent)->owner->frame->workspace == workspace + || IS_OMNIPRESENT(((WIcon*)parent)->owner) + || wPreferences.sticky_icons) + && ((WIcon*)parent)->mapped) { - *retX = ((WIcon*)parent)->owner->icon_x; - *retY = ((WIcon*)parent)->owner->icon_y; + *retX = ((WIcon*)parent)->owner->icon_x; + *retY = ((WIcon*)parent)->owner->icon_y; - ok = 1; + ok = 1; } else if (wcore->descriptor.parent_type == WCLASS_WINDOW - && ((WWindow*)parent)->flags.icon_moved - && (((WWindow*)parent)->frame->workspace == workspace - || IS_OMNIPRESENT((WWindow*)parent) - || wPreferences.sticky_icons)) { - *retX = ((WWindow*)parent)->icon_x; - *retY = ((WWindow*)parent)->icon_y; - - ok = 1; + && ((WWindow*)parent)->flags.icon_moved + && (((WWindow*)parent)->frame->workspace == workspace + || IS_OMNIPRESENT((WWindow*)parent) + || wPreferences.sticky_icons)) { + *retX = ((WWindow*)parent)->icon_x; + *retY = ((WWindow*)parent)->icon_y; + + ok = 1; } - + /* * Check if it is inside the screen. */ if (ok) { - if (*retX < sx1-wPreferences.icon_size) - ok = 0; - else if (*retX > sx2) - ok = 0; - - if (*retY < sy1-wPreferences.icon_size) - ok = 0; - else if (*retY > sy2) - ok = 0; + if (*retX < sx1-wPreferences.icon_size) + ok = 0; + else if (*retX > sx2) + ok = 0; + + if (*retY < sy1-wPreferences.icon_size) + ok = 0; + else if (*retY > sy2) + ok = 0; } return ok; @@ -156,10 +155,10 @@ PlaceIcon(WScreen *scr, int *x_ret, int *y_ret, int head) #if 0 if (scr->dock) { - if (scr->dock->on_right_side) + if (scr->dock->on_right_side) sx2 -= isize + DOCK_EXTRA_SPACE; - else - sx1 += isize + DOCK_EXTRA_SPACE; + else + sx1 += isize + DOCK_EXTRA_SPACE; } #endif @@ -168,34 +167,34 @@ PlaceIcon(WScreen *scr, int *x_ret, int *y_ret, int head) fullW = (sx2-sx1)/isize; fullH = (sy2-sy1)/isize; - /* icon yard boundaries */ + /* icon yard boundaries */ if (wPreferences.icon_yard & IY_VERT) { - pf = fullH; - sf = fullW; + pf = fullH; + sf = fullW; } else { - pf = fullW; - sf = fullH; + pf = fullW; + sf = fullH; } if (wPreferences.icon_yard & IY_RIGHT) { - xo = sx2 - isize; - xs = -1; + xo = sx2 - isize; + xs = -1; } else { - xo = sx1; - xs = 1; + xo = sx1; + xs = 1; } if (wPreferences.icon_yard & IY_TOP) { - yo = sy1; - ys = 1; + yo = sy1; + ys = 1; } else { - yo = sy2 - isize; - ys = -1; + yo = sy2 - isize; + ys = -1; } /* * Create a map with the occupied slots. 1 means the slot is used - * or at least partially used. + * or at least partially used. * The slot usage can be optimized by only marking fully used slots - * or slots that have most of it covered. + * or slots that have most of it covered. * Space usage is worse than the fvwm algorithm (used in the old version) * but complexity is much better (faster) than it. */ @@ -206,25 +205,25 @@ PlaceIcon(WScreen *scr, int *x_ret, int *y_ret, int head) WM_ETARETI_BAG(scr->stacking_list, obj, iter) { - while (obj) { - int x, y; - - if (iconPosition(obj, sx1, sy1, sx2, sy2, scr->current_workspace, - &x, &y)) { - int xdi, ydi; /* rounded down */ - int xui, yui; /* rounded up */ - - xdi = x/isize; - ydi = y/isize; - xui = (x+isize/2)/isize; - yui = (y+isize/2)/isize; - map[INDEX(xdi,ydi)] = 1; - map[INDEX(xdi,yui)] = 1; - map[INDEX(xui,ydi)] = 1; - map[INDEX(xui,yui)] = 1; - } - obj = obj->stacking->under; - } + while (obj) { + int x, y; + + if (iconPosition(obj, sx1, sy1, sx2, sy2, scr->current_workspace, + &x, &y)) { + int xdi, ydi; /* rounded down */ + int xui, yui; /* rounded up */ + + xdi = x/isize; + ydi = y/isize; + xui = (x+isize/2)/isize; + yui = (y+isize/2)/isize; + map[INDEX(xdi,ydi)] = 1; + map[INDEX(xdi,yui)] = 1; + map[INDEX(xui,ydi)] = 1; + map[INDEX(xui,yui)] = 1; + } + obj = obj->stacking->under; + } } /* * Default position @@ -236,23 +235,23 @@ PlaceIcon(WScreen *scr, int *x_ret, int *y_ret, int head) * Look for an empty slot */ for (si=0; si p2) { tmp = p1; p1 = p2; @@ -284,7 +283,7 @@ calcIntersectionLength(int p1, int l1, int p2, int l2) isect = l2; else isect = p1 + l1 - p2; - + return isect; } @@ -295,10 +294,10 @@ calcIntersectionLength(int p1, int l1, int p2, int l2) int calcIntersectionArea(int x1, int y1, int w1, int h1, - int x2, int y2, int w2, int h2) + int x2, int y2, int w2, int h2) { return calcIntersectionLength(x1, w1, x2, w2) - * calcIntersectionLength(y1, h1, y2, h2); + * calcIntersectionLength(y1, h1, y2, h2); } @@ -308,11 +307,11 @@ calcSumOfCoveredAreas(WWindow *wwin, int x, int y, int w, int h) int sum_isect = 0; WWindow *test_window; int tw,tx,ty,th; - + test_window = wwin->screen_ptr->focused_window; for(;test_window != NULL && test_window->prev != NULL;) - test_window = test_window->prev; - + test_window = test_window->prev; + for(; test_window != NULL; test_window = test_window->next) { if (test_window->frame->core->stacking->window_level < WMNormalLevel) { @@ -339,7 +338,7 @@ calcSumOfCoveredAreas(WWindow *wwin, int x, int y, int w, int h) sum_isect += calcIntersectionArea(tx, ty, tw, th, x, y, w, h); } } - + return sum_isect; } @@ -347,7 +346,7 @@ calcSumOfCoveredAreas(WWindow *wwin, int x, int y, int w, int h) static void smartPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, unsigned int width, unsigned int height, - WArea usableArea) + WArea usableArea) { //WScreen *scr = wwin->screen_ptr; int test_x = 0, test_y = Y_ORIGIN(scr); @@ -357,36 +356,36 @@ smartPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, int sum_isect; if (wwin->frame) { - height += wwin->frame->top_width + wwin->frame->bottom_width; + height += wwin->frame->top_width + wwin->frame->bottom_width; } else { - if (HAS_TITLEBAR(wwin)) height += 18; - if (HAS_RESIZEBAR(wwin)) height += 8; + if (HAS_TITLEBAR(wwin)) height += 18; + if (HAS_RESIZEBAR(wwin)) height += 8; } if (HAS_BORDER(wwin)) { - height += 2; - width += 2; + height += 2; + width += 2; } sx = X_ORIGIN(scr); min_isect = INT_MAX; min_isect_x = sx; min_isect_y = test_y; - + while (((test_y + height) < usableArea.y2)) { - test_x = sx; - while ((test_x + width) < usableArea.x2) { + test_x = sx; + while ((test_x + width) < usableArea.x2) { sum_isect = calcSumOfCoveredAreas(wwin, test_x, test_y, width, height); - if (sum_isect < min_isect) { - min_isect = sum_isect; - min_isect_x = test_x; - min_isect_y = test_y; - } - - test_x += PLACETEST_HSTEP; - } - test_y += PLACETEST_VSTEP; + if (sum_isect < min_isect) { + min_isect = sum_isect; + min_isect_x = test_x; + min_isect_y = test_y; + } + + test_x += PLACETEST_HSTEP; + } + test_y += PLACETEST_VSTEP; } from_x = min_isect_x - PLACETEST_HSTEP + 1; @@ -406,11 +405,11 @@ smartPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, sum_isect = calcSumOfCoveredAreas(wwin, test_x, test_y, width, height); - if (sum_isect < min_isect) { - min_isect = sum_isect; - min_isect_x = test_x; - min_isect_y = test_y; - } + if (sum_isect < min_isect) { + min_isect = sum_isect; + min_isect_x = test_x; + min_isect_y = test_y; + } } } @@ -422,7 +421,7 @@ smartPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, static Bool autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, unsigned int width, unsigned int height, int tryCount, - WArea usableArea) + WArea usableArea) { WScreen *scr = wwin->screen_ptr; int test_x = 0, test_y = Y_ORIGIN(scr); @@ -431,14 +430,14 @@ autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, WWindow *test_window; if (wwin->frame) { - height += wwin->frame->top_width + wwin->frame->bottom_width; + height += wwin->frame->top_width + wwin->frame->bottom_width; } else { - if (HAS_TITLEBAR(wwin)) height += 18; - if (HAS_RESIZEBAR(wwin)) height += 8; + if (HAS_TITLEBAR(wwin)) height += 18; + if (HAS_RESIZEBAR(wwin)) height += 8; } if (HAS_BORDER(wwin)) { - height += 2; - width += 2; + height += 2; + width += 2; } swidth = usableArea.x2-usableArea.x1; @@ -447,20 +446,20 @@ autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, /* this was based on fvwm2's smart placement */ while (((test_y + height) < (usableArea.y2 - usableArea.y1)) && !loc_ok) { - test_x = sx; + test_x = sx; - while (((test_x + width) < swidth) && (!loc_ok)) { + while (((test_x + width) < swidth) && (!loc_ok)) { - loc_ok = True; - test_window = scr->focused_window; + loc_ok = True; + test_window = scr->focused_window; - while ((test_window != NULL) && (loc_ok == True)) { + while ((test_window != NULL) && (loc_ok == True)) { - if (test_window->frame->core->stacking->window_level - < WMNormalLevel && tryCount > 0) { - test_window = test_window->next; - continue; - } + if (test_window->frame->core->stacking->window_level + < WMNormalLevel && tryCount > 0) { + test_window = test_window->next; + continue; + } #if 0 tw = test_window->client.width; if (test_window->flags.shaded) @@ -468,34 +467,34 @@ autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, else th = test_window->client.height + extra_height; #else - tw = test_window->frame->core->width; - th = test_window->frame->core->height; + tw = test_window->frame->core->width; + th = test_window->frame->core->height; #endif - tx = test_window->frame_x; - ty = test_window->frame_y; + tx = test_window->frame_x; + ty = test_window->frame_y; - if ((tx < (test_x + width)) && ((tx + tw) > test_x) && - (ty < (test_y + height)) && ((ty + th) > test_y) && - (test_window->flags.mapped || + if ((tx < (test_x + width)) && ((tx + tw) > test_x) && + (ty < (test_y + height)) && ((ty + th) > test_y) && + (test_window->flags.mapped || (test_window->flags.shaded && test_window->frame->workspace==scr->current_workspace && - !(test_window->flags.miniaturized || - test_window->flags.hidden)))) { + !(test_window->flags.miniaturized || + test_window->flags.hidden)))) { loc_ok = False; - } - test_window = test_window->next; - } + } + test_window = test_window->next; + } - test_window = scr->focused_window; + test_window = scr->focused_window; - while ((test_window != NULL) && (loc_ok == True)) { + while ((test_window != NULL) && (loc_ok == True)) { - if (test_window->frame->core->stacking->window_level - < WMNormalLevel && tryCount > 0) { - test_window = test_window->prev; - continue; - } + if (test_window->frame->core->stacking->window_level + < WMNormalLevel && tryCount > 0) { + test_window = test_window->prev; + continue; + } #if 0 tw = test_window->client.width; if (test_window->flags.shaded) @@ -503,83 +502,83 @@ autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, else th = test_window->client.height + extra_height; #else - tw = test_window->frame->core->width; - th = test_window->frame->core->height; + tw = test_window->frame->core->width; + th = test_window->frame->core->height; #endif - tx = test_window->frame_x; - ty = test_window->frame_y; + tx = test_window->frame_x; + ty = test_window->frame_y; - if ((tx < (test_x + width)) && ((tx + tw) > test_x) && - (ty < (test_y + height)) && ((ty + th) > test_y) && - (test_window->flags.mapped || - (test_window->flags.shaded && + if ((tx < (test_x + width)) && ((tx + tw) > test_x) && + (ty < (test_y + height)) && ((ty + th) > test_y) && + (test_window->flags.mapped || + (test_window->flags.shaded && test_window->frame->workspace==scr->current_workspace && - !(test_window->flags.miniaturized || - test_window->flags.hidden)))) { + !(test_window->flags.miniaturized || + test_window->flags.hidden)))) { loc_ok = False; - } - test_window = test_window->prev; - } - if (loc_ok == True) { - *x_ret = test_x; - *y_ret = test_y; - break; - } - test_x += PLACETEST_HSTEP; - } - test_y += PLACETEST_VSTEP; + } + test_window = test_window->prev; + } + if (loc_ok == True) { + *x_ret = test_x; + *y_ret = test_y; + break; + } + test_x += PLACETEST_HSTEP; + } + test_y += PLACETEST_VSTEP; } return loc_ok; } -static void +static void cascadeWindow(WScreen *scr, WWindow *wwin, int *x_ret, int *y_ret, unsigned int width, unsigned int height, int h, - WArea usableArea) + WArea usableArea) { if (wwin->frame) { - height += wwin->frame->top_width + wwin->frame->bottom_width; + height += wwin->frame->top_width + wwin->frame->bottom_width; } else { - if (HAS_TITLEBAR(wwin)) height += 18; - if (HAS_RESIZEBAR(wwin)) height += 8; + if (HAS_TITLEBAR(wwin)) height += 18; + if (HAS_RESIZEBAR(wwin)) height += 8; } if (HAS_BORDER(wwin)) { - height += 2; - width += 2; + height += 2; + width += 2; } - + *x_ret = h * scr->cascade_index + X_ORIGIN(scr); *y_ret = h * scr->cascade_index + Y_ORIGIN(scr); if (width + *x_ret > usableArea.x2 || height + *y_ret > usableArea.y2) { - scr->cascade_index = 0; - *x_ret = X_ORIGIN(scr); - *y_ret = Y_ORIGIN(scr); + scr->cascade_index = 0; + *x_ret = X_ORIGIN(scr); + *y_ret = Y_ORIGIN(scr); } } static void randomPlaceWindow(WScreen *scr, WWindow *wwin, int *x_ret, int *y_ret, - unsigned int width, unsigned int height, - WArea usableArea) + unsigned int width, unsigned int height, + WArea usableArea) { int w, h; - + if (wwin->frame) { - height += wwin->frame->top_width + wwin->frame->bottom_width; + height += wwin->frame->top_width + wwin->frame->bottom_width; } else { - if (HAS_TITLEBAR(wwin)) height += 18; - if (HAS_RESIZEBAR(wwin)) height += 8; + if (HAS_TITLEBAR(wwin)) height += 18; + if (HAS_RESIZEBAR(wwin)) height += 8; } if (HAS_BORDER(wwin)) { - height += 2; - width += 2; + height += 2; + width += 2; } - + w = ((usableArea.x2-X_ORIGIN(scr)) - width); h = ((usableArea.y2-Y_ORIGIN(scr)) - height); if (w<1) w = 1; @@ -596,65 +595,65 @@ PlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, { WScreen *scr = wwin->screen_ptr; int h = WMFontHeight(scr->title_font) + (wPreferences.window_title_clearance + TITLEBAR_EXTEND_SPACE) * 2; - WArea usableArea = wGetUsableAreaForHead(scr, - wGetHeadForPointerLocation(scr), - NULL, True); - + WArea usableArea = wGetUsableAreaForHead(scr, + wGetHeadForPointerLocation(scr), + NULL, True); + switch (wPreferences.window_placement) { - case WPM_MANUAL: - InteractivePlaceWindow(wwin, x_ret, y_ret, width, height); - break; - - case WPM_SMART: - smartPlaceWindow(wwin, x_ret, y_ret, width, height, usableArea); - break; - - case WPM_AUTO: - if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, 0, - usableArea)) { - break; - } else if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, 1, - usableArea)) { - break; - } - /* there isn't a break here, because if we fail, it should fall - through to cascade placement, as people who want tiling want - automagicness aren't going to want to place their window */ - - case WPM_CASCADE: + case WPM_MANUAL: + InteractivePlaceWindow(wwin, x_ret, y_ret, width, height); + break; + + case WPM_SMART: + smartPlaceWindow(wwin, x_ret, y_ret, width, height, usableArea); + break; + + case WPM_AUTO: + if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, 0, + usableArea)) { + break; + } else if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, 1, + usableArea)) { + break; + } + /* there isn't a break here, because if we fail, it should fall + through to cascade placement, as people who want tiling want + automagicness aren't going to want to place their window */ + + case WPM_CASCADE: if (wPreferences.window_placement == WPM_AUTO) scr->cascade_index++; - cascadeWindow(scr, wwin, x_ret, y_ret, width, height, h, usableArea); + cascadeWindow(scr, wwin, x_ret, y_ret, width, height, h, usableArea); if (wPreferences.window_placement == WPM_CASCADE) scr->cascade_index++; - break; + break; - case WPM_RANDOM: - randomPlaceWindow(scr, wwin, x_ret, y_ret, width, height, usableArea); - break; + case WPM_RANDOM: + randomPlaceWindow(scr, wwin, x_ret, y_ret, width, height, usableArea); + break; #ifdef DEBUG - default: - puts("Invalid window placement!!!"); - *x_ret = 0; - *y_ret = 0; + default: + puts("Invalid window placement!!!"); + *x_ret = 0; + *y_ret = 0; #endif } - + /* * clip to usableArea instead of full screen * this will also take dock/clip etc.. into account * aswell as being xinerama friendly */ if (*x_ret + width > usableArea.x2) - *x_ret = usableArea.x2 - width; + *x_ret = usableArea.x2 - width; if (*x_ret < usableArea.x1) *x_ret = usableArea.x1; if (*y_ret + height > usableArea.y2) - *y_ret = usableArea.y2 - height; + *y_ret = usableArea.y2 - height; if (*y_ret < usableArea.y1) *y_ret = usableArea.y1; } diff --git a/src/properties.c b/src/properties.c index 11aa8da4..0a52f05d 100644 --- a/src/properties.c +++ b/src/properties.c @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -62,13 +62,13 @@ PropGetNormalHints(Window window, XSizeHints *size_hints, int *pre_iccm) long supplied_hints; if (!XGetWMNormalHints(dpy, window, size_hints, &supplied_hints)) { - return False; - } + return False; + } if (supplied_hints==(USPosition|USSize|PPosition|PSize|PMinSize|PMaxSize - |PResizeInc|PAspect)) { - *pre_iccm = 1; + |PResizeInc|PAspect)) { + *pre_iccm = 1; } else { - *pre_iccm = 0; + *pre_iccm = 0; } return True; } @@ -81,15 +81,15 @@ PropGetWMClass(Window window, char **wm_class, char **wm_instance) class_hint = XAllocClassHint(); if (XGetClassHint(dpy,window,class_hint) == 0) { - *wm_class = NULL; - *wm_instance = NULL; - XFree(class_hint); - return False; + *wm_class = NULL; + *wm_instance = NULL; + XFree(class_hint); + return False; } *wm_instance = class_hint->res_name; *wm_class = class_hint->res_class; - XFree(class_hint); + XFree(class_hint); return True; } @@ -99,20 +99,20 @@ PropGetProtocols(Window window, WProtocols *prots) { Atom *protocols; int count, i; - + memset(prots, 0, sizeof(WProtocols)); if (!XGetWMProtocols(dpy, window, &protocols, &count)) { - return; + return; } for (i=0; iTAKE_FOCUS=1; - else if (protocols[i]==_XA_WM_DELETE_WINDOW) - prots->DELETE_WINDOW=1; - else if (protocols[i]==_XA_WM_SAVE_YOURSELF) - prots->SAVE_YOURSELF=1; - else if (protocols[i]==_XA_GNUSTEP_WM_MINIATURIZE_WINDOW) - prots->MINIATURIZE_WINDOW=1; + if (protocols[i]==_XA_WM_TAKE_FOCUS) + prots->TAKE_FOCUS=1; + else if (protocols[i]==_XA_WM_DELETE_WINDOW) + prots->DELETE_WINDOW=1; + else if (protocols[i]==_XA_WM_SAVE_YOURSELF) + prots->SAVE_YOURSELF=1; + else if (protocols[i]==_XA_GNUSTEP_WM_MINIATURIZE_WINDOW) + prots->MINIATURIZE_WINDOW=1; } XFree(protocols); } @@ -120,7 +120,7 @@ PropGetProtocols(Window window, WProtocols *prots) unsigned char* PropGetCheckProperty(Window window, Atom hint, Atom type, int format, - int count, int *retCount) + int count, int *retCount) { Atom type_ret; int fmt_ret; @@ -130,24 +130,24 @@ PropGetCheckProperty(Window window, Atom hint, Atom type, int format, int tmp; if (count <= 0) - tmp = 0xffffff; + tmp = 0xffffff; else - tmp = count; + tmp = count; if (XGetWindowProperty(dpy, window, hint, 0, tmp, False, type, - &type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret, - (unsigned char **)&data)!=Success || !data) - return NULL; + &type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret, + (unsigned char **)&data)!=Success || !data) + return NULL; if ((type!=AnyPropertyType && type!=type_ret) - || (count > 0 && nitems_ret != count) - || (format != 0 && format != fmt_ret)) { - XFree(data); - return NULL; + || (count > 0 && nitems_ret != count) + || (format != 0 && format != fmt_ret)) { + XFree(data); + return NULL; } if (retCount) - *retCount = nitems_ret; + *retCount = nitems_ret; return data; } @@ -159,16 +159,16 @@ PropGetGNUstepWMAttr(Window window, GNUstepWMAttributes **attr) unsigned long *data; data = (unsigned long*)PropGetCheckProperty(window, _XA_GNUSTEP_WM_ATTR, - _XA_GNUSTEP_WM_ATTR, 32, 9, - NULL); - + _XA_GNUSTEP_WM_ATTR, 32, 9, + NULL); + if (!data) - return False; - + return False; + *attr = malloc(sizeof(GNUstepWMAttributes)); if (!*attr) { - XFree(data); - return False; + XFree(data); + return False; } (*attr)->flags = data[0]; (*attr)->window_style = data[1]; @@ -192,13 +192,13 @@ PropSetWMakerProtocols(Window root) { Atom protocols[3]; int count=0; - + protocols[count++] = _XA_WINDOWMAKER_MENU; protocols[count++] = _XA_WINDOWMAKER_WM_FUNCTION; protocols[count++] = _XA_WINDOWMAKER_NOTICEBOARD; XChangeProperty(dpy, root, _XA_WINDOWMAKER_WM_PROTOCOLS, XA_ATOM, - 32, PropModeReplace, (unsigned char *)protocols, count); + 32, PropModeReplace, (unsigned char *)protocols, count); } @@ -208,50 +208,50 @@ PropSetIconTileHint(WScreen *scr, RImage *image) static Atom imageAtom = 0; unsigned char *tmp; int x, y; - + if (scr->info_window == None) - return; - + return; + if (!imageAtom) { - /* - * WIDTH, HEIGHT (16 bits, MSB First) - * array of R,G,B,A bytes - */ - imageAtom = XInternAtom(dpy, "_RGBA_IMAGE", False); + /* + * WIDTH, HEIGHT (16 bits, MSB First) + * array of R,G,B,A bytes + */ + imageAtom = XInternAtom(dpy, "_RGBA_IMAGE", False); } - + tmp = malloc(image->width * image->height * 4 + 4); if (!tmp) { - wwarning("could not allocate memory to set _WINDOWMAKER_ICON_TILE hint"); - return; + wwarning("could not allocate memory to set _WINDOWMAKER_ICON_TILE hint"); + return; } - + tmp[0] = image->width>>8; tmp[1] = image->width&0xff; tmp[2] = image->height>>8; tmp[3] = image->height&0xff; - + if (image->format == RRGBAFormat) { - memcpy(&tmp[4], image->data, image->width*image->height*4); + memcpy(&tmp[4], image->data, image->width*image->height*4); } else { - char *ptr = tmp+4; - char *src = image->data; - - for (y = 0; y < image->height; y++) { - for (x = 0; x < image->width; x++) { - *ptr++ = *src++; - *ptr++ = *src++; - *ptr++ = *src++; - *ptr++ = 255; - } - } + char *ptr = tmp+4; + char *src = image->data; + + for (y = 0; y < image->height; y++) { + for (x = 0; x < image->width; x++) { + *ptr++ = *src++; + *ptr++ = *src++; + *ptr++ = *src++; + *ptr++ = 255; + } + } } - + XChangeProperty(dpy, scr->info_window, _XA_WINDOWMAKER_ICON_TILE, - imageAtom, 8, PropModeReplace, tmp, - image->width * image->height * 4 + 4); + imageAtom, 8, PropModeReplace, tmp, + image->width * image->height * 4 + 4); wfree(tmp); - + } @@ -262,10 +262,10 @@ PropGetClientLeader(Window window) Window leader; win = (Window*)PropGetCheckProperty(window, _XA_WM_CLIENT_LEADER, - XA_WINDOW, 32, 1, NULL); + XA_WINDOW, 32, 1, NULL); if (!win) - return None; + return None; leader = (Window)*win; XFree(win); @@ -279,23 +279,23 @@ char* PropGetClientID(Window window) { XTextProperty txprop; - + txprop.value = NULL; if (XGetTextProperty(dpy, window, &txprop, _XA_SM_CLIENT_ID)!=Success) { - return NULL; + return NULL; } - - if (txprop.encoding == XA_STRING && txprop.format == 8 - && txprop.nitems > 0) { - return (char*)txprop.value; + if (txprop.encoding == XA_STRING && txprop.format == 8 + && txprop.nitems > 0) { + + return (char*)txprop.value; } else { - if (txprop.value) - XFree(txprop.value); + if (txprop.value) + XFree(txprop.value); - return NULL; + return NULL; } } @@ -304,23 +304,23 @@ char* PropGetWindowRole(Window window) { XTextProperty txprop; - + txprop.value = NULL; if (XGetTextProperty(dpy, window, &txprop, _XA_WM_WINDOW_ROLE)!=Success) { - return NULL; + return NULL; } - if (txprop.encoding == XA_STRING && txprop.format == 8 - && txprop.nitems > 0) { + if (txprop.encoding == XA_STRING && txprop.format == 8 + && txprop.nitems > 0) { - return (char*)txprop.value; + return (char*)txprop.value; } else { - if (txprop.value) - XFree(txprop.value); + if (txprop.value) + XFree(txprop.value); - return NULL; + return NULL; } } #endif /* XSMP_ENABLED */ @@ -330,7 +330,7 @@ void PropWriteGNUstepWMAttr(Window window, GNUstepWMAttributes *attr) { unsigned long data[9]; - + data[0] = attr->flags; data[1] = attr->window_style; data[2] = attr->window_level; @@ -341,8 +341,8 @@ PropWriteGNUstepWMAttr(Window window, GNUstepWMAttributes *attr) data[6] = attr->miniaturize_mask; data[7] = attr->close_mask; data[8] = attr->extra_flags; - XChangeProperty(dpy, window, _XA_GNUSTEP_WM_ATTR, _XA_GNUSTEP_WM_ATTR, - 32, PropModeReplace, (unsigned char *)data, 9); + XChangeProperty(dpy, window, _XA_GNUSTEP_WM_ATTR, _XA_GNUSTEP_WM_ATTR, + 32, PropModeReplace, (unsigned char *)data, 9); } @@ -353,10 +353,10 @@ PropGetWindowState(Window window) long state; data = (long*)PropGetCheckProperty(window, _XA_WM_STATE, _XA_WM_STATE, - 32, 1, NULL); + 32, 1, NULL); if (!data) - return -1; + return -1; state = *data; XFree(data); diff --git a/src/properties.h b/src/properties.h index a2e75dc3..37080621 100644 --- a/src/properties.h +++ b/src/properties.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -25,8 +25,8 @@ #include "GNUstep.h" -unsigned char* PropGetCheckProperty(Window window, Atom hint, Atom type, - int format, int count, int *retCount); +unsigned char* PropGetCheckProperty(Window window, Atom hint, Atom type, + int format, int count, int *retCount); int PropGetWindowState(Window window); diff --git a/src/resources.c b/src/resources.c index 72272275..05e9bca0 100644 --- a/src/resources.c +++ b/src/resources.c @@ -1,9 +1,9 @@ /* resources.c - manage X resources (colors etc) - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -41,12 +41,12 @@ int wGetColor(WScreen *scr, char *color_name, XColor *color) { if (!XParseColor(dpy, scr->w_colormap, color_name, color)) { - wwarning(_("could not parse color \"%s\""), color_name); - return False; + wwarning(_("could not parse color \"%s\""), color_name); + return False; } if (!XAllocColor(dpy, scr->w_colormap, color)) { - wwarning(_("could not allocate color \"%s\""), color_name); - return False; + wwarning(_("could not allocate color \"%s\""), color_name); + return False; } return True; } @@ -56,9 +56,10 @@ void wFreeColor(WScreen *scr, unsigned long pixel) { if (pixel!=scr->white_pixel && pixel!=scr->black_pixel) { - unsigned long colors[1]; - - colors[0] = pixel; - XFreeColors(dpy, scr->w_colormap, colors, 1, 0); + unsigned long colors[1]; + + colors[0] = pixel; + XFreeColors(dpy, scr->w_colormap, colors, 1, 0); } } + diff --git a/src/resources.h b/src/resources.h index 95a1a1d3..b47e8f1e 100644 --- a/src/resources.h +++ b/src/resources.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ diff --git a/src/rootmenu.c b/src/rootmenu.c index 9329132e..acbf1425 100644 --- a/src/rootmenu.c +++ b/src/rootmenu.c @@ -1,10 +1,10 @@ /* rootmenu.c- user defined menu - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima * Copyright (c) 1998-2003 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. */ @@ -43,7 +43,7 @@ #include "WindowMaker.h" #include "actions.h" #include "menu.h" -#include "funcs.h" +#include "funcs.h" #include "dialog.h" #include "keybind.h" #include "stacking.h" @@ -72,12 +72,12 @@ extern int wScreenCount; static WMenu *readMenuPipe(WScreen *scr, char **file_name); static WMenu *readMenuFile(WScreen *scr, char *file_name); static WMenu *readMenuDirectory(WScreen *scr, char *title, char **file_name, - char *command); + char *command); typedef struct Shortcut { struct Shortcut *next; - + int modifier; KeyCode keycode; WMenuEntry *entry; @@ -102,9 +102,9 @@ static Shortcut *shortcutList = NULL; * "Quit" EXIT * "Quick Quit" EXIT QUICK * "Menu Name" END - * + * * Commands may be preceded by SHORTCUT key - * + * * Built-in commands: * * INFO_PANEL - shows the Info Panel @@ -143,7 +143,7 @@ static Shortcut *shortcutList = NULL; * dock state now. * CLEAR_SESSION - clears any previous saved session. This will not have * any effect if SaveSessionOnExit is True. - * + * */ #define M_QUICK 1 @@ -158,13 +158,13 @@ execCommand(WMenu *menu, WMenuEntry *entry) cmdline = ExpandOptions(menu->frame->screen_ptr, (char*)entry->clientdata); XGrabPointer(dpy, menu->frame->screen_ptr->root_win, True, 0, - GrabModeAsync, GrabModeAsync, None, wCursor[WCUR_WAIT], - CurrentTime); + GrabModeAsync, GrabModeAsync, None, wCursor[WCUR_WAIT], + CurrentTime); XSync(dpy, 0); if (cmdline) { - ExecuteShellCommand(menu->frame->screen_ptr, cmdline); - wfree(cmdline); + ExecuteShellCommand(menu->frame->screen_ptr, cmdline); + wfree(cmdline); } XUngrabPointer(dpy, CurrentTime); XSync(dpy, 0); @@ -179,7 +179,7 @@ exitCommand(WMenu *menu, WMenuEntry *entry) /* prevent reentrant calls */ if (inside) - return; + return; inside = 1; #define R_CANCEL 0 @@ -207,9 +207,9 @@ exitCommand(WMenu *menu, WMenuEntry *entry) } if (result==R_EXIT) { #ifdef DEBUG - printf("Exiting WindowMaker.\n"); + printf("Exiting WindowMaker.\n"); #endif - Shutdown(WSExitMode); + Shutdown(WSExitMode); } #undef R_EXIT #undef R_CANCEL @@ -225,39 +225,39 @@ shutdownCommand(WMenu *menu, WMenuEntry *entry) /* prevent reentrant calls */ if (inside) - return; + return; inside = 1; #define R_CANCEL 0 #define R_CLOSE 1 #define R_KILL 2 - + result = R_CANCEL; if ((long)entry->clientdata==M_QUICK) - result = R_CLOSE; + result = R_CLOSE; else { #ifdef XSMP_ENABLED - if (wSessionIsManaged()) { - int r; - - r = wMessageDialog(menu->frame->screen_ptr, - _("Close X session"), - _("Close Window System session?\n" - "Kill might close applications with unsaved data."), - _("Close"), _("Kill"), _("Cancel")); - if (r==WAPRDefault) - result = R_CLOSE; - else if (r==WAPRAlternate) - result = R_KILL; - } else + if (wSessionIsManaged()) { + int r; + + r = wMessageDialog(menu->frame->screen_ptr, + _("Close X session"), + _("Close Window System session?\n" + "Kill might close applications with unsaved data."), + _("Close"), _("Kill"), _("Cancel")); + if (r==WAPRDefault) + result = R_CLOSE; + else if (r==WAPRAlternate) + result = R_KILL; + } else #endif - { - int r, oldSaveSessionFlag; + { + int r, oldSaveSessionFlag; oldSaveSessionFlag = wPreferences.save_session_on_exit; - r = wExitDialog(menu->frame->screen_ptr, + r = wExitDialog(menu->frame->screen_ptr, _("Kill X session"), _("Kill Window System session?\n" "(all applications will be closed)"), @@ -269,18 +269,18 @@ shutdownCommand(WMenu *menu, WMenuEntry *entry) * user canceled the operation. */ wPreferences.save_session_on_exit = oldSaveSessionFlag; } - } - } - + } + } + if (result!=R_CANCEL) { #ifdef XSMP_ENABLED - if (result == R_CLOSE) { - Shutdown(WSLogoutMode); - } else + if (result == R_CLOSE) { + Shutdown(WSLogoutMode); + } else #endif /* XSMP_ENABLED */ - { - Shutdown(WSKillMode); - } + { + Shutdown(WSKillMode); + } } #undef R_CLOSE #undef R_CANCEL @@ -328,7 +328,7 @@ static void saveSessionCommand(WMenu *menu, WMenuEntry *entry) { if (!wPreferences.save_session_on_exit) - wSessionSaveState(menu->frame->screen_ptr); + wSessionSaveState(menu->frame->screen_ptr); wScreenSaveState(menu->frame->screen_ptr); } @@ -366,7 +366,7 @@ getLocalizedMenuFile(char *menu) int len; if (!Locale) - return NULL; + return NULL; len = strlen(menu)+strlen(Locale)+8; buffer = wmalloc(len); @@ -374,7 +374,7 @@ getLocalizedMenuFile(char *menu) /* try menu.locale_name */ snprintf(buffer, len, "%s.%s", menu, Locale); if (access(buffer, F_OK)==0) { - return buffer; + return buffer; } /* position of locale in our buffer */ @@ -383,18 +383,18 @@ getLocalizedMenuFile(char *menu) /* check if it is in the form aa_bb.encoding and check for aa_bb */ ptr = strchr(locale, '.'); if (ptr) { - *ptr = 0; - if (access(buffer, F_OK)==0) { - return buffer; - } + *ptr = 0; + if (access(buffer, F_OK)==0) { + return buffer; + } } /* now check for aa */ ptr = strchr(locale, '_'); if (ptr) { - *ptr = 0; - if (access(buffer, F_OK)==0) { - return buffer; - } + *ptr = 0; + if (access(buffer, F_OK)==0) { + return buffer; + } } wfree(buffer); @@ -407,13 +407,13 @@ static void raiseMenus(WMenu *menu) { int i; - + if (menu->flags.mapped) { - wRaiseFrame(menu->frame->core); + wRaiseFrame(menu->frame->core); } for (i=0; icascade_no; i++) { - if (menu->cascades[i]) - raiseMenus(menu->cascades[i]); + if (menu->cascades[i]) + raiseMenus(menu->cascades[i]); } } @@ -448,20 +448,20 @@ void wRootMenuBindShortcuts(Window window) { Shortcut *ptr; - + ptr = shortcutList; while (ptr) { - if (ptr->modifier!=AnyModifier) { - XGrabKey(dpy, ptr->keycode, ptr->modifier|LockMask, - window, True, GrabModeAsync, GrabModeAsync); + if (ptr->modifier!=AnyModifier) { + XGrabKey(dpy, ptr->keycode, ptr->modifier|LockMask, + window, True, GrabModeAsync, GrabModeAsync); #ifdef NUMLOCK_HACK - wHackedGrabKey(ptr->keycode, ptr->modifier, - window, True, GrabModeAsync, GrabModeAsync); + wHackedGrabKey(ptr->keycode, ptr->modifier, + window, True, GrabModeAsync, GrabModeAsync); #endif - } - XGrabKey(dpy, ptr->keycode, ptr->modifier, window, True, - GrabModeAsync, GrabModeAsync); - ptr = ptr->next; + } + XGrabKey(dpy, ptr->keycode, ptr->modifier, window, True, + GrabModeAsync, GrabModeAsync); + ptr = ptr->next; } } @@ -470,16 +470,16 @@ static void rebindKeygrabs(WScreen *scr) { WWindow *wwin; - + wwin = scr->focused_window; - + while (wwin!=NULL) { - XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window); + XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window); - if (!WFLAGP(wwin, no_bind_keys)) { - wWindowSetKeyGrabs(wwin); - } - wwin = wwin->prev; + if (!WFLAGP(wwin, no_bind_keys)) { + wWindowSetKeyGrabs(wwin); + } + wwin = wwin->prev; } } @@ -492,14 +492,14 @@ removeShortcutsForMenu(WMenu *menu) ptr = shortcutList; while (ptr!=NULL) { - tmp = ptr->next; - if (ptr->menu == menu) { - wfree(ptr); - } else { - ptr->next = newList; - newList = ptr; - } - ptr = tmp; + tmp = ptr->next; + if (ptr->menu == menu) { + wfree(ptr); + } else { + ptr->next = newList; + newList = ptr; + } + ptr = tmp; } shortcutList = newList; menu->menu->screen_ptr->flags.root_menu_changed_shortcuts = 1; @@ -508,61 +508,61 @@ removeShortcutsForMenu(WMenu *menu) static Bool addShortcut(char *file, char *shortcutDefinition, WMenu *menu, - WMenuEntry *entry) + WMenuEntry *entry) { - Shortcut *ptr; + Shortcut *ptr; KeySym ksym; char *k; char buf[128], *b; ptr = wmalloc(sizeof(Shortcut)); - + strcpy(buf, shortcutDefinition); b = (char*)buf; /* get modifiers */ ptr->modifier = 0; while ((k = strchr(b, '+'))!=NULL) { - int mod; - - *k = 0; - mod = wXModifierFromKey(b); - if (mod<0) { - wwarning(_("%s:invalid key modifier \"%s\""), file, b); - wfree(ptr); - return False; - } - ptr->modifier |= mod; - - b = k+1; + int mod; + + *k = 0; + mod = wXModifierFromKey(b); + if (mod<0) { + wwarning(_("%s:invalid key modifier \"%s\""), file, b); + wfree(ptr); + return False; + } + ptr->modifier |= mod; + + b = k+1; } - + /* get key */ ksym = XStringToKeysym(b); - + if (ksym==NoSymbol) { - wwarning(_("%s:invalid kbd shortcut specification \"%s\" for entry %s"), - file, shortcutDefinition, entry->text); - wfree(ptr); - return False; + wwarning(_("%s:invalid kbd shortcut specification \"%s\" for entry %s"), + file, shortcutDefinition, entry->text); + wfree(ptr); + return False; } - + ptr->keycode = XKeysymToKeycode(dpy, ksym); if (ptr->keycode==0) { - wwarning(_("%s:invalid key in shortcut \"%s\" for entry %s"), file, - shortcutDefinition, entry->text); - wfree(ptr); - return False; + wwarning(_("%s:invalid key in shortcut \"%s\" for entry %s"), file, + shortcutDefinition, entry->text); + wfree(ptr); + return False; } ptr->menu = menu; ptr->entry = entry; - + ptr->next = shortcutList; shortcutList = ptr; - + menu->menu->screen_ptr->flags.root_menu_changed_shortcuts = 1; - + return True; } @@ -573,15 +573,15 @@ static char* cropline(char *line) { char *end; - + if (strlen(line)==0) - return line; - + return line; + end = &(line[strlen(line)])-1; while (isspace(*line) && *line!=0) line++; while (end>line && isspace(*end)) { - *end=0; - end--; + *end=0; + end--; } return line; } @@ -655,7 +655,7 @@ separateCommand(char *line, char ***file, char **command) wwarning(_("%s: missing command"), line); break; } - WMAddToArray(array, token); + WMAddToArray(array, token); } } while (token!=NULL && tmp!=NULL); @@ -681,53 +681,53 @@ constructMenu(WMenu *menu, WMenuEntry *entry) char *lpath = NULL; int i, first=-1; time_t last=0; - + separateCommand((char*)entry->clientdata, &path, &cmd); if (path == NULL || *path==NULL || **path==0) { - wwarning(_("invalid OPEN_MENU specification: %s"), - (char*)entry->clientdata); - return; + wwarning(_("invalid OPEN_MENU specification: %s"), + (char*)entry->clientdata); + return; } if (path[0][0]=='|') { /* pipe menu */ - if (!menu->cascades[entry->cascade] || - menu->cascades[entry->cascade]->timestamp == 0) { + if (!menu->cascades[entry->cascade] || + menu->cascades[entry->cascade]->timestamp == 0) { /* parse pipe */ - submenu = readMenuPipe(menu->frame->screen_ptr, path); + submenu = readMenuPipe(menu->frame->screen_ptr, path); if(submenu != NULL) { - if (path[0][1] == '|') - submenu->timestamp = 0; - else + if (path[0][1] == '|') + submenu->timestamp = 0; + else submenu->timestamp = 1; /* there's no automatic reloading */ - } - } else { - submenu = NULL; + } + } else { + submenu = NULL; } - + } else { i=0; while(path[i] != NULL) { - char *tmp; - - if (strcmp(path[i], "-noext")==0) { - i++; - continue; - } - - tmp = wexpandpath(path[i]); - wfree(path[i]); - lpath = getLocalizedMenuFile(tmp); - if (lpath) { - wfree(tmp); - path[i] = lpath; - lpath = NULL; - } else { - path[i] = tmp; - } + char *tmp; + + if (strcmp(path[i], "-noext")==0) { + i++; + continue; + } + + tmp = wexpandpath(path[i]); + wfree(path[i]); + lpath = getLocalizedMenuFile(tmp); + if (lpath) { + wfree(tmp); + path[i] = lpath; + lpath = NULL; + } else { + path[i] = tmp; + } if (stat(path[i], &stat_buf)==0) { if (last < stat_buf.st_mtime) @@ -748,36 +748,36 @@ constructMenu(WMenu *menu, WMenuEntry *entry) goto finish; } stat(path[first], &stat_buf); - if (!menu->cascades[entry->cascade] - || menu->cascades[entry->cascade]->timestamp < last) { + if (!menu->cascades[entry->cascade] + || menu->cascades[entry->cascade]->timestamp < last) { - if (S_ISDIR(stat_buf.st_mode)) { - /* menu directory */ - submenu = readMenuDirectory(menu->frame->screen_ptr, + if (S_ISDIR(stat_buf.st_mode)) { + /* menu directory */ + submenu = readMenuDirectory(menu->frame->screen_ptr, entry->text, path, cmd); - if (submenu) - submenu->timestamp = last; - } else if (S_ISREG(stat_buf.st_mode)) { - /* menu file */ - - if (cmd || path[1]) - wwarning(_("too many parameters in OPEN_MENU: %s"), - (char*)entry->clientdata); - - submenu = readMenuFile(menu->frame->screen_ptr, path[first]); - if (submenu) - submenu->timestamp = stat_buf.st_mtime; - } else { - submenu = NULL; - } - } else { - submenu = NULL; - } + if (submenu) + submenu->timestamp = last; + } else if (S_ISREG(stat_buf.st_mode)) { + /* menu file */ + + if (cmd || path[1]) + wwarning(_("too many parameters in OPEN_MENU: %s"), + (char*)entry->clientdata); + + submenu = readMenuFile(menu->frame->screen_ptr, path[first]); + if (submenu) + submenu->timestamp = stat_buf.st_mtime; + } else { + submenu = NULL; + } + } else { + submenu = NULL; + } } if (submenu) { - wMenuEntryRemoveCascade(menu, entry); - wMenuEntrySetCascade(menu, entry, submenu); + wMenuEntryRemoveCascade(menu, entry); + wMenuEntrySetCascade(menu, entry, submenu); } finish: @@ -786,7 +786,7 @@ finish: wfree(path[i++]); wfree(path); if (cmd) - wfree(cmd); + wfree(cmd); } @@ -794,7 +794,7 @@ static void cleanupWorkspaceMenu(WMenu *menu) { if (menu->frame->screen_ptr->workspace_menu == menu) - menu->frame->screen_ptr->workspace_menu = NULL; + menu->frame->screen_ptr->workspace_menu = NULL; } @@ -805,19 +805,19 @@ addWorkspaceMenu(WScreen *scr, WMenu *menu, char *title) WMenuEntry *entry; if (scr->flags.added_workspace_menu) { - wwarning(_("There are more than one WORKSPACE_MENU commands in the applications menu. Only one is allowed.")); - return NULL; + wwarning(_("There are more than one WORKSPACE_MENU commands in the applications menu. Only one is allowed.")); + return NULL; } else { - scr->flags.added_workspace_menu = 1; + scr->flags.added_workspace_menu = 1; + + wsmenu = wWorkspaceMenuMake(scr, True); + wsmenu->on_destroy = cleanupWorkspaceMenu; - wsmenu = wWorkspaceMenuMake(scr, True); - wsmenu->on_destroy = cleanupWorkspaceMenu; + scr->workspace_menu = wsmenu; + entry = wMenuAddCallback(menu, title, NULL, NULL); + wMenuEntrySetCascade(menu, entry, wsmenu); - scr->workspace_menu = wsmenu; - entry = wMenuAddCallback(menu, title, NULL, NULL); - wMenuEntrySetCascade(menu, entry, wsmenu); - - wWorkspaceMenuUpdate(scr, wsmenu); + wWorkspaceMenuUpdate(scr, wsmenu); } return entry; } @@ -827,7 +827,7 @@ static void cleanupWindowsMenu(WMenu *menu) { if (menu->frame->screen_ptr->switch_menu == menu) - menu->frame->screen_ptr->switch_menu = NULL; + menu->frame->screen_ptr->switch_menu = NULL; } @@ -839,22 +839,22 @@ addWindowsMenu(WScreen *scr, WMenu *menu, char *title) WMenuEntry *entry; if (scr->flags.added_windows_menu) { - wwarning(_("There are more than one WINDOWS_MENU commands in the applications menu. Only one is allowed.")); - return NULL; + wwarning(_("There are more than one WINDOWS_MENU commands in the applications menu. Only one is allowed.")); + return NULL; } else { - scr->flags.added_windows_menu = 1; - - wwmenu = wMenuCreate(scr, _("Window List"), False); - wwmenu->on_destroy = cleanupWindowsMenu; - scr->switch_menu = wwmenu; - wwin = scr->focused_window; - while (wwin) { - UpdateSwitchMenu(scr, wwin, ACTION_ADD); - - wwin = wwin->prev; - } - entry = wMenuAddCallback(menu, title, NULL, NULL); - wMenuEntrySetCascade(menu, entry, wwmenu); + scr->flags.added_windows_menu = 1; + + wwmenu = wMenuCreate(scr, _("Window List"), False); + wwmenu->on_destroy = cleanupWindowsMenu; + scr->switch_menu = wwmenu; + wwin = scr->focused_window; + while (wwin) { + UpdateSwitchMenu(scr, wwin, ACTION_ADD); + + wwin = wwin->prev; + } + entry = wMenuAddCallback(menu, title, NULL, NULL); + wMenuEntrySetCascade(menu, entry, wwmenu); } return entry; } @@ -862,132 +862,132 @@ addWindowsMenu(WScreen *scr, WMenu *menu, char *title) static WMenuEntry* addMenuEntry(WMenu *menu, char *title, char *shortcut, char *command, - char *params, char *file_name) + char *params, char *file_name) { WScreen *scr; WMenuEntry *entry = NULL; Bool shortcutOk = False; if (!menu) - return NULL; + return NULL; scr = menu->frame->screen_ptr; if (strcmp(command, "OPEN_MENU")==0) { - if (!params) { - wwarning(_("%s:missing parameter for menu command \"%s\""), - file_name, command); - } else { - WMenu *dummy; - char *path; - + if (!params) { + wwarning(_("%s:missing parameter for menu command \"%s\""), + file_name, command); + } else { + WMenu *dummy; + char *path; + path = wfindfile(DEF_CONFIG_PATHS, params); - if (!path) { - path = wstrdup(params); - } - dummy = wMenuCreate(scr, title, False); - dummy->on_destroy = removeShortcutsForMenu; - entry = wMenuAddCallback(menu, title, constructMenu, path); - entry->free_cdata = free; - wMenuEntrySetCascade(menu, entry, dummy); - } + if (!path) { + path = wstrdup(params); + } + dummy = wMenuCreate(scr, title, False); + dummy->on_destroy = removeShortcutsForMenu; + entry = wMenuAddCallback(menu, title, constructMenu, path); + entry->free_cdata = free; + wMenuEntrySetCascade(menu, entry, dummy); + } } else if (strcmp(command, "EXEC")==0) { - if (!params) - wwarning(_("%s:missing parameter for menu command \"%s\""), - file_name, command); - else { - entry = wMenuAddCallback(menu, title, execCommand, - wstrconcat("exec ", params)); - entry->free_cdata = free; - shortcutOk = True; - } + if (!params) + wwarning(_("%s:missing parameter for menu command \"%s\""), + file_name, command); + else { + entry = wMenuAddCallback(menu, title, execCommand, + wstrconcat("exec ", params)); + entry->free_cdata = free; + shortcutOk = True; + } } else if (strcmp(command, "SHEXEC")==0) { - if (!params) - wwarning(_("%s:missing parameter for menu command \"%s\""), - file_name, command); - else { - entry = wMenuAddCallback(menu, title, execCommand, - wstrdup(params)); - entry->free_cdata = free; - shortcutOk = True; - } + if (!params) + wwarning(_("%s:missing parameter for menu command \"%s\""), + file_name, command); + else { + entry = wMenuAddCallback(menu, title, execCommand, + wstrdup(params)); + entry->free_cdata = free; + shortcutOk = True; + } } else if (strcmp(command, "EXIT")==0) { - - if (params && strcmp(params, "QUICK")==0) - entry = wMenuAddCallback(menu, title, exitCommand, (void*)M_QUICK); - else - entry = wMenuAddCallback(menu, title, exitCommand, NULL); - shortcutOk = True; + if (params && strcmp(params, "QUICK")==0) + entry = wMenuAddCallback(menu, title, exitCommand, (void*)M_QUICK); + else + entry = wMenuAddCallback(menu, title, exitCommand, NULL); + + shortcutOk = True; } else if (strcmp(command, "SHUTDOWN")==0) { - - if (params && strcmp(params, "QUICK")==0) - entry = wMenuAddCallback(menu, title, shutdownCommand, - (void*)M_QUICK); - else - entry = wMenuAddCallback(menu, title, shutdownCommand, NULL); - - shortcutOk = True; + + if (params && strcmp(params, "QUICK")==0) + entry = wMenuAddCallback(menu, title, shutdownCommand, + (void*)M_QUICK); + else + entry = wMenuAddCallback(menu, title, shutdownCommand, NULL); + + shortcutOk = True; } else if (strcmp(command, "REFRESH")==0) { - entry = wMenuAddCallback(menu, title, refreshCommand, NULL); - - shortcutOk = True; + entry = wMenuAddCallback(menu, title, refreshCommand, NULL); + + shortcutOk = True; } else if (strcmp(command, "WORKSPACE_MENU")==0) { - entry = addWorkspaceMenu(scr, menu, title); - - shortcutOk = True; + entry = addWorkspaceMenu(scr, menu, title); + + shortcutOk = True; } else if (strcmp(command, "WINDOWS_MENU")==0) { - entry = addWindowsMenu(scr, menu, title); + entry = addWindowsMenu(scr, menu, title); - shortcutOk = True; + shortcutOk = True; } else if (strcmp(command, "ARRANGE_ICONS")==0) { - entry = wMenuAddCallback(menu, title, arrangeIconsCommand, NULL); - - shortcutOk = True; + entry = wMenuAddCallback(menu, title, arrangeIconsCommand, NULL); + + shortcutOk = True; } else if (strcmp(command, "HIDE_OTHERS")==0) { - entry = wMenuAddCallback(menu, title, hideOthersCommand, NULL); - - shortcutOk = True; + entry = wMenuAddCallback(menu, title, hideOthersCommand, NULL); + + shortcutOk = True; } else if (strcmp(command, "SHOW_ALL")==0) { - entry = wMenuAddCallback(menu, title, showAllCommand, NULL); - - shortcutOk = True; + entry = wMenuAddCallback(menu, title, showAllCommand, NULL); + + shortcutOk = True; } else if (strcmp(command, "RESTART")==0) { - entry = wMenuAddCallback(menu, title, restartCommand, - params ? wstrdup(params) : NULL); - entry->free_cdata = free; - shortcutOk = True; + entry = wMenuAddCallback(menu, title, restartCommand, + params ? wstrdup(params) : NULL); + entry->free_cdata = free; + shortcutOk = True; } else if (strcmp(command, "SAVE_SESSION")==0) { entry = wMenuAddCallback(menu, title, saveSessionCommand, NULL); - - shortcutOk = True; + + shortcutOk = True; } else if (strcmp(command, "CLEAR_SESSION")==0) { entry = wMenuAddCallback(menu, title, clearSessionCommand, NULL); - shortcutOk = True; + shortcutOk = True; } else if (strcmp(command, "INFO_PANEL")==0) { - entry = wMenuAddCallback(menu, title, infoPanelCommand, NULL); - shortcutOk = True; + entry = wMenuAddCallback(menu, title, infoPanelCommand, NULL); + shortcutOk = True; } else if (strcmp(command, "LEGAL_PANEL")==0) { - entry = wMenuAddCallback(menu, title, legalPanelCommand, NULL); - shortcutOk = True; + entry = wMenuAddCallback(menu, title, legalPanelCommand, NULL); + shortcutOk = True; } else { - wwarning(_("%s:unknown command \"%s\" in menu config."), file_name, - command); - - return NULL; + wwarning(_("%s:unknown command \"%s\" in menu config."), file_name, + command); + + return NULL; } - + if (shortcut && entry) { - if (!shortcutOk) { - wwarning(_("%s:can't add shortcut for entry \"%s\""), file_name, - title); - } else { - if (addShortcut(file_name, shortcut, menu, entry)) { - - entry->rtext = GetShortcutString(shortcut); - /* - entry->rtext = wstrdup(shortcut); - */ - } - } + if (!shortcutOk) { + wwarning(_("%s:can't add shortcut for entry \"%s\""), file_name, + title); + } else { + if (addShortcut(file_name, shortcut, menu, entry)) { + + entry->rtext = GetShortcutString(shortcut); + /* + entry->rtext = wstrdup(shortcut); + */ + } + } } return entry; @@ -999,10 +999,10 @@ addMenuEntry(WMenu *menu, char *title, char *shortcut, char *command, static void separateline(char *line, char *title, char *command, char *parameter, - char *shortcut) + char *shortcut) { int l, i; - + l = strlen(line); *title = 0; @@ -1012,14 +1012,14 @@ separateline(char *line, char *title, char *command, char *parameter, /* get the title */ while (isspace(*line) && (*line!=0)) line++; if (*line=='"') { - line++; - i=0; - while (line[i]!='"' && (line[i]!=0)) i++; - if (line[i]!='"') - return; + line++; + i=0; + while (line[i]!='"' && (line[i]!=0)) i++; + if (line[i]!='"') + return; } else { - i=0; - while (!isspace(line[i]) && (line[i]!=0)) i++; + i=0; + while (!isspace(line[i]) && (line[i]!=0)) i++; } strncpy(title, line, i); title[i++]=0; @@ -1028,7 +1028,7 @@ separateline(char *line, char *title, char *command, char *parameter, /* get the command or shortcut keyword */ while (isspace(*line) && (*line!=0)) line++; if (*line==0) - return; + return; i=0; while (!isspace(line[i]) && (line[i]!=0)) i++; strncpy(command, line, i); @@ -1036,51 +1036,51 @@ separateline(char *line, char *title, char *command, char *parameter, line+=i; if (strcmp(command, "SHORTCUT")==0) { - /* get the shortcut key */ - while (isspace(*line) && (*line!=0)) line++; - if (*line=='"') { - line++; - i=0; - while (line[i]!='"' && (line[i]!=0)) i++; - if (line[i]!='"') - return; - } else { - i=0; - while (!isspace(line[i]) && (line[i]!=0)) i++; - } - strncpy(shortcut, line, i); - shortcut[i++]=0; - line+=i; - - *command=0; - - /* get the command */ - while (isspace(*line) && (*line!=0)) line++; - if (*line==0) - return; - i=0; - while (!isspace(line[i]) && (line[i]!=0)) i++; - strncpy(command, line, i); - command[i++]=0; - line+=i; + /* get the shortcut key */ + while (isspace(*line) && (*line!=0)) line++; + if (*line=='"') { + line++; + i=0; + while (line[i]!='"' && (line[i]!=0)) i++; + if (line[i]!='"') + return; + } else { + i=0; + while (!isspace(line[i]) && (line[i]!=0)) i++; + } + strncpy(shortcut, line, i); + shortcut[i++]=0; + line+=i; + + *command=0; + + /* get the command */ + while (isspace(*line) && (*line!=0)) line++; + if (*line==0) + return; + i=0; + while (!isspace(line[i]) && (line[i]!=0)) i++; + strncpy(command, line, i); + command[i++]=0; + line+=i; } /* get the parameters */ while (isspace(*line) && (*line!=0)) line++; if (*line==0) - return; - + return; + if (*line=='"') { - line++; - l = 0; - while (line[l]!=0 && line[l]!='"') { - parameter[l] = line[l]; - l++; - } - parameter[l] = 0; - return; + line++; + l = 0; + while (line[l]!=0 && line[l]!='"') { + parameter[l] = line[l]; + l++; + } + parameter[l] = 0; + return; } - + l = strlen(line); while (isspace(line[l]) && (l>0)) l--; strncpy(parameter, line, l); @@ -1098,79 +1098,79 @@ parseCascade(WScreen *scr, WMenu *menu, FILE *file, char *file_name) char shortcut[MAXLINE]; char params[MAXLINE]; char *line; - + while (!feof(file)) { - int lsize, ok; - - ok = 0; - fgets(linebuf, MAXLINE, file); - line = cropline(linebuf); - lsize = strlen(line); - do { - if (line[lsize-1]=='\\') { - char *line2; - int lsize2; - fgets(elinebuf, MAXLINE, file); - line2=cropline(elinebuf); - lsize2=strlen(line2); - if (lsize2+lsize>MAXLINE) { - wwarning(_("%s:maximal line size exceeded in menu config: %s"), - file_name, line); - ok=2; - } else { - line[lsize-1]=0; - lsize+=lsize2-1; - strcat(line, line2); - } - } else { - ok=1; - } - } while (!ok && !feof(file)); - if (ok==2) - continue; - - if (line[0]==0 || line[0]=='#' || (line[0]=='/' && line[1]=='/')) - continue; - - - separateline(line, title, command, params, shortcut); - - if (!command[0]) { - wwarning(_("%s:missing command in menu config: %s"), file_name, - line); - goto error; - } - - if (strcasecmp(command, "MENU")==0) { - WMenu *cascade; - - /* start submenu */ - - cascade = wMenuCreate(scr, title, False); - cascade->on_destroy = removeShortcutsForMenu; - if (parseCascade(scr, cascade, file, file_name)==NULL) { - wMenuDestroy(cascade, True); - } else { - wMenuEntrySetCascade(menu, - wMenuAddCallback(menu, title, NULL, NULL), - cascade); - } - } else if (strcasecmp(command, "END")==0) { - /* end of menu */ - return menu; - - } else { - /* normal items */ - addMenuEntry(menu, title, shortcut[0] ? shortcut : NULL, command, - params[0] ? params : NULL, file_name); - } + int lsize, ok; + + ok = 0; + fgets(linebuf, MAXLINE, file); + line = cropline(linebuf); + lsize = strlen(line); + do { + if (line[lsize-1]=='\\') { + char *line2; + int lsize2; + fgets(elinebuf, MAXLINE, file); + line2=cropline(elinebuf); + lsize2=strlen(line2); + if (lsize2+lsize>MAXLINE) { + wwarning(_("%s:maximal line size exceeded in menu config: %s"), + file_name, line); + ok=2; + } else { + line[lsize-1]=0; + lsize+=lsize2-1; + strcat(line, line2); + } + } else { + ok=1; + } + } while (!ok && !feof(file)); + if (ok==2) + continue; + + if (line[0]==0 || line[0]=='#' || (line[0]=='/' && line[1]=='/')) + continue; + + + separateline(line, title, command, params, shortcut); + + if (!command[0]) { + wwarning(_("%s:missing command in menu config: %s"), file_name, + line); + goto error; + } + + if (strcasecmp(command, "MENU")==0) { + WMenu *cascade; + + /* start submenu */ + + cascade = wMenuCreate(scr, title, False); + cascade->on_destroy = removeShortcutsForMenu; + if (parseCascade(scr, cascade, file, file_name)==NULL) { + wMenuDestroy(cascade, True); + } else { + wMenuEntrySetCascade(menu, + wMenuAddCallback(menu, title, NULL, NULL), + cascade); + } + } else if (strcasecmp(command, "END")==0) { + /* end of menu */ + return menu; + + } else { + /* normal items */ + addMenuEntry(menu, title, shortcut[0] ? shortcut : NULL, command, + params[0] ? params : NULL, file_name); + } } wwarning(_("%s:syntax error in menu file:END declaration missing"), - file_name); + file_name); return menu; - error: +error: return menu; } @@ -1193,72 +1193,72 @@ readMenuFile(WScreen *scr, char *file_name) #ifdef USECPP if (!wPreferences.flags.nocpp) { - args = MakeCPPArgs(file_name); - if (!args) { - wwarning(_("could not make arguments for menu file preprocessor")); - } else { - snprintf(command, sizeof(command), "%s %s %s", - CPP_PATH, args, file_name); - wfree(args); - file = popen(command, "r"); - if (!file) { - wsyserror(_("%s:could not open/preprocess menu file"), - file_name); - } else { - cpp = 1; - } - } + args = MakeCPPArgs(file_name); + if (!args) { + wwarning(_("could not make arguments for menu file preprocessor")); + } else { + snprintf(command, sizeof(command), "%s %s %s", + CPP_PATH, args, file_name); + wfree(args); + file = popen(command, "r"); + if (!file) { + wsyserror(_("%s:could not open/preprocess menu file"), + file_name); + } else { + cpp = 1; + } + } } #endif /* USECPP */ if (!file) { - file = fopen(file_name, "rb"); - if (!file) { - wsyserror(_("%s:could not open menu file"), file_name); - return NULL; - } + file = fopen(file_name, "rb"); + if (!file) { + wsyserror(_("%s:could not open menu file"), file_name); + return NULL; + } } - + while (!feof(file)) { - if (!fgets(linebuf, MAXLINE, file)) - break; - line = cropline(linebuf); - if (line[0]==0 || line[0]=='#' || (line[0]=='/' && line[1]=='/')) - continue; - - separateline(line, title, command, params, shortcut); - - if (!command[0]) { - wwarning(_("%s:missing command in menu config: %s"), file_name, - line); - break; - } - if (strcasecmp(command, "MENU")==0) { - menu = wMenuCreate(scr, title, True); - menu->on_destroy = removeShortcutsForMenu; - if (!parseCascade(scr, menu, file, file_name)) { - wMenuDestroy(menu, True); - } - break; - } else { - wwarning(_("%s:invalid menu file. MENU command is missing"), - file_name); - break; - } + if (!fgets(linebuf, MAXLINE, file)) + break; + line = cropline(linebuf); + if (line[0]==0 || line[0]=='#' || (line[0]=='/' && line[1]=='/')) + continue; + + separateline(line, title, command, params, shortcut); + + if (!command[0]) { + wwarning(_("%s:missing command in menu config: %s"), file_name, + line); + break; + } + if (strcasecmp(command, "MENU")==0) { + menu = wMenuCreate(scr, title, True); + menu->on_destroy = removeShortcutsForMenu; + if (!parseCascade(scr, menu, file, file_name)) { + wMenuDestroy(menu, True); + } + break; + } else { + wwarning(_("%s:invalid menu file. MENU command is missing"), + file_name); + break; + } } - + #ifdef CPP if (cpp) { - if (pclose(file)==-1) { - wsyserror(_("error reading preprocessed menu data")); - } + if (pclose(file)==-1) { + wsyserror(_("error reading preprocessed menu data")); + } } else { - fclose(file); + fclose(file); } #else fclose(file); #endif - + return menu; } @@ -1266,7 +1266,7 @@ readMenuFile(WScreen *scr, char *file_name) /************ Menu Configuration From Pipe *************/ static WMenu* -readMenuPipe(WScreen *scr, char **file_name) +readMenuPipe(WScreen *scr, char **file_name) { WMenu *menu=NULL; FILE *file = NULL; @@ -1287,67 +1287,67 @@ readMenuPipe(WScreen *scr, char **file_name) flat_file[0] = '\0'; for(i=0; file_name[i]!=NULL; i++) { - strcat(flat_file, file_name[i]); - strcat(flat_file, " "); + strcat(flat_file, file_name[i]); + strcat(flat_file, " "); } filename = flat_file + (flat_file[1]=='|'?2:1); #ifdef USECPP if (!wPreferences.flags.nocpp) { - args = MakeCPPArgs(filename); - if (!args) { - wwarning(_("could not make arguments for menu file preprocessor")); - } else { - snprintf(command, sizeof(command), "%s | %s %s", - filename, CPP_PATH, args); - - wfree(args); - file = popen(command, "r"); - if (!file) { - wsyserror(_("%s:could not open/preprocess menu file"), filename); - } else { - cpp = 1; - } - } + args = MakeCPPArgs(filename); + if (!args) { + wwarning(_("could not make arguments for menu file preprocessor")); + } else { + snprintf(command, sizeof(command), "%s | %s %s", + filename, CPP_PATH, args); + + wfree(args); + file = popen(command, "r"); + if (!file) { + wsyserror(_("%s:could not open/preprocess menu file"), filename); + } else { + cpp = 1; + } + } } #endif /* USECPP */ if (!file) { - file = popen(filename, "rb"); + file = popen(filename, "rb"); - if (!file) { - wsyserror(_("%s:could not open menu file"), filename); - return NULL; - } + if (!file) { + wsyserror(_("%s:could not open menu file"), filename); + return NULL; + } } while (!feof(file)) { - if (!fgets(linebuf, MAXLINE, file)) - break; - line = cropline(linebuf); - if (line[0]==0 || line[0]=='#' || (line[0]=='/' && line[1]=='/')) - continue; - - separateline(line, title, command, params, shortcut); - - if (!command[0]) { - wwarning(_("%s:missing command in menu config: %s"), file_name, - line); - break; - } - if (strcasecmp(command, "MENU")==0) { - menu = wMenuCreate(scr, title, True); - menu->on_destroy = removeShortcutsForMenu; - if (!parseCascade(scr, menu, file, filename)) { - wMenuDestroy(menu, True); - } - break; - } else { - wwarning(_("%s:no title given for the root menu"), filename); - break; - } + if (!fgets(linebuf, MAXLINE, file)) + break; + line = cropline(linebuf); + if (line[0]==0 || line[0]=='#' || (line[0]=='/' && line[1]=='/')) + continue; + + separateline(line, title, command, params, shortcut); + + if (!command[0]) { + wwarning(_("%s:missing command in menu config: %s"), file_name, + line); + break; + } + if (strcasecmp(command, "MENU")==0) { + menu = wMenuCreate(scr, title, True); + menu->on_destroy = removeShortcutsForMenu; + if (!parseCascade(scr, menu, file, filename)) { + wMenuDestroy(menu, True); + } + break; + } else { + wwarning(_("%s:no title given for the root menu"), filename); + break; + } } pclose(file); @@ -1380,15 +1380,15 @@ isFilePackage(char *file) { int l; - /* check if the extension indicates this file is a + /* check if the extension indicates this file is a * file package. For now, only recognize .themed */ l = strlen(file); if (l > 7 && strcmp(&(file[l-7]), ".themed")==0) { - return True; + return True; } else { - return False; + return False; } } @@ -1407,17 +1407,17 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command) dir_data *data; int stripExtension = 0; - + dirs = WMCreateArray(16); files = WMCreateArray(16); - + i=0; while (path[i]!=NULL) { - if (strcmp(path[i], "-noext")==0) { - stripExtension = 1; - i++; - continue; - } + if (strcmp(path[i], "-noext")==0) { + stripExtension = 1; + i++; + continue; + } dir = opendir(path[i]); if (!dir) { @@ -1431,13 +1431,13 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command) strcmp(dentry->d_name, "..")==0) continue; - if (dentry->d_name[0] == '.') - continue; + if (dentry->d_name[0] == '.') + continue; buffer = malloc(strlen(path[i])+strlen(dentry->d_name)+4); if (!buffer) { wsyserror(_("out of memory while constructing directory menu %s"), - path[i]); + path[i]); break; } @@ -1449,21 +1449,21 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command) wsyserror(_("%s:could not stat file \"%s\" in menu directory"), path[i], dentry->d_name); } else { - Bool isFilePack = False; + Bool isFilePack = False; - data = NULL; + data = NULL; if (S_ISDIR(stat_buf.st_mode) - && !(isFilePack = isFilePackage(dentry->d_name))) { + && !(isFilePack = isFilePackage(dentry->d_name))) { /* access always returns success for user root */ if (access(buffer, X_OK)==0) { /* Directory is accesible. Add to directory list */ - data = (dir_data*) wmalloc(sizeof(dir_data)); - data->name = wstrdup(dentry->d_name); - data->index = i; + data = (dir_data*) wmalloc(sizeof(dir_data)); + data->name = wstrdup(dentry->d_name); + data->index = i; - WMAddToArray(dirs, data); + WMAddToArray(dirs, data); } } else if (S_ISREG(stat_buf.st_mode) || isFilePack) { /* Hack because access always returns X_OK success for user root */ @@ -1472,11 +1472,11 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command) (command==NULL && access(buffer, X_OK)==0 && (stat_buf.st_mode & S_IXANY))) { - data = (dir_data*) wmalloc(sizeof(dir_data)); - data->name = wstrdup(dentry->d_name); - data->index = i; + data = (dir_data*) wmalloc(sizeof(dir_data)); + data->name = wstrdup(dentry->d_name); + data->index = i; - WMAddToArray(files, data); + WMAddToArray(files, data); } } } @@ -1486,10 +1486,10 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command) closedir(dir); i++; } - + if (!WMGetArrayItemCount(dirs) && !WMGetArrayItemCount(files)) { - WMFreeArray(dirs); - WMFreeArray(files); + WMFreeArray(dirs); + WMFreeArray(files); return NULL; } @@ -1503,27 +1503,27 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command) /* New directory. Use same OPEN_MENU command that was used * for the current directory. */ length = strlen(path[data->index])+strlen(data->name)+6; - if (stripExtension) - length += 7; + if (stripExtension) + length += 7; if (command) length += strlen(command) + 6; buffer = malloc(length); if (!buffer) { wsyserror(_("out of memory while constructing directory menu %s"), - path[data->index]); + path[data->index]); break; } - - buffer[0] = '\0'; + + buffer[0] = '\0'; if (stripExtension) strcat(buffer, "-noext "); have_space = strchr(path[data->index], ' ')!=NULL || - strchr(data->name, ' ')!=NULL; + strchr(data->name, ' ')!=NULL; - if (have_space) + if (have_space) strcat(buffer, "\""); - strcat(buffer, path[data->index]); + strcat(buffer, path[data->index]); strcat(buffer, "/"); strcat(buffer, data->name); @@ -1537,9 +1537,9 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command) addMenuEntry(menu, data->name, NULL, "OPEN_MENU", buffer, path[data->index]); wfree(buffer); - if (data->name) - wfree(data->name); - wfree(data); + if (data->name) + wfree(data->name); + wfree(data); } WM_ITERATE_ARRAY(files, data, iter) { @@ -1551,12 +1551,12 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command) buffer = malloc(length); if (!buffer) { wsyserror(_("out of memory while constructing directory menu %s"), - path[data->index]); + path[data->index]); break; } have_space = strchr(path[data->index], ' ')!=NULL || - strchr(data->name, ' ')!=NULL; + strchr(data->name, ' ')!=NULL; if (command!=NULL) { strcpy(buffer, command); strcat(buffer, " "); @@ -1577,19 +1577,19 @@ readMenuDirectory(WScreen *scr, char *title, char **path, char *command) if (have_space) strcat(buffer, "\""); - if (stripExtension) { - char *ptr = strrchr(data->name, '.'); - if (ptr && ptr!=data->name) - *ptr = 0; - } + if (stripExtension) { + char *ptr = strrchr(data->name, '.'); + if (ptr && ptr!=data->name) + *ptr = 0; + } addMenuEntry(menu, data->name, NULL, "SHEXEC", buffer, path[data->index]); wfree(buffer); - if (data->name) - wfree(data->name); - wfree(data); + if (data->name) + wfree(data->name); + wfree(data); } - + WMFreeArray(files); WMFreeArray(dirs); @@ -1603,7 +1603,7 @@ static WMenu* makeDefaultMenu(WScreen *scr) { WMenu *menu=NULL; - + menu = wMenuCreate(scr, _("Commands"), True); wMenuAddCallback(menu, "XTerm", execCommand, "xterm"); wMenuAddCallback(menu, "rxvt", execCommand, "rxvt"); @@ -1617,11 +1617,11 @@ makeDefaultMenu(WScreen *scr) /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * configureMenu-- * Reads root menu configuration from defaults database. - * - *---------------------------------------------------------------------- + * + *---------------------------------------------------------------------- */ static WMenu* configureMenu(WScreen *scr, WMPropList *definition) @@ -1632,72 +1632,72 @@ configureMenu(WScreen *scr, WMPropList *definition) WMPropList *title, *command, *params; char *tmp, *mtitle; - + if (WMIsPLString(definition)) { - struct stat stat_buf; - char *path = NULL; - Bool menu_is_default = False; - - /* menu definition is a string. Probably a path, so parse the file */ - - tmp = wexpandpath(WMGetFromPLString(definition)); - - path = getLocalizedMenuFile(tmp); - - if (!path) - path = wfindfile(DEF_CONFIG_PATHS, tmp); - - if (!path) { - path = wfindfile(DEF_CONFIG_PATHS, DEF_MENU_FILE); - menu_is_default = True; - } - - if (!path) { - wsyserror(_("could not find menu file \"%s\" referenced in WMRootMenu"), - tmp); - wfree(tmp); - return NULL; - } - - if (stat(path, &stat_buf)<0) { - wsyserror(_("could not access menu \"%s\" referenced in WMRootMenu"), path); - wfree(path); - wfree(tmp); - return NULL; - } - - if (!scr->root_menu || stat_buf.st_mtime > scr->root_menu->timestamp - /* if the pointer in WMRootMenu has changed */ - || WDRootMenu->timestamp > scr->root_menu->timestamp) { - - if (menu_is_default) { - wwarning(_("using default menu file \"%s\" as the menu referenced in WMRootMenu could not be found "), - path); - } - - menu = readMenuFile(scr, path); - if (menu) - menu->timestamp = WMAX(stat_buf.st_mtime, WDRootMenu->timestamp); - } else { - menu = NULL; - } - wfree(path); - wfree(tmp); - - return menu; + struct stat stat_buf; + char *path = NULL; + Bool menu_is_default = False; + + /* menu definition is a string. Probably a path, so parse the file */ + + tmp = wexpandpath(WMGetFromPLString(definition)); + + path = getLocalizedMenuFile(tmp); + + if (!path) + path = wfindfile(DEF_CONFIG_PATHS, tmp); + + if (!path) { + path = wfindfile(DEF_CONFIG_PATHS, DEF_MENU_FILE); + menu_is_default = True; + } + + if (!path) { + wsyserror(_("could not find menu file \"%s\" referenced in WMRootMenu"), + tmp); + wfree(tmp); + return NULL; + } + + if (stat(path, &stat_buf)<0) { + wsyserror(_("could not access menu \"%s\" referenced in WMRootMenu"), path); + wfree(path); + wfree(tmp); + return NULL; + } + + if (!scr->root_menu || stat_buf.st_mtime > scr->root_menu->timestamp + /* if the pointer in WMRootMenu has changed */ + || WDRootMenu->timestamp > scr->root_menu->timestamp) { + + if (menu_is_default) { + wwarning(_("using default menu file \"%s\" as the menu referenced in WMRootMenu could not be found "), + path); + } + + menu = readMenuFile(scr, path); + if (menu) + menu->timestamp = WMAX(stat_buf.st_mtime, WDRootMenu->timestamp); + } else { + menu = NULL; + } + wfree(path); + wfree(tmp); + + return menu; } count = WMGetPropListItemCount(definition); if (count==0) - return NULL; + return NULL; elem = WMGetFromPLArray(definition, 0); if (!WMIsPLString(elem)) { - tmp = WMGetPropListDescription(elem, False); - wwarning(_("%s:format error in root menu configuration \"%s\""), - "WMRootMenu", tmp); - wfree(tmp); - return NULL; + tmp = WMGetPropListDescription(elem, False); + wwarning(_("%s:format error in root menu configuration \"%s\""), + "WMRootMenu", tmp); + wfree(tmp); + return NULL; } mtitle = WMGetFromPLString(elem); @@ -1706,94 +1706,94 @@ configureMenu(WScreen *scr, WMPropList *definition) #ifdef GLOBAL_SUBMENU_FILE { - WMenu *submenu; - WMenuEntry *mentry; + WMenu *submenu; + WMenuEntry *mentry; - submenu = readMenuFile(scr, GLOBAL_SUBMENU_FILE); + submenu = readMenuFile(scr, GLOBAL_SUBMENU_FILE); - if (submenu) { - mentry = wMenuAddCallback(menu, submenu->frame->title, NULL, NULL); - wMenuEntrySetCascade(menu, mentry, submenu); - } + if (submenu) { + mentry = wMenuAddCallback(menu, submenu->frame->title, NULL, NULL); + wMenuEntrySetCascade(menu, mentry, submenu); + } } #endif for (i=1; iframe->title, NULL, - NULL); - wMenuEntrySetCascade(menu, mentry, submenu); - } - } else { - int idx = 0; - WMPropList *shortcut; - /* normal entry */ - - title = WMGetFromPLArray(elem, idx++); - shortcut = WMGetFromPLArray(elem, idx++); - if (strcmp(WMGetFromPLString(shortcut), "SHORTCUT")==0) { - shortcut = WMGetFromPLArray(elem, idx++); - command = WMGetFromPLArray(elem, idx++); - } else { - command = shortcut; - shortcut = NULL; - } - params = WMGetFromPLArray(elem, idx++); - - if (!title || !command) - goto error; - - addMenuEntry(menu, WMGetFromPLString(title), - shortcut ? WMGetFromPLString(shortcut) : NULL, - WMGetFromPLString(command), - params ? WMGetFromPLString(params) : NULL, "WMRootMenu"); - } - continue; - - error: - tmp = WMGetPropListDescription(elem, False); - wwarning(_("%s:format error in root menu configuration \"%s\""), - "WMRootMenu", tmp); - wfree(tmp); + if (WMIsPLString(elem)) { + char *file; + + file = WMGetFromPLString(elem); + + } +#endif + if (!WMIsPLArray(elem) || WMGetPropListItemCount(elem) < 2) + goto error; + + if (WMIsPLArray(WMGetFromPLArray(elem,1))) { + WMenu *submenu; + WMenuEntry *mentry; + + /* submenu */ + submenu = configureMenu(scr, elem); + if (submenu) { + mentry = wMenuAddCallback(menu, submenu->frame->title, NULL, + NULL); + wMenuEntrySetCascade(menu, mentry, submenu); + } + } else { + int idx = 0; + WMPropList *shortcut; + /* normal entry */ + + title = WMGetFromPLArray(elem, idx++); + shortcut = WMGetFromPLArray(elem, idx++); + if (strcmp(WMGetFromPLString(shortcut), "SHORTCUT")==0) { + shortcut = WMGetFromPLArray(elem, idx++); + command = WMGetFromPLArray(elem, idx++); + } else { + command = shortcut; + shortcut = NULL; + } + params = WMGetFromPLArray(elem, idx++); + + if (!title || !command) + goto error; + + addMenuEntry(menu, WMGetFromPLString(title), + shortcut ? WMGetFromPLString(shortcut) : NULL, + WMGetFromPLString(command), + params ? WMGetFromPLString(params) : NULL, "WMRootMenu"); + } + continue; + + error: + tmp = WMGetPropListDescription(elem, False); + wwarning(_("%s:format error in root menu configuration \"%s\""), + "WMRootMenu", tmp); + wfree(tmp); } - + return menu; } /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * OpenRootMenu-- * Opens the root menu, parsing the menu configuration from the * defaults database. * If the menu is already mapped and is not sticked to the * root window, it will be unmapped. - * + * * Side effects: * The menu may be remade. - * + * * Notes: * Construction of OPEN_MENU entries are delayed to the moment the * user map's them. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ void OpenRootMenu(WScreen *scr, int x, int y, int keyboard) @@ -1801,11 +1801,11 @@ OpenRootMenu(WScreen *scr, int x, int y, int keyboard) WMenu *menu=NULL; WMPropList *definition; /* - static WMPropList *domain=NULL; - - if (!domain) { - domain = WMCreatePLString("WMRootMenu"); - } + static WMPropList *domain=NULL; + + if (!domain) { + domain = WMCreatePLString("WMRootMenu"); + } */ scr->flags.root_menu_changed_shortcuts = 0; @@ -1813,60 +1813,60 @@ OpenRootMenu(WScreen *scr, int x, int y, int keyboard) scr->flags.added_windows_menu = 0; if (scr->root_menu && scr->root_menu->flags.mapped) { - menu = scr->root_menu; - if (!menu->flags.buttoned) { - wMenuUnmap(menu); - } else { - wRaiseFrame(menu->frame->core); - - if (keyboard) - wMenuMapAt(menu, 0, 0, True); - else - wMenuMapCopyAt(menu, x-menu->frame->core->width/2, y); - } - return; + menu = scr->root_menu; + if (!menu->flags.buttoned) { + wMenuUnmap(menu); + } else { + wRaiseFrame(menu->frame->core); + + if (keyboard) + wMenuMapAt(menu, 0, 0, True); + else + wMenuMapCopyAt(menu, x-menu->frame->core->width/2, y); + } + return; } - - + + definition = WDRootMenu->dictionary; -/* - definition = PLGetDomain(domain); - */ + /* + definition = PLGetDomain(domain); + */ if (definition) { - if (WMIsPLArray(definition)) { - if (!scr->root_menu - || WDRootMenu->timestamp > scr->root_menu->timestamp) { - menu = configureMenu(scr, definition); - if (menu) - menu->timestamp = WDRootMenu->timestamp; - - } else - menu = NULL; - } else { - menu = configureMenu(scr, definition); - } + if (WMIsPLArray(definition)) { + if (!scr->root_menu + || WDRootMenu->timestamp > scr->root_menu->timestamp) { + menu = configureMenu(scr, definition); + if (menu) + menu->timestamp = WDRootMenu->timestamp; + + } else + menu = NULL; + } else { + menu = configureMenu(scr, definition); + } } if (!menu) { - /* menu hasn't changed or could not be read */ - if (!scr->root_menu) { - wMessageDialog(scr, _("Error"), - _("The applications menu could not be loaded. " - "Look at the console output for a detailed " - "description of the errors."), - _("OK"), NULL, NULL); - - menu = makeDefaultMenu(scr); - scr->root_menu = menu; - } - menu = scr->root_menu; + /* menu hasn't changed or could not be read */ + if (!scr->root_menu) { + wMessageDialog(scr, _("Error"), + _("The applications menu could not be loaded. " + "Look at the console output for a detailed " + "description of the errors."), + _("OK"), NULL, NULL); + + menu = makeDefaultMenu(scr); + scr->root_menu = menu; + } + menu = scr->root_menu; } else { - /* new root menu */ - if (scr->root_menu) { - wMenuDestroy(scr->root_menu, True); - } - scr->root_menu = menu; + /* new root menu */ + if (scr->root_menu) { + wMenuDestroy(scr->root_menu, True); + } + scr->root_menu = menu; } if (menu) { int newx, newy; @@ -1882,9 +1882,10 @@ OpenRootMenu(WScreen *scr, int x, int y, int keyboard) } wMenuMapAt(menu, newx, newy, keyboard); } - + if (scr->flags.root_menu_changed_shortcuts) - rebindKeygrabs(scr); + rebindKeygrabs(scr); } #endif /* !LITE */ + diff --git a/src/rootmenu.h b/src/rootmenu.h index 889977a0..f909ae8c 100644 --- a/src/rootmenu.h +++ b/src/rootmenu.h @@ -1,9 +1,9 @@ -/* rootmenu.h- user defined menu - * +/* rootmenu.h- user defined menu + * * Window Maker window manager - * + * * Copyright (c) 2000-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -33,10 +33,10 @@ typedef struct _WRootMenuReader { WRootMenuData (*openMenuFile)(char *path); Bool (*hasMoreData)(WRootMenuData *data); Bool (*nextCommand)(WRootMenuData *data, - char **title, - char **command, - char **parameter, - char **shortcut); + char **title, + char **command, + char **parameter, + char **shortcut); void (*closeMenuFile)(WRootMenuData *data); } WRootMenuReader; diff --git a/src/screen.c b/src/screen.c index 62cd0e7a..61f4407b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1,9 +1,9 @@ /* screen.c - screen management - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -32,8 +32,8 @@ #ifdef SHAPE #include #endif -#ifdef KEEP_XKB_LOCK_STATUS -#include +#ifdef KEEP_XKB_LOCK_STATUS +#include #endif /* KEEP_XKB_LOCK_STATUS */ #include @@ -75,13 +75,13 @@ #ifdef LITE #define EVENT_MASK (LeaveWindowMask|EnterWindowMask|PropertyChangeMask\ - |SubstructureNotifyMask|PointerMotionMask \ - |SubstructureRedirectMask|KeyPressMask|KeyReleaseMask) + |SubstructureNotifyMask|PointerMotionMask \ + |SubstructureRedirectMask|KeyPressMask|KeyReleaseMask) #else #define EVENT_MASK (LeaveWindowMask|EnterWindowMask|PropertyChangeMask\ - |SubstructureNotifyMask|PointerMotionMask \ - |SubstructureRedirectMask|ButtonPressMask|ButtonReleaseMask\ - |KeyPressMask|KeyReleaseMask) + |SubstructureNotifyMask|PointerMotionMask \ + |SubstructureRedirectMask|ButtonPressMask|ButtonReleaseMask\ + |KeyPressMask|KeyReleaseMask) #endif /**** Global variables ****/ @@ -94,7 +94,7 @@ extern Atom _XA_WINDOWMAKER_NOTICEBOARD; extern int wScreenCount; -#ifdef KEEP_XKB_LOCK_STATUS +#ifdef KEEP_XKB_LOCK_STATUS extern int wXkbSupported; #endif @@ -134,15 +134,15 @@ make_keys() * X error handler used to catch errors when trying to do * XSelectInput() on the root window. These errors probably mean that * there already is some other window manager running. - * + * * Returns: * Nothing, unless something really evil happens... - * + * * Side effects: * CantManageScreen is set to 1; - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ -static int +static int alreadyRunningError(Display *dpy, XErrorEvent *error) { CantManageScreen = 1; @@ -151,19 +151,19 @@ alreadyRunningError(Display *dpy, XErrorEvent *error) /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * allocButtonPixmaps-- * Allocate pixmaps used on window operation buttons (those in the * titlebar). The pixmaps are linked to the program. If XPM is supported * XPM pixmaps are used otherwise, equivalent bitmaps are used. - * + * * Returns: * Nothing - * + * * Side effects: - * Allocates shared pixmaps for the screen. These pixmaps should + * Allocates shared pixmaps for the screen. These pixmaps should * not be freed by anybody. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ static void allocButtonPixmaps(WScreen *scr) @@ -173,41 +173,41 @@ allocButtonPixmaps(WScreen *scr) /* create predefined pixmaps */ pix = wPixmapCreateFromXPMData(scr, PRED_CLOSE_XPM); if (pix) - pix->shared = 1; + pix->shared = 1; scr->b_pixmaps[WBUT_CLOSE] = pix; pix = wPixmapCreateFromXPMData(scr, PRED_BROKEN_CLOSE_XPM); if (pix) - pix->shared = 1; + pix->shared = 1; scr->b_pixmaps[WBUT_BROKENCLOSE] = pix; pix = wPixmapCreateFromXPMData(scr, PRED_ICONIFY_XPM); if (pix) - pix->shared = 1; + pix->shared = 1; scr->b_pixmaps[WBUT_ICONIFY] = pix; #ifdef XKB_BUTTON_HINT pix = wPixmapCreateFromXPMData(scr, PRED_XKBGROUP1_XPM); if (pix) - pix->shared = 1; + pix->shared = 1; scr->b_pixmaps[WBUT_XKBGROUP1] = pix; pix = wPixmapCreateFromXPMData(scr, PRED_XKBGROUP2_XPM); if (pix) - pix->shared = 1; + pix->shared = 1; scr->b_pixmaps[WBUT_XKBGROUP2] = pix; pix = wPixmapCreateFromXPMData(scr, PRED_XKBGROUP3_XPM); if (pix) - pix->shared = 1; + pix->shared = 1; scr->b_pixmaps[WBUT_XKBGROUP3] = pix; pix = wPixmapCreateFromXPMData(scr, PRED_XKBGROUP4_XPM); if (pix) - pix->shared = 1; + pix->shared = 1; scr->b_pixmaps[WBUT_XKBGROUP4] = pix; #endif - + pix = wPixmapCreateFromXPMData(scr, PRED_KILL_XPM); if (pix) - pix->shared = 1; + pix->shared = 1; scr->b_pixmaps[WBUT_KILL] = pix; } @@ -231,32 +231,32 @@ make3Dots(WScreen *scr) GC gc2, gc; XGCValues gcv; Pixmap pix, mask; - + gc = scr->copy_gc; - pix = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size, - wPreferences.icon_size, scr->w_depth); + pix = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size, + wPreferences.icon_size, scr->w_depth); XSetForeground(dpy, gc, scr->black_pixel); - XFillRectangle(dpy, pix, gc, 0, 0, wPreferences.icon_size, - wPreferences.icon_size); + XFillRectangle(dpy, pix, gc, 0, 0, wPreferences.icon_size, + wPreferences.icon_size); XSetForeground(dpy, gc, scr->white_pixel); draw_dot(scr, pix, 4, wPreferences.icon_size-6, gc); draw_dot(scr, pix, 9, wPreferences.icon_size-6, gc); draw_dot(scr, pix, 14, wPreferences.icon_size-6, gc); - mask = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size, - wPreferences.icon_size, 1); + mask = XCreatePixmap(dpy, scr->w_win, wPreferences.icon_size, + wPreferences.icon_size, 1); gcv.foreground = 0; gcv.graphics_exposures = False; gc2 = XCreateGC(dpy, mask, GCForeground|GCGraphicsExposures, &gcv); - XFillRectangle(dpy, mask, gc2, 0, 0, wPreferences.icon_size, - wPreferences.icon_size); + XFillRectangle(dpy, mask, gc2, 0, 0, wPreferences.icon_size, + wPreferences.icon_size); XSetForeground(dpy, gc2, 1); XFillRectangle(dpy, mask, gc2, 4, wPreferences.icon_size-6, 3, 2); XFillRectangle(dpy, mask, gc2, 9, wPreferences.icon_size-6, 3, 2); XFillRectangle(dpy, mask, gc2, 14, wPreferences.icon_size-6, 3, 2); - + XFreeGC(dpy, gc2); - + wpix = wPixmapCreate(scr, pix, mask); wpix->shared = 1; @@ -271,9 +271,9 @@ allocGCs(WScreen *scr) XColor color; int gcm; - scr->stipple_bitmap = - XCreateBitmapFromData(dpy, scr->w_win, STIPPLE_DATA, STIPPLE_WIDTH, - STIPPLE_HEIGHT); + scr->stipple_bitmap = + XCreateBitmapFromData(dpy, scr->w_win, STIPPLE_DATA, STIPPLE_WIDTH, + STIPPLE_HEIGHT); gcv.stipple = scr->stipple_bitmap; gcv.foreground = scr->white_pixel; @@ -282,7 +282,7 @@ allocGCs(WScreen *scr) gcm = GCForeground|GCStipple|GCFillStyle|GCGraphicsExposures; scr->stipple_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv); - + /* selected icon border GCs */ gcv.function = GXcopy; gcv.foreground = scr->white_pixel; @@ -315,25 +315,25 @@ allocGCs(WScreen *scr) * of the original color in PseudoColor when not all color cells are * initialized */ if (DefaultVisual(dpy, scr->screen)->class==PseudoColor) - gcv.plane_mask = (1<<(scr->depth-1))|1; + gcv.plane_mask = (1<<(scr->depth-1))|1; else - gcv.plane_mask = AllPlanes; + gcv.plane_mask = AllPlanes; gcv.foreground = color.pixel; if (gcv.foreground == 0) - gcv.foreground = 1; + gcv.foreground = 1; gcv.line_width = DEF_FRAME_THICKNESS; gcv.subwindow_mode = IncludeInferiors; gcv.graphics_exposures = False; scr->frame_gc = XCreateGC(dpy, scr->root_win, GCForeground|GCGraphicsExposures - |GCFunction|GCSubwindowMode|GCLineWidth - |GCPlaneMask, &gcv); - + |GCFunction|GCSubwindowMode|GCLineWidth + |GCPlaneMask, &gcv); + /* line GC */ gcv.foreground = color.pixel; if (gcv.foreground == 0) /* XOR:ing with a zero is not going to be of much use, so - in that case, we somewhat arbitrarily xor with 17 instead. */ + in that case, we somewhat arbitrarily xor with 17 instead. */ gcv.foreground = 17; gcv.function = GXxor; @@ -352,7 +352,7 @@ allocGCs(WScreen *scr) gcv.background = scr->black_pixel; gcv.graphics_exposures = False; scr->copy_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground - |GCGraphicsExposures, &gcv); + |GCGraphicsExposures, &gcv); /* misc drawing GC */ gcv.graphics_exposures = False; @@ -376,29 +376,29 @@ createPixmaps(WScreen *scr) /* load pixmaps */ pix = wPixmapCreateFromXBMData(scr, (char*)MENU_RADIO_INDICATOR_XBM_DATA, - (char*)MENU_RADIO_INDICATOR_XBM_DATA, - MENU_RADIO_INDICATOR_XBM_SIZE, - MENU_RADIO_INDICATOR_XBM_SIZE, - scr->black_pixel, scr->white_pixel); + (char*)MENU_RADIO_INDICATOR_XBM_DATA, + MENU_RADIO_INDICATOR_XBM_SIZE, + MENU_RADIO_INDICATOR_XBM_SIZE, + scr->black_pixel, scr->white_pixel); if (pix!=NULL) pix->shared = 1; scr->menu_radio_indicator = pix; pix = wPixmapCreateFromXBMData(scr, (char*)MENU_CHECK_INDICATOR_XBM_DATA, - (char*)MENU_CHECK_INDICATOR_XBM_DATA, - MENU_CHECK_INDICATOR_XBM_SIZE, - MENU_CHECK_INDICATOR_XBM_SIZE, - scr->black_pixel, scr->white_pixel); + (char*)MENU_CHECK_INDICATOR_XBM_DATA, + MENU_CHECK_INDICATOR_XBM_SIZE, + MENU_CHECK_INDICATOR_XBM_SIZE, + scr->black_pixel, scr->white_pixel); if (pix!=NULL) pix->shared = 1; scr->menu_check_indicator = pix; pix = wPixmapCreateFromXBMData(scr, (char*)MENU_MINI_INDICATOR_XBM_DATA, - (char*)MENU_MINI_INDICATOR_XBM_DATA, - MENU_MINI_INDICATOR_XBM_SIZE, - MENU_MINI_INDICATOR_XBM_SIZE, - scr->black_pixel, scr->white_pixel); + (char*)MENU_MINI_INDICATOR_XBM_DATA, + MENU_MINI_INDICATOR_XBM_SIZE, + MENU_MINI_INDICATOR_XBM_SIZE, + scr->black_pixel, scr->white_pixel); if (pix!=NULL) pix->shared = 1; scr->menu_mini_indicator = pix; @@ -425,11 +425,11 @@ createPixmaps(WScreen *scr) image = wDefaultGetImage(scr, "Logo", "WMPanel"); if (!image) { - wwarning(_("could not load logo image for panels: %s"), - RMessageForError(RErrorCode)); + wwarning(_("could not load logo image for panels: %s"), + RMessageForError(RErrorCode)); } else { WMSetApplicationIconImage(scr->wmscreen, image); - RReleaseImage(image); + RReleaseImage(image); } scr->dock_dots = make3Dots(scr); @@ -445,32 +445,32 @@ createPixmaps(WScreen *scr) * Creates some windows used internally by the program. One to * receive input focus when no other window can get it and another * to display window geometry information during window resize/move. - * + * * Returns: * Nothing - * + * * Side effects: * Windows are created and some colors are allocated for the * window background. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ static void createInternalWindows(WScreen *scr) { int vmask; XSetWindowAttributes attribs; - + /* InputOnly window to get the focus when no other window can get it */ vmask = CWEventMask|CWOverrideRedirect; attribs.event_mask = KeyPressMask|FocusChangeMask; attribs.override_redirect = True; scr->no_focus_win=XCreateWindow(dpy,scr->root_win,-10, -10, 4, 4, 0, 0, - InputOnly,CopyFromParent, vmask, &attribs); + InputOnly,CopyFromParent, vmask, &attribs); XSelectInput(dpy, scr->no_focus_win, KeyPressMask|KeyReleaseMask); XMapWindow(dpy, scr->no_focus_win); XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, CurrentTime); - + /* shadow window for dock buttons */ vmask = CWBorderPixel|CWBackPixmap|CWBackPixel|CWCursor|CWSaveUnder|CWOverrideRedirect; attribs.border_pixel = scr->black_pixel; @@ -482,34 +482,34 @@ createInternalWindows(WScreen *scr) vmask |= CWColormap; attribs.colormap = scr->w_colormap; scr->dock_shadow = - XCreateWindow(dpy, scr->root_win, 0, 0, wPreferences.icon_size, - wPreferences.icon_size, 0, scr->w_depth, CopyFromParent, - scr->w_visual, vmask, &attribs); + XCreateWindow(dpy, scr->root_win, 0, 0, wPreferences.icon_size, + wPreferences.icon_size, 0, scr->w_depth, CopyFromParent, + scr->w_visual, vmask, &attribs); /* workspace name balloon for clip */ vmask = CWBackPixel|CWSaveUnder|CWOverrideRedirect|CWColormap - |CWBorderPixel; + |CWBorderPixel; attribs.save_under = True; attribs.override_redirect = True; attribs.colormap = scr->w_colormap; attribs.background_pixel = scr->icon_back_texture->normal.pixel; attribs.border_pixel = 0; /* do not care */ scr->clip_balloon = - XCreateWindow(dpy, scr->root_win, 0, 0, 10, 10, 0, scr->w_depth, - CopyFromParent, scr->w_visual, vmask, &attribs); + XCreateWindow(dpy, scr->root_win, 0, 0, 10, 10, 0, scr->w_depth, + CopyFromParent, scr->w_visual, vmask, &attribs); + - /* workspace name */ vmask = CWBackPixel|CWSaveUnder|CWOverrideRedirect|CWColormap - |CWBorderPixel; + |CWBorderPixel; attribs.save_under = True; attribs.override_redirect = True; attribs.colormap = scr->w_colormap; attribs.background_pixel = scr->icon_back_texture->normal.pixel; attribs.border_pixel = 0; /* do not care */ scr->workspace_name = - XCreateWindow(dpy, scr->root_win, 0, 0, 10, 10, 0, scr->w_depth, - CopyFromParent, scr->w_visual, vmask, &attribs); + XCreateWindow(dpy, scr->root_win, 0, 0, 10, 10, 0, scr->w_depth, + CopyFromParent, scr->w_visual, vmask, &attribs); /* * If the window is clicked without having ButtonPress selected, the @@ -536,25 +536,25 @@ aquireManagerSelection(WScreen *scr) /* if there is another manager running, don't try to replace it * (for now, at least) */ if (XGetSelectionOwner(dpy, scr->managerAtom) != None) { - XUngrabServer(dpy); - return False; + XUngrabServer(dpy); + return False; } /* become the manager for this screen */ scr->managerWindow = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 1, 1, - 0, 0, 0); + 0, 0, 0); XSelectInput(dpy, scr->managerWindow, PropertyChangeMask); /* get a timestamp */ XChangeProperty(dpy, scr->managerWindow, scr->managerAtom, - XA_INTEGER, 32, PropModeAppend, NULL, 0); + XA_INTEGER, 32, PropModeAppend, NULL, 0); while (1) { - XWindowEvent(dpy, scr->managerWindow, &ev); - if (ev.type == PropertyNotify) { - timestamp = ev.xproperty.time; - break; - } + XWindowEvent(dpy, scr->managerWindow, &ev); + if (ev.type == PropertyNotify) { + timestamp = ev.xproperty.time; + break; + } } XSelectInput(dpy, scr->managerWindow, NoEvents); XDeleteProperty(dpy, scr->managerWindow, scr->managerAtom); @@ -585,20 +585,20 @@ aquireManagerSelection(WScreen *scr) /* *---------------------------------------------------------------------- * wScreenInit-- - * Initializes the window manager for the given screen and + * Initializes the window manager for the given screen and * allocates a WScreen descriptor for it. Many resources are allocated * for the screen and the root window is setup appropriately. * * Returns: * The WScreen descriptor for the screen. - * + * * Side effects: * Many resources are allocated and the IconSize property is * set on the root window. * The program can be aborted if some fatal error occurs. - * + * * TODO: User specifiable visual. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ WScreen* wScreenInit(int screen_number) @@ -615,7 +615,7 @@ wScreenInit(int screen_number) memset(scr, 0, sizeof(WScreen)); scr->stacking_list = WMCreateTreeBag(); - + /* initialize globals */ scr->screen = screen_number; scr->root_win = RootWindow(dpy, screen_number); @@ -631,20 +631,20 @@ wScreenInit(int screen_number) scr->totalUsableArea = (WArea *)wmalloc(sizeof(WArea)*wXineramaHeads(scr)); for (i=0; iusableArea[i].x1 = scr->totalUsableArea[i].x1 = rect.pos.x; - scr->usableArea[i].y1 = scr->totalUsableArea[i].y1 = rect.pos.y; - scr->usableArea[i].x2 = scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width; - scr->usableArea[i].y2 = scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height; + WMRect rect = wGetRectForHead(scr, i); + scr->usableArea[i].x1 = scr->totalUsableArea[i].x1 = rect.pos.x; + scr->usableArea[i].y1 = scr->totalUsableArea[i].y1 = rect.pos.y; + scr->usableArea[i].x2 = scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width; + scr->usableArea[i].y2 = scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height; } scr->fakeGroupLeaders = WMCreateArray(16); #if 0 if (!aquireManagerSelection(scr)) { - wfree(scr); + wfree(scr); - return NULL; + return NULL; } #endif CantManageScreen = 0; @@ -653,86 +653,86 @@ wScreenInit(int screen_number) event_mask = EVENT_MASK; if (wPreferences.disable_root_mouse) { - event_mask &= ~(ButtonPressMask|ButtonReleaseMask); + event_mask &= ~(ButtonPressMask|ButtonReleaseMask); } - + XSelectInput(dpy, scr->root_win, event_mask); -#ifdef KEEP_XKB_LOCK_STATUS +#ifdef KEEP_XKB_LOCK_STATUS /* Only GroupLock doesn't work correctly in my system since right-alt * can change mode while holding it too - ]d */ if (wXkbSupported) { XkbSelectEvents(dpy,XkbUseCoreKbd, - XkbStateNotifyMask, - XkbStateNotifyMask); + XkbStateNotifyMask, + XkbStateNotifyMask); } #endif /* KEEP_XKB_LOCK_STATUS */ XSync(dpy, False); XSetErrorHandler(oldHandler); - + if (CantManageScreen) { - wfree(scr); - return NULL; + wfree(scr); + return NULL; } - + XDefineCursor(dpy, scr->root_win, wCursor[WCUR_ROOT]); /* screen descriptor for raster graphic library */ rattr.flags = RC_RenderMode | RC_ColorsPerChannel | RC_StandardColormap; - rattr.render_mode = wPreferences.no_dithering - ? RBestMatchRendering - : RDitheredRendering; + rattr.render_mode = wPreferences.no_dithering + ? RBestMatchRendering + : RDitheredRendering; /* if the std colormap stuff works ok, this will be ignored */ rattr.colors_per_channel = wPreferences.cmap_size; if (rattr.colors_per_channel<2) - rattr.colors_per_channel = 2; + rattr.colors_per_channel = 2; + - /* will only be accounted for in PseudoColor */ if (wPreferences.flags.create_stdcmap) { - rattr.standard_colormap_mode = RCreateStdColormap; + rattr.standard_colormap_mode = RCreateStdColormap; } else { - rattr.standard_colormap_mode = RUseStdColormap; + rattr.standard_colormap_mode = RUseStdColormap; } if (wVisualID>=0) { - rattr.flags |= RC_VisualID; - rattr.visualid = wVisualID; + rattr.flags |= RC_VisualID; + rattr.visualid = wVisualID; } - + scr->rcontext = RCreateContext(dpy, screen_number, &rattr); if (!scr->rcontext && RErrorCode == RERR_STDCMAPFAIL) { - wwarning(RMessageForError(RErrorCode)); + wwarning(RMessageForError(RErrorCode)); - rattr.flags &= ~RC_StandardColormap; - rattr.standard_colormap_mode = RUseStdColormap; + rattr.flags &= ~RC_StandardColormap; + rattr.standard_colormap_mode = RUseStdColormap; - scr->rcontext = RCreateContext(dpy, screen_number, &rattr); + scr->rcontext = RCreateContext(dpy, screen_number, &rattr); } if (!scr->rcontext) { - wwarning(_("could not initialize graphics library context: %s"), - RMessageForError(RErrorCode)); - wAbort(False); + wwarning(_("could not initialize graphics library context: %s"), + RMessageForError(RErrorCode)); + wAbort(False); } else { - char **formats; - int i = 0; - - formats = RSupportedFileFormats(); - if (formats) { - for (i=0; formats[i]!=NULL; i++) { - if (strcmp(formats[i], "TIFF")==0) { - scr->flags.supports_tiff = 1; - break; - } - } - } + char **formats; + int i = 0; + + formats = RSupportedFileFormats(); + if (formats) { + for (i=0; formats[i]!=NULL; i++) { + if (strcmp(formats[i], "TIFF")==0) { + scr->flags.supports_tiff = 1; + break; + } + } + } } - + scr->w_win = scr->rcontext->drawable; scr->w_visual = scr->rcontext->visual; scr->w_depth = scr->rcontext->depth; @@ -740,11 +740,11 @@ wScreenInit(int screen_number) /* create screen descriptor for WINGs */ scr->wmscreen = WMCreateScreenWithRContext(dpy, screen_number, - scr->rcontext); + scr->rcontext); if (!scr->wmscreen) { - wfatal(_("could not initialize WINGs widget set")); - return NULL; + wfatal(_("could not initialize WINGs widget set")); + return NULL; } scr->black = WMBlackColor(scr->wmscreen); @@ -758,21 +758,21 @@ wScreenInit(int screen_number) scr->dark_pixel = WMColorPixel(scr->darkGray); { - XColor xcol; - /* frame boder color */ - wGetColor(scr, FRAME_BORDER_COLOR, &xcol); - scr->frame_border_pixel = xcol.pixel; + XColor xcol; + /* frame boder color */ + wGetColor(scr, FRAME_BORDER_COLOR, &xcol); + scr->frame_border_pixel = xcol.pixel; } /* 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. + * create before reading the defaults, because it will be used there. */ - scr->info_window = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 10, 10, - 0, 0, 0); - + scr->info_window = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 10, 10, + 0, 0, 0); + /* read defaults for this screen */ wReadDefaults(scr, WDWindowMaker->dictionary); @@ -814,11 +814,11 @@ wScreenInit(int screen_number) /* setup our noticeboard */ XChangeProperty(dpy, scr->info_window, _XA_WINDOWMAKER_NOTICEBOARD, - XA_WINDOW, 32, PropModeReplace, - (unsigned char*)&scr->info_window, 1); + XA_WINDOW, 32, PropModeReplace, + (unsigned char*)&scr->info_window, 1); XChangeProperty(dpy, scr->root_win, _XA_WINDOWMAKER_NOTICEBOARD, - XA_WINDOW, 32, PropModeReplace, - (unsigned char*)&scr->info_window, 1); + XA_WINDOW, 32, PropModeReplace, + (unsigned char*)&scr->info_window, 1); #ifdef BALLOON_TEXT @@ -859,120 +859,120 @@ wScreenUpdateUsableArea(WScreen *scr) rect.pos.y = scr->dock->y_pos; rect.size.width = wPreferences.icon_size; rect.size.height = wPreferences.icon_size; - dock_head = wGetHeadForRect(scr, rect); + dock_head = wGetHeadForRect(scr, rect); } - + for (i=0; itotalUsableArea[i].x1 = rect.pos.x; scr->totalUsableArea[i].y1 = rect.pos.y; scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width; scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height; - if (scr->dock && dock_head==i && + if (scr->dock && dock_head==i && (!scr->dock->lowered || wPreferences.no_window_over_dock)) { - int offset = wPreferences.icon_size + DOCK_EXTRA_SPACE; + int offset = wPreferences.icon_size + DOCK_EXTRA_SPACE; - if (scr->dock->on_right_side) { - scr->totalUsableArea[i].x2 -= offset; - } else { - scr->totalUsableArea[i].x1 += offset; - } - } + if (scr->dock->on_right_side) { + scr->totalUsableArea[i].x2 -= offset; + } else { + scr->totalUsableArea[i].x1 += offset; + } + } #ifdef NETWM_HINTS { - WArea area; - if (wNETWMGetUsableArea(scr, i, &area)) { - scr->totalUsableArea[i].x1 = WMAX(scr->totalUsableArea[i].x1, area.x1); - scr->totalUsableArea[i].y1 = WMAX(scr->totalUsableArea[i].y1, area.y1); - scr->totalUsableArea[i].x2 = WMIN(scr->totalUsableArea[i].x2, area.x2); - scr->totalUsableArea[i].y2 = WMIN(scr->totalUsableArea[i].y2, area.y2); - } - } + WArea area; + if (wNETWMGetUsableArea(scr, i, &area)) { + scr->totalUsableArea[i].x1 = WMAX(scr->totalUsableArea[i].x1, area.x1); + scr->totalUsableArea[i].y1 = WMAX(scr->totalUsableArea[i].y1, area.y1); + scr->totalUsableArea[i].x2 = WMIN(scr->totalUsableArea[i].x2, area.x2); + scr->totalUsableArea[i].y2 = WMIN(scr->totalUsableArea[i].y2, area.y2); + } + } #endif #ifdef GNOME_STUFF - { - WArea area; - if (wGNOMEGetUsableArea(scr, i, &area)) { - scr->totalUsableArea[i].x1 = WMAX(scr->totalUsableArea[i].x1, area.x1); - scr->totalUsableArea[i].y1 = WMAX(scr->totalUsableArea[i].y1, area.y1); - scr->totalUsableArea[i].x2 = WMIN(scr->totalUsableArea[i].x2, area.x2); - scr->totalUsableArea[i].y2 = WMIN(scr->totalUsableArea[i].y2, area.y2); - } - } + { + WArea area; + if (wGNOMEGetUsableArea(scr, i, &area)) { + scr->totalUsableArea[i].x1 = WMAX(scr->totalUsableArea[i].x1, area.x1); + scr->totalUsableArea[i].y1 = WMAX(scr->totalUsableArea[i].y1, area.y1); + scr->totalUsableArea[i].x2 = WMIN(scr->totalUsableArea[i].x2, area.x2); + scr->totalUsableArea[i].y2 = WMIN(scr->totalUsableArea[i].y2, area.y2); + } + } #endif #ifdef KWM_HINTS - { - WArea area; - if (wKWMGetUsableArea(scr, i, &area)) { - scr->totalUsableArea[i].x1 = WMAX(scr->totalUsableArea[i].x1, area.x1); - scr->totalUsableArea[i].y1 = WMAX(scr->totalUsableArea[i].y1, area.y1); - scr->totalUsableArea[i].x2 = WMIN(scr->totalUsableArea[i].x2, area.x2); - scr->totalUsableArea[i].y2 = WMIN(scr->totalUsableArea[i].y2, area.y2); - } - } + { + WArea area; + if (wKWMGetUsableArea(scr, i, &area)) { + scr->totalUsableArea[i].x1 = WMAX(scr->totalUsableArea[i].x1, area.x1); + scr->totalUsableArea[i].y1 = WMAX(scr->totalUsableArea[i].y1, area.y1); + scr->totalUsableArea[i].x2 = WMIN(scr->totalUsableArea[i].x2, area.x2); + scr->totalUsableArea[i].y2 = WMIN(scr->totalUsableArea[i].y2, area.y2); + } + } #endif - scr->usableArea[i] = scr->totalUsableArea[i]; + scr->usableArea[i] = scr->totalUsableArea[i]; #if 0 - printf("usableArea[%d]: %d %d %d %d\n", i, + printf("usableArea[%d]: %d %d %d %d\n", i, scr->usableArea[i].x1, scr->usableArea[i].x2, scr->usableArea[i].y1, scr->usableArea[i].y2); #endif - if (wPreferences.no_window_over_icons) { - if (wPreferences.icon_yard & IY_VERT) { - if (wPreferences.icon_yard & IY_RIGHT) { - scr->totalUsableArea[i].x2 -= wPreferences.icon_size; - } else { - scr->totalUsableArea[i].x1 += wPreferences.icon_size; - } - } else { - if (wPreferences.icon_yard & IY_TOP) { - scr->totalUsableArea[i].y1 += wPreferences.icon_size; - } else { - scr->totalUsableArea[i].y2 -= wPreferences.icon_size; - } - } - } - - if (scr->totalUsableArea[i].x2 - scr->totalUsableArea[i].x1 < rect.size.width/2) { - scr->totalUsableArea[i].x1 = rect.pos.x; - scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width; + if (wPreferences.no_window_over_icons) { + if (wPreferences.icon_yard & IY_VERT) { + if (wPreferences.icon_yard & IY_RIGHT) { + scr->totalUsableArea[i].x2 -= wPreferences.icon_size; + } else { + scr->totalUsableArea[i].x1 += wPreferences.icon_size; + } + } else { + if (wPreferences.icon_yard & IY_TOP) { + scr->totalUsableArea[i].y1 += wPreferences.icon_size; + } else { + scr->totalUsableArea[i].y2 -= wPreferences.icon_size; + } + } + } + + if (scr->totalUsableArea[i].x2 - scr->totalUsableArea[i].x1 < rect.size.width/2) { + scr->totalUsableArea[i].x1 = rect.pos.x; + scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width; } - if (scr->totalUsableArea[i].y2 - scr->totalUsableArea[i].y1 < rect.size.height/2) { - scr->totalUsableArea[i].y1 = rect.pos.y; - scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height; - } - - tmp_area = (scr->totalUsableArea[i].x2 - scr->totalUsableArea[i].x1) * - (scr->totalUsableArea[i].y2 - scr->totalUsableArea[i].y1); - - if (tmp_area > best_area) { - best_area = tmp_area; - area = scr->totalUsableArea[i]; - } - - { - unsigned size = wPreferences.workspace_border_size; - unsigned position = wPreferences.workspace_border_position; - - if (size>0 && position!=WB_NONE) { - if (position & WB_LEFTRIGHT) { - scr->totalUsableArea[i].x1 += size; - scr->totalUsableArea[i].x2 -= size; - } - if (position & WB_TOPBOTTOM) { - scr->totalUsableArea[i].y1 += size; - scr->totalUsableArea[i].y2 -= size; - } - } - } + if (scr->totalUsableArea[i].y2 - scr->totalUsableArea[i].y1 < rect.size.height/2) { + scr->totalUsableArea[i].y1 = rect.pos.y; + scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height; + } + + tmp_area = (scr->totalUsableArea[i].x2 - scr->totalUsableArea[i].x1) * + (scr->totalUsableArea[i].y2 - scr->totalUsableArea[i].y1); + + if (tmp_area > best_area) { + best_area = tmp_area; + area = scr->totalUsableArea[i]; + } + + { + unsigned size = wPreferences.workspace_border_size; + unsigned position = wPreferences.workspace_border_position; + + if (size>0 && position!=WB_NONE) { + if (position & WB_LEFTRIGHT) { + scr->totalUsableArea[i].x1 += size; + scr->totalUsableArea[i].x2 -= size; + } + if (position & WB_TOPBOTTOM) { + scr->totalUsableArea[i].y1 += size; + scr->totalUsableArea[i].y2 -= size; + } + } + } } #ifdef NETWM_HINTS @@ -990,58 +990,58 @@ wScreenUpdateUsableArea(WScreen *scr) { scr->totalUsableArea = scr->usableArea; - if (scr->dock && (!scr->dock->lowered - || wPreferences.no_window_over_dock)) { + if (scr->dock && (!scr->dock->lowered + || wPreferences.no_window_over_dock)) { - int offset = wPreferences.icon_size + DOCK_EXTRA_SPACE; + int offset = wPreferences.icon_size + DOCK_EXTRA_SPACE; - if (scr->dock->on_right_side) { - scr->totalUsableArea.x2 = WMIN(scr->totalUsableArea.x2, - scr->scr_width - offset); - } else { - scr->totalUsableArea.x1 = WMAX(scr->totalUsableArea.x1, offset); - } + if (scr->dock->on_right_side) { + scr->totalUsableArea.x2 = WMIN(scr->totalUsableArea.x2, + scr->scr_width - offset); + } else { + scr->totalUsableArea.x1 = WMAX(scr->totalUsableArea.x1, offset); + } } - + if (wPreferences.no_window_over_icons) { - if (wPreferences.icon_yard & IY_VERT) { - - if (!(wPreferences.icon_yard & IY_RIGHT)) { - scr->totalUsableArea.x1 += wPreferences.icon_size; - } else { - scr->totalUsableArea.x2 -= wPreferences.icon_size; - } - } else { - - if (wPreferences.icon_yard & IY_TOP) { - scr->totalUsableArea.y1 += wPreferences.icon_size; - } else { - scr->totalUsableArea.y2 -= wPreferences.icon_size; - } - } + if (wPreferences.icon_yard & IY_VERT) { + + if (!(wPreferences.icon_yard & IY_RIGHT)) { + scr->totalUsableArea.x1 += wPreferences.icon_size; + } else { + scr->totalUsableArea.x2 -= wPreferences.icon_size; + } + } else { + + if (wPreferences.icon_yard & IY_TOP) { + scr->totalUsableArea.y1 += wPreferences.icon_size; + } else { + scr->totalUsableArea.y2 -= wPreferences.icon_size; + } + } } #ifdef NETWM_HINTS { - WArea area; - if (wNETWMGetUsableArea(scr, &area)) { - scr->totalUsableArea.x1 = WMAX(scr->totalUsableArea.x1, area.x1); - scr->totalUsableArea.y1 = WMAX(scr->totalUsableArea.y1, area.y1); - scr->totalUsableArea.x2 = WMIN(scr->totalUsableArea.x2, area.x2); - scr->totalUsableArea.y2 = WMIN(scr->totalUsableArea.y2, area.y2); - } + WArea area; + if (wNETWMGetUsableArea(scr, &area)) { + scr->totalUsableArea.x1 = WMAX(scr->totalUsableArea.x1, area.x1); + scr->totalUsableArea.y1 = WMAX(scr->totalUsableArea.y1, area.y1); + scr->totalUsableArea.x2 = WMIN(scr->totalUsableArea.x2, area.x2); + scr->totalUsableArea.y2 = WMIN(scr->totalUsableArea.y2, area.y2); + } } #endif #ifdef KWM_HINTS { - WArea area; - if (wKWMGetUsableArea(scr, &area)) { - scr->totalUsableArea.x1 = WMAX(scr->totalUsableArea.x1, area.x1); - scr->totalUsableArea.y1 = WMAX(scr->totalUsableArea.y1, area.y1); - scr->totalUsableArea.x2 = WMIN(scr->totalUsableArea.x2, area.x2); - scr->totalUsableArea.y2 = WMIN(scr->totalUsableArea.y2, area.y2); - } + WArea area; + if (wKWMGetUsableArea(scr, &area)) { + scr->totalUsableArea.x1 = WMAX(scr->totalUsableArea.x1, area.x1); + scr->totalUsableArea.y1 = WMAX(scr->totalUsableArea.y1, area.y1); + scr->totalUsableArea.x2 = WMIN(scr->totalUsableArea.x2, area.x2); + scr->totalUsableArea.y2 = WMIN(scr->totalUsableArea.y2, area.y2); + } } #endif @@ -1092,22 +1092,22 @@ wScreenUpdateUsableArea(WScreen *scr) #endif /* GNOME_STUFF */ if (scr->totalUsableArea.x2 - scr->totalUsableArea.x1 < scr->scr_width/2) { - scr->totalUsableArea.x2 = scr->usableArea.x2; - scr->totalUsableArea.x1 = scr->usableArea.x1; + scr->totalUsableArea.x2 = scr->usableArea.x2; + scr->totalUsableArea.x1 = scr->usableArea.x1; } if (scr->totalUsableArea.y2 - scr->totalUsableArea.y1 < scr->scr_height/2) { - scr->totalUsableArea.y2 = scr->usableArea.y2; - scr->totalUsableArea.y1 = scr->usableArea.y1; + scr->totalUsableArea.y2 = scr->usableArea.y2; + scr->totalUsableArea.y1 = scr->usableArea.y1; } #ifdef not_used #ifdef KWM_HINTS { - int i; + int i; - for (i = 0; i < scr->workspace_count; i++) { - wKWMSetUsableAreaHint(scr, i); - } + for (i = 0; i < scr->workspace_count; i++) { + wKWMSetUsableAreaHint(scr, i); + } } #endif #endif @@ -1154,18 +1154,18 @@ wScreenRestoreState(WScreen *scr) make_keys(); if (wScreenCount == 1) { - path = wdefaultspathfordomain("WMState"); + path = wdefaultspathfordomain("WMState"); } else { - char buf[16]; - snprintf(buf, sizeof(buf), "WMState.%i", scr->screen); - path = wdefaultspathfordomain(buf); + char buf[16]; + snprintf(buf, sizeof(buf), "WMState.%i", scr->screen); + path = wdefaultspathfordomain(buf); } scr->session_state = WMReadPropListFromFile(path); wfree(path); if (!scr->session_state && wScreenCount>1) { - path = wdefaultspathfordomain("WMState"); - scr->session_state = WMReadPropListFromFile(path); - wfree(path); + path = wdefaultspathfordomain("WMState"); + scr->session_state = WMReadPropListFromFile(path); + wfree(path); } if (!scr->session_state) { @@ -1211,17 +1211,17 @@ wScreenSaveState(WScreen *scr) XChangeProperty(dpy, scr->root_win, _XA_WINDOWMAKER_STATE, _XA_WINDOWMAKER_STATE, 32, PropModeReplace, (unsigned char *) data, 2); - + /* save state of windows */ wwin = scr->focused_window; while (wwin) { - wWindowSaveState(wwin); - wwin = wwin->prev; + wWindowSaveState(wwin); + wwin = wwin->prev; } if (wPreferences.flags.noupdates) - return; + return; old_state = scr->session_state; @@ -1264,14 +1264,14 @@ wScreenSaveState(WScreen *scr) wMenuSaveState(scr); if (wScreenCount == 1) { - str = wdefaultspathfordomain("WMState"); + str = wdefaultspathfordomain("WMState"); } else { - char buf[16]; - snprintf(buf, sizeof(buf), "WMState.%i", scr->screen); - str = wdefaultspathfordomain(buf); + char buf[16]; + snprintf(buf, sizeof(buf), "WMState.%i", scr->screen); + str = wdefaultspathfordomain(buf); } if (!WMWritePropListToFile(scr->session_state, str, True)) { - wsyserror(_("could not save session state in %s"), str); + wsyserror(_("could not save session state in %s"), str); } wfree(str); WMReleasePropList(old_state); @@ -1307,42 +1307,42 @@ wScreenBringInside(WScreen *scr, int *x, int *y, int width, int height) #if 0 /* NOTE: gives funky group movement */ if (flags & XFLAG_MULTIPLE) { - /* - * since we span multiple heads, pull window totaly inside - */ - if (*x < sx1) - *x = sx1, moved = 1; - else if (*x + width > sx2) - *x = sx2 - width, moved = 1; - - if (*y < sy1) - *y = sy1, moved = 1; - else if (*y + height > sy2) - *y = sy2 - height, moved = 1; - - return moved; + /* + * since we span multiple heads, pull window totaly inside + */ + if (*x < sx1) + *x = sx1, moved = 1; + else if (*x + width > sx2) + *x = sx2 - width, moved = 1; + + if (*y < sy1) + *y = sy1, moved = 1; + else if (*y + height > sy2) + *y = sy2 - height, moved = 1; + + return moved; } #endif - + if (width > 20) - tol_w = width/2; + tol_w = width/2; else - tol_w = 20; + tol_w = 20; if (height > 20) - tol_h = height/2; + tol_h = height/2; else - tol_h = 20; + tol_h = 20; if (*x + width < sx1 + 10) - *x = sx1 - tol_w, moved = 1; + *x = sx1 - tol_w, moved = 1; else if (*x >= sx2 - 10) - *x = sx2 - tol_w - 1, moved = 1; + *x = sx2 - tol_w - 1, moved = 1; if (*y < sy1 - height + 10) - *y = sy1 - tol_h, moved = 1; + *y = sy1 - tol_h, moved = 1; else if (*y >= sy2 - 10) - *y = sy2 - tol_h - 1, moved = 1; + *y = sy2 - tol_h - 1, moved = 1; return moved; } @@ -1371,14 +1371,14 @@ wScreenKeepInside(WScreen *scr, int *x, int *y, int width, int height) sy2 = sy1 + rect.size.height; if (*x < sx1) - *x = sx1, moved = 1; + *x = sx1, moved = 1; else if (*x + width > sx2) - *x = sx2 - width, moved = 1; + *x = sx2 - width, moved = 1; if (*y < sy1) - *y = sy1, moved = 1; + *y = sy1, moved = 1; else if (*y + height > sy2) - *y = sy2 - height, moved = 1; + *y = sy2 - height, moved = 1; return moved; } diff --git a/src/screen.h b/src/screen.h index 12514099..bd233cac 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -86,12 +86,12 @@ typedef struct _WScreen { Colormap colormap; /* root colormap */ int root_colormap_install_count; struct WWindow *original_cmap_window; /* colormap before installing - * root colormap temporarily */ + * root colormap temporarily */ struct WWindow *cmap_window; Colormap current_colormap; Window w_win; /* window to use as drawable - * for new GCs, pixmaps etc. */ + * for new GCs, pixmaps etc. */ Visual *w_visual; int w_depth; Colormap w_colormap; /* our colormap */ @@ -99,12 +99,12 @@ typedef struct _WScreen { WXineramaInfo xine_info; Window no_focus_win; /* window to get focus when nobody - * else can do it */ + * else can do it */ struct WWindow *focused_window; /* window that has the focus - * Use this list if you want to - * traverse the entire window list - */ + * Use this list if you want to + * traverse the entire window list + */ WMArray *selected_windows; @@ -115,12 +115,12 @@ typedef struct _WScreen { struct WApplication *wapp_list; /* list of all aplications */ WMBag *stacking_list; /* bag of lists of windows - * in stacking order. - * Indexed by window level - * and each list on the array - * is ordered from the topmost to - * the lowest window - */ + * in stacking order. + * Indexed by window level + * and each list on the array + * is ordered from the topmost to + * the lowest window + */ int window_count; /* number of windows in window_list */ @@ -134,10 +134,10 @@ typedef struct _WScreen { WReservedArea *reservedAreas; /* used to build totalUsableArea */ WArea *usableArea; /* area of the workspace where - * we can put windows on, as defined - * by other clients (not us) */ + * we can put windows on, as defined + * by other clients (not us) */ WArea *totalUsableArea; /* same as above, but including - * the dock and other stuff */ + * the dock and other stuff */ WMColor *black; WMColor *white; @@ -152,15 +152,15 @@ typedef struct _WScreen { Pixmap stipple_bitmap; Pixmap transp_stipple; /* for making holes in icon masks for - * transparent icon simulation */ + * transparent icon simulation */ WMFont *title_font; /* default font for the titlebars */ WMFont *menu_title_font; /* font for menu titlebars */ WMFont *menu_entry_font; /* font for menu items */ WMFont *icon_title_font; /* for icon titles */ WMFont *clip_title_font; /* for clip titles */ WMFont *info_text_font; /* text on things like geometry - * hint boxes */ - + * hint boxes */ + XFontStruct *tech_draw_font; /* font for tech draw style geom view needs to be a core font so we can use it with a XORing GC */ @@ -187,7 +187,7 @@ typedef struct _WScreen { union WTexture *menu_item_texture; /* menu item texture */ struct WTexSolid *menu_item_auxtexture; /* additional texture to draw menu - * cascade arrows */ + * cascade arrows */ struct WTexSolid *icon_title_texture;/* icon titles */ struct WTexSolid *widget_texture; @@ -236,9 +236,9 @@ typedef struct _WScreen { struct WDock *last_dock; WAppIconChain *global_icons; /* for omnipresent icons chain in clip */ int global_icon_count; /* How many global icons do we have */ - + Window clip_balloon; /* window for workspace name */ - + int keymove_tick; #ifdef GRADIENT_CLIP_ARROW @@ -246,9 +246,9 @@ typedef struct _WScreen { #endif struct RContext *rcontext; /* wrlib context */ - + WMScreen *wmscreen; /* for widget library */ - + struct RImage *icon_tile; struct RImage *clip_tile; Pixmap icon_tile_pixmap; /* for app supplied icons */ @@ -257,8 +257,8 @@ typedef struct _WScreen { Pixmap def_ticon_pixmap; struct WDialogData *dialog_data; - - + + struct W_GeometryView *gview; /* size/position view */ #ifdef NEWSTUFF @@ -274,7 +274,7 @@ typedef struct _WScreen { Time last_click_time; Window last_click_window; int last_click_button; - + /* balloon help data */ struct _WBalloon *balloon; @@ -286,11 +286,11 @@ typedef struct _WScreen { /* for raise-delay */ WMHandlerID *autoRaiseTimer; Window autoRaiseWindow; /* window that is scheduled to be - * raised */ + * raised */ Window scrolledFMaximize; /* full maximized window which was - scrolled down for titlebar access */ + scrolled down for titlebar access */ /* for window shortcuts */ WMArray *shortcutWindows[MAX_WINDOW_SHORTCUTS]; @@ -302,7 +302,7 @@ typedef struct _WScreen { #ifdef KWM_HINTS Window kwm_dock; #endif - + #ifdef NETWM_HINTS struct NetData *netdata; #endif @@ -311,25 +311,25 @@ typedef struct _WScreen { pid_t helper_pid; struct { - unsigned int startup:1; /* during window manager startup */ - unsigned int regenerate_icon_textures:1; - unsigned int dnd_data_convertion_status:1; - unsigned int root_menu_changed_shortcuts:1; - unsigned int added_workspace_menu:1; - unsigned int added_windows_menu:1; - unsigned int startup2:1; /* startup phase 2 */ - unsigned int supports_tiff:1; - unsigned int clip_balloon_mapped:1; - unsigned int next_click_is_not_double:1; - unsigned int backimage_helper_launched:1; - /* some client has issued a WM_COLORMAP_NOTIFY */ - unsigned int colormap_stuff_blocked:1; - unsigned int doing_alt_tab:1; - unsigned int jump_back_pending:1; + unsigned int startup:1; /* during window manager startup */ + unsigned int regenerate_icon_textures:1; + unsigned int dnd_data_convertion_status:1; + unsigned int root_menu_changed_shortcuts:1; + unsigned int added_workspace_menu:1; + unsigned int added_windows_menu:1; + unsigned int startup2:1; /* startup phase 2 */ + unsigned int supports_tiff:1; + unsigned int clip_balloon_mapped:1; + unsigned int next_click_is_not_double:1; + unsigned int backimage_helper_launched:1; + /* some client has issued a WM_COLORMAP_NOTIFY */ + unsigned int colormap_stuff_blocked:1; + unsigned int doing_alt_tab:1; + unsigned int jump_back_pending:1; unsigned int ignore_focus_events:1; #ifdef KWM_HINTS - unsigned int kwm_syncing_name:1; - unsigned int kwm_syncing_count:1; + unsigned int kwm_syncing_name:1; + unsigned int kwm_syncing_count:1; #endif } flags; } WScreen; diff --git a/src/session.c b/src/session.c index 7020f6c5..cbb38a7b 100644 --- a/src/session.c +++ b/src/session.c @@ -17,45 +17,45 @@ * * 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. */ /* - * + * * If defined(XSMP_ENABLED) and session manager is running then * do normal stuff * else * do pre-R6 session management stuff (save window state and relaunch) * * When doing a checkpoint: - * + * * = Without XSMP * Open "Stop"/status Dialog * Send SAVE_YOURSELF to clients and wait for reply * Save restart info * Save state of clients - * + * * = With XSMP * Send checkpoint request to sm * * When exiting: * ------------- - * + * * = Without XSMP - * + * * Open "Exit Now"/status Dialog * Send SAVE_YOURSELF to clients and wait for reply * Save restart info * Save state of clients * Send DELETE to all clients * When no more clients are left or user hit "Exit Now", exit - * + * * = With XSMP * * Send Shutdown request to session manager - * if SaveYourself message received, save state of clients + * if SaveYourself message received, save state of clients * if the Die message is received, exit. */ @@ -156,7 +156,7 @@ make_keys() -static int +static int getBool(WMPropList *value) { char *val; @@ -169,20 +169,20 @@ getBool(WMPropList *value) } if ((val[1]=='\0' && (val[0]=='y' || val[0]=='Y')) - || strcasecmp(val, "YES")==0) { + || strcasecmp(val, "YES")==0) { - return 1; + return 1; } else if ((val[1]=='\0' && (val[0]=='n' || val[0]=='N')) - || strcasecmp(val, "NO")==0) { - return 0; + || strcasecmp(val, "NO")==0) { + return 0; } else { - int i; - if (sscanf(val, "%i", &i)==1) { - return (i!=0); - } else { - wwarning(_("can't convert \"%s\" to boolean"), val); - return 0; - } + int i; + if (sscanf(val, "%i", &i)==1) { + return (i!=0); + } else { + wwarning(_("can't convert \"%s\" to boolean"), val); + return 0; + } } } @@ -192,14 +192,14 @@ getInt(WMPropList *value) { char *val; unsigned n; - + if (!WMIsPLString(value)) - return 0; + return 0; val = WMGetFromPLString(value); if (!val) - return 0; + return 0; if (sscanf(val, "%u", &n) != 1) - return 0; + return 0; return n; } @@ -240,25 +240,25 @@ makeWindowState(WWindow *wwin, WApplication *wapp) name = WMCreatePLString(buffer); cmd = WMCreatePLString(command); /*sprintf(buffer, "%d", wwin->frame->workspace+1); - workspace = WMCreatePLString(buffer);*/ + workspace = WMCreatePLString(buffer);*/ workspace = WMCreatePLString(scr->workspaces[wwin->frame->workspace]->name); shaded = wwin->flags.shaded ? sYes : sNo; miniaturized = wwin->flags.miniaturized ? sYes : sNo; hidden = wwin->flags.hidden ? sYes : sNo; - snprintf(buffer, sizeof(buffer), "%ix%i+%i+%i", - wwin->client.width, wwin->client.height, - wwin->frame_x, wwin->frame_y); + snprintf(buffer, sizeof(buffer), "%ix%i+%i+%i", + wwin->client.width, wwin->client.height, + wwin->frame_x, wwin->frame_y); geometry = WMCreatePLString(buffer); - - for (mask = 0, i = 0; i < MAX_WINDOW_SHORTCUTS; i++) { - if (scr->shortcutWindows[i] != NULL && - WMGetFirstInArray(scr->shortcutWindows[i], wwin) != WANotFound) { - mask |= 1<shortcutWindows[i] != NULL && + WMGetFirstInArray(scr->shortcutWindows[i], wwin) != WANotFound) { + mask |= 1<app_icon && wapp->app_icon->dock) { int i; char *name; @@ -332,7 +332,7 @@ wSessionSaveState(WScreen *scr) if ((wwin->transient_for==None || wwin->transient_for==wwin->screen_ptr->root_win) && WMGetFirstInArray(wapp_list, (void*)appId)==WANotFound - && !WFLAGP(wwin, dont_save_session)) { + && !WFLAGP(wwin, dont_save_session)) { /* A entry for this application was not yet saved. Save one. */ if ((win_info = makeWindowState(wwin, wapp))!=NULL) { WMAddToPLArray(list, win_info); @@ -342,7 +342,7 @@ wSessionSaveState(WScreen *scr) * application list, so no multiple entries for the same * application are saved. */ - WMAddToArray(wapp_list, (void*)appId); + WMAddToArray(wapp_list, (void*)appId); } } wwin = wwin->prev; @@ -389,7 +389,7 @@ execCommand(WScreen *scr, char *command, char *host) char **args; int i; - SetupEnvironment(scr); + SetupEnvironment(scr); args = malloc(sizeof(char*)*(argc+1)); if (!args) @@ -442,17 +442,17 @@ getWindowState(WScreen *scr, WMPropList *win_state) state->hidden = getBool(value); if ((value = WMGetFromPLDictionary(win_state, sShortcutMask))!=NULL) { mask = getInt(value); - state->window_shortcuts = mask; + state->window_shortcuts = mask; } - + value = WMGetFromPLDictionary(win_state, sGeometry); if (value && WMIsPLString(value)) { if (!(sscanf(WMGetFromPLString(value), "%ix%i+%i+%i", - &state->w, &state->h, &state->x, &state->y)==4 && - (state->w>0 && state->h>0))) { - state->w = 0; - state->h = 0; - } + &state->w, &state->h, &state->x, &state->y)==4 && + (state->w>0 && state->h>0))) { + state->w = 0; + state->h = 0; + } } return state; @@ -486,7 +486,7 @@ wSessionRestoreState(WScreen *scr) return; count = WMGetPropListItemCount(apps); - if (count==0) + if (count==0) return; for (i=0; iwm_instance) && SAME(class, btn->wm_class) && SAME(command, btn->command) && - !btn->launching) { + !btn->launching) { found = 1; break; } @@ -614,12 +614,12 @@ clearWaitingAckState(WScreen *scr) WApplication *wapp; for (wwin = scr->focused_window; wwin != NULL; wwin = wwin->prev) { - wwin->flags.waiting_save_ack = 0; - if (wwin->main_window != None) { - wapp = wApplicationOf(wwin->main_window); - if (wapp) - wapp->main_window_desc->flags.waiting_save_ack = 0; - } + wwin->flags.waiting_save_ack = 0; + if (wwin->main_window != None) { + wapp = wApplicationOf(wwin->main_window); + if (wapp) + wapp->main_window_desc->flags.waiting_save_ack = 0; + } } } @@ -627,9 +627,9 @@ clearWaitingAckState(WScreen *scr) void wSessionSaveClients(WScreen *scr) { - + } - + /* * With XSMP, this job is done by smproxy @@ -642,10 +642,10 @@ wSessionSendSaveYourself(WScreen *scr) /* freeze client interaction with clients */ XGrabKeyboard(dpy, scr->root_win, False, GrabModeAsync, GrabModeAsync, - CurrentTime); + CurrentTime); XGrabPointer(dpy, scr->root_win, False, ButtonPressMask|ButtonReleaseMask, - GrabModeAsync, GrabModeAsync, scr->root_win, None, - CurrentTime); + GrabModeAsync, GrabModeAsync, scr->root_win, None, + CurrentTime); clearWaitingAckState(scr); @@ -653,34 +653,34 @@ wSessionSendSaveYourself(WScreen *scr) /* first send SAVE_YOURSELF for everybody */ for (wwin = scr->focused_window; wwin != NULL; wwin = wwin->prev) { - WWindow *mainWin; + WWindow *mainWin; - mainWin = wWindowFor(wwin->main_window); + mainWin = wWindowFor(wwin->main_window); - if (mainWin) { - /* if the client is a multi-window client, only send message - * to the main window */ - wwin = mainWin; - } + if (mainWin) { + /* if the client is a multi-window client, only send message + * to the main window */ + wwin = mainWin; + } - /* make sure the SAVE_YOURSELF flag is up-to-date */ - PropGetProtocols(wwin->client_win, &wwin->protocols); + /* make sure the SAVE_YOURSELF flag is up-to-date */ + PropGetProtocols(wwin->client_win, &wwin->protocols); - if (wwin->protocols.SAVE_YOURSELF) { - if (!wwin->flags.waiting_save_ack) { - wClientSendProtocol(wwin, _XA_WM_SAVE_YOURSELF, LastTimestamp); + if (wwin->protocols.SAVE_YOURSELF) { + if (!wwin->flags.waiting_save_ack) { + wClientSendProtocol(wwin, _XA_WM_SAVE_YOURSELF, LastTimestamp); - wwin->flags.waiting_save_ack = 1; - count++; - } - } else { - wwin->flags.waiting_save_ack = 0; - } + wwin->flags.waiting_save_ack = 1; + count++; + } + } else { + wwin->flags.waiting_save_ack = 0; + } } /* then wait for acknowledge */ while (count > 0) { - + } XUngrabPointer(dpy, CurrentTime); @@ -691,28 +691,28 @@ wSessionSendSaveYourself(WScreen *scr) #ifdef XSMP_ENABLED /* - * With full session management support, the part of WMState + * With full session management support, the part of WMState * that store client window state will become obsolete (maybe we can reuse * the old code too), * but we still need to store state info like the dock and workspaces. * It is better to keep dock/wspace info in WMState because the user * might want to keep the dock configuration while not wanting to - * resume a previously saved session. - * So, wmaker specific state info can be saved in - * ~/GNUstep/.AppInfo/WindowMaker/statename.state + * resume a previously saved session. + * So, wmaker specific state info can be saved in + * ~/GNUstep/.AppInfo/WindowMaker/statename.state * Its better to not put it in the defaults directory because: * - its not a defaults file (having domain names like wmaker0089504baa * in the defaults directory wouldn't be very neat) * - this state file is not meant to be edited by users - * + * * The old session code will become obsolete. When wmaker is * compiled with R6 sm support compiled in, it'll be better to * use a totally rewritten state saving code, but we can keep - * the current code for when XSMP_ENABLED is not compiled in. - * + * the current code for when XSMP_ENABLED is not compiled in. + * * This will be confusing to old users (well get lots of "SAVE_SESSION broke!" * messages), but it'll be better. - * + * * -readme */ @@ -722,15 +722,15 @@ getWindowRole(Window window) { XTextProperty prop; static Atom atom = 0; - + if (!atom) - atom = XInternAtom(dpy, "WM_WINDOW_ROLE", False); + atom = XInternAtom(dpy, "WM_WINDOW_ROLE", False); if (XGetTextProperty(dpy, window, &prop, atom)) { - if (prop.encoding == XA_STRING && prop.format == 8 && prop.nitems > 0) - return prop.value; + if (prop.encoding == XA_STRING && prop.format == 8 && prop.nitems > 0) + return prop.value; } - + return NULL; } @@ -745,7 +745,7 @@ getWindowRole(Window window) * WM_CLASS.class * WM_NAME * WM_COMMAND - * + * * geometry * state = (miniaturized, shaded, etc) * attribute @@ -760,18 +760,18 @@ makeAppState(WWindow *wwin) WApplication *wapp; WMPropList *state; WScreen *scr = wwin->screen_ptr; - + state = WMCreatePLArray(NULL, NULL); wapp = wApplicationOf(wwin->main_window); - + if (wapp) { if (wapp->app_icon && wapp->app_icon->dock) { - if (wapp->app_icon->dock == scr->dock) { - WMAddToPLArray(state, WMCreatePLString("Dock")); - } else { - int i; + if (wapp->app_icon->dock == scr->dock) { + WMAddToPLArray(state, WMCreatePLString("Dock")); + } else { + int i; for(i=0; iworkspace_count; i++) if(scr->workspaces[i]->clip == wapp->app_icon->dock) @@ -779,14 +779,14 @@ makeAppState(WWindow *wwin) assert(i < scr->workspace_count); - WMAddToPLArray(state, - WMCreatePLString(scr->workspaces[i]->name)); - } - } - - WMAddToPLArray(state, WMCreatePLString(wapp->hidden ? "1" : "0")); + WMAddToPLArray(state, + WMCreatePLString(scr->workspaces[i]->name)); + } + } + + WMAddToPLArray(state, WMCreatePLString(wapp->hidden ? "1" : "0")); } - + return state; } @@ -804,12 +804,12 @@ wSessionGetStateFor(WWindow *wwin, WSessionData *state) index = 3; /* geometry */ - value = WMGetFromPLArray(slist, index++); + value = WMGetFromPLArray(slist, index++); str = WMGetFromPLString(value); sscanf(str, "%i %i %i %i %i %i", &state->x, &state->y, - &state->width, &state->height, - &state->user_changed_width, &state->user_changed_height); + &state->width, &state->height, + &state->user_changed_width, &state->user_changed_height); /* state */ @@ -817,7 +817,7 @@ wSessionGetStateFor(WWindow *wwin, WSessionData *state) str = WMGetFromPLString(value); sscanf(str, "%i %i %i", &state->miniaturized, &state->shaded, - &state->maximized); + &state->maximized); /* attributes */ @@ -856,38 +856,38 @@ makeAttributeState(WWindow *wwin) char buffer[256]; #define W_FLAG(wwin, FLAG) ((wwin)->defined_user_flags.FLAG \ - ? (wwin)->user_flags.FLAG : -1) + ? (wwin)->user_flags.FLAG : -1) snprintf(buffer, sizeof(buffer), - "%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i", - W_FLAG(no_titlebar), - W_FLAG(no_resizable), - W_FLAG(no_closable), - W_FLAG(no_miniaturizable), - W_FLAG(no_resizebar), - W_FLAG(no_close_button), - W_FLAG(no_miniaturize_button), - /* - W_FLAG(broken_close), - W_FLAG(kill_close), - */ - W_FLAG(no_shadeable), - W_FLAG(omnipresent), - W_FLAG(skip_window_list), - W_FLAG(floating), - W_FLAG(sunken), - W_FLAG(no_bind_keys), - W_FLAG(no_bind_mouse), - W_FLAG(no_hide_others), - W_FLAG(no_appicon), - W_FLAG(dont_move_off), - W_FLAG(no_focusable), - W_FLAG(always_user_icon), - W_FLAG(start_miniaturized), - W_FLAG(start_hidden), - W_FLAG(start_maximized), - W_FLAG(dont_save_session), - W_FLAG(emulate_appicon)); + "%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i", + W_FLAG(no_titlebar), + W_FLAG(no_resizable), + W_FLAG(no_closable), + W_FLAG(no_miniaturizable), + W_FLAG(no_resizebar), + W_FLAG(no_close_button), + W_FLAG(no_miniaturize_button), + /* + W_FLAG(broken_close), + W_FLAG(kill_close), + */ + W_FLAG(no_shadeable), + W_FLAG(omnipresent), + W_FLAG(skip_window_list), + W_FLAG(floating), + W_FLAG(sunken), + W_FLAG(no_bind_keys), + W_FLAG(no_bind_mouse), + W_FLAG(no_hide_others), + W_FLAG(no_appicon), + W_FLAG(dont_move_off), + W_FLAG(no_focusable), + W_FLAG(always_user_icon), + W_FLAG(start_miniaturized), + W_FLAG(start_hidden), + W_FLAG(start_maximized), + W_FLAG(dont_save_session), + W_FLAG(emulate_appicon)); return WMCreatePLString(buffer); } @@ -897,7 +897,7 @@ static void appendStringInArray(WMPropList *array, char *str) { WMPropList *val; - + val = WMCreatePLString(str); WMAddToPLArray(array, val); WMReleasePropList(val); @@ -915,14 +915,14 @@ makeClientState(WWindow *wwin) unsigned shortcuts; state = WMCreatePLArray(NULL, NULL); - + /* WM_WINDOW_ROLE */ str = getWindowRole(wwin->client_win); if (!str) - appendStringInArray(state, ""); + appendStringInArray(state, ""); else { - appendStringInArray(state, str); - XFree(str); + appendStringInArray(state, str); + XFree(str); } /* WM_CLASS.instance */ @@ -933,19 +933,19 @@ makeClientState(WWindow *wwin) /* WM_NAME */ if (wwin->flags.wm_name_changed) - appendStringInArray(state, ""); + appendStringInArray(state, ""); else - appendStringInArray(state, wwin->frame->name); + appendStringInArray(state, wwin->frame->name); /* geometry */ snprintf(buffer, sizeof(buffer), "%i %i %i %i %i %i", wwin->frame_x, wwin->frame_y, - wwin->client.width, wwin->client.height, - wwin->flags.user_changed_width, wwin->flags.user_changed_height); + wwin->client.width, wwin->client.height, + wwin->flags.user_changed_width, wwin->flags.user_changed_height); appendStringInArray(state, buffer); /* state */ snprintf(buffer, sizeof(buffer), "%i %i %i", wwin->flags.miniaturized, - wwin->flags.shaded, wwin->flags.maximized); + wwin->flags.shaded, wwin->flags.maximized); appendStringInArray(state, buffer); /* attributes */ @@ -965,9 +965,9 @@ makeClientState(WWindow *wwin) /* shortcuts */ shortcuts = 0; for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) { - if (scr->shortcutWindow[i] == wwin) { - shortcuts |= 1 << i; - } + if (scr->shortcutWindow[i] == wwin) { + shortcuts |= 1 << i; + } } snprintf(buffer, sizeof(buffer), "%ui", shortcuts); appendStringInArray(tmp, buffer); @@ -998,36 +998,36 @@ smSaveYourselfPhase2Proc(SmcConn smc_conn, SmPointer client_data) #endif /* save session state */ - + /* the file that will contain the state */ prefix = getenv("SM_SAVE_DIR"); if (!prefix) { - prefix = wusergnusteppath(); - if (prefix) - gsPrefix = True; + prefix = wusergnusteppath(); + if (prefix) + gsPrefix = True; } if (!prefix) { - prefix = getenv("HOME"); + prefix = getenv("HOME"); } if (!prefix) - prefix = "."; + prefix = "."; len = strlen(prefix)+64; statefile = malloc(len); if (!statefile) { - wwarning(_("out of memory while saving session state")); - goto fail; + wwarning(_("out of memory while saving session state")); + goto fail; } t = time(); i = 0; do { - if (gsPrefix) - snprintf(statefile, len, "%s/.AppInfo/WindowMaker/wmaker.%l%i.state", - prefix, t, i); - else - snprintf(statefile, len, "%s/wmaker.%l%i.state", prefix, t, i); - i++; + if (gsPrefix) + snprintf(statefile, len, "%s/.AppInfo/WindowMaker/wmaker.%l%i.state", + prefix, t, i); + else + snprintf(statefile, len, "%s/wmaker.%l%i.state", prefix, t, i); + i++; } while (access(F_OK, statefile)!=-1); /* save the states of all windows we're managing */ @@ -1040,30 +1040,30 @@ smSaveYourselfPhase2Proc(SmcConn smc_conn, SmPointer client_data) * version_info ::= 'version' = '1'; * state ::= 'state' = array of screen_info * screen_info ::= array of (screen number, window_info, window_info, ...) - * window_info ::= + * window_info ::= */ for (i=0; iscreen); - pscreen = WMCreatePLArray(WMCreatePLString(buf), NULL); + snprintf(buf, sizeof(buf), "%i", scr->screen); + pscreen = WMCreatePLArray(WMCreatePLString(buf), NULL); - wwin = scr->focused_window; - while (wwin) { + wwin = scr->focused_window; + while (wwin) { WMPropList *pwindow; - pwindow = makeClientState(wwin); - WMAddToPLArray(pscreen, pwindow); + pwindow = makeClientState(wwin); + WMAddToPLArray(pscreen, pwindow); - wwin = wwin->prev; - } + wwin = wwin->prev; + } - WMAddToPLArray(state, pscreen); + WMAddToPLArray(state, pscreen); } plState = WMCreatePLDictionary(WMCreatePLString("Version"), @@ -1079,12 +1079,12 @@ smSaveYourselfPhase2Proc(SmcConn smc_conn, SmPointer client_data) * startup time */ for (argc=0, i=0; argv[i]!=NULL; i++) { - if (strcmp(argv[i], "-clientid")==0 - || strcmp(argv[i], "-restore")==0) { - i++; - } else { - argc++; - } + if (strcmp(argv[i], "-clientid")==0 + || strcmp(argv[i], "-restore")==0) { + i++; + } else { + argc++; + } } prop[0].name = SmRestartCommand; @@ -1098,21 +1098,21 @@ smSaveYourselfPhase2Proc(SmcConn smc_conn, SmPointer client_data) prop[1].num_vals = argc; if (!prop[0].vals || !prop[1].vals) { - wwarning(_("end of memory while saving session state")); - goto fail; + wwarning(_("end of memory while saving session state")); + goto fail; } for (j=0, i=0; ihelper_pid) - kill(scr->helper_pid, SIGKILL); + scr = wScreenWithNumber(i); + if (scr) { + if (scr->helper_pid) + kill(scr->helper_pid, SIGKILL); - /* if the session is not being managed, save restart info */ + /* if the session is not being managed, save restart info */ #ifdef XSMP_ENABLED - if (!wSessionIsManaged()) + if (!wSessionIsManaged()) #endif - wSessionSaveClients(scr); + wSessionSaveClients(scr); #ifdef KWM_HINTS - wKWMShutdown(scr, True); + wKWMShutdown(scr, True); #endif - wScreenSaveState(scr); - - if (mode == WSKillMode) - wipeDesktop(scr); - else - RestoreDesktop(scr); - } - } - ExecExitScript(); - Exit(0); - break; - - case WSRestartPreparationMode: - for (i=0; ihelper_pid) - kill(scr->helper_pid, SIGKILL); + wScreenSaveState(scr); + + if (mode == WSKillMode) + wipeDesktop(scr); + else + RestoreDesktop(scr); + } + } + ExecExitScript(); + Exit(0); + break; + + case WSRestartPreparationMode: + for (i=0; ihelper_pid) + kill(scr->helper_pid, SIGKILL); #ifdef KWM_HINTS - wKWMShutdown(scr, False); + wKWMShutdown(scr, False); #endif #ifdef OLWM_HINTS - wOLWMShutdown(scr); + wOLWMShutdown(scr); #endif - wScreenSaveState(scr); + wScreenSaveState(scr); - RestoreDesktop(scr); - } - } - break; + RestoreDesktop(scr); + } + } + break; } } @@ -153,32 +153,32 @@ restoreWindows(WMBag *bag, WMBagIterator iter) if (iter == NULL) { - core = WMBagFirst(bag, &iter); + core = WMBagFirst(bag, &iter); } else { - core = WMBagNext(bag, &iter); + core = WMBagNext(bag, &iter); } if (core == NULL) - return; + return; restoreWindows(bag, iter); /* go to the end of the list */ while (core->stacking->under) - core = core->stacking->under; + core = core->stacking->under; while (core) { - next = core->stacking->above; + next = core->stacking->above; - if (core->descriptor.parent_type==WCLASS_WINDOW) { - Window window; + if (core->descriptor.parent_type==WCLASS_WINDOW) { + Window window; - wwin = core->descriptor.parent; - window = wwin->client_win; - wUnmanageWindow(wwin, !wwin->flags.internal_window, False); - XMapWindow(dpy, window); - } - core = next; + wwin = core->descriptor.parent; + window = wwin->client_win; + wUnmanageWindow(wwin, !wwin->flags.internal_window, False); + XMapWindow(dpy, window); + } + core = next; } } @@ -190,17 +190,17 @@ restoreWindows(WMBag *bag, WMBagIterator iter) * * Side effects: * All frame windows are removed and windows are reparented - * back to root. Windows that are outside the screen are - * brought to a viable place. - * - *---------------------------------------------------------------------- + * back to root. Windows that are outside the screen are + * brought to a viable place. + * + *---------------------------------------------------------------------- */ void RestoreDesktop(WScreen *scr) { if (scr->helper_pid > 0) { - kill(scr->helper_pid, SIGTERM); - scr->helper_pid = 0; + kill(scr->helper_pid, SIGTERM); + scr->helper_pid = 0; } XGrabServer(dpy); @@ -222,12 +222,12 @@ RestoreDesktop(WScreen *scr) * wipeDesktop-- * Kills all windows in a screen. Send DeleteWindow to all windows * that support it and KillClient on all windows that don't. - * + * * Side effects: * All managed windows are closed. - * + * * TODO: change to XQueryTree() - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ static void wipeDesktop(WScreen *scr) @@ -236,11 +236,11 @@ wipeDesktop(WScreen *scr) wwin = scr->focused_window; while (wwin) { - if (wwin->protocols.DELETE_WINDOW) - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); - else - wClientKill(wwin); - wwin = wwin->prev; + if (wwin->protocols.DELETE_WINDOW) + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + else + wClientKill(wwin); + wwin = wwin->prev; } XSync(dpy, False); } diff --git a/src/stacking.c b/src/stacking.c index 104b2a0e..e6d0f26b 100644 --- a/src/stacking.c +++ b/src/stacking.c @@ -1,9 +1,9 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima * Copyright (c) 1998-2003 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 @@ -16,7 +16,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. */ @@ -44,7 +44,8 @@ extern XContext wStackContext; extern WPreferences wPreferences; -static void notifyStackChange(WCoreWindow *frame, char *detail) +static void +notifyStackChange(WCoreWindow *frame, char *detail) { WWindow *wwin = wWindowFor(frame->window); @@ -53,17 +54,17 @@ static void notifyStackChange(WCoreWindow *frame, char *detail) /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * RemakeStackList-- * Remakes the stacking_list for the screen, getting the real * stacking order from the server and reordering windows that are not * in the correct stacking. - * + * * Side effects: - * The stacking order list and the actual window stacking + * The stacking order list and the actual window stacking * may be changed (corrected) - * - *---------------------------------------------------------------------- + * + *---------------------------------------------------------------------- */ void RemakeStackList(WScreen *scr) @@ -75,39 +76,39 @@ RemakeStackList(WScreen *scr) WCoreWindow *tmp; int level; int i, c; - + if (!XQueryTree(dpy, scr->root_win, &junkr, &junkp, &windows, &nwindows)) { - wwarning(_("could not get window list!!")); - return; + wwarning(_("could not get window list!!")); + return; } else { - WMEmptyBag(scr->stacking_list); - - /* verify list integrity */ - c=0; - for (i=0; istacking->window_level; - tmp = WMGetFromBag(scr->stacking_list, level); - if (tmp) - tmp->stacking->above = frame; - frame->stacking->under = tmp; - frame->stacking->above = NULL; - WMSetInBag(scr->stacking_list, level, frame); + WMEmptyBag(scr->stacking_list); + + /* verify list integrity */ + c=0; + for (i=0; istacking->window_level; + tmp = WMGetFromBag(scr->stacking_list, level); + if (tmp) + tmp->stacking->above = frame; + frame->stacking->under = tmp; + frame->stacking->above = NULL; + WMSetInBag(scr->stacking_list, level, frame); } XFree(windows); #ifdef DEBUG - if (c!=scr->window_count) { - puts("Found different number of windows than in window lists!!!"); - } + if (c!=scr->window_count) { + puts("Found different number of windows than in window lists!!!"); + } #endif - scr->window_count = c; - } - + scr->window_count = c; + } + CommitStacking(scr); } @@ -119,10 +120,10 @@ RemakeStackList(WScreen *scr) * Reorders the actual window stacking, so that it has the stacking * order in the internal window stacking lists. It does the opposite * of RemakeStackList(). - * + * * Side effects: * Windows may be restacked. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ void CommitStacking(WScreen *scr) @@ -131,24 +132,24 @@ CommitStacking(WScreen *scr) int nwindows, i; Window *windows; WMBagIterator iter; - + nwindows = scr->window_count; windows = wmalloc(sizeof(Window)*nwindows); - + i = 0; WM_ETARETI_BAG(scr->stacking_list, tmp, iter) { - while (tmp) { + while (tmp) { #ifdef DEBUG - if (i>=nwindows) { - puts("Internal inconsistency! window_count is incorrect!!!"); - printf("window_count says %i windows\n", nwindows); - wfree(windows); - return; - } + if (i>=nwindows) { + puts("Internal inconsistency! window_count is incorrect!!!"); + printf("window_count says %i windows\n", nwindows); + wfree(windows); + return; + } #endif - windows[i++] = tmp->window; - tmp = tmp->stacking->under; - } + windows[i++] = tmp->window; + tmp = tmp->stacking->under; + } } XRestackWindows(dpy, windows, i); wfree(windows); @@ -156,7 +157,7 @@ CommitStacking(WScreen *scr) #ifdef VIRTUAL_DESKTOP wWorkspaceRaiseEdge(scr); #endif - + WMPostNotificationName(WMNResetStacking, scr, NULL); } @@ -164,10 +165,10 @@ CommitStacking(WScreen *scr) *---------------------------------------------------------------------- * moveFrameToUnder-- * Reestacks windows so that "frame" is under "under". - * + * * Returns: * None - * + * * Side effects: * Changes the stacking order of frame. *---------------------------------------------------------------------- @@ -185,17 +186,17 @@ moveFrameToUnder(WCoreWindow *under, WCoreWindow *frame) /* *---------------------------------------------------------------------- * wRaiseFrame-- - * Raises a frame taking the window level into account. - * + * Raises a frame taking the window level into account. + * * Returns: * None - * + * * Side effects: * Window stacking order and stacking list are changed. - * - *---------------------------------------------------------------------- + * + *---------------------------------------------------------------------- */ -void +void wRaiseFrame(WCoreWindow *frame) { WCoreWindow *wlist = frame; @@ -204,14 +205,14 @@ wRaiseFrame(WCoreWindow *frame) /* already on top */ if (frame->stacking->above == NULL) { - return; + return; } /* insert it on top of other windows on the same level */ if (frame->stacking->under) - frame->stacking->under->stacking->above = frame->stacking->above; + frame->stacking->under->stacking->above = frame->stacking->above; if (frame->stacking->above) - frame->stacking->above->stacking->under = frame->stacking->under; + frame->stacking->above->stacking->under = frame->stacking->under; frame->stacking->above = NULL; frame->stacking->under = WMGetFromBag(scr->stacking_list, level); @@ -220,44 +221,44 @@ wRaiseFrame(WCoreWindow *frame) } WMSetInBag(scr->stacking_list, level, frame); - /* raise transients under us from bottom to top + /* raise transients under us from bottom to top * so that the order is kept */ again: wlist = frame->stacking->under; while (wlist && wlist->stacking->under) - wlist = wlist->stacking->under; + wlist = wlist->stacking->under; while (wlist && wlist!=frame) { - if (wlist->stacking->child_of == frame) { - wRaiseFrame(wlist); - goto again; - } - wlist = wlist->stacking->above; + if (wlist->stacking->child_of == frame) { + wRaiseFrame(wlist); + goto again; + } + wlist = wlist->stacking->above; } /* try to optimize things a little */ if (frame->stacking->above == NULL) { - WMBagIterator iter; - WCoreWindow *above = WMBagLast(scr->stacking_list, &iter); - int i, last = above->stacking->window_level; - - /* find the 1st level above us which has windows in it */ - for (i = level+1, above = NULL; i <= last; i++) { - above = WMGetFromBag(scr->stacking_list, i); - if (above != NULL) - break; - } - - if (above != frame && above != NULL) { - while (above->stacking->under) - above = above->stacking->under; - moveFrameToUnder(above, frame); - } else { - /* no window above us */ - above = NULL; - XRaiseWindow(dpy, frame->window); - } + WMBagIterator iter; + WCoreWindow *above = WMBagLast(scr->stacking_list, &iter); + int i, last = above->stacking->window_level; + + /* find the 1st level above us which has windows in it */ + for (i = level+1, above = NULL; i <= last; i++) { + above = WMGetFromBag(scr->stacking_list, i); + if (above != NULL) + break; + } + + if (above != frame && above != NULL) { + while (above->stacking->under) + above = above->stacking->under; + moveFrameToUnder(above, frame); + } else { + /* no window above us */ + above = NULL; + XRaiseWindow(dpy, frame->window); + } } else { - moveFrameToUnder(frame->stacking->above, frame); + moveFrameToUnder(frame->stacking->above, frame); } notifyStackChange(frame, "raise"); @@ -272,37 +273,37 @@ void wRaiseLowerFrame(WCoreWindow *frame) { if (!frame->stacking->above - ||(frame->stacking->window_level - !=frame->stacking->above->stacking->window_level)) { + ||(frame->stacking->window_level + !=frame->stacking->above->stacking->window_level)) { - wLowerFrame(frame); + wLowerFrame(frame); } else { - WCoreWindow *scan = frame->stacking->above; - WWindow *frame_wwin = (WWindow*) frame->descriptor.parent; - - while (scan) { - - if (scan->descriptor.parent_type == WCLASS_WINDOW) { - WWindow *scan_wwin = (WWindow*)scan->descriptor.parent; - - if (wWindowObscuresWindow(scan_wwin, frame_wwin) - && scan_wwin->flags.mapped) { - break; - } - } - scan = scan->stacking->above; - } - - if (scan) { - wRaiseFrame(frame); - } else { - wLowerFrame(frame); - } + WCoreWindow *scan = frame->stacking->above; + WWindow *frame_wwin = (WWindow*) frame->descriptor.parent; + + while (scan) { + + if (scan->descriptor.parent_type == WCLASS_WINDOW) { + WWindow *scan_wwin = (WWindow*)scan->descriptor.parent; + + if (wWindowObscuresWindow(scan_wwin, frame_wwin) + && scan_wwin->flags.mapped) { + break; + } + } + scan = scan->stacking->above; + } + + if (scan) { + wRaiseFrame(frame); + } else { + wLowerFrame(frame); + } } } -void +void wLowerFrame(WCoreWindow *frame) { WScreen *scr = frame->screen_ptr; @@ -311,38 +312,38 @@ wLowerFrame(WCoreWindow *frame) /* already in bottom */ if (wlist->stacking->under == NULL) { - return; + return; } /* cant lower transient below below its owner */ if (wlist->stacking->under == wlist->stacking->child_of) { - return; + return; } /* remove from the list */ if (WMGetFromBag(scr->stacking_list, level) == frame) { - /* it was the top window */ - WMSetInBag(scr->stacking_list, level, frame->stacking->under); - frame->stacking->under->stacking->above = NULL; + /* it was the top window */ + WMSetInBag(scr->stacking_list, level, frame->stacking->under); + frame->stacking->under->stacking->above = NULL; } else { - if (frame->stacking->under) - frame->stacking->under->stacking->above = frame->stacking->above; - if (frame->stacking->above) - frame->stacking->above->stacking->under = frame->stacking->under; + if (frame->stacking->under) + frame->stacking->under->stacking->above = frame->stacking->above; + if (frame->stacking->above) + frame->stacking->above->stacking->under = frame->stacking->under; } wlist = WMGetFromBag(scr->stacking_list, level); /* look for place to put this window */ if (wlist) { - WCoreWindow *owner = frame->stacking->child_of; - - if (owner != wlist) { - while (wlist->stacking->under) { - /* if this is a transient, it should not be placed under - * it's owner */ - if (owner == wlist->stacking->under) - break; - wlist = wlist->stacking->under; - } - } + WCoreWindow *owner = frame->stacking->child_of; + + if (owner != wlist) { + while (wlist->stacking->under) { + /* if this is a transient, it should not be placed under + * it's owner */ + if (owner == wlist->stacking->under) + break; + wlist = wlist->stacking->under; + } + } } /* insert under the place found */ frame->stacking->above = wlist; @@ -356,31 +357,31 @@ wLowerFrame(WCoreWindow *frame) } if (frame->stacking->above == NULL) { - WMBagIterator iter; - WCoreWindow *above = WMBagLast(scr->stacking_list, &iter); - int i, last = above->stacking->window_level; - - /* find the 1st level above us which has windows in it */ - for (i = level+1, above = NULL; i <= last; i++) { - above = WMGetFromBag(scr->stacking_list, i); - if (above != NULL) - break; - } - - if (above != frame && above != NULL) { - while (above->stacking->under) - above = above->stacking->under; - moveFrameToUnder(above, frame); - } else { - /* no window below us */ - XLowerWindow(dpy, frame->window); - } + WMBagIterator iter; + WCoreWindow *above = WMBagLast(scr->stacking_list, &iter); + int i, last = above->stacking->window_level; + + /* find the 1st level above us which has windows in it */ + for (i = level+1, above = NULL; i <= last; i++) { + above = WMGetFromBag(scr->stacking_list, i); + if (above != NULL) + break; + } + + if (above != frame && above != NULL) { + while (above->stacking->under) + above = above->stacking->under; + moveFrameToUnder(above, frame); + } else { + /* no window below us */ + XLowerWindow(dpy, frame->window); + } } else { - moveFrameToUnder(frame->stacking->above, frame); + moveFrameToUnder(frame->stacking->above, frame); } - notifyStackChange(frame, "lower"); - + notifyStackChange(frame, "lower"); + #ifdef VIRTUAL_DESKTOP wWorkspaceRaiseEdge(scr); #endif @@ -392,13 +393,13 @@ wLowerFrame(WCoreWindow *frame) * AddToStackList-- * Inserts the frame in the top of the stacking list. The * stacking precedence is obeyed. - * + * * Returns: * None - * + * * Side effects: * The frame is added to it's screen's window list. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ void AddToStackList(WCoreWindow *frame) @@ -407,47 +408,47 @@ AddToStackList(WCoreWindow *frame) int index = frame->stacking->window_level; WScreen *scr = frame->screen_ptr; WCoreWindow *trans = NULL; - + frame->screen_ptr->window_count++; XSaveContext(dpy, frame->window, wStackContext, (XPointer)frame); curtop = WMGetFromBag(scr->stacking_list, index); /* first window in this level */ if (curtop == NULL) { - WMSetInBag(scr->stacking_list, index, frame); - frame->stacking->above = NULL; - frame->stacking->under = NULL; - CommitStacking(scr); - return; + WMSetInBag(scr->stacking_list, index, frame); + frame->stacking->above = NULL; + frame->stacking->under = NULL; + CommitStacking(scr); + return; } /* check if this is a transient owner */ wlist = curtop; while (wlist) { - if (wlist->stacking->child_of == frame) - trans = wlist; - wlist = wlist->stacking->under; + if (wlist->stacking->child_of == frame) + trans = wlist; + wlist = wlist->stacking->under; } /* trans will hold the transient in the lowest position * in stacking list */ - + frame->stacking->above = trans; if (trans != NULL) { - /* window is owner of a transient.. put it below - * the lowest transient */ - frame->stacking->under = trans->stacking->under; - if (trans->stacking->under) { - trans->stacking->under->stacking->above = frame; - } - trans->stacking->under = frame; + /* window is owner of a transient.. put it below + * the lowest transient */ + frame->stacking->under = trans->stacking->under; + if (trans->stacking->under) { + trans->stacking->under->stacking->above = frame; + } + trans->stacking->under = frame; } else { - /* window is not owner of transients.. just put it in the - * top of other windows */ - frame->stacking->under = curtop; - curtop->stacking->above = frame; - WMSetInBag(scr->stacking_list, index, frame); + /* window is not owner of transients.. just put it in the + * top of other windows */ + frame->stacking->under = curtop; + curtop->stacking->above = frame; + WMSetInBag(scr->stacking_list, index, frame); } - CommitStacking(scr); + CommitStacking(scr); } @@ -455,14 +456,14 @@ AddToStackList(WCoreWindow *frame) *---------------------------------------------------------------------- * MoveInStackListAbove-- * Moves the frame above "next". - * + * * Returns: * None - * + * * Side effects: * Stacking order may be changed. * Window level for frame may be changed. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ void MoveInStackListAbove(WCoreWindow *next, WCoreWindow *frame) @@ -481,7 +482,7 @@ MoveInStackListAbove(WCoreWindow *next, WCoreWindow *frame) tmpw = WMGetFromBag(scr->stacking_list, index); if (tmpw == frame) - WMSetInBag(scr->stacking_list, index, frame->stacking->under); + WMSetInBag(scr->stacking_list, index, frame->stacking->under); if (frame->stacking->under) frame->stacking->under->stacking->above = frame->stacking->above; if (frame->stacking->above) @@ -492,21 +493,21 @@ MoveInStackListAbove(WCoreWindow *next, WCoreWindow *frame) frame->stacking->above = next->stacking->above; next->stacking->above = frame; if (tmpw == next) - WMSetInBag(scr->stacking_list, index, frame); + WMSetInBag(scr->stacking_list, index, frame); /* try to optimize things a little */ if (frame->stacking->above == NULL) { WCoreWindow *above = NULL; - WMBagIterator iter; + WMBagIterator iter; - for (above = WMBagIteratorAtIndex(scr->stacking_list, index+1, &iter); - above != NULL; - above = WMBagNext(scr->stacking_list, &iter)) { + for (above = WMBagIteratorAtIndex(scr->stacking_list, index+1, &iter); + above != NULL; + above = WMBagNext(scr->stacking_list, &iter)) { - /* can't optimize */ - while (above->stacking->under) - above = above->stacking->under; - break; + /* can't optimize */ + while (above->stacking->under) + above = above->stacking->under; + break; } if (above == NULL) { XRaiseWindow(dpy, frame->window); @@ -518,7 +519,7 @@ MoveInStackListAbove(WCoreWindow *next, WCoreWindow *frame) } WMPostNotificationName(WMNResetStacking, scr, NULL); - + #ifdef VIRTUAL_DESKTOP wWorkspaceRaiseEdge(scr); #endif @@ -529,14 +530,14 @@ MoveInStackListAbove(WCoreWindow *next, WCoreWindow *frame) *---------------------------------------------------------------------- * MoveInStackListUnder-- * Moves the frame to under "prev". - * + * * Returns: * None - * + * * Side effects: * Stacking order may be changed. * Window level for frame may be changed. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ void MoveInStackListUnder(WCoreWindow *prev, WCoreWindow *frame) @@ -566,7 +567,7 @@ MoveInStackListUnder(WCoreWindow *prev, WCoreWindow *frame) frame->stacking->under = prev->stacking->under; prev->stacking->under = frame; moveFrameToUnder(prev, frame); - + WMPostNotificationName(WMNResetStacking, scr, NULL); } @@ -577,17 +578,17 @@ RemoveFromStackList(WCoreWindow *frame) int index = frame->stacking->window_level; if (XDeleteContext(dpy, frame->window, wStackContext)==XCNOENT) { - wwarning("RemoveFromStackingList(): window not in list "); - return; + wwarning("RemoveFromStackingList(): window not in list "); + return; } /* remove from the window stack list */ if (frame->stacking->under) - frame->stacking->under->stacking->above = frame->stacking->above; + frame->stacking->under->stacking->above = frame->stacking->above; if (frame->stacking->above) - frame->stacking->above->stacking->under = frame->stacking->under; + frame->stacking->above->stacking->under = frame->stacking->under; else /* this was the first window on the list */ - WMSetInBag(frame->screen_ptr->stacking_list, index, - frame->stacking->under); + WMSetInBag(frame->screen_ptr->stacking_list, index, + frame->stacking->under); frame->screen_ptr->window_count--; @@ -601,15 +602,16 @@ ChangeStackingLevel(WCoreWindow *frame, int new_level) int old_level; if (frame->stacking->window_level == new_level) - return; + return; old_level = frame->stacking->window_level; RemoveFromStackList(frame); frame->stacking->window_level = new_level; AddToStackList(frame); if (old_level > new_level) { - wRaiseFrame(frame); + wRaiseFrame(frame); } else { - wLowerFrame(frame); + wLowerFrame(frame); } } + diff --git a/src/stacking.h b/src/stacking.h index cac2f41b..73245b61 100644 --- a/src/stacking.h +++ b/src/stacking.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ diff --git a/src/startup.c b/src/startup.c index 6d155f2e..514087c0 100644 --- a/src/startup.c +++ b/src/startup.c @@ -16,7 +16,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. */ @@ -165,38 +165,38 @@ static void manageAllWindows(WScreen *scr, int crashed); extern void NotifyDeadProcess(pid_t pid, unsigned char status); -static int +static int catchXError(Display *dpy, XErrorEvent *error) { char buffer[MAXLINE]; - + /* ignore some errors */ - if (error->resourceid != None - && ((error->error_code == BadDrawable - && error->request_code == X_GetGeometry) - || (error->error_code == BadMatch - && (error->request_code == X_SetInputFocus)) - || (error->error_code == BadWindow) - /* - && (error->request_code == X_GetWindowAttributes - || error->request_code == X_SetInputFocus - || error->request_code == X_ChangeWindowAttributes - || error->request_code == X_GetProperty - || error->request_code == X_ChangeProperty - || error->request_code == X_QueryTree - || error->request_code == X_GrabButton - || error->request_code == X_UngrabButton - || error->request_code == X_SendEvent - || error->request_code == X_ConfigureWindow)) - */ - || (error->request_code == X_InstallColormap))) { + if (error->resourceid != None + && ((error->error_code == BadDrawable + && error->request_code == X_GetGeometry) + || (error->error_code == BadMatch + && (error->request_code == X_SetInputFocus)) + || (error->error_code == BadWindow) + /* + && (error->request_code == X_GetWindowAttributes + || error->request_code == X_SetInputFocus + || error->request_code == X_ChangeWindowAttributes + || error->request_code == X_GetProperty + || error->request_code == X_ChangeProperty + || error->request_code == X_QueryTree + || error->request_code == X_GrabButton + || error->request_code == X_UngrabButton + || error->request_code == X_SendEvent + || error->request_code == X_ConfigureWindow)) + */ + || (error->request_code == X_InstallColormap))) { #ifndef DEBUG - return 0; + return 0; #else - printf("got X error %x %x %x\n", error->request_code, - error->error_code, (unsigned)error->resourceid); - return 0; + printf("got X error %x %x %x\n", error->request_code, + error->error_code, (unsigned)error->resourceid); + return 0; #endif } FormatXError(dpy, error, buffer, MAXLINE); @@ -206,10 +206,10 @@ catchXError(Display *dpy, XErrorEvent *error) /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * handleXIO- - * Handle X shutdowns and other stuff. - *---------------------------------------------------------------------- + * Handle X shutdowns and other stuff. + *---------------------------------------------------------------------- */ static int handleXIO(Display *xio_dpy) @@ -230,12 +230,12 @@ static void delayedAction(void *cdata) { if (WDelayedActionSet == 0) { - return; + return; } WDelayedActionSet--; - /* + /* * Make the event dispatcher do whatever it needs to do, - * including handling zombie processes, restart and exit + * including handling zombie processes, restart and exit * signals. */ DispatchEvent(NULL); @@ -246,7 +246,7 @@ delayedAction(void *cdata) *---------------------------------------------------------------------- * handleExitSig-- * User generated exit signal handler. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ static RETSIGTYPE handleExitSig(int sig) @@ -255,7 +255,7 @@ handleExitSig(int sig) sigfillset(&sigs); sigprocmask(SIG_BLOCK, &sigs, NULL); - + if (sig == SIGUSR1) { #ifdef SYS_SIGLIST_DECLARED wwarning(_("got signal %i (%s) - restarting\n"), sig, sys_siglist[sig]); @@ -263,11 +263,11 @@ handleExitSig(int sig) wwarning(_("got signal %i - restarting\n"), sig); #endif - SIG_WCHANGE_STATE(WSTATE_NEED_RESTART); - /* setup idle handler, so that this will be handled when - * the select() is returned becaused of the signal, even if - * there are no X events in the queue */ - WDelayedActionSet++; + SIG_WCHANGE_STATE(WSTATE_NEED_RESTART); + /* setup idle handler, so that this will be handled when + * the select() is returned becaused of the signal, even if + * there are no X events in the queue */ + WDelayedActionSet++; } else if (sig == SIGUSR2) { #ifdef SYS_SIGLIST_DECLARED wwarning(_("got signal %i (%s) - rereading defaults\n"), sig, sys_siglist[sig]); @@ -287,11 +287,11 @@ handleExitSig(int sig) wwarning(_("got signal %i - exiting...\n"), sig); #endif - SIG_WCHANGE_STATE(WSTATE_NEED_EXIT); + SIG_WCHANGE_STATE(WSTATE_NEED_EXIT); - WDelayedActionSet++; + WDelayedActionSet++; } - + sigprocmask(SIG_UNBLOCK, &sigs, NULL); } @@ -306,7 +306,7 @@ dummyHandler(int sig) *---------------------------------------------------------------------- * handleSig-- * general signal handler. Exits the program gently. - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- */ static RETSIGTYPE handleSig(int sig) @@ -316,11 +316,11 @@ handleSig(int sig) #ifndef NO_EMERGENCY_AUTORESTART int crashAction, i; char *argv[2]; - + argv[1] = NULL; #endif - - /* + + /* * No functions that potentially do Xlib calls should be called from * here. Xlib calls are not reentrant so the integrity of Xlib is * not guaranteed if a Xlib call is made from a signal handler. @@ -338,21 +338,21 @@ handleSig(int sig) * the flags accordingly. -Dan */ if (sig==SIGSEGV || sig==SIGFPE || sig==SIGBUS || sig==SIGILL - || sig==SIGABRT) { - if (already_crashed) { - wfatal(_("crashed while trying to do some post-crash cleanup. Aborting immediatelly.")); + || sig==SIGABRT) { + if (already_crashed) { + wfatal(_("crashed while trying to do some post-crash cleanup. Aborting immediatelly.")); signal(sig, SIG_DFL); kill(getpid(), sig); return; - } - already_crashed = 1; + } + already_crashed = 1; - dumpcore = 1; + dumpcore = 1; + + /* + * Yeah, we shouldn't do this, but it's already crashed anyway :P + */ - /* - * Yeah, we shouldn't do this, but it's already crashed anyway :P - */ - #ifndef NO_EMERGENCY_AUTORESTART /* Close the X connection and open a new one. This is to avoid messing * Xlib because we call to Xlib functions in a signal handler. @@ -364,7 +364,7 @@ handleSig(int sig) CARD32 data[2]; WWindow *wwin; - XGrabServer(dpy); + XGrabServer(dpy); crashAction = wShowCrashingDialogPanel(sig); /* @@ -388,7 +388,7 @@ handleSig(int sig) } } - + XCloseDisplay(dpy); dpy = NULL; } else { @@ -409,7 +409,7 @@ handleSig(int sig) /* fallback to alternate window manager then */ } - wmessage(_("trying to start alternate window manager...")); + wmessage(_("trying to start alternate window manager...")); for (i=0; i0 || (pid<0 && errno==EINTR)) { - NotifyDeadProcess(pid, WEXITSTATUS(status)); + NotifyDeadProcess(pid, WEXITSTATUS(status)); } WDelayedActionSet++; - + sigprocmask(SIG_UNBLOCK, &sigs, NULL); - errno = save_errno; + errno = save_errno; } @@ -466,7 +466,7 @@ static int getWorkspaceState(Window root, WWorkspaceState **state) { Atom type_ret; - int fmt_ret; + int fmt_ret; unsigned long nitems_ret; unsigned long bytes_after_ret; CARD32 *data; @@ -497,8 +497,8 @@ getOffendingModifiers() XModifierKeymap *modmap; KeyCode nlock, slock; static int mask_table[8] = { - ShiftMask,LockMask,ControlMask,Mod1Mask, - Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask + ShiftMask,LockMask,ControlMask,Mod1Mask, + Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask }; nlock = XKeysymToKeycode(dpy, XK_Num_Lock); @@ -509,118 +509,118 @@ getOffendingModifiers() * so that we can bind the grabs for when they are enabled too. */ modmap = XGetModifierMapping(dpy); - + if (modmap!=NULL && modmap->max_keypermod>0) { - for (i=0; i<8*modmap->max_keypermod; i++) { - if (modmap->modifiermap[i]==nlock && nlock!=0) - _NumLockMask = mask_table[i/modmap->max_keypermod]; - else if (modmap->modifiermap[i]==slock && slock!=0) - _ScrollLockMask = mask_table[i/modmap->max_keypermod]; - } + for (i=0; i<8*modmap->max_keypermod; i++) { + if (modmap->modifiermap[i]==nlock && nlock!=0) + _NumLockMask = mask_table[i/modmap->max_keypermod]; + else if (modmap->modifiermap[i]==slock && slock!=0) + _ScrollLockMask = mask_table[i/modmap->max_keypermod]; + } } if (modmap) - XFreeModifiermap(modmap); + XFreeModifiermap(modmap); } #ifdef NUMLOCK_HACK -void +void wHackedGrabKey(int keycode, unsigned int modifiers, - Window grab_window, Bool owner_events, int pointer_mode, - int keyboard_mode) + Window grab_window, Bool owner_events, int pointer_mode, + int keyboard_mode) { if (modifiers == AnyModifier) - return; - + return; + /* grab all combinations of the modifier with CapsLock, NumLock and * ScrollLock. How much memory/CPU does such a monstrosity consume * in the server? */ if (_NumLockMask) - XGrabKey(dpy, keycode, modifiers|_NumLockMask, - grab_window, owner_events, pointer_mode, keyboard_mode); + XGrabKey(dpy, keycode, modifiers|_NumLockMask, + grab_window, owner_events, pointer_mode, keyboard_mode); if (_ScrollLockMask) - XGrabKey(dpy, keycode, modifiers|_ScrollLockMask, - grab_window, owner_events, pointer_mode, keyboard_mode); + XGrabKey(dpy, keycode, modifiers|_ScrollLockMask, + grab_window, owner_events, pointer_mode, keyboard_mode); if (_NumLockMask && _ScrollLockMask) - XGrabKey(dpy, keycode, modifiers|_NumLockMask|_ScrollLockMask, - grab_window, owner_events, pointer_mode, keyboard_mode); + XGrabKey(dpy, keycode, modifiers|_NumLockMask|_ScrollLockMask, + grab_window, owner_events, pointer_mode, keyboard_mode); if (_NumLockMask) - XGrabKey(dpy, keycode, modifiers|_NumLockMask|LockMask, - grab_window, owner_events, pointer_mode, keyboard_mode); + XGrabKey(dpy, keycode, modifiers|_NumLockMask|LockMask, + grab_window, owner_events, pointer_mode, keyboard_mode); if (_ScrollLockMask) - XGrabKey(dpy, keycode, modifiers|_ScrollLockMask|LockMask, - grab_window, owner_events, pointer_mode, keyboard_mode); + XGrabKey(dpy, keycode, modifiers|_ScrollLockMask|LockMask, + grab_window, owner_events, pointer_mode, keyboard_mode); if (_NumLockMask && _ScrollLockMask) - XGrabKey(dpy, keycode, modifiers|_NumLockMask|_ScrollLockMask|LockMask, - grab_window, owner_events, pointer_mode, keyboard_mode); + XGrabKey(dpy, keycode, modifiers|_NumLockMask|_ScrollLockMask|LockMask, + grab_window, owner_events, pointer_mode, keyboard_mode); /* phew, I guess that's all, right? */ } #endif -void -wHackedGrabButton(unsigned int button, unsigned int modifiers, - Window grab_window, Bool owner_events, - unsigned int event_mask, int pointer_mode, - int keyboard_mode, Window confine_to, Cursor cursor) +void +wHackedGrabButton(unsigned int button, unsigned int modifiers, + Window grab_window, Bool owner_events, + unsigned int event_mask, int pointer_mode, + int keyboard_mode, Window confine_to, Cursor cursor) { XGrabButton(dpy, button, modifiers, grab_window, owner_events, - event_mask, pointer_mode, keyboard_mode, confine_to, cursor); + event_mask, pointer_mode, keyboard_mode, confine_to, cursor); if (modifiers==AnyModifier) - return; + return; XGrabButton(dpy, button, modifiers|LockMask, grab_window, owner_events, - event_mask, pointer_mode, keyboard_mode, confine_to, cursor); - -#ifdef NUMLOCK_HACK + event_mask, pointer_mode, keyboard_mode, confine_to, cursor); + +#ifdef NUMLOCK_HACK /* same as above, but for mouse buttons */ if (_NumLockMask) - XGrabButton(dpy, button, modifiers|_NumLockMask, - grab_window, owner_events, event_mask, pointer_mode, - keyboard_mode, confine_to, cursor); + XGrabButton(dpy, button, modifiers|_NumLockMask, + grab_window, owner_events, event_mask, pointer_mode, + keyboard_mode, confine_to, cursor); if (_ScrollLockMask) - XGrabButton(dpy, button, modifiers|_ScrollLockMask, - grab_window, owner_events, event_mask, pointer_mode, - keyboard_mode, confine_to, cursor); + XGrabButton(dpy, button, modifiers|_ScrollLockMask, + grab_window, owner_events, event_mask, pointer_mode, + keyboard_mode, confine_to, cursor); if (_NumLockMask && _ScrollLockMask) - XGrabButton(dpy, button, modifiers|_ScrollLockMask|_NumLockMask, - grab_window, owner_events, event_mask, pointer_mode, - keyboard_mode, confine_to, cursor); + XGrabButton(dpy, button, modifiers|_ScrollLockMask|_NumLockMask, + grab_window, owner_events, event_mask, pointer_mode, + keyboard_mode, confine_to, cursor); if (_NumLockMask) - XGrabButton(dpy, button, modifiers|_NumLockMask|LockMask, - grab_window, owner_events, event_mask, pointer_mode, - keyboard_mode, confine_to, cursor); + XGrabButton(dpy, button, modifiers|_NumLockMask|LockMask, + grab_window, owner_events, event_mask, pointer_mode, + keyboard_mode, confine_to, cursor); if (_ScrollLockMask) - XGrabButton(dpy, button, modifiers|_ScrollLockMask|LockMask, - grab_window, owner_events, event_mask, pointer_mode, - keyboard_mode, confine_to, cursor); + XGrabButton(dpy, button, modifiers|_ScrollLockMask|LockMask, + grab_window, owner_events, event_mask, pointer_mode, + keyboard_mode, confine_to, cursor); if (_NumLockMask && _ScrollLockMask) - XGrabButton(dpy, button, modifiers|_ScrollLockMask|_NumLockMask|LockMask, - grab_window, owner_events, event_mask, pointer_mode, - keyboard_mode, confine_to, cursor); + XGrabButton(dpy, button, modifiers|_ScrollLockMask|_NumLockMask|LockMask, + grab_window, owner_events, event_mask, pointer_mode, + keyboard_mode, confine_to, cursor); #endif /* NUMLOCK_HACK */ } #ifdef notused void -wHackedUngrabButton(unsigned int button, unsigned int modifiers, - Window grab_window) +wHackedUngrabButton(unsigned int button, unsigned int modifiers, + Window grab_window) { XUngrabButton(dpy, button, modifiers|_NumLockMask, - grab_window); + grab_window); XUngrabButton(dpy, button, modifiers|_ScrollLockMask, - grab_window); + grab_window); XUngrabButton(dpy, button, modifiers|_NumLockMask|_ScrollLockMask, - grab_window); + grab_window); XUngrabButton(dpy, button, modifiers|_NumLockMask|LockMask, - grab_window); + grab_window); XUngrabButton(dpy, button, modifiers|_ScrollLockMask|LockMask, - grab_window); + grab_window); XUngrabButton(dpy, button, modifiers|_NumLockMask|_ScrollLockMask|LockMask, - grab_window); + grab_window); } #endif @@ -641,7 +641,7 @@ wScreenForRootWindow(Window window) int i; if (wScreenCount==1) - return wScreen[0]; + return wScreen[0]; /* * Since the number of heads will probably be small (normally 2), @@ -649,9 +649,9 @@ wScreenForRootWindow(Window window) * of the overhead. */ for (i=0; iroot_win == window) { - return wScreen[i]; - } + if (wScreen[i]->root_win == window) { + return wScreen[i]; + } } return wScreenForWindow(window); @@ -664,7 +664,7 @@ wScreenSearchForRootWindow(Window window) int i; if (wScreenCount==1) - return wScreen[0]; + return wScreen[0]; /* * Since the number of heads will probably be small (normally 2), @@ -672,11 +672,11 @@ wScreenSearchForRootWindow(Window window) * of the overhead. */ for (i=0; iroot_win == window) { - return wScreen[i]; - } + if (wScreen[i]->root_win == window) { + return wScreen[i]; + } } - + return wScreenForWindow(window); } @@ -687,29 +687,29 @@ wScreenForWindow(Window window) XWindowAttributes attr; if (wScreenCount==1) - return wScreen[0]; + return wScreen[0]; if (XGetWindowAttributes(dpy, window, &attr)) { - return wScreenForRootWindow(attr.root); + return wScreenForRootWindow(attr.root); } return NULL; } static char *atomNames[] = { - "WM_STATE", - "WM_CHANGE_STATE", - "WM_PROTOCOLS", - "WM_TAKE_FOCUS", - "WM_DELETE_WINDOW", - "WM_SAVE_YOURSELF", - "WM_CLIENT_LEADER", - "WM_COLORMAP_WINDOWS", - "WM_COLORMAP_NOTIFY", + "WM_STATE", + "WM_CHANGE_STATE", + "WM_PROTOCOLS", + "WM_TAKE_FOCUS", + "WM_DELETE_WINDOW", + "WM_SAVE_YOURSELF", + "WM_CLIENT_LEADER", + "WM_COLORMAP_WINDOWS", + "WM_COLORMAP_NOTIFY", "_WINDOWMAKER_MENU", - "_WINDOWMAKER_STATE", - "_WINDOWMAKER_WM_PROTOCOLS", + "_WINDOWMAKER_STATE", + "_WINDOWMAKER_WM_PROTOCOLS", "_WINDOWMAKER_WM_FUNCTION", "_WINDOWMAKER_NOTICEBOARD", "_WINDOWMAKER_COMMAND", @@ -727,7 +727,7 @@ static char *atomNames[] = { * StartUp-- * starts the window manager and setup global data. * Called from main() at startup. - * + * * Side effects: * global data declared in main.c is initialized *---------------------------------------------------------- @@ -759,21 +759,21 @@ StartUp(Bool defaultScreenOnly) wStackContext = XUniqueContext(); wVEdgeContext = XUniqueContext(); -/* _XA_VERSION = XInternAtom(dpy, "VERSION", False);*/ + /* _XA_VERSION = XInternAtom(dpy, "VERSION", False);*/ #ifdef HAVE_XINTERNATOMS XInternAtoms(dpy, atomNames, sizeof(atomNames)/sizeof(char*), - False, atom); + False, atom); #else { - int i; - for (i = 0; i < sizeof(atomNames)/sizeof(char*); i++) { - atom[i] = XInternAtom(dpy, atomNames[i], False); - } + int i; + for (i = 0; i < sizeof(atomNames)/sizeof(char*); i++) { + atom[i] = XInternAtom(dpy, atomNames[i], False); + } } #endif - + _XA_WM_STATE = atom[0]; _XA_WM_CHANGE_STATE = atom[1]; _XA_WM_PROTOCOLS = atom[2]; @@ -823,17 +823,17 @@ StartUp(Bool defaultScreenOnly) wCursor[WCUR_TEXT] = XCreateFontCursor(dpy, XC_xterm); /* odd name???*/ wCursor[WCUR_SELECT] = XCreateFontCursor(dpy, XC_cross); { - Pixmap cur = XCreatePixmap(dpy, DefaultRootWindow(dpy), 16, 16, 1); - GC gc = XCreateGC(dpy, cur, 0, NULL); - XColor black; - memset(&black, 0, sizeof(XColor)); - XSetForeground(dpy, gc, 0); - XFillRectangle(dpy, cur, gc, 0, 0, 16, 16); - XFreeGC(dpy, gc); - wCursor[WCUR_EMPTY] = XCreatePixmapCursor(dpy, cur, cur, &black, &black, 0, 0); - XFreePixmap(dpy, cur); + Pixmap cur = XCreatePixmap(dpy, DefaultRootWindow(dpy), 16, 16, 1); + GC gc = XCreateGC(dpy, cur, 0, NULL); + XColor black; + memset(&black, 0, sizeof(XColor)); + XSetForeground(dpy, gc, 0); + XFillRectangle(dpy, cur, gc, 0, 0, 16, 16); + XFreeGC(dpy, gc); + wCursor[WCUR_EMPTY] = XCreatePixmapCursor(dpy, cur, cur, &black, &black, 0, 0); + XFreePixmap(dpy, cur); } - + /* signal handler stuff that gets called when a signal is caught */ WMAddPersistentTimerHandler(500, delayedAction, NULL); @@ -849,7 +849,7 @@ StartUp(Bool defaultScreenOnly) sigaction(SIGABRT, &sig_action, NULL); sig_action.sa_handler = handleExitSig; - + /* Here we set SA_RESTART for safety, because SIGUSR1 may not be handled * immediately. -Dan */ sig_action.sa_flags = SA_RESTART; @@ -894,8 +894,8 @@ StartUp(Bool defaultScreenOnly) /* initialize defaults stuff */ WDWindowMaker = wDefaultsInitDomain("WindowMaker", True); if (!WDWindowMaker->dictionary) { - wwarning(_("could not read domain \"%s\" from defaults database"), - "WindowMaker"); + wwarning(_("could not read domain \"%s\" from defaults database"), + "WindowMaker"); } /* read defaults that don't change until a restart and are @@ -904,23 +904,23 @@ StartUp(Bool defaultScreenOnly) /* check sanity of some values */ if (wPreferences.icon_size < 16) { - wwarning(_("icon size is configured to %i, but it's too small. Using 16, instead\n"), - wPreferences.icon_size); - wPreferences.icon_size = 16; + wwarning(_("icon size is configured to %i, but it's too small. Using 16, instead\n"), + wPreferences.icon_size); + wPreferences.icon_size = 16; } /* init other domains */ WDRootMenu = wDefaultsInitDomain("WMRootMenu", False); if (!WDRootMenu->dictionary) { - wwarning(_("could not read domain \"%s\" from defaults database"), - "WMRootMenu"); + wwarning(_("could not read domain \"%s\" from defaults database"), + "WMRootMenu"); } wDefaultsMergeGlobalMenus(WDRootMenu); WDWindowAttributes = wDefaultsInitDomain("WMWindowAttributes", True); if (!WDWindowAttributes->dictionary) { - wwarning(_("could not read domain \"%s\" from defaults database"), - "WMWindowAttributes"); + wwarning(_("could not read domain \"%s\" from defaults database"), + "WMWindowAttributes"); } XSetErrorHandler((XErrorHandler)catchXError); @@ -929,7 +929,7 @@ StartUp(Bool defaultScreenOnly) /* ignore j */ wShapeSupported = XShapeQueryExtension(dpy, &wShapeEventBase, &j); #endif - + #ifdef KEEP_XKB_LOCK_STATUS wXkbSupported = XkbQueryExtension(dpy, NULL, &wXkbEventBase, NULL, NULL, NULL); if(wPreferences.modelock && !wXkbSupported) { @@ -939,9 +939,9 @@ StartUp(Bool defaultScreenOnly) #endif if (defaultScreenOnly) { - max = 1; + max = 1; } else { - max = ScreenCount(dpy); + max = ScreenCount(dpy); } wScreen = wmalloc(sizeof(WScreen*)*max); @@ -949,20 +949,20 @@ StartUp(Bool defaultScreenOnly) /* manage the screens */ for (j = 0; j < max; j++) { - if (defaultScreenOnly || max==1) { - wScreen[wScreenCount] = wScreenInit(DefaultScreen(dpy)); - if (!wScreen[wScreenCount]) { - wfatal(_("it seems that there is already a window manager running")); - Exit(1); - } - } else { - wScreen[wScreenCount] = wScreenInit(j); - if (!wScreen[wScreenCount]) { - wwarning(_("could not manage screen %i"), j); - continue; - } - } - wScreenCount++; + if (defaultScreenOnly || max==1) { + wScreen[wScreenCount] = wScreenInit(DefaultScreen(dpy)); + if (!wScreen[wScreenCount]) { + wfatal(_("it seems that there is already a window manager running")); + Exit(1); + } + } else { + wScreen[wScreenCount] = wScreenInit(j); + if (!wScreen[wScreenCount]) { + wwarning(_("could not manage screen %i"), j); + continue; + } + } + wScreenCount++; } #ifndef LITE @@ -974,15 +974,15 @@ StartUp(Bool defaultScreenOnly) int crashed; /* restore workspace state */ - if (!getWorkspaceState(wScreen[j]->root_win, &ws_state)) { - ws_state = NULL; - } + if (!getWorkspaceState(wScreen[j]->root_win, &ws_state)) { + ws_state = NULL; + } - wScreenRestoreState(wScreen[j]); + wScreenRestoreState(wScreen[j]); - /* manage all windows that were already here before us */ - if (!wPreferences.flags.nodock && wScreen[j]->dock) - wScreen[j]->last_dock = wScreen[j]->dock; + /* manage all windows that were already here before us */ + if (!wPreferences.flags.nodock && wScreen[j]->dock) + wScreen[j]->last_dock = wScreen[j]->dock; if (ws_state && (ws_state->flags & WFLAGS_CRASHED)!=0) crashed = 1; @@ -991,52 +991,52 @@ StartUp(Bool defaultScreenOnly) manageAllWindows(wScreen[j], crashed); - /* restore saved menus */ - wMenuRestoreState(wScreen[j]); - - /* If we're not restarting restore session */ - if (ws_state == NULL && !wPreferences.flags.norestore) - wSessionRestoreState(wScreen[j]); - - if (!wPreferences.flags.noautolaunch) { - /* auto-launch apps */ - if (!wPreferences.flags.nodock && wScreen[j]->dock) { - wScreen[j]->last_dock = wScreen[j]->dock; - wDockDoAutoLaunch(wScreen[j]->dock, 0); - } - /* auto-launch apps in clip */ - if (!wPreferences.flags.noclip) { - int i; - for(i=0; iworkspace_count; i++) { - if (wScreen[j]->workspaces[i]->clip) { - wScreen[j]->last_dock = wScreen[j]->workspaces[i]->clip; - wDockDoAutoLaunch(wScreen[j]->workspaces[i]->clip, i); - } - } - } - } - - /* go to workspace where we were before restart */ - if (ws_state) { - wWorkspaceForceChange(wScreen[j], ws_state->workspace); - wfree(ws_state); - } else { - wSessionRestoreLastWorkspace(wScreen[j]); - } + /* restore saved menus */ + wMenuRestoreState(wScreen[j]); + + /* If we're not restarting restore session */ + if (ws_state == NULL && !wPreferences.flags.norestore) + wSessionRestoreState(wScreen[j]); + + if (!wPreferences.flags.noautolaunch) { + /* auto-launch apps */ + if (!wPreferences.flags.nodock && wScreen[j]->dock) { + wScreen[j]->last_dock = wScreen[j]->dock; + wDockDoAutoLaunch(wScreen[j]->dock, 0); + } + /* auto-launch apps in clip */ + if (!wPreferences.flags.noclip) { + int i; + for(i=0; iworkspace_count; i++) { + if (wScreen[j]->workspaces[i]->clip) { + wScreen[j]->last_dock = wScreen[j]->workspaces[i]->clip; + wDockDoAutoLaunch(wScreen[j]->workspaces[i]->clip, i); + } + } + } + } + + /* go to workspace where we were before restart */ + if (ws_state) { + wWorkspaceForceChange(wScreen[j], ws_state->workspace); + wfree(ws_state); + } else { + wSessionRestoreLastWorkspace(wScreen[j]); + } #ifdef KWM_HINTS - wKWMSetInitializedHint(wScreen[j]); + wKWMSetInitializedHint(wScreen[j]); #endif } - + if (wScreenCount == 0) { - wfatal(_("could not manage any screen")); - Exit(1); + wfatal(_("could not manage any screen")); + Exit(1); } if (!wPreferences.flags.nopolling && !wPreferences.flags.noupdates) { - /* setup defaults file polling */ - WMAddTimerHandler(3000, wDefaultsCheckDomains, NULL); + /* setup defaults file polling */ + WMAddTimerHandler(3000, wDefaultsCheckDomains, NULL); } } @@ -1047,8 +1047,8 @@ static Bool windowInList(Window window, Window *list, int count) { for (; count>=0; count--) { - if (window == list[count]) - return True; + if (window == list[count]) + return True; } return False; } @@ -1057,12 +1057,12 @@ windowInList(Window window, Window *list, int count) *----------------------------------------------------------------------- * manageAllWindows-- * Manages all windows in the screen. - * + * * Notes: * Called when the wm is being started. * No events can be processed while the windows are being - * reparented/managed. - *----------------------------------------------------------------------- + * reparented/managed. + *----------------------------------------------------------------------- */ static void manageAllWindows(WScreen *scr, int crashRecovery) @@ -1080,54 +1080,54 @@ manageAllWindows(WScreen *scr, int crashRecovery) /* first remove all icon windows */ for (i = 0; i < nchildren; i++) { - XWMHints *wmhints; - - if (children[i]==None) - continue; - - wmhints = XGetWMHints(dpy, children[i]); - if (wmhints && (wmhints->flags & IconWindowHint)) { - for (j = 0; j < nchildren; j++) { - if (children[j] == wmhints->icon_window) { - XFree(wmhints); - wmhints = NULL; - children[j] = None; - break; - } - } - } - if (wmhints) { - XFree(wmhints); - } + XWMHints *wmhints; + + if (children[i]==None) + continue; + + wmhints = XGetWMHints(dpy, children[i]); + if (wmhints && (wmhints->flags & IconWindowHint)) { + for (j = 0; j < nchildren; j++) { + if (children[j] == wmhints->icon_window) { + XFree(wmhints); + wmhints = NULL; + children[j] = None; + break; + } + } + } + if (wmhints) { + XFree(wmhints); + } } for (i = 0; i < nchildren; i++) { - if (children[i] == None) - continue; + if (children[i] == None) + continue; #ifdef KWM_HINTS - wKWMCheckModule(scr, children[i]); + wKWMCheckModule(scr, children[i]); #endif - wwin = wManageWindow(scr, children[i]); - if (wwin) { - /* apply states got from WSavedState */ - /* shaded + minimized is not restored correctly */ - if (wwin->flags.shaded) { - wwin->flags.shaded = 0; - wShadeWindow(wwin); - } - if (wwin->flags.miniaturized - && (wwin->transient_for == None - || wwin->transient_for == scr->root_win - || !windowInList(wwin->transient_for, children, - nchildren))) { - - wwin->flags.skip_next_animation = 1; - wwin->flags.miniaturized = 0; - wIconifyWindow(wwin); - } else { - wClientSetState(wwin, NormalState, None); + wwin = wManageWindow(scr, children[i]); + if (wwin) { + /* apply states got from WSavedState */ + /* shaded + minimized is not restored correctly */ + if (wwin->flags.shaded) { + wwin->flags.shaded = 0; + wShadeWindow(wwin); + } + if (wwin->flags.miniaturized + && (wwin->transient_for == None + || wwin->transient_for == scr->root_win + || !windowInList(wwin->transient_for, children, + nchildren))) { + + wwin->flags.skip_next_animation = 1; + wwin->flags.miniaturized = 0; + wIconifyWindow(wwin); + } else { + wClientSetState(wwin, NormalState, None); } if (crashRecovery) { int border; @@ -1136,27 +1136,27 @@ manageAllWindows(WScreen *scr, int crashRecovery) wWindowMove(wwin, wwin->frame_x - border, wwin->frame_y - border - - (wwin->frame->titlebar ? + (wwin->frame->titlebar ? wwin->frame->titlebar->height : 0)); } - } + } } XUngrabServer(dpy); /* hide apps */ wwin = scr->focused_window; while (wwin) { - if (wwin->flags.hidden) { - WApplication *wapp = wApplicationOf(wwin->main_window); - - if (wapp) { - wwin->flags.hidden = 0; - wHideApplication(wapp); - } else { - wwin->flags.hidden = 0; - } - } - wwin = wwin->prev; + if (wwin->flags.hidden) { + WApplication *wapp = wApplicationOf(wwin->main_window); + + if (wapp) { + wwin->flags.hidden = 0; + wHideApplication(wapp); + } else { + wwin->flags.hidden = 0; + } + } + wwin = wwin->prev; } XFree(children); @@ -1164,9 +1164,9 @@ manageAllWindows(WScreen *scr, int crashRecovery) scr->flags.startup2 = 1; while (XPending(dpy)) { - XEvent ev; - WMNextEvent(dpy, &ev); - WMHandleEvent(&ev); + XEvent ev; + WMNextEvent(dpy, &ev); + WMHandleEvent(&ev); } wWorkspaceForceChange(scr, 0); if (!wPreferences.flags.noclip) @@ -1175,4 +1175,3 @@ manageAllWindows(WScreen *scr, int crashRecovery) } - diff --git a/src/superfluous.c b/src/superfluous.c index 8e3aedf0..d3fde5a4 100644 --- a/src/superfluous.c +++ b/src/superfluous.c @@ -1,9 +1,9 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima * Copyright (c) 1998-2003 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 @@ -16,7 +16,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. */ @@ -51,7 +51,7 @@ static void play(Display *dpy, int pitch, int delay) { XKeyboardControl kc; - + kc.bell_pitch = pitch; kc.bell_percent = 50; kc.bell_duration = delay; @@ -77,23 +77,23 @@ DoKaboom(WScreen *scr, Window win, int x, int y) XGCValues gcv; int i; int w, h; - int run; - XEvent event; + int run; + XEvent event; h = w = wPreferences.icon_size; if (x < 0 || x + w > scr->scr_width || y < 0 || y + h > scr->scr_height) - return; + return; icon = RCreateImageFromDrawable(scr->rcontext, win, None); if (!icon) - return; - + return; + gcv.foreground = scr->white_pixel; gcv.background = scr->black_pixel; gcv.graphics_exposures = False; gcv.subwindow_mode = IncludeInferiors; gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground|GCSubwindowMode - |GCGraphicsExposures, &gcv); + |GCGraphicsExposures, &gcv); XGrabServer(dpy); @@ -113,19 +113,19 @@ DoKaboom(WScreen *scr, Window win, int x, int y) for (i=0,run=0; ircontext, image, &pixmap); - XCopyArea(dpy, pixmap, scr->root_win, gc, 0, 0, w, h, x, y); - XFreePixmap(dpy, pixmap); - XFlush(dpy); - if(!run) wusleep(1000); + XEvent foo; + if (!run && XCheckTypedEvent(dpy, ButtonPress, &foo)) { + run=1; + XPutBackEvent(dpy, &foo); + } + image = RCloneImage(back); + RCombineImagesWithOpaqueness(image, icon, + (DEMATERIALIZE_STEPS-1-i)*256/(DEMATERIALIZE_STEPS+2)); + RConvertImage(scr->rcontext, image, &pixmap); + XCopyArea(dpy, pixmap, scr->root_win, gc, 0, 0, w, h, x, y); + XFreePixmap(dpy, pixmap); + XFlush(dpy); + if(!run) wusleep(1000); } while (XCheckTypedEvent(dpy, MotionNotify, &event)) { @@ -163,130 +163,130 @@ DoKaboom(WScreen *scr, Window win, int x, int y) Pixmap tmp; XSetClipMask(dpy, scr->copy_gc, None); - tmp = XCreatePixmap(dpy, scr->root_win, wPreferences.icon_size, - wPreferences.icon_size, scr->depth); + tmp = XCreatePixmap(dpy, scr->root_win, wPreferences.icon_size, + wPreferences.icon_size, scr->depth); if (scr->w_visual == DefaultVisual(dpy, scr->screen)) - XCopyArea(dpy, win, tmp, scr->copy_gc, 0, 0, wPreferences.icon_size, - wPreferences.icon_size, 0, 0); + XCopyArea(dpy, win, tmp, scr->copy_gc, 0, 0, wPreferences.icon_size, + wPreferences.icon_size, 0, 0); else { - XImage *image; - - image = XGetImage(dpy, win, 0, 0, wPreferences.icon_size, - wPreferences.icon_size, AllPlanes, ZPixmap); - if (!image) { - XUnmapWindow(dpy, win); - return; - } - XPutImage(dpy, tmp, scr->copy_gc, image, 0, 0, 0, 0, - wPreferences.icon_size, wPreferences.icon_size); - XDestroyImage(image); + XImage *image; + + image = XGetImage(dpy, win, 0, 0, wPreferences.icon_size, + wPreferences.icon_size, AllPlanes, ZPixmap); + if (!image) { + XUnmapWindow(dpy, win); + return; + } + XPutImage(dpy, tmp, scr->copy_gc, image, 0, 0, 0, 0, + wPreferences.icon_size, wPreferences.icon_size); + XDestroyImage(image); } for (i=0,k=0; i0) { - XEvent foo; + XEvent foo; - if (XCheckTypedEvent(dpy, ButtonPress, &foo)) { - XPutBackEvent(dpy, &foo); - XClearWindow(dpy, scr->root_win); - break; - } + if (XCheckTypedEvent(dpy, ButtonPress, &foo)) { + XPutBackEvent(dpy, &foo); + XClearWindow(dpy, scr->root_win); + break; + } - for (i=0; i=0) { - int _px = px[i]>>KAB_PRECISION; + for (i=0; i=0) { + int _px = px[i]>>KAB_PRECISION; #ifdef ICON_KABOOM_EXTRA - XClearArea(dpy, scr->root_win, ptx[1][i], pty[1][i], - ICON_KABOOM_PIECE_SIZE, ICON_KABOOM_PIECE_SIZE, - False); - - ptx[1][i] = ptx[0][i]; - pty[1][i] = pty[0][i]; - ptx[0][i] = _px; - pty[0][i] = py[i]; + XClearArea(dpy, scr->root_win, ptx[1][i], pty[1][i], + ICON_KABOOM_PIECE_SIZE, ICON_KABOOM_PIECE_SIZE, + False); + + ptx[1][i] = ptx[0][i]; + pty[1][i] = pty[0][i]; + ptx[0][i] = _px; + pty[0][i] = py[i]; #else - XClearArea(dpy, scr->root_win, _px, py[i], - ICON_KABOOM_PIECE_SIZE, ICON_KABOOM_PIECE_SIZE, - False); + XClearArea(dpy, scr->root_win, _px, py[i], + ICON_KABOOM_PIECE_SIZE, ICON_KABOOM_PIECE_SIZE, + False); #endif - px[i]+=pvx[i]; - py[i]+=pvy[i]; - _px = px[i]>>KAB_PRECISION; + px[i]+=pvx[i]; + py[i]+=pvy[i]; + _px = px[i]>>KAB_PRECISION; pvy[i]++; if (_px<-wPreferences.icon_size || _px>sw || py[i]>=sh) { #ifdef ICON_KABOOM_EXTRA - if (py[i]>sh && _px0) { - pvy[i] = -(pvy[i]/2); - if (abs(pvy[i]) > 3) { - py[i] = sh-ICON_KABOOM_PIECE_SIZE; - XCopyArea(dpy, tmp, scr->root_win, scr->copy_gc, - ax[i]*ICON_KABOOM_PIECE_SIZE, - ay[i]*ICON_KABOOM_PIECE_SIZE, - ICON_KABOOM_PIECE_SIZE, - ICON_KABOOM_PIECE_SIZE, - _px, py[i]); - } else { - ax[i] = -1; - } - } else { - ax[i] = -1; - } - if (ax[i]<0) { - for (ll=0; ll<2; ll++) - XClearArea(dpy, scr->root_win, ptx[ll][i], pty[ll][i], - ICON_KABOOM_PIECE_SIZE, - ICON_KABOOM_PIECE_SIZE, False); - k--; - } + if (py[i]>sh && _px0) { + pvy[i] = -(pvy[i]/2); + if (abs(pvy[i]) > 3) { + py[i] = sh-ICON_KABOOM_PIECE_SIZE; + XCopyArea(dpy, tmp, scr->root_win, scr->copy_gc, + ax[i]*ICON_KABOOM_PIECE_SIZE, + ay[i]*ICON_KABOOM_PIECE_SIZE, + ICON_KABOOM_PIECE_SIZE, + ICON_KABOOM_PIECE_SIZE, + _px, py[i]); + } else { + ax[i] = -1; + } + } else { + ax[i] = -1; + } + if (ax[i]<0) { + for (ll=0; ll<2; ll++) + XClearArea(dpy, scr->root_win, ptx[ll][i], pty[ll][i], + ICON_KABOOM_PIECE_SIZE, + ICON_KABOOM_PIECE_SIZE, False); + k--; + } #else /* !ICON_KABOOM_EXTRA */ ax[i]=-1; - k--; + k--; #endif /* !ICON_KABOOM_EXTRA */ - } else { - XCopyArea(dpy, tmp, scr->root_win, scr->copy_gc, - ax[i]*ICON_KABOOM_PIECE_SIZE, ay[i]*ICON_KABOOM_PIECE_SIZE, - ICON_KABOOM_PIECE_SIZE, ICON_KABOOM_PIECE_SIZE, - _px, py[i]); - } - } - } - - XFlush(dpy); + } else { + XCopyArea(dpy, tmp, scr->root_win, scr->copy_gc, + ax[i]*ICON_KABOOM_PIECE_SIZE, ay[i]*ICON_KABOOM_PIECE_SIZE, + ICON_KABOOM_PIECE_SIZE, ICON_KABOOM_PIECE_SIZE, + _px, py[i]); + } + } + } + + XFlush(dpy); #ifdef SPEAKER_SOUND - play(dpy, 100+rand()%250, 12); + play(dpy, 100+rand()%250, 12); #else -# if (MINIATURIZE_ANIMATION_DELAY_Z > 0) - wusleep(MINIATURIZE_ANIMATION_DELAY_Z*2); +# if (MINIATURIZE_ANIMATION_DELAY_Z > 0) + wusleep(MINIATURIZE_ANIMATION_DELAY_Z*2); # endif #endif } - + XFreePixmap(dpy, tmp); } #endif /* NORMAL_ICON_KABOOM */ @@ -314,20 +314,20 @@ MakeGhostDock(WDock *dock, int sx, int dx, int y) virtual_tiles = h / wPreferences.icon_size; /* The visible ones */ if (h % wPreferences.icon_size) virtual_tiles++; /* There is one partially visible tile at end */ - + img=XGetImage(dpy, scr->root_win, dx, y, wPreferences.icon_size, h, AllPlanes, ZPixmap); if (!img) - return None; + return None; red_mask = img->red_mask; green_mask = img->green_mask; blue_mask = img->blue_mask; - + back = RCreateImageFromXImage(scr->rcontext, img, NULL); XDestroyImage(img); if (!back) { - return None; + return None; } for (i=0;imax_icons;i++) { @@ -336,7 +336,7 @@ MakeGhostDock(WDock *dock, int sx, int dx, int y) Pixmap which; j = dock->icon_array[i]->yindex * wPreferences.icon_size; n = (h - j < wPreferences.icon_size) ? h - j : - wPreferences.icon_size; + wPreferences.icon_size; if (dock->icon_array[i]->icon->pixmap) which = dock->icon_array[i]->icon->pixmap; else @@ -368,9 +368,9 @@ MakeGhostDock(WDock *dock, int sx, int dx, int y) RConvertImage(scr->rcontext, back, &pixmap); - + RReleaseImage(back); - + return pixmap; } @@ -384,12 +384,12 @@ MakeGhostIcon(WScreen *scr, Drawable drawable) if (!drawable) - return None; - + return None; + back = RCreateImageFromDrawable(scr->rcontext, drawable, None); - if (!back) - return None; - + if (!back) + return None; + color.red = 0xff; color.green = 0xff; color.blue = 0xff; @@ -397,9 +397,9 @@ MakeGhostIcon(WScreen *scr, Drawable drawable) RClearImage(back, &color); RConvertImage(scr->rcontext, back, &pixmap); - + RReleaseImage(back); - + return pixmap; } @@ -412,7 +412,7 @@ DoWindowBirth(WWindow *wwin) int width = wwin->frame->core->width; int height = wwin->frame->core->height; int w = WMIN(width, 20); - int h = WMIN(height, 20); + int h = WMIN(height, 20); int x, y; int dw, dh; int i; @@ -425,24 +425,24 @@ DoWindowBirth(WWindow *wwin) y = wwin->frame_y + (height-h)/2; XMoveResizeWindow(dpy, wwin->frame->core->window, x, y, w, h); - + XMapWindow(dpy, wwin->frame->core->window); - + XFlush(dpy); for (i=0; iframe->core->window, x, y, w, h); - XFlush(dpy); - /* a timeout */ - if (time(NULL)-time0 > MAX_ANIMATION_TIME) - break; + x -= dw/2 + dw%2; + y -= dh/2 + dh%2; + w += dw; + h += dh; + XMoveResizeWindow(dpy, wwin->frame->core->window, x, y, w, h); + XFlush(dpy); + /* a timeout */ + if (time(NULL)-time0 > MAX_ANIMATION_TIME) + break; } XMoveResizeWindow(dpy, wwin->frame->core->window, - wwin->frame_x, wwin->frame_y, width, height); + wwin->frame_x, wwin->frame_y, width, height); XFlush(dpy); } #else @@ -464,8 +464,8 @@ void DoWindowBirth(WWindow *wwin) center_y = wwin->frame_y + (height - h) / 2; animateResize(scr, center_x, center_y, 1, 1, - wwin->frame_x , wwin->frame_y, width, height, - 0); + wwin->frame_x , wwin->frame_y, width, height, + 0); } #else void @@ -494,29 +494,29 @@ loadData(WScreen *scr) f = fopen(PKGDATADIR"/xtree.dat", "rb"); if (!f) - return False; + return False; image = RCreateImage(50, 50, False); if (!image) { - fclose(f); - return False; + fclose(f); + return False; } for (i = 0; i < 12; i++) { - if (fread(image->data, 50*50*3, 1, f)!=1) { - goto error; - } - if (!RConvertImage(scr->rcontext, image, &(d[i]))) { - goto error; - } + if (fread(image->data, 50*50*3, 1, f)!=1) { + goto error; + } + if (!RConvertImage(scr->rcontext, image, &(d[i]))) { + goto error; + } } RReleaseImage(image); fclose(f); for (i=0; i<12; i++) { - data[i] = WMCreatePixmapFromXPixmaps(scr->wmscreen, d[i], None, 50, 50, - scr->w_depth); + data[i] = WMCreatePixmapFromXPixmaps(scr->wmscreen, d[i], None, 50, 50, + scr->w_depth); } return True; @@ -527,7 +527,7 @@ error: fclose(f); while (--i > 0) { - XFreePixmap(dpy, d[i]); + XFreePixmap(dpy, d[i]); } return False; @@ -553,19 +553,19 @@ InitXThing(WScreen *scr) static int i = 0; if (i) - return True; + return True; t = time(NULL); l = localtime(&t); if ((l->tm_mon!=11||l->tm_mday<24||l->tm_mday>26)) { - return False; + return False; } if (!loadData(scr)) - return False; + return False; i = 1; - + return True; } @@ -617,30 +617,30 @@ InitGhostWindowMove(WWindow *wwin) gdata->boxY = wwin->frame_y; gdata->window = - XCreateSimpleWindow(dpy, scr->root_win, wwin->frame_x, wwin->frame_y, - gdata->width, gdata->height, 0, 0, 0); + XCreateSimpleWindow(dpy, scr->root_win, wwin->frame_x, wwin->frame_y, + gdata->width, gdata->height, 0, 0, 0); - gdata->winImage = RGetXImage(scr->rcontext, wwin->frame->core->window, - 0, 0, gdata->width, gdata->height); + gdata->winImage = RGetXImage(scr->rcontext, wwin->frame->core->window, + 0, 0, gdata->width, gdata->height); - gdata->backImage = RCreateXImage(scr->rcontext, scr->w_depth, - gdata->width, gdata->height); + gdata->backImage = RCreateXImage(scr->rcontext, scr->w_depth, + gdata->width, gdata->height); memcpy(gdata->backImage->image->data, gdata->winImage->image->data, - gdata->winImage->image->bytes_per_line * gdata->height); + gdata->winImage->image->bytes_per_line * gdata->height); gdata->image = RCreateXImage(scr->rcontext, scr->w_depth, - gdata->width, gdata->height); + gdata->width, gdata->height); ptr = (unsigned short*)gdata->winImage->image->data; mask = 0x7b00|0x3d0|0x1e; for (i = 0; - i < gdata->winImage->image->bytes_per_line * gdata->height; - i++, ptr++) { + i < gdata->winImage->image->bytes_per_line * gdata->height; + i++, ptr++) { - *ptr &= mask; + *ptr &= mask; } return gdata; @@ -661,11 +661,11 @@ mergeGhostWindow(_GhostWindowData *gdata) count = gdata->winImage->image->bytes_per_line * gdata->height; while (count--) { - *ptr = (*ptrw + *ptrb) >> 1; + *ptr = (*ptrw + *ptrb) >> 1; - ptr++; - ptrw++; - ptrb++; + ptr++; + ptrw++; + ptrb++; } } @@ -677,131 +677,131 @@ UpdateGhostWindowMove(void *data, int x, int y) WScreen *scr = gdata->scr; /* no intersection of new background with current */ - if (x + gdata->width <= gdata->boxX - || x >= gdata->boxX + gdata->width - || y + gdata->height <= gdata->boxY - || y >= gdata->boxY + gdata->height) { - int i; + if (x + gdata->width <= gdata->boxX + || x >= gdata->boxX + gdata->width + || y + gdata->height <= gdata->boxY + || y >= gdata->boxY + gdata->height) { + int i; - RDestroyXImage(gdata->backImage); + RDestroyXImage(gdata->backImage); - gdata->backImage = RGetXImage(scr->rcontext, scr->root_win, x, y, - gdata->width, gdata->height); + gdata->backImage = RGetXImage(scr->rcontext, scr->root_win, x, y, + gdata->width, gdata->height); - ptr = (unsigned short*)gdata->backImage->image->data; + ptr = (unsigned short*)gdata->backImage->image->data; - mask = 0x7b00|0x3d0|0x1e; + mask = 0x7b00|0x3d0|0x1e; - for (i = 0; - i < gdata->winImage->image->bytes_per_line * gdata->height; - i++, ptr++) { + for (i = 0; + i < gdata->winImage->image->bytes_per_line * gdata->height; + i++, ptr++) { - *ptr &= mask; - } + *ptr &= mask; + } } else { - int hx, hw, hy, hh; - int vx, vw, vy, vh; - int i, j; - unsigned char *backP = gdata->backImage->image->data; - unsigned char *winP = gdata->winImage->image->data; - int backLineLen = gdata->backImage->image->bytes_per_line; - int winLineLen = gdata->winImage->image->bytes_per_line; - - /* 1st move the area of the current backImage that overlaps - * the new backImage to it's new position */ - - if (x < gdata->boxX) { - vx = x + gdata->width; - vw = gdata->width - vx; - } else if (x > gdata->boxX) { - vw = gdata->boxX + gdata->width - x; - vx = gdata->boxX - vw; - } else { - vx = 0; - vw = gdata->width; - } - - if (y < gdata->boxY) { - vy = y + gdata->height; - vh = gdata->height - vy; - } else if (y > gdata->boxY) { - vh = gdata->boxY + gdata->height - y; - vy = gdata->boxY - vh; - } else { - vy = 0; - vh = gdata->height; - } - - if (y < gdata->boxY) { - int dy = vy - gdata->boxY; - - if (x < gdata->boxX) { - for (i = vh - 1; i >= 0; i--) { - memmove(&backP[(i + dy) * backLineLen + 2 * vx], - &backP[i * backLineLen], 2 * vw); - } - } else /* if (x > gdata->boxX) */ { - for (i = vh - 1; i >= 0; i--) { - memmove(&backP[(i + dy) * backLineLen], - &backP[i * backLineLen + 2 * vx], 2 * vw); - } - } - } else /*if (y > gdata->boxY) */ { - int dy = gdata->boxY - vy; - - if (x < gdata->boxX) { - for (i = 0; i < vh - 1; i++) { - memmove(&backP[i * backLineLen + 2 * vx], - &backP[(i + dy) * backLineLen], 2 * vw); - } - } else /*if (x > gdata->boxX) */ { - for (i = 0; i < vh - 1; i++) { - memmove(&backP[i * backLineLen], - &backP[(i + dy) * backLineLen + 2 * vx], 2 * vw); - } - } - } - - /* 2nd grab the background image from the screen and copy to the - * buffer. also maskout the lsb of rgb in each pixel of grabbed data */ - - if (y < gdata->boxY) { - vy = y; - vh = gdata->boxY - vy; - - hy = y + vh; - hh = gdata->height - vh; - } else if (y > gdata->boxY) { - vy = gdata->boxY + gdata->height; - vh = vy - (y + gdata->height); - - hy = y; - hh = y - gdata->boxY; - } else { - vy = vh = 0; - - hy = y; - hh = gdata->height; - } - - if (x < gdata->boxX) { - hx = x; - hw = gdata->boxX - hx; - } else if (x > gdata->boxX) { - hx = gdata->boxX + gdata->width; - hw = hx - (x + gdata->width); - } else { - hx = hw = 0; - - vx = x; - vw = gdata->width; - } - - /* 1st the top/bottom part */ - - - - /* 2nd the left/right part */ + int hx, hw, hy, hh; + int vx, vw, vy, vh; + int i, j; + unsigned char *backP = gdata->backImage->image->data; + unsigned char *winP = gdata->winImage->image->data; + int backLineLen = gdata->backImage->image->bytes_per_line; + int winLineLen = gdata->winImage->image->bytes_per_line; + + /* 1st move the area of the current backImage that overlaps + * the new backImage to it's new position */ + + if (x < gdata->boxX) { + vx = x + gdata->width; + vw = gdata->width - vx; + } else if (x > gdata->boxX) { + vw = gdata->boxX + gdata->width - x; + vx = gdata->boxX - vw; + } else { + vx = 0; + vw = gdata->width; + } + + if (y < gdata->boxY) { + vy = y + gdata->height; + vh = gdata->height - vy; + } else if (y > gdata->boxY) { + vh = gdata->boxY + gdata->height - y; + vy = gdata->boxY - vh; + } else { + vy = 0; + vh = gdata->height; + } + + if (y < gdata->boxY) { + int dy = vy - gdata->boxY; + + if (x < gdata->boxX) { + for (i = vh - 1; i >= 0; i--) { + memmove(&backP[(i + dy) * backLineLen + 2 * vx], + &backP[i * backLineLen], 2 * vw); + } + } else /* if (x > gdata->boxX) */ { + for (i = vh - 1; i >= 0; i--) { + memmove(&backP[(i + dy) * backLineLen], + &backP[i * backLineLen + 2 * vx], 2 * vw); + } + } + } else /*if (y > gdata->boxY) */ { + int dy = gdata->boxY - vy; + + if (x < gdata->boxX) { + for (i = 0; i < vh - 1; i++) { + memmove(&backP[i * backLineLen + 2 * vx], + &backP[(i + dy) * backLineLen], 2 * vw); + } + } else /*if (x > gdata->boxX) */ { + for (i = 0; i < vh - 1; i++) { + memmove(&backP[i * backLineLen], + &backP[(i + dy) * backLineLen + 2 * vx], 2 * vw); + } + } + } + + /* 2nd grab the background image from the screen and copy to the + * buffer. also maskout the lsb of rgb in each pixel of grabbed data */ + + if (y < gdata->boxY) { + vy = y; + vh = gdata->boxY - vy; + + hy = y + vh; + hh = gdata->height - vh; + } else if (y > gdata->boxY) { + vy = gdata->boxY + gdata->height; + vh = vy - (y + gdata->height); + + hy = y; + hh = y - gdata->boxY; + } else { + vy = vh = 0; + + hy = y; + hh = gdata->height; + } + + if (x < gdata->boxX) { + hx = x; + hw = gdata->boxX - hx; + } else if (x > gdata->boxX) { + hx = gdata->boxX + gdata->width; + hw = hx - (x + gdata->width); + } else { + hx = hw = 0; + + vx = x; + vw = gdata->width; + } + + /* 1st the top/bottom part */ + + + + /* 2nd the left/right part */ } mergeGhostWindow(gdata); diff --git a/src/superfluous.h b/src/superfluous.h index ae6f459b..99b087b5 100644 --- a/src/superfluous.h +++ b/src/superfluous.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ diff --git a/src/switchmenu.c b/src/switchmenu.c index 0a9b0ebf..c8117d55 100644 --- a/src/switchmenu.c +++ b/src/switchmenu.c @@ -1,9 +1,9 @@ -/* +/* * Window Maker window manager - * + * * Copyright (c) 1997 Shige Abe * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -78,13 +78,13 @@ focusWindow(WMenu *menu, WMenuEntry *entry) x = wwin->frame_x; y = wwin->frame_y; - + /* bring window back to visible area */ - move = wScreenBringInside(scr, &x, &y, wwin->frame->core->width, - wwin->frame->core->height); + move = wScreenBringInside(scr, &x, &y, wwin->frame->core->width, + wwin->frame->core->height); if (move) { - wWindowConfigure(wwin, x, y, wwin->client.width, wwin->client.height); + wWindowConfigure(wwin, x, y, wwin->client.width, wwin->client.height); } } @@ -111,53 +111,53 @@ InitializeSwitchMenu() /* * - * Open switch menu + * Open switch menu * */ -void +void OpenSwitchMenu(WScreen *scr, int x, int y, int keyboard) { WMenu *switchmenu = scr->switch_menu; WWindow *wwin; if (switchmenu) { - if (switchmenu->flags.mapped) { - if (!switchmenu->flags.buttoned) { - wMenuUnmap(switchmenu); - } else { - wRaiseFrame(switchmenu->frame->core); - - if (keyboard) - wMenuMapAt(switchmenu, 0, 0, True); - else - wMenuMapCopyAt(switchmenu, - x-switchmenu->frame->core->width/2, y); - } - } else { - if (keyboard && x==scr->scr_width/2 && y==scr->scr_height/2) { - y = y - switchmenu->frame->core->height/2; - } - wMenuMapAt(switchmenu, x-switchmenu->frame->core->width/2, y, - keyboard); - } - return; + if (switchmenu->flags.mapped) { + if (!switchmenu->flags.buttoned) { + wMenuUnmap(switchmenu); + } else { + wRaiseFrame(switchmenu->frame->core); + + if (keyboard) + wMenuMapAt(switchmenu, 0, 0, True); + else + wMenuMapCopyAt(switchmenu, + x-switchmenu->frame->core->width/2, y); + } + } else { + if (keyboard && x==scr->scr_width/2 && y==scr->scr_height/2) { + y = y - switchmenu->frame->core->height/2; + } + wMenuMapAt(switchmenu, x-switchmenu->frame->core->width/2, y, + keyboard); + } + return; } switchmenu = wMenuCreate(scr,_("Windows"),True); scr->switch_menu = switchmenu; - - + + wwin = scr->focused_window; while (wwin) { - UpdateSwitchMenu(scr, wwin, ACTION_ADD); + UpdateSwitchMenu(scr, wwin, ACTION_ADD); wwin = wwin->prev; } - + if (switchmenu) { int newx, newy; - if (!switchmenu->flags.realized) - wMenuRealize(switchmenu); + if (!switchmenu->flags.realized) + wMenuRealize(switchmenu); if (keyboard && x==0 && y==0) { newx = newy = 0; @@ -179,24 +179,24 @@ menuIndexForWindow(WMenu *menu, WWindow *wwin, int old_pos) int idx; if (menu->entry_no == 0) - return -1; + return -1; #define WS(i) ((WWindow*)menu->entries[i]->clientdata)->frame->workspace if (old_pos >= 0) { - if (WS(old_pos) >= wwin->frame->workspace - && (old_pos == 0 || WS(old_pos-1) <= wwin->frame->workspace)) { - return old_pos; - } + if (WS(old_pos) >= wwin->frame->workspace + && (old_pos == 0 || WS(old_pos-1) <= wwin->frame->workspace)) { + return old_pos; + } } #undef WS for (idx = 0; idx < menu->entry_no; idx++) { - WWindow *tw = (WWindow*)menu->entries[idx]->clientdata; + WWindow *tw = (WWindow*)menu->entries[idx]->clientdata; - if (!IS_OMNIPRESENT(tw) - && tw->frame->workspace > wwin->frame->workspace) { - break; - } + if (!IS_OMNIPRESENT(tw) + && tw->frame->workspace > wwin->frame->workspace) { + break; + } } return idx; @@ -217,7 +217,7 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action) int checkVisibility = 0; if (!wwin->screen_ptr->switch_menu) - return; + return; /* * This menu is updated under the following conditions: * @@ -228,142 +228,142 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action) * 4. When a window changes its workspace. */ if (action == ACTION_ADD) { - char *t; - int idx; - - if (wwin->flags.internal_window || WFLAGP(wwin, skip_window_list)) - return; - - if (wwin->frame->title) - snprintf(title, len, "%s", wwin->frame->title); - else - snprintf(title, len, "%s", DEF_WINDOW_TITLE); - t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH); - - if (IS_OMNIPRESENT(wwin)) - idx = -1; - else { - idx = menuIndexForWindow(switchmenu, wwin, -1); - } - - entry = wMenuInsertCallback(switchmenu, idx, t, focusWindow, wwin); - wfree(t); - - entry->flags.indicator = 1; - entry->rtext = wmalloc(MAX_WORKSPACENAME_WIDTH+8); - if (IS_OMNIPRESENT(wwin)) - snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[*]"); - else - snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[%s]", - scr->workspaces[wwin->frame->workspace]->name); - - if (wwin->flags.hidden) { - entry->flags.indicator_type = MI_HIDDEN; - entry->flags.indicator_on = 1; - } else if (wwin->flags.miniaturized) { - entry->flags.indicator_type = MI_MINIWINDOW; - entry->flags.indicator_on = 1; - } else if (wwin->flags.focused) { - entry->flags.indicator_type = MI_DIAMOND; - entry->flags.indicator_on = 1; - } else if (wwin->flags.shaded) { - entry->flags.indicator_type = MI_SHADED; - entry->flags.indicator_on = 1; - } - - wMenuRealize(switchmenu); - checkVisibility = 1; + char *t; + int idx; + + if (wwin->flags.internal_window || WFLAGP(wwin, skip_window_list)) + return; + + if (wwin->frame->title) + snprintf(title, len, "%s", wwin->frame->title); + else + snprintf(title, len, "%s", DEF_WINDOW_TITLE); + t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH); + + if (IS_OMNIPRESENT(wwin)) + idx = -1; + else { + idx = menuIndexForWindow(switchmenu, wwin, -1); + } + + entry = wMenuInsertCallback(switchmenu, idx, t, focusWindow, wwin); + wfree(t); + + entry->flags.indicator = 1; + entry->rtext = wmalloc(MAX_WORKSPACENAME_WIDTH+8); + if (IS_OMNIPRESENT(wwin)) + snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[*]"); + else + snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[%s]", + scr->workspaces[wwin->frame->workspace]->name); + + if (wwin->flags.hidden) { + entry->flags.indicator_type = MI_HIDDEN; + entry->flags.indicator_on = 1; + } else if (wwin->flags.miniaturized) { + entry->flags.indicator_type = MI_MINIWINDOW; + entry->flags.indicator_on = 1; + } else if (wwin->flags.focused) { + entry->flags.indicator_type = MI_DIAMOND; + entry->flags.indicator_on = 1; + } else if (wwin->flags.shaded) { + entry->flags.indicator_type = MI_SHADED; + entry->flags.indicator_on = 1; + } + + wMenuRealize(switchmenu); + checkVisibility = 1; } else { - char *t; - for (i=0; ientry_no; i++) { - entry = switchmenu->entries[i]; - /* this is the entry that was changed */ - if (entry->clientdata == wwin) { - switch (action) { - case ACTION_REMOVE: - wMenuRemoveItem(switchmenu, i); - wMenuRealize(switchmenu); - checkVisibility = 1; - break; - - case ACTION_CHANGE: - if (entry->text) - wfree(entry->text); - + char *t; + for (i=0; ientry_no; i++) { + entry = switchmenu->entries[i]; + /* this is the entry that was changed */ + if (entry->clientdata == wwin) { + switch (action) { + case ACTION_REMOVE: + wMenuRemoveItem(switchmenu, i); + wMenuRealize(switchmenu); + checkVisibility = 1; + break; + + case ACTION_CHANGE: + if (entry->text) + wfree(entry->text); + if (wwin->frame->title) snprintf(title, MAX_MENU_TEXT_LENGTH, "%s", wwin->frame->title); else snprintf(title, MAX_MENU_TEXT_LENGTH, "%s", - DEF_WINDOW_TITLE); - - t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH); - entry->text = t; - - wMenuRealize(switchmenu); - checkVisibility = 1; - break; - - case ACTION_CHANGE_WORKSPACE: - if (entry->rtext) { - int idx = -1; - char *t, *rt; - int it, ion; - - if (IS_OMNIPRESENT(wwin)) { - snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, - "[*]"); - } else { - snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, - "[%s]", scr->workspaces[wwin->frame->workspace]->name); - } - - rt = entry->rtext; - entry->rtext = NULL; - t = entry->text; - entry->text = NULL; - - it = entry->flags.indicator_type; - ion = entry->flags.indicator_on; - - wMenuRemoveItem(switchmenu, i); - - if (!IS_OMNIPRESENT(wwin) && idx < 0) { - idx = menuIndexForWindow(switchmenu, wwin, i); - } - - entry = wMenuInsertCallback(switchmenu, idx, t, - focusWindow, wwin); - wfree(t); - entry->rtext = rt; - entry->flags.indicator = 1; - entry->flags.indicator_type = it; - entry->flags.indicator_on = ion; - } - wMenuRealize(switchmenu); - checkVisibility = 1; - break; - - - case ACTION_CHANGE_STATE: - if (wwin->flags.hidden) { - entry->flags.indicator_type = MI_HIDDEN; - entry->flags.indicator_on = 1; - } else if (wwin->flags.miniaturized) { - entry->flags.indicator_type = MI_MINIWINDOW; - entry->flags.indicator_on = 1; - } else if (wwin->flags.shaded && !wwin->flags.focused) { - entry->flags.indicator_type = MI_SHADED; - entry->flags.indicator_on = 1; - } else { - entry->flags.indicator_on = wwin->flags.focused; - entry->flags.indicator_type = MI_DIAMOND; - } - break; - } - break; - } - } + DEF_WINDOW_TITLE); + + t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH); + entry->text = t; + + wMenuRealize(switchmenu); + checkVisibility = 1; + break; + + case ACTION_CHANGE_WORKSPACE: + if (entry->rtext) { + int idx = -1; + char *t, *rt; + int it, ion; + + if (IS_OMNIPRESENT(wwin)) { + snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, + "[*]"); + } else { + snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, + "[%s]", scr->workspaces[wwin->frame->workspace]->name); + } + + rt = entry->rtext; + entry->rtext = NULL; + t = entry->text; + entry->text = NULL; + + it = entry->flags.indicator_type; + ion = entry->flags.indicator_on; + + wMenuRemoveItem(switchmenu, i); + + if (!IS_OMNIPRESENT(wwin) && idx < 0) { + idx = menuIndexForWindow(switchmenu, wwin, i); + } + + entry = wMenuInsertCallback(switchmenu, idx, t, + focusWindow, wwin); + wfree(t); + entry->rtext = rt; + entry->flags.indicator = 1; + entry->flags.indicator_type = it; + entry->flags.indicator_on = ion; + } + wMenuRealize(switchmenu); + checkVisibility = 1; + break; + + + case ACTION_CHANGE_STATE: + if (wwin->flags.hidden) { + entry->flags.indicator_type = MI_HIDDEN; + entry->flags.indicator_on = 1; + } else if (wwin->flags.miniaturized) { + entry->flags.indicator_type = MI_MINIWINDOW; + entry->flags.indicator_on = 1; + } else if (wwin->flags.shaded && !wwin->flags.focused) { + entry->flags.indicator_type = MI_SHADED; + entry->flags.indicator_on = 1; + } else { + entry->flags.indicator_on = wwin->flags.focused; + entry->flags.indicator_type = MI_DIAMOND; + } + break; + } + break; + } + } } if (checkVisibility) { int tmp; @@ -386,25 +386,25 @@ UpdateSwitchMenuWorkspace(WScreen *scr, int workspace) WMenu *menu = scr->switch_menu; int i; WWindow *wwin; - + if (!menu) - return; - + return; + for (i=0; ientry_no; i++) { - wwin = (WWindow*)menu->entries[i]->clientdata; - - if (wwin->frame->workspace==workspace - && !IS_OMNIPRESENT(wwin)) { - if (IS_OMNIPRESENT(wwin)) - snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH,"[*]"); - else - snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH,"[%s]", - scr->workspaces[wwin->frame->workspace]->name); - menu->flags.realized = 0; - } + wwin = (WWindow*)menu->entries[i]->clientdata; + + if (wwin->frame->workspace==workspace + && !IS_OMNIPRESENT(wwin)) { + if (IS_OMNIPRESENT(wwin)) + snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH,"[*]"); + else + snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH,"[%s]", + scr->workspaces[wwin->frame->workspace]->name); + menu->flags.realized = 0; + } } if (!menu->flags.realized) - wMenuRealize(menu); + wMenuRealize(menu); } @@ -419,21 +419,21 @@ observer(void *self, WMNotification *notif) return; if (strcmp(name, WMNManaged) == 0) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_ADD); + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_ADD); else if (strcmp(name, WMNUnmanaged) == 0) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_REMOVE); + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_REMOVE); else if (strcmp(name, WMNChangedWorkspace) == 0) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE); + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE); else if (strcmp(name, WMNChangedFocus) == 0) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE); + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE); else if (strcmp(name, WMNChangedName) == 0) - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE); + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE); else if (strcmp(name, WMNChangedState) == 0) { - if (strcmp((char*)data, "omnipresent") == 0) { - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE); - } else { - UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE); - } + if (strcmp((char*)data, "omnipresent") == 0) { + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE); + } else { + UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE); + } } } @@ -446,11 +446,12 @@ wsobserver(void *self, WMNotification *notif) void *data = WMGetNotificationClientData(notif); if (strcmp(name, WMNWorkspaceNameChanged) == 0) { - UpdateSwitchMenuWorkspace(scr, (int)data); + UpdateSwitchMenuWorkspace(scr, (int)data); } else if (strcmp(name, WMNWorkspaceChanged) == 0) { - + } } #endif /* !LITE */ + diff --git a/src/text.c b/src/text.c index c483d640..54643bea 100644 --- a/src/text.c +++ b/src/text.c @@ -1,4 +1,4 @@ -/********************************************************************\ +/******************************************************************** * text.c -- a basic text field * * Copyright (C) 1997 Robin D. Clark * * * @@ -20,7 +20,7 @@ * Internet: rclark@cs.hmc.edu * * Address: 609 8th Street * * Huntington Beach, CA 92648-4632 * -\********************************************************************/ + ********************************************************************/ #include "wconfig.h" @@ -39,7 +39,7 @@ /* X11R5 don't have this */ #ifndef IsPrivateKeypadKey #define IsPrivateKeypadKey(keysym) \ - (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF)) + (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF)) #endif @@ -55,9 +55,9 @@ extern Cursor wCursor[WCUR_LAST]; -/********************************************************************\ +/******************************************************************** * The event handler for the text-field: * -\********************************************************************/ + ********************************************************************/ static void textEventHandler( WObjDescriptor *desc, XEvent *event ); static void handleExpose( WObjDescriptor *desc, XEvent *event ); @@ -67,7 +67,7 @@ static void textInsert( WTextInput *wtext, char *txt ); static void blink(void *data); #endif -/********************************************************************\ +/******************************************************************** * handleKeyPress * * handle cursor keys, regular keys, etc. Inserts characters in * * text field, at cursor position, if it is a "Normal" key. If * @@ -80,226 +80,226 @@ static void blink(void *data); * Return: True, unless the ksym is ignored * * Global: modifier - the bitfield that keeps track of the modifier * * keys that are down * -\********************************************************************/ + ********************************************************************/ static int handleKeyPress( WTextInput *wtext, XKeyEvent *event ) - { - KeySym ksym; - char buffer[32]; - int count; - - count = XLookupString(event, buffer, 32, &ksym, NULL); - - /* Ignore these keys: */ - if( IsFunctionKey(ksym) || IsKeypadKey(ksym) || - IsMiscFunctionKey(ksym) || IsPFKey(ksym) || - IsPrivateKeypadKey(ksym) ) - /* If we don't handle it, make sure it isn't a key that - * the window manager needs to see */ - return False; - - /* Take care of the cursor keys.. ignore up and down - * cursor keys */ - else if( IsCursorKey(ksym) ) +{ + KeySym ksym; + char buffer[32]; + int count; + + count = XLookupString(event, buffer, 32, &ksym, NULL); + + /* Ignore these keys: */ + if( IsFunctionKey(ksym) || IsKeypadKey(ksym) || + IsMiscFunctionKey(ksym) || IsPFKey(ksym) || + IsPrivateKeypadKey(ksym) ) + /* If we don't handle it, make sure it isn't a key that + * the window manager needs to see */ + return False; + + /* Take care of the cursor keys.. ignore up and down + * cursor keys */ + else if( IsCursorKey(ksym) ) { - int length = wtext->text.length; - switch(ksym) - { - case XK_Home: - case XK_Begin: - wtext->text.endPos = 0; - break; - case XK_Left: - wtext->text.endPos--; - break; - case XK_Right: - wtext->text.endPos++; - break; - case XK_End: - wtext->text.endPos = length; - break; - default: - return False; - } - /* make sure that the startPos and endPos have values - * that make sense (ie the are in [0..length] ) */ - if( wtext->text.endPos < 0 ) - wtext->text.endPos = 0; - if( wtext->text.endPos > length ) - wtext->text.endPos = length; - wtext->text.startPos = wtext->text.endPos; - } - else + int length = wtext->text.length; + switch(ksym) + { + case XK_Home: + case XK_Begin: + wtext->text.endPos = 0; + break; + case XK_Left: + wtext->text.endPos--; + break; + case XK_Right: + wtext->text.endPos++; + break; + case XK_End: + wtext->text.endPos = length; + break; + default: + return False; + } + /* make sure that the startPos and endPos have values + * that make sense (ie the are in [0..length] ) */ + if( wtext->text.endPos < 0 ) + wtext->text.endPos = 0; + if( wtext->text.endPos > length ) + wtext->text.endPos = length; + wtext->text.startPos = wtext->text.endPos; + } + else { - switch(ksym) - { - /* Ignore these keys: */ - case XK_Escape: - wtext->canceled = True; - case XK_Return: - wtext->done = True; - break; - case XK_Tab: - case XK_Num_Lock: - break; - - case XK_Delete: - /* delete after cursor */ - if( (wtext->text.endPos == wtext->text.startPos) && - (wtext->text.endPos < wtext->text.length) ) - wtext->text.endPos++; - textInsert( wtext, "" ); - break; - case XK_BackSpace: - /* delete before cursor */ - if( (wtext->text.endPos == wtext->text.startPos) && - (wtext->text.startPos > 0) ) - wtext->text.startPos--; - textInsert( wtext, "" ); - break; - default: - if (count==1 && !iscntrl(buffer[0])) { - buffer[count] = 0; - textInsert( wtext, buffer); - } - } - } - return True; - } - - - -/********************************************************************\ - * textXYtoPos * + switch(ksym) + { + /* Ignore these keys: */ + case XK_Escape: + wtext->canceled = True; + case XK_Return: + wtext->done = True; + break; + case XK_Tab: + case XK_Num_Lock: + break; + + case XK_Delete: + /* delete after cursor */ + if( (wtext->text.endPos == wtext->text.startPos) && + (wtext->text.endPos < wtext->text.length) ) + wtext->text.endPos++; + textInsert( wtext, "" ); + break; + case XK_BackSpace: + /* delete before cursor */ + if( (wtext->text.endPos == wtext->text.startPos) && + (wtext->text.startPos > 0) ) + wtext->text.startPos--; + textInsert( wtext, "" ); + break; + default: + if (count==1 && !iscntrl(buffer[0])) { + buffer[count] = 0; + textInsert( wtext, buffer); + } + } + } + return True; +} + + + +/******************************************************************** + * textXYtoPos * * given X coord, return position in array * -\********************************************************************/ + ********************************************************************/ static int textXtoPos( WTextInput *wtext, int x ) - { - int pos; - x -= wtext->xOffset; - - for( pos=0; wtext->text.txt[pos] != '\0'; pos++ ) +{ + int pos; + x -= wtext->xOffset; + + for( pos=0; wtext->text.txt[pos] != '\0'; pos++ ) { - if( x < 0 ) - break; - else - x -= WMWidthOfString( wtext->font, &(wtext->text.txt[pos]), 1 ); + if( x < 0 ) + break; + else + x -= WMWidthOfString( wtext->font, &(wtext->text.txt[pos]), 1 ); } - - return pos; - } -/********************************************************************\ + return pos; +} + +/******************************************************************** * wTextCreate * * create an instance of a text class * * * * Args: * * Return: * * Global: dpy - the display * -\********************************************************************/ + ********************************************************************/ WTextInput * wTextCreate( WCoreWindow *core, int x, int y, int width, int height ) - { - WTextInput *wtext; +{ + WTextInput *wtext; - ENTER("wTextCreate"); + ENTER("wTextCreate"); - wtext = wmalloc(sizeof(WTextInput)); - wtext->core = wCoreCreate( core, x, y, width, height ); - wtext->core->descriptor.handle_anything = &textEventHandler; - wtext->core->descriptor.handle_expose = &handleExpose; - wtext->core->descriptor.parent_type = WCLASS_TEXT_INPUT; - wtext->core->descriptor.parent = wtext; + wtext = wmalloc(sizeof(WTextInput)); + wtext->core = wCoreCreate( core, x, y, width, height ); + wtext->core->descriptor.handle_anything = &textEventHandler; + wtext->core->descriptor.handle_expose = &handleExpose; + wtext->core->descriptor.parent_type = WCLASS_TEXT_INPUT; + wtext->core->descriptor.parent = wtext; - wtext->font = core->screen_ptr->menu_entry_font; + wtext->font = core->screen_ptr->menu_entry_font; - XDefineCursor( dpy, wtext->core->window, wCursor[WCUR_TEXT] ); + XDefineCursor( dpy, wtext->core->window, wCursor[WCUR_TEXT] ); - /* setup the text: */ - wtext->text.txt = (char *)wmalloc(sizeof(char)); - wtext->text.txt[0] = '\0'; - wtext->text.length = 0; - wtext->text.startPos = 0; - wtext->text.endPos = 0; + /* setup the text: */ + wtext->text.txt = (char *)wmalloc(sizeof(char)); + wtext->text.txt[0] = '\0'; + wtext->text.length = 0; + wtext->text.startPos = 0; + wtext->text.endPos = 0; { - XGCValues gcv; - - gcv.foreground = core->screen_ptr->black_pixel; - gcv.background = core->screen_ptr->white_pixel; - gcv.line_width = 1; - gcv.function = GXcopy; - - wtext->gc = XCreateGC( dpy, wtext->core->window, - (GCForeground|GCBackground| - GCFunction|GCLineWidth), - &gcv ); + XGCValues gcv; - /* set up the regular context */ - gcv.foreground = core->screen_ptr->black_pixel; - gcv.background = core->screen_ptr->white_pixel; - gcv.line_width = 1; - gcv.function = GXcopy; + gcv.foreground = core->screen_ptr->black_pixel; + gcv.background = core->screen_ptr->white_pixel; + gcv.line_width = 1; + gcv.function = GXcopy; - wtext->regGC = XCreateGC( dpy, wtext->core->window, + wtext->gc = XCreateGC( dpy, wtext->core->window, (GCForeground|GCBackground| - GCFunction|GCLineWidth), + GCFunction|GCLineWidth), &gcv ); - /* set up the inverted context */ - gcv.function = GXcopyInverted; + /* set up the regular context */ + gcv.foreground = core->screen_ptr->black_pixel; + gcv.background = core->screen_ptr->white_pixel; + gcv.line_width = 1; + gcv.function = GXcopy; - wtext->invGC = XCreateGC( dpy, wtext->core->window, - (GCForeground|GCBackground| - GCFunction|GCLineWidth), - &gcv ); + wtext->regGC = XCreateGC( dpy, wtext->core->window, + (GCForeground|GCBackground| + GCFunction|GCLineWidth), + &gcv ); + + /* set up the inverted context */ + gcv.function = GXcopyInverted; - /* and set the background! */ - XSetWindowBackground( dpy, wtext->core->window, gcv.background ); + wtext->invGC = XCreateGC( dpy, wtext->core->window, + (GCForeground|GCBackground| + GCFunction|GCLineWidth), + &gcv ); + + /* and set the background! */ + XSetWindowBackground( dpy, wtext->core->window, gcv.background ); } - - /* Figure out the y-offset... */ - wtext->yOffset = (height - WMFontHeight(wtext->font))/2; - wtext->xOffset = wtext->yOffset; - - wtext->canceled = False; - wtext->done = False; /* becomes True when the user * - * hits "Return" key */ - - XMapRaised(dpy, wtext->core->window); - - LEAVE("wTextCreate"); - - return wtext; - } - -/********************************************************************\ + + /* Figure out the y-offset... */ + wtext->yOffset = (height - WMFontHeight(wtext->font))/2; + wtext->xOffset = wtext->yOffset; + + wtext->canceled = False; + wtext->done = False; /* becomes True when the user * + * hits "Return" key */ + + XMapRaised(dpy, wtext->core->window); + + LEAVE("wTextCreate"); + + return wtext; +} + +/******************************************************************** * wTextDestroy * * * * Args: wtext - the text field * * Return: * * Global: dpy - the display * -\********************************************************************/ + ********************************************************************/ void wTextDestroy( WTextInput *wtext ) - { - ENTER("wTextDestroy") - +{ + ENTER("wTextDestroy") + #if 0 - if (wtext->magic) - wDeleteTimerHandler(wtext->magic); - wtext->magic = NULL; + if (wtext->magic) + wDeleteTimerHandler(wtext->magic); + wtext->magic = NULL; #endif - XFreeGC( dpy, wtext->gc ); - XFreeGC( dpy, wtext->regGC ); - XFreeGC( dpy, wtext->invGC ); - wfree( wtext->text.txt ); - wCoreDestroy( wtext->core ); - wfree( wtext ); - - LEAVE("wTextDestroy"); - } + XFreeGC( dpy, wtext->gc ); + XFreeGC( dpy, wtext->regGC ); + XFreeGC( dpy, wtext->invGC ); + wfree( wtext->text.txt ); + wCoreDestroy( wtext->core ); + wfree( wtext ); + + LEAVE("wTextDestroy"); +} /* The text-field consists of a frame drawn around the outside, @@ -311,7 +311,7 @@ wTextDestroy( WTextInput *wtext ) * then call wTextRefresh to redraw the text-box */ -/********************************************************************\ +/******************************************************************** * textRefresh * * Redraw the text field. Call this after messing with the text * * field. wTextRefresh re-draws the inside of the text field. If * @@ -321,7 +321,7 @@ wTextDestroy( WTextInput *wtext ) * Args: wtext - the text field * * Return: none * * Global: dpy - the display * -\********************************************************************/ + ********************************************************************/ static void textRefresh(WTextInput *wtext) { @@ -383,30 +383,30 @@ textRefresh(WTextInput *wtext) } -/********************************************************************\ +/******************************************************************** * wTextPaint * * * * Args: wtext - the text field * * Return: * * Global: dpy - the display * -\********************************************************************/ + ********************************************************************/ void wTextPaint( WTextInput *wtext ) - { - ENTER("wTextPaint"); +{ + ENTER("wTextPaint"); - /* refresh */ - textRefresh( wtext ); + /* refresh */ + textRefresh( wtext ); - /* Draw box */ - XDrawRectangle(dpy, wtext->core->window, wtext->gc, 0, 0, - wtext->core->width-1, wtext->core->height-1); + /* Draw box */ + XDrawRectangle(dpy, wtext->core->window, wtext->gc, 0, 0, + wtext->core->width-1, wtext->core->height-1); - LEAVE("wTextPaint"); - } + LEAVE("wTextPaint"); +} -/********************************************************************\ +/******************************************************************** * wTextGetText * * return the string in the text field wText. DO NOT FREE THE * * RETURNED STRING! * @@ -414,17 +414,17 @@ wTextPaint( WTextInput *wtext ) * Args: wtext - the text field * * Return: the text in the text field (NULL terminated) * * Global: * -\********************************************************************/ + ********************************************************************/ char * wTextGetText( WTextInput *wtext ) - { - if (!wtext->canceled) - return wtext->text.txt; - else - return NULL; - } - -/********************************************************************\ +{ + if (!wtext->canceled) + return wtext->text.txt; + else + return NULL; +} + +/******************************************************************** * wTextPutText * * Put the string txt in the text field wText. The text field * * needs to be explicitly refreshed after wTextPutText by calling * @@ -435,25 +435,25 @@ wTextGetText( WTextInput *wtext ) * txt - the new text string... freed by the text field! * * Return: none * * Global: * -\********************************************************************/ + ********************************************************************/ void wTextPutText( WTextInput *wtext, char *txt ) - { - int length = strlen(txt); - - /* no memory leaks! free the old txt */ - if( wtext->text.txt != NULL ) - wfree( wtext->text.txt ); - - wtext->text.txt = (char *)wmalloc((length+1)*sizeof(char)); - strcpy(wtext->text.txt, txt ); - wtext->text.length = length; - /* By default No text is selected, and the cursor is at the end */ - wtext->text.startPos = length; - wtext->text.endPos = length; - } - -/********************************************************************\ +{ + int length = strlen(txt); + + /* no memory leaks! free the old txt */ + if( wtext->text.txt != NULL ) + wfree( wtext->text.txt ); + + wtext->text.txt = (char *)wmalloc((length+1)*sizeof(char)); + strcpy(wtext->text.txt, txt ); + wtext->text.length = length; + /* By default No text is selected, and the cursor is at the end */ + wtext->text.startPos = length; + wtext->text.endPos = length; +} + +/******************************************************************** * textInsert * * Insert some text at the cursor. (if startPos != endPos, * * replace the selected text, otherwise insert) * @@ -463,56 +463,56 @@ wTextPutText( WTextInput *wtext, char *txt ) * txt - the new text string... freed by the text field! * * Return: none * * Global: * -\********************************************************************/ + ********************************************************************/ static void textInsert( WTextInput *wtext, char *txt ) - { - char *newTxt; - int newLen, txtLen, i,j; - int sp,ep; - - /* we need sp < ep */ - if( wtext->text.startPos > wtext->text.endPos ) +{ + char *newTxt; + int newLen, txtLen, i,j; + int sp,ep; + + /* we need sp < ep */ + if( wtext->text.startPos > wtext->text.endPos ) { - sp = wtext->text.endPos; - ep = wtext->text.startPos; + sp = wtext->text.endPos; + ep = wtext->text.startPos; } - else + else { - sp = wtext->text.startPos; - ep = wtext->text.endPos; + sp = wtext->text.startPos; + ep = wtext->text.endPos; } - - txtLen = strlen(txt); - newLen = wtext->text.length + txtLen - (ep - sp) + 1; - - newTxt = (char *)malloc(newLen*sizeof(char)); - - /* copy the old text up to sp */ - for( i=0; itext.txt[i]; - - /* insert new text */ - for( j=0; jtext.length; j++,i++ ) - newTxt[i] = wtext->text.txt[j]; - - newTxt[i] = '\0'; - - /* By default No text is selected, and the cursor is at the end - * of inserted text */ - wtext->text.startPos = sp+txtLen; - wtext->text.endPos = sp+txtLen; - - wfree(wtext->text.txt); - wtext->text.txt = newTxt; - wtext->text.length = newLen-1; - } - -/********************************************************************\ + + txtLen = strlen(txt); + newLen = wtext->text.length + txtLen - (ep - sp) + 1; + + newTxt = (char *)malloc(newLen*sizeof(char)); + + /* copy the old text up to sp */ + for( i=0; itext.txt[i]; + + /* insert new text */ + for( j=0; jtext.length; j++,i++ ) + newTxt[i] = wtext->text.txt[j]; + + newTxt[i] = '\0'; + + /* By default No text is selected, and the cursor is at the end + * of inserted text */ + wtext->text.startPos = sp+txtLen; + wtext->text.endPos = sp+txtLen; + + wfree(wtext->text.txt); + wtext->text.txt = newTxt; + wtext->text.length = newLen-1; +} + +/******************************************************************** * wTextSelect * * Select some text. If start == end, then the cursor is moved * * to that position. If end == -1, then the text from start to * @@ -525,16 +525,16 @@ textInsert( WTextInput *wtext, char *txt ) * end - the end of the selected text * * Return: none * * Global: * -\********************************************************************/ + ********************************************************************/ void wTextSelect( WTextInput *wtext, int start, int end ) - { - if( end == -1 ) - wtext->text.endPos = wtext->text.length; - else - wtext->text.endPos = end; - wtext->text.startPos = start; - } +{ + if( end == -1 ) + wtext->text.endPos = wtext->text.length; + else + wtext->text.endPos = end; + wtext->text.startPos = start; +} #if 0 static void @@ -543,108 +543,108 @@ blink(void *data) int x; WTextInput *wtext = (WTextInput*)data; GC gc; - - /* And draw a quick little line for the cursor position */ + + /* And draw a quick little line for the cursor position */ if (wtext->blink_on) { - gc = wtext->regGC; - wtext->blink_on = 0; + gc = wtext->regGC; + wtext->blink_on = 0; } else { - gc = wtext->invGC; - wtext->blink_on = 1; + gc = wtext->invGC; + wtext->blink_on = 1; } x = WMWidthOfString( wtext->font, wtext->text.txt, wtext->text.endPos ) - + wtext->xOffset; + + wtext->xOffset; XDrawLine( dpy, wtext->core->window, gc, x, 2, x, wtext->core->height-3); if (wtext->blinking) - wtext->magic = wAddTimerHandler(CURSOR_BLINK_RATE, blink, data); + wtext->magic = wAddTimerHandler(CURSOR_BLINK_RATE, blink, data); } #endif -/********************************************************************\ +/******************************************************************** * textEventHandler -- handles and dispatches all the events that * * the text field class supports * * * * Args: desc - all we need to know about this object * * Return: none * * Global: * -\********************************************************************/ + ********************************************************************/ static void textEventHandler( WObjDescriptor *desc, XEvent *event ) - { - WTextInput *wtext = desc->parent; - int handled = False; /* has the event been handled */ +{ + WTextInput *wtext = desc->parent; + int handled = False; /* has the event been handled */ - switch( event->type ) + switch( event->type ) { case MotionNotify: - /* If the button isn't down, we don't care about the - * event, but otherwise we want to adjust the selected - * text so we can wTextRefresh() */ - if( event->xmotion.state & (Button1Mask|Button3Mask|Button2Mask) ) - { - PDEBUG("MotionNotify"); - handled = True; - wtext->text.endPos = textXtoPos( wtext, event->xmotion.x ); - } - break; + /* If the button isn't down, we don't care about the + * event, but otherwise we want to adjust the selected + * text so we can wTextRefresh() */ + if( event->xmotion.state & (Button1Mask|Button3Mask|Button2Mask) ) + { + PDEBUG("MotionNotify"); + handled = True; + wtext->text.endPos = textXtoPos( wtext, event->xmotion.x ); + } + break; case ButtonPress: - PDEBUG("ButtonPress"); - handled = True; - wtext->text.startPos = textXtoPos( wtext, event->xbutton.x ); - wtext->text.endPos = wtext->text.startPos; - break; + PDEBUG("ButtonPress"); + handled = True; + wtext->text.startPos = textXtoPos( wtext, event->xbutton.x ); + wtext->text.endPos = wtext->text.startPos; + break; case ButtonRelease: - PDEBUG("ButtonRelease"); - handled = True; - wtext->text.endPos = textXtoPos( wtext, event->xbutton.x ); - break; + PDEBUG("ButtonRelease"); + handled = True; + wtext->text.endPos = textXtoPos( wtext, event->xbutton.x ); + break; case KeyPress: - PDEBUG("KeyPress"); - handled = handleKeyPress( wtext, &event->xkey ); - break; + PDEBUG("KeyPress"); + handled = handleKeyPress( wtext, &event->xkey ); + break; case EnterNotify: - PDEBUG("EnterNotify"); - handled = True; + PDEBUG("EnterNotify"); + handled = True; #if 0 - if (!wtext->magic) - { - wtext->magic = wAddTimerHandler(CURSOR_BLINK_RATE, blink, wtext); - wtext->blink_on = !wtext->blink_on; - blink(wtext); - wtext->blinking = 1; + if (!wtext->magic) + { + wtext->magic = wAddTimerHandler(CURSOR_BLINK_RATE, blink, wtext); + wtext->blink_on = !wtext->blink_on; + blink(wtext); + wtext->blinking = 1; } #endif - break; + break; case LeaveNotify: - PDEBUG("LeaveNotify"); - handled = True; + PDEBUG("LeaveNotify"); + handled = True; #if 0 - wtext->blinking = 0; - if (wtext->blink_on) - blink(wtext); - if (wtext->magic) - wDeleteTimerHandler(wtext->magic); - wtext->magic = NULL; + wtext->blinking = 0; + if (wtext->blink_on) + blink(wtext); + if (wtext->magic) + wDeleteTimerHandler(wtext->magic); + wtext->magic = NULL; #endif - break; + break; default: - break; + break; } - - if( handled ) - textRefresh(wtext); - else - WMHandleEvent(event); - - return; - } + + if( handled ) + textRefresh(wtext); + else + WMHandleEvent(event); + + return; +} static void diff --git a/src/text.h b/src/text.h index e287a81a..4fca47a5 100644 --- a/src/text.h +++ b/src/text.h @@ -1,4 +1,4 @@ -/********************************************************************\ +/******************************************************************** * text.h -- a basic text field * * Copyright (C) 1997 Robin D. Clark * * * @@ -20,7 +20,7 @@ * Internet: rclark@cs.hmc.edu * * Address: 609 8th Street * * Huntington Beach, CA 92648-4632 * -\********************************************************************/ + ********************************************************************/ #ifndef __TEXT_H__ #define __TEXT_H__ @@ -28,33 +28,33 @@ #include "wcore.h" typedef struct { - char *txt; /* ptr to the text */ - int length; /* length of txt[] */ - int startPos; /* beginning of selected text */ - int endPos; /* end of selected text */ -} WTextBlock; /* if startPos == endPos, no txt * - * is selected... they give the * - * cursor position. */ + char *txt; /* ptr to the text */ + int length; /* length of txt[] */ + int startPos; /* beginning of selected text */ + int endPos; /* end of selected text */ +} WTextBlock; /* if startPos == endPos, no txt * + * is selected... they give the * + * cursor position. */ typedef struct { - WCoreWindow *core; - WMFont *font; - WTextBlock text; - GC gc; - GC regGC; /* the normal GC */ - GC invGC; /* inverted, for selected text */ - WMagicNumber *magic; - short xOffset; - short yOffset; - unsigned int done:1; - unsigned int blink_on:1; - unsigned int blinking:1; - unsigned int canceled:1; + WCoreWindow *core; + WMFont *font; + WTextBlock text; + GC gc; + GC regGC; /* the normal GC */ + GC invGC; /* inverted, for selected text */ + WMagicNumber *magic; + short xOffset; + short yOffset; + unsigned int done:1; + unsigned int blink_on:1; + unsigned int blinking:1; + unsigned int canceled:1; } WTextInput; /** PROTOTYPES ******************************************************/ -WTextInput* wTextCreate( WCoreWindow *core, int x, int y, int width, - int height ); +WTextInput* wTextCreate( WCoreWindow *core, int x, int y, int width, + int height ); void wTextDestroy( WTextInput *wText ); void wTextPaint( WTextInput *wText ); char* wTextGetText( WTextInput *wText ); diff --git a/src/texture.c b/src/texture.c index 670d1146..0fd2ad30 100644 --- a/src/texture.c +++ b/src/texture.c @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -54,7 +54,7 @@ wTextureMakeSolid(WScreen *scr, XColor *color) WTexSolid *texture; int gcm; XGCValues gcv; - + texture = wmalloc(sizeof(WTexture)); texture->type = WTEX_SOLID; @@ -63,36 +63,36 @@ wTextureMakeSolid(WScreen *scr, XColor *color) XAllocColor(dpy, scr->w_colormap, color); texture->normal = *color; if (color->red==0 && color->blue==0 && color->green == 0) { - texture->light.red = 0xb6da; - texture->light.green = 0xb6da; - texture->light.blue = 0xb6da; - texture->dim.red = 0x6185; - texture->dim.green = 0x6185; - texture->dim.blue = 0x6185; + texture->light.red = 0xb6da; + texture->light.green = 0xb6da; + texture->light.blue = 0xb6da; + texture->dim.red = 0x6185; + texture->dim.green = 0x6185; + texture->dim.blue = 0x6185; } else { - RColor rgb; - RHSVColor hsv, hsv2; - int v; - - rgb.red = color->red >> 8; - rgb.green = color->green >> 8; - rgb.blue = color->blue >> 8; - RRGBtoHSV(&rgb, &hsv); - RHSVtoRGB(&hsv, &rgb); - hsv2 = hsv; - - v = hsv.value*16/10; - hsv.value = (v > 255 ? 255 : v); - RHSVtoRGB(&hsv, &rgb); - texture->light.red = rgb.red << 8; - texture->light.green = rgb.green << 8; - texture->light.blue = rgb.blue << 8; - - hsv2.value = hsv2.value/2; - RHSVtoRGB(&hsv2, &rgb); - texture->dim.red = rgb.red << 8; - texture->dim.green = rgb.green << 8; - texture->dim.blue = rgb.blue << 8; + RColor rgb; + RHSVColor hsv, hsv2; + int v; + + rgb.red = color->red >> 8; + rgb.green = color->green >> 8; + rgb.blue = color->blue >> 8; + RRGBtoHSV(&rgb, &hsv); + RHSVtoRGB(&hsv, &rgb); + hsv2 = hsv; + + v = hsv.value*16/10; + hsv.value = (v > 255 ? 255 : v); + RHSVtoRGB(&hsv, &rgb); + texture->light.red = rgb.red << 8; + texture->light.green = rgb.green << 8; + texture->light.blue = rgb.blue << 8; + + hsv2.value = hsv2.value/2; + RHSVtoRGB(&hsv2, &rgb); + texture->dim.red = rgb.red << 8; + texture->dim.green = rgb.green << 8; + texture->dim.blue = rgb.blue << 8; } texture->dark.red = 0; texture->dark.green = 0; @@ -107,9 +107,9 @@ wTextureMakeSolid(WScreen *scr, XColor *color) gcv.background = gcv.foreground = texture->light.pixel; texture->light_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv); - gcv.background = gcv.foreground = texture->dim.pixel; + gcv.background = gcv.foreground = texture->dim.pixel; texture->dim_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv); - + gcv.background = gcv.foreground = texture->dark.pixel; texture->dark_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv); @@ -136,80 +136,80 @@ wTextureDestroy(WScreen *scr, WTexture *texture) int i; int count=0; unsigned long colors[8]; - -#ifdef DEBUG + +#ifdef DEBUG if (texture==NULL) { - printf("BUG: trying to free NULL texture\n"); - return; + printf("BUG: trying to free NULL texture\n"); + return; } #endif - /* + /* * some stupid servers don't like white or black being freed... */ #define CANFREE(c) (c!=scr->black_pixel && c!=scr->white_pixel && c!=0) switch (texture->any.type) { - case WTEX_SOLID: - XFreeGC(dpy, texture->solid.light_gc); - XFreeGC(dpy, texture->solid.dark_gc); - XFreeGC(dpy, texture->solid.dim_gc); - if (CANFREE(texture->solid.light.pixel)) - colors[count++] = texture->solid.light.pixel; - if (CANFREE(texture->solid.dim.pixel)) - colors[count++] = texture->solid.dim.pixel; - if (CANFREE(texture->solid.dark.pixel)) - colors[count++] = texture->solid.dark.pixel; - break; - - case WTEX_PIXMAP: - RReleaseImage(texture->pixmap.pixmap); - break; - - case WTEX_MHGRADIENT: - case WTEX_MVGRADIENT: - case WTEX_MDGRADIENT: - for (i=0; texture->mgradient.colors[i]!=NULL; i++) { - wfree(texture->mgradient.colors[i]); - } - wfree(texture->mgradient.colors); - break; - - case WTEX_THGRADIENT: - case WTEX_TVGRADIENT: - case WTEX_TDGRADIENT: - RReleaseImage(texture->tgradient.pixmap); - break; + case WTEX_SOLID: + XFreeGC(dpy, texture->solid.light_gc); + XFreeGC(dpy, texture->solid.dark_gc); + XFreeGC(dpy, texture->solid.dim_gc); + if (CANFREE(texture->solid.light.pixel)) + colors[count++] = texture->solid.light.pixel; + if (CANFREE(texture->solid.dim.pixel)) + colors[count++] = texture->solid.dim.pixel; + if (CANFREE(texture->solid.dark.pixel)) + colors[count++] = texture->solid.dark.pixel; + break; + + case WTEX_PIXMAP: + RReleaseImage(texture->pixmap.pixmap); + break; + + case WTEX_MHGRADIENT: + case WTEX_MVGRADIENT: + case WTEX_MDGRADIENT: + for (i=0; texture->mgradient.colors[i]!=NULL; i++) { + wfree(texture->mgradient.colors[i]); + } + wfree(texture->mgradient.colors); + break; + + case WTEX_THGRADIENT: + case WTEX_TVGRADIENT: + case WTEX_TDGRADIENT: + RReleaseImage(texture->tgradient.pixmap); + break; #ifdef TEXTURE_PLUGIN - case WTEX_FUNCTION: + case WTEX_FUNCTION: #ifdef HAVE_DLFCN_H if (texture->function.handle) { - dlclose(texture->function.handle); - } + dlclose(texture->function.handle); + } #endif - for (i = 0; i < texture->function.argc; i++) { - wfree(texture->function.argv[i]); - } - wfree(texture->function.argv); - break; + for (i = 0; i < texture->function.argc; i++) { + wfree(texture->function.argv[i]); + } + wfree(texture->function.argv); + break; #endif /* TEXTURE_PLUGIN */ } if (CANFREE(texture->any.color.pixel)) - colors[count++] = texture->any.color.pixel; + colors[count++] = texture->any.color.pixel; if (count > 0) { - XErrorHandler oldhandler; - - /* ignore error from buggy servers that don't know how - * to do reference counting for colors. */ - XSync(dpy,0); - oldhandler = XSetErrorHandler(dummyErrorHandler); - XFreeColors(dpy, scr->w_colormap, colors, count, 0); - XSync(dpy,0); - XSetErrorHandler(oldhandler); + XErrorHandler oldhandler; + + /* ignore error from buggy servers that don't know how + * to do reference counting for colors. */ + XSync(dpy,0); + oldhandler = XSetErrorHandler(dummyErrorHandler); + XFreeColors(dpy, scr->w_colormap, colors, count, 0); + XSync(dpy,0); + XSetErrorHandler(oldhandler); } XFreeGC(dpy, texture->any.gc); wfree(texture); -#undef CANFREE +#undef CANFREE } @@ -220,12 +220,12 @@ wTextureMakeGradient(WScreen *scr, int style, RColor *from, RColor *to) WTexGradient *texture; XGCValues gcv; - + texture = wmalloc(sizeof(WTexture)); memset(texture, 0, sizeof(WTexture)); texture->type = style; texture->subtype = 0; - + texture->color1 = *from; texture->color2 = *to; @@ -237,7 +237,7 @@ wTextureMakeGradient(WScreen *scr, int style, RColor *from, RColor *to) gcv.background = gcv.foreground = texture->normal.pixel; gcv.graphics_exposures = False; texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground - |GCGraphicsExposures, &gcv); + |GCGraphicsExposures, &gcv); return texture; } @@ -247,36 +247,36 @@ wTextureMakeGradient(WScreen *scr, int style, RColor *from, RColor *to) WTexIGradient* wTextureMakeIGradient(WScreen *scr, int thickness1, RColor colors1[2], - int thickness2, RColor colors2[2]) + int thickness2, RColor colors2[2]) { WTexIGradient *texture; XGCValues gcv; int i; - + texture = wmalloc(sizeof(WTexture)); memset(texture, 0, sizeof(WTexture)); texture->type = WTEX_IGRADIENT; for (i = 0; i < 2; i++) { - texture->colors1[i] = colors1[i]; - texture->colors2[i] = colors2[i]; + texture->colors1[i] = colors1[i]; + texture->colors2[i] = colors2[i]; } texture->thickness1 = thickness1; texture->thickness2 = thickness2; if (thickness1 >= thickness2) { - texture->normal.red = (colors1[0].red + colors1[1].red)<<7; - texture->normal.green = (colors1[0].green + colors1[1].green)<<7; - texture->normal.blue = (colors1[0].blue + colors1[1].blue)<<7; + texture->normal.red = (colors1[0].red + colors1[1].red)<<7; + texture->normal.green = (colors1[0].green + colors1[1].green)<<7; + texture->normal.blue = (colors1[0].blue + colors1[1].blue)<<7; } else { - texture->normal.red = (colors2[0].red + colors2[1].red)<<7; - texture->normal.green = (colors2[0].green + colors2[1].green)<<7; - texture->normal.blue = (colors2[0].blue + colors2[1].blue)<<7; + texture->normal.red = (colors2[0].red + colors2[1].red)<<7; + texture->normal.green = (colors2[0].green + colors2[1].green)<<7; + texture->normal.blue = (colors2[0].blue + colors2[1].blue)<<7; } XAllocColor(dpy, scr->w_colormap, &texture->normal); gcv.background = gcv.foreground = texture->normal.pixel; gcv.graphics_exposures = False; texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground - |GCGraphicsExposures, &gcv); + |GCGraphicsExposures, &gcv); return texture; } @@ -290,26 +290,26 @@ wTextureMakeMGradient(WScreen *scr, int style, RColor **colors) XGCValues gcv; int i; - + texture = wmalloc(sizeof(WTexture)); memset(texture, 0, sizeof(WTexture)); texture->type = style; texture->subtype = 0; - + i=0; while (colors[i]!=NULL) i++; i--; texture->normal.red = (colors[0]->red<<8); texture->normal.green = (colors[0]->green<<8); texture->normal.blue = (colors[0]->blue<<8); - + texture->colors = colors; XAllocColor(dpy, scr->w_colormap, &texture->normal); gcv.background = gcv.foreground = texture->normal.pixel; gcv.graphics_exposures = False; texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground - |GCGraphicsExposures, &gcv); + |GCGraphicsExposures, &gcv); return texture; } @@ -328,14 +328,14 @@ wTextureMakePixmap(WScreen *scr, int style, char *pixmap_file, XColor *color) if (!file) { wwarning(_("image file \"%s\" used as texture could not be found."), pixmap_file); - return NULL; + return NULL; } image = RLoadImage(scr->rcontext, file, 0); if (!image) { - wwarning(_("could not load texture pixmap \"%s\":%s"), file, - RMessageForError(RErrorCode)); - wfree(file); - return NULL; + wwarning(_("could not load texture pixmap \"%s\":%s"), file, + RMessageForError(RErrorCode)); + wfree(file); + return NULL; } wfree(file); @@ -350,16 +350,16 @@ wTextureMakePixmap(WScreen *scr, int style, char *pixmap_file, XColor *color) gcv.background = gcv.foreground = texture->normal.pixel; gcv.graphics_exposures = False; texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground - |GCGraphicsExposures, &gcv); + |GCGraphicsExposures, &gcv); texture->pixmap = image; - + return texture; } WTexTGradient* wTextureMakeTGradient(WScreen *scr, int style, RColor *from, RColor *to, - char *pixmap_file, int opacity) + char *pixmap_file, int opacity) { WTexTGradient *texture; XGCValues gcv; @@ -370,21 +370,21 @@ wTextureMakeTGradient(WScreen *scr, int style, RColor *from, RColor *to, if (!file) { wwarning(_("image file \"%s\" used as texture could not be found."), pixmap_file); - return NULL; + return NULL; } image = RLoadImage(scr->rcontext, file, 0); if (!image) { - wwarning(_("could not load texture pixmap \"%s\":%s"), file, - RMessageForError(RErrorCode)); - wfree(file); - return NULL; + wwarning(_("could not load texture pixmap \"%s\":%s"), file, + RMessageForError(RErrorCode)); + wfree(file); + return NULL; } wfree(file); texture = wmalloc(sizeof(WTexture)); memset(texture, 0, sizeof(WTexture)); texture->type = style; - + texture->opacity = opacity; texture->color1 = *from; @@ -398,7 +398,7 @@ wTextureMakeTGradient(WScreen *scr, int style, RColor *from, RColor *to, gcv.background = gcv.foreground = texture->normal.pixel; gcv.graphics_exposures = False; texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground - |GCGraphicsExposures, &gcv); + |GCGraphicsExposures, &gcv); texture->pixmap = image; @@ -413,46 +413,46 @@ wTextureMakeFunction(WScreen *scr, char *lib, char *func, int argc, char **argv) XColor fallbackColor; XGCValues gcv; WTexFunction *texture; - + texture = wmalloc(sizeof(WTexture)); texture->type = WTEX_FUNCTION; texture->handle = NULL; texture->render = 0; texture->argc = argc; texture->argv = argv; - + fallbackColor.red = 0x8000; fallbackColor.green = 0x8000; fallbackColor.blue = 0x8000; - + gcv.background = gcv.foreground = fallbackColor.pixel; gcv.graphics_exposures = False; texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground - |GCGraphicsExposures, &gcv); - + |GCGraphicsExposures, &gcv); + # ifdef HAVE_DLFCN_H /* open the library */ texture->handle = dlopen(lib, RTLD_LAZY); if (!texture->handle) { wwarning(_("library \"%s\" cound not be opened."), lib); - wfree(argv); - wfree(texture); - return NULL; + wfree(argv); + wfree(texture); + return NULL; } - + /* find the function */ texture->render = dlsym(texture->handle, func); if (!texture->render) { wwarning(_("function \"%s\" not found in library \"%s\""), func, lib); - wfree(argv); - dlclose(texture->handle); - wfree(texture); - return NULL; + wfree(argv); + dlclose(texture->handle); + wfree(texture); + return NULL; } # else wwarning(_("function textures not supported on this system, sorry.")); # endif - + /* success! */ return texture; } @@ -461,27 +461,27 @@ wTextureMakeFunction(WScreen *scr, char *lib, char *func, int argc, char **argv) RImage* wTextureRenderImage(WTexture *texture, int width, int height, - int relief) + int relief) { RImage *image = NULL; RColor color1; int d; int subtype; - + switch (texture->any.type) { - case WTEX_SOLID: - image = RCreateImage(width, height, False); - - color1.red = texture->solid.normal.red >> 8; - color1.green = texture->solid.normal.green >> 8; - color1.blue = texture->solid.normal.blue >> 8; + case WTEX_SOLID: + image = RCreateImage(width, height, False); + + color1.red = texture->solid.normal.red >> 8; + color1.green = texture->solid.normal.green >> 8; + color1.blue = texture->solid.normal.blue >> 8; color1.alpha = 255; - - RClearImage(image, &color1); - break; - - case WTEX_PIXMAP: - if (texture->pixmap.subtype == WTP_TILE) { + + RClearImage(image, &color1); + break; + + case WTEX_PIXMAP: + if (texture->pixmap.subtype == WTP_TILE) { image = RMakeTiledImage(texture->pixmap.pixmap, width, height); } else if (texture->pixmap.subtype == WTP_CENTER) { color1.red = texture->pixmap.normal.red>>8; @@ -493,153 +493,153 @@ wTextureRenderImage(WTexture *texture, int width, int height, } else { image = RScaleImage(texture->pixmap.pixmap, width, height); } - break; - - case WTEX_IGRADIENT: - image = RRenderInterwovenGradient(width, height, - texture->igradient.colors1, - texture->igradient.thickness1, - texture->igradient.colors2, - texture->igradient.thickness2); - break; - - case WTEX_HGRADIENT: - subtype = RGRD_HORIZONTAL; - goto render_gradient; - - case WTEX_VGRADIENT: - subtype = RGRD_VERTICAL; - goto render_gradient; - - case WTEX_DGRADIENT: - subtype = RGRD_DIAGONAL; - render_gradient: - - image = RRenderGradient(width, height, &texture->gradient.color1, - &texture->gradient.color2, subtype); - break; - - case WTEX_MHGRADIENT: - subtype = RGRD_HORIZONTAL; - goto render_mgradient; - - case WTEX_MVGRADIENT: - subtype = RGRD_VERTICAL; - goto render_mgradient; - - case WTEX_MDGRADIENT: - subtype = RGRD_DIAGONAL; - render_mgradient: - image = RRenderMultiGradient(width, height, - &(texture->mgradient.colors[1]), - subtype); - break; - - case WTEX_THGRADIENT: - subtype = RGRD_HORIZONTAL; - goto render_tgradient; - - case WTEX_TVGRADIENT: - subtype = RGRD_VERTICAL; - goto render_tgradient; - - case WTEX_TDGRADIENT: - subtype = RGRD_DIAGONAL; - render_tgradient: - { - RImage *grad; - - image = RMakeTiledImage(texture->tgradient.pixmap, width, height); - if (!image) - break; - - grad = RRenderGradient(width, height, &texture->tgradient.color1, - &texture->tgradient.color2, subtype); - if (!grad) { - RReleaseImage(image); - image = NULL; - break; - } - - RCombineImagesWithOpaqueness(image, grad, - texture->tgradient.opacity); - RReleaseImage(grad); - } - break; + break; + + case WTEX_IGRADIENT: + image = RRenderInterwovenGradient(width, height, + texture->igradient.colors1, + texture->igradient.thickness1, + texture->igradient.colors2, + texture->igradient.thickness2); + break; + + case WTEX_HGRADIENT: + subtype = RGRD_HORIZONTAL; + goto render_gradient; + + case WTEX_VGRADIENT: + subtype = RGRD_VERTICAL; + goto render_gradient; + + case WTEX_DGRADIENT: + subtype = RGRD_DIAGONAL; + render_gradient: + + image = RRenderGradient(width, height, &texture->gradient.color1, + &texture->gradient.color2, subtype); + break; + + case WTEX_MHGRADIENT: + subtype = RGRD_HORIZONTAL; + goto render_mgradient; + + case WTEX_MVGRADIENT: + subtype = RGRD_VERTICAL; + goto render_mgradient; + + case WTEX_MDGRADIENT: + subtype = RGRD_DIAGONAL; + render_mgradient: + image = RRenderMultiGradient(width, height, + &(texture->mgradient.colors[1]), + subtype); + break; + + case WTEX_THGRADIENT: + subtype = RGRD_HORIZONTAL; + goto render_tgradient; + + case WTEX_TVGRADIENT: + subtype = RGRD_VERTICAL; + goto render_tgradient; + + case WTEX_TDGRADIENT: + subtype = RGRD_DIAGONAL; + render_tgradient: + { + RImage *grad; + + image = RMakeTiledImage(texture->tgradient.pixmap, width, height); + if (!image) + break; + + grad = RRenderGradient(width, height, &texture->tgradient.color1, + &texture->tgradient.color2, subtype); + if (!grad) { + RReleaseImage(image); + image = NULL; + break; + } + + RCombineImagesWithOpaqueness(image, grad, + texture->tgradient.opacity); + RReleaseImage(grad); + } + break; #ifdef TEXTURE_PLUGIN - case WTEX_FUNCTION: + case WTEX_FUNCTION: #ifdef HAVE_DLFCN_H - if (texture->function.render) { + if (texture->function.render) { image = texture->function.render ( - texture->function.argc, texture->function.argv, - width, height, relief); - } + texture->function.argc, texture->function.argv, + width, height, relief); + } #endif - if (!image) { - RErrorCode = RERR_INTERNAL; - } + if (!image) { + RErrorCode = RERR_INTERNAL; + } break; #endif /* TEXTURE_PLUGIN */ - default: - puts("ERROR in wTextureRenderImage()"); - image = NULL; - break; + default: + puts("ERROR in wTextureRenderImage()"); + image = NULL; + break; } if (!image) { - RColor gray; - - wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode)); - - image = RCreateImage(width, height, False); - if (image == NULL) { - wwarning(_("could not allocate image buffer")); - return NULL; - } - - gray.red = 190; - gray.green = 190; - gray.blue = 190; + RColor gray; + + wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode)); + + image = RCreateImage(width, height, False); + if (image == NULL) { + wwarning(_("could not allocate image buffer")); + return NULL; + } + + gray.red = 190; + gray.green = 190; + gray.blue = 190; gray.alpha = 255; - RClearImage(image, &gray); + RClearImage(image, &gray); } /* render bevel */ - + switch (relief) { case WREL_ICON: - d = RBEV_RAISED3; - break; - - case WREL_RAISED: - d = RBEV_RAISED2; - break; - - case WREL_SUNKEN: - d = RBEV_SUNKEN; - break; - - case WREL_FLAT: - d = 0; - break; - - case WREL_MENUENTRY: - d = -WREL_MENUENTRY; - break; - - default: - d = 0; + d = RBEV_RAISED3; + break; + + case WREL_RAISED: + d = RBEV_RAISED2; + break; + + case WREL_SUNKEN: + d = RBEV_SUNKEN; + break; + + case WREL_FLAT: + d = 0; + break; + + case WREL_MENUENTRY: + d = -WREL_MENUENTRY; + break; + + default: + d = 0; } - + if (d > 0) { - RBevelImage(image, d); + RBevelImage(image, d); } else if (d < 0) { - bevelImage(image, -d); + bevelImage(image, -d); } - + return image; } @@ -651,40 +651,40 @@ bevelImage(RImage *image, int relief) int width = image->width; int height = image->height; RColor color; - + switch (relief) { - case WREL_MENUENTRY: - color.red = color.green = color.blue = 80; - color.alpha = 0; - /**/ - ROperateLine(image, RAddOperation, 1, 0, width-2, 0, &color); - /**/ - - ROperateLine(image, RAddOperation, 0, 0, 0, height-1, &color); - - color.red = color.green = color.blue = 40; - color.alpha = 0; - ROperateLine(image, RSubtractOperation, width-1, 0, width-1, - height-1, &color); - - /**/ - ROperateLine(image, RSubtractOperation, 1, height-2, width-2, - height-2, &color); - - color.red = color.green = color.blue = 0; - color.alpha = 255; - RDrawLine(image, 0, height-1, width-1, height-1, &color); - /**/ - break; + case WREL_MENUENTRY: + color.red = color.green = color.blue = 80; + color.alpha = 0; + /**/ + ROperateLine(image, RAddOperation, 1, 0, width-2, 0, &color); + /**/ + + ROperateLine(image, RAddOperation, 0, 0, 0, height-1, &color); + + color.red = color.green = color.blue = 40; + color.alpha = 0; + ROperateLine(image, RSubtractOperation, width-1, 0, width-1, + height-1, &color); + + /**/ + ROperateLine(image, RSubtractOperation, 1, height-2, width-2, + height-2, &color); + + color.red = color.green = color.blue = 0; + color.alpha = 255; + RDrawLine(image, 0, height-1, width-1, height-1, &color); + /**/ + break; } } - - + + void wDrawBevel(Drawable d, unsigned width, unsigned height, - WTexSolid *texture, int relief) + WTexSolid *texture, int relief) { GC light, dim, dark; XSegment segs[4]; @@ -695,59 +695,59 @@ wDrawBevel(Drawable d, unsigned width, unsigned height, dim = texture->dim_gc; dark = texture->dark_gc; switch (relief) { - case WREL_FLAT: - return; - case WREL_MENUENTRY: - case WREL_RAISED: - case WREL_ICON: - segs[0].x1 = 1; - segs[0].x2 = width - 2; - segs[0].y2 = segs[0].y1 = height - 2; - segs[1].x1 = width - 2; - segs[1].y1 = 1; - segs[1].x2 = width - 2; - segs[1].y2 = height - 2; - XDrawSegments(dpy, d, dim, segs, 2); - segs[0].x1 = 0; - segs[0].x2 = width - 1; - segs[0].y2 = segs[0].y1 = height - 1; - segs[1].x1 = segs[1].x2 = width - 1; - segs[1].y1 = 0; - segs[1].y2 = height - 1; - XDrawSegments(dpy, d, dark, segs, 2); - segs[0].x1 = segs[0].y1 = segs[0].y2 = 0; - segs[0].x2 = width - 2; - segs[1].x1 = segs[1].y1 = 0; - segs[1].x2 = 0; - segs[1].y2 = height - 2; - XDrawSegments(dpy, d, light, segs, 2); - if (relief==WREL_ICON) { - segs[0].x1 = segs[0].y1 = segs[0].y2 = 1; - segs[0].x2 = width - 2; - segs[1].x1 = segs[1].y1 = 1; - segs[1].x2 = 1; - segs[1].y2 = height - 2; - XDrawSegments(dpy, d, light, segs, 2); - } - break; -#ifdef unused - case WREL_SUNKEN: - segs[0].x1 = 0; - segs[0].x2 = width - 1; - segs[0].y2 = segs[0].y1 = 0; - segs[1].x1 = segs[1].x2 = 0; - segs[1].y1 = 0; - segs[1].y2 = height - 1; - XDrawSegments(dpy, d, dark, segs, 2); - - segs[0].x1 = 0; - segs[0].y1 = segs[0].y2 = height - 1; - segs[0].x2 = width - 1; - segs[1].x2 = segs[1].x1 = width - 1; - segs[1].y1 = 1; - segs[1].y2 = height - 1; - XDrawSegments(dpy, d, light, segs, 2); - break; + case WREL_FLAT: + return; + case WREL_MENUENTRY: + case WREL_RAISED: + case WREL_ICON: + segs[0].x1 = 1; + segs[0].x2 = width - 2; + segs[0].y2 = segs[0].y1 = height - 2; + segs[1].x1 = width - 2; + segs[1].y1 = 1; + segs[1].x2 = width - 2; + segs[1].y2 = height - 2; + XDrawSegments(dpy, d, dim, segs, 2); + segs[0].x1 = 0; + segs[0].x2 = width - 1; + segs[0].y2 = segs[0].y1 = height - 1; + segs[1].x1 = segs[1].x2 = width - 1; + segs[1].y1 = 0; + segs[1].y2 = height - 1; + XDrawSegments(dpy, d, dark, segs, 2); + segs[0].x1 = segs[0].y1 = segs[0].y2 = 0; + segs[0].x2 = width - 2; + segs[1].x1 = segs[1].y1 = 0; + segs[1].x2 = 0; + segs[1].y2 = height - 2; + XDrawSegments(dpy, d, light, segs, 2); + if (relief==WREL_ICON) { + segs[0].x1 = segs[0].y1 = segs[0].y2 = 1; + segs[0].x2 = width - 2; + segs[1].x1 = segs[1].y1 = 1; + segs[1].x2 = 1; + segs[1].y2 = height - 2; + XDrawSegments(dpy, d, light, segs, 2); + } + break; +#ifdef unused + case WREL_SUNKEN: + segs[0].x1 = 0; + segs[0].x2 = width - 1; + segs[0].y2 = segs[0].y1 = 0; + segs[1].x1 = segs[1].x2 = 0; + segs[1].y1 = 0; + segs[1].y2 = height - 1; + XDrawSegments(dpy, d, dark, segs, 2); + + segs[0].x1 = 0; + segs[0].y1 = segs[0].y2 = height - 1; + segs[0].x2 = width - 1; + segs[1].x2 = segs[1].x1 = width - 1; + segs[1].y1 = 1; + segs[1].y2 = height - 1; + XDrawSegments(dpy, d, light, segs, 2); + break; #endif } } diff --git a/src/texture.h b/src/texture.h index af872295..8a8063c7 100644 --- a/src/texture.h +++ b/src/texture.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -69,7 +69,7 @@ typedef struct WTexSolid { char subtype; XColor normal; GC normal_gc; - + GC light_gc; GC dim_gc; GC dark_gc; @@ -148,7 +148,7 @@ typedef struct WTexFunction { } WTexFunction; typedef union WTexture { - WTexAny any; + WTexAny any; WTexSolid solid; WTexGradient gradient; WTexIGradient igradient; @@ -164,8 +164,8 @@ WTexGradient *wTextureMakeGradient(WScreen*, int, RColor*, RColor*); WTexMGradient *wTextureMakeMGradient(WScreen*, int, RColor**); WTexTGradient *wTextureMakeTGradient(WScreen*, int, RColor*, RColor*, char *, int); WTexIGradient *wTextureMakeIGradient(WScreen*, int, RColor[], int, RColor[]); -WTexPixmap *wTextureMakePixmap(WScreen *scr, int style, char *pixmap_file, - XColor *color); +WTexPixmap *wTextureMakePixmap(WScreen *scr, int style, char *pixmap_file, + XColor *color); #ifdef TEXTURE_PLUGIN WTexFunction *wTextureMakeFunction(WScreen*, char *, char *, int, char **); #endif @@ -176,12 +176,12 @@ struct RImage *wTextureRenderImage(WTexture*, int, int, int); void wTexturePaintTitlebar(struct WWindow *wwin, WTexture *texture, Pixmap *tdata, - int repaint); + int repaint); #define FREE_PIXMAP(p) if ((p)!=None) XFreePixmap(dpy, (p)), (p)=None void wDrawBevel(Drawable d, unsigned width, unsigned height, - WTexSolid *texture, int relief); + WTexSolid *texture, int relief); #endif diff --git a/src/usermenu.c b/src/usermenu.c index b3c94263..d1a77654 100644 --- a/src/usermenu.c +++ b/src/usermenu.c @@ -17,9 +17,9 @@ * * 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. - * + * * * * * * * * * * * User defined menu is good, but beer's always better * if someone wanna start hacking something, He heard... @@ -33,7 +33,7 @@ * TODONOT * - allow applications to share their menu. ] think it * looks wierd since there still are more than 1 appicon. - * + * * Syntax... * ( * "Program Name", @@ -49,12 +49,12 @@ * ("Exit Command", EXIT) * ) * ) - * + * * Tips: * - If you don't want short cut keys to be listed * in the right side of entries, you can just put them * in array instead of using the string directly. - * + * */ #include "wconfig.h" @@ -191,7 +191,7 @@ convertShortcuts(WScreen *scr, WMPropList *shortcut) } keyover: - + /* get key */ if (!j) { puts("fatal j"); @@ -201,7 +201,7 @@ keyover: } data->key_no = j; data->screen = scr; - + return data; } @@ -226,21 +226,21 @@ configureUserMenu(WScreen *scr, WMPropList *plum) if (!WMIsPLString(elem)) { return NULL; } - + mtitle = WMGetFromPLString(elem); - + menu=wMenuCreateForApp(scr, mtitle, True); - + for(i=1; iframe->title, - NULL, NULL); + NULL, NULL); wMenuEntrySetCascade(menu, mentry, submenu); } else { @@ -251,7 +251,7 @@ configureUserMenu(WScreen *scr, WMPropList *plum) command = WMGetFromPLArray(elem,idx++); if (WMGetPropListItemCount(elem) >= 3) params = WMGetFromPLArray(elem,idx++); - + if (!title || !command) return menu; @@ -261,7 +261,7 @@ configureUserMenu(WScreen *scr, WMPropList *plum) data = convertShortcuts(scr, params); if (data){ entry = wMenuAddCallback(menu, WMGetFromPLString(title), - notifyClient, data); + notifyClient, data); if (entry) { if (WMIsPLString(params)) { @@ -272,10 +272,10 @@ configureUserMenu(WScreen *scr, WMPropList *plum) if (WMGetPropListItemCount(elem) >= 4) { instances = WMGetFromPLArray(elem,idx++); if(WMIsPLArray(instances)) - if (instances && WMGetPropListItemCount(instances) - && WMIsPLArray(instances)){ - entry->instances = WMRetainPropList(instances); - } + if (instances && WMGetPropListItemCount(instances) + && WMIsPLArray(instances)){ + entry->instances = WMRetainPropList(instances); + } } } } @@ -292,9 +292,9 @@ wUserMenuRefreshInstances(WMenu *menu, WWindow *wwin) { WMenuEntry* entry; int i,j,count,paintflag; - + paintflag=0; - + if(!menu) return; for (i=0; ientry_no; i++) { @@ -318,9 +318,9 @@ wUserMenuRefreshInstances(WMenu *menu, WWindow *wwin) } for (i=0; i < menu->cascade_no; i++) { if (!menu->cascades[i]->flags.brother) - wUserMenuRefreshInstances(menu->cascades[i], wwin); + wUserMenuRefreshInstances(menu->cascades[i], wwin); else - wUserMenuRefreshInstances(menu->cascades[i]->brother, wwin); + wUserMenuRefreshInstances(menu->cascades[i]->brother, wwin); } if (paintflag) @@ -339,7 +339,7 @@ readUserMenuFile(WScreen *scr, char *file_name) menu=NULL; plum = WMReadPropListFromFile(file_name); /**/ - + if(plum){ menu = configureUserMenu(scr, plum); WMReleasePropList(plum); @@ -356,14 +356,14 @@ wUserMenuGet(WScreen *scr, WWindow *wwin) char *path = NULL; char *tmp; if (wwin->wm_instance && wwin->wm_class) { - int len = strlen(wwin->wm_instance)+strlen(wwin->wm_class)+7; + int len = strlen(wwin->wm_instance)+strlen(wwin->wm_class)+7; tmp=wmalloc(len); snprintf(tmp,len,"%s.%s.menu",wwin->wm_instance,wwin->wm_class); path = wfindfile(DEF_USER_MENU_PATHS,tmp); wfree(tmp); if (!path) return NULL; - + if (wwin) { menu = readUserMenuFile(scr, path); } @@ -374,3 +374,4 @@ wUserMenuGet(WScreen *scr, WWindow *wwin) } #endif /* USER_MENU */ + diff --git a/src/usermenu.h b/src/usermenu.h index 9fc4878c..68387443 100644 --- a/src/usermenu.h +++ b/src/usermenu.h @@ -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. */ diff --git a/src/wconfig.h.in b/src/wconfig.h.in index 4c7b1c87..b11646d3 100644 --- a/src/wconfig.h.in +++ b/src/wconfig.h.in @@ -1,10 +1,10 @@ /* * wconfig.h- default configuration and definitions + compile time options - * + * * WindowMaker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -30,9 +30,9 @@ /* *-------------------------------------------------------------------- * Feature Selection - * - * Comment out the following #defines if you want to - * disable a feature. + * + * Comment out the following #defines if you want to + * disable a feature. * Also check the features you can enable through configure. *-------------------------------------------------------------------- */ @@ -101,7 +101,7 @@ */ #undef NO_EMERGENCY_AUTORESTART -/* +/* * The window manager that is autorestarted */ #define FALLBACK_WINDOWMANAGER "blackbox" @@ -123,7 +123,7 @@ * for applications that change their shape frequently (like xdaliclock * -shape), removing flickering. If wmaker and your display are on * different machines and the network connection is slow, it is not - * recommended. + * recommended. */ #undef OPTIMIZE_SHAPE @@ -138,7 +138,7 @@ /* * disable/enable workspace indicator in the dock */ -#undef WS_INDICATOR +#undef WS_INDICATOR /* @@ -217,7 +217,7 @@ /* *-------------------------------------------------------------------- * Default Configuration - * + * * Some of the following options can be configured in * the preference files, but if for some reason, they can't * be used, these defaults will be. @@ -226,10 +226,10 @@ *-------------------------------------------------------------------- */ -/* list of paths to look for the config files, searched in order +/* list of paths to look for the config files, searched in order * of appearance */ #define DEF_CONFIG_PATHS \ -"~/GNUstep/Library/WindowMaker:"PKGDATADIR + "~/GNUstep/Library/WindowMaker:"PKGDATADIR #define DEF_MENU_FILE "menu" @@ -253,17 +253,17 @@ /* pixmap path */ #define DEF_PIXMAP_PATHS \ -"(\"~/pixmaps\",\"~/GNUstep/Library/WindowMaker/Pixmaps\",\""PIXMAPDIR"\")" + "(\"~/pixmaps\",\"~/GNUstep/Library/WindowMaker/Pixmaps\",\""PIXMAPDIR"\")" #ifdef USER_MENU #define GLOBAL_USER_MENU_PATH PKGDATADIR"/UserMenus" #define DEF_USER_MENU_PATHS \ -"~/GNUstep/Library/WindowMaker/UserMenus:"GLOBAL_USER_MENU_PATH + "~/GNUstep/Library/WindowMaker/UserMenus:"GLOBAL_USER_MENU_PATH #endif /* icon path */ #define DEF_ICON_PATHS \ -"(\"~/pixmaps\",\"~/GNUstep/Library/Icons\",\"/usr/include/X11/pixmaps/\",\""PIXMAPDIR"\")" + "(\"~/pixmaps\",\"~/GNUstep/Library/Icons\",\"/usr/include/X11/pixmaps/\",\""PIXMAPDIR"\")" /* window title to use for untitled windows */ @@ -301,7 +301,7 @@ #define DEF_MENU_TEXT_EXTEND_SPACE "0" #define TITLEBAR_EXTEND_SPACE 4 -#define DEF_XPM_CLOSENESS 40000 +#define DEF_XPM_CLOSENESS 40000 /* default position of application menus */ #define DEF_APPMENU_X 10 @@ -313,7 +313,7 @@ /* Window level where icons reside */ #define NORMAL_ICON_LEVEL WMNormalLevel -/* do not divide main menu and submenu in different tiers, +/* do not divide main menu and submenu in different tiers, * opposed to OpenStep */ #define SINGLE_MENULEVEL @@ -337,7 +337,7 @@ #define MINIATURIZE_ANIMATION_STEPS_F 16 #define MINIATURIZE_ANIMATION_DELAY_F 1000 #define MINIATURIZE_ANIMATION_TWIST_F 0.5 - + #define HIDE_ANIMATION_STEPS (MINIATURIZE_ANIMATION_STEPS*2/3) @@ -410,7 +410,7 @@ /* workspace name on switch display */ #define WORKSPACE_NAME_FADE_DELAY 30 -#ifdef VIRTUAL_DESKTOP +#ifdef VIRTUAL_DESKTOP /* workspace virtual edge speed */ #define VIRTUALEDGE_SCROLL_VSTEP 30 #define VIRTUALEDGE_SCROLL_HSTEP 30 @@ -474,7 +474,7 @@ #define CURSOR_BLINK_RATE 300 #define MOVE_THRESHOLD 5 /* how many pixels to move before dragging windows - * and other objects */ + * and other objects */ #define KEY_CONTROL_WINDOW_WEIGHT 1 @@ -482,10 +482,10 @@ #define MAX_WORKSPACENAME_WIDTH 32 #define MAX_WINDOWLIST_WIDTH 160 /* max width of window title in - * window list */ + * window list */ #define DEFAULTS_CHECK_INTERVAL 2000 /* how often wmaker will check for - * changes in the config files */ + * changes in the config files */ /* if your keyboard don't have arrow keys */ #undef ARROWLESS_KBD diff --git a/src/wcore.c b/src/wcore.c index 9ee70d72..6da62256 100644 --- a/src/wcore.c +++ b/src/wcore.c @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -51,7 +51,7 @@ extern XContext wWinContext; */ WCoreWindow* wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height, - int bwidth) + int bwidth) { WCoreWindow *core; int vmask; @@ -60,10 +60,10 @@ wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height, core = wmalloc(sizeof(WCoreWindow)); memset(core, 0, sizeof(WCoreWindow)); - /* don't set CWBackPixel so that transparent XRender windows + /* don't set CWBackPixel so that transparent XRender windows are see-through */ vmask = /*CWBackPixmap|CWBackPixel|*/CWBorderPixel|CWCursor|CWEventMask - |CWOverrideRedirect; + |CWOverrideRedirect; attribs.override_redirect = True; attribs.cursor = wCursor[WCUR_DEFAULT]; attribs.background_pixmap = None; @@ -77,14 +77,14 @@ wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height, attribs.colormap = screen->w_colormap; core->window = XCreateWindow(dpy, screen->root_win, x, y, width, height, - bwidth, screen->w_depth, CopyFromParent, - screen->w_visual, vmask, &attribs); + bwidth, screen->w_depth, CopyFromParent, + screen->w_visual, vmask, &attribs); core->width = width; core->height = height; core->screen_ptr = screen; core->descriptor.self = core; - + XClearWindow(dpy, core->window); XSaveContext(dpy, core->window, wWinContext, (XPointer)&core->descriptor); @@ -94,21 +94,21 @@ wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height, /* - *---------------------------------------------------------------------- + *---------------------------------------------------------------------- * wCoreCreate-- * Creates a brand new child window. * The window will have a border width of 0 and color is black. - * + * * Returns: * A initialized core window structure. - * + * * Side effects: * A window context for the created window is saved. - * + * * Notes: * The event mask is initialized to a default value. - * - *---------------------------------------------------------------------- + * + *---------------------------------------------------------------------- */ WCoreWindow* wCoreCreate(WCoreWindow *parent, int x, int y, int width, int height) @@ -125,16 +125,16 @@ wCoreCreate(WCoreWindow *parent, int x, int y, int width, int height) attribs.background_pixmap = None; attribs.background_pixel = parent->screen_ptr->black_pixel; attribs.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask - | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask - | LeaveWindowMask; + | ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask + | LeaveWindowMask; /* - vmask |= CWColormap; - attribs.colormap = parent->screen_ptr->w_colormap; + vmask |= CWColormap; + attribs.colormap = parent->screen_ptr->w_colormap; */ core->window = - XCreateWindow(dpy, parent->window, x, y, width, height, 0, - parent->screen_ptr->w_depth, CopyFromParent, - parent->screen_ptr->w_visual, vmask, &attribs); + XCreateWindow(dpy, parent->window, x, y, width, height, 0, + parent->screen_ptr->w_depth, CopyFromParent, + parent->screen_ptr->w_visual, vmask, &attribs); core->width=width; core->height=height; core->screen_ptr = parent->screen_ptr; @@ -151,7 +151,7 @@ void wCoreDestroy(WCoreWindow *core) { if (core->stacking) { - wfree(core->stacking); + wfree(core->stacking); } XDeleteContext(dpy, core->window, wWinContext); XDestroyWindow(dpy, core->window); @@ -164,22 +164,22 @@ wCoreConfigure(WCoreWindow *core, int req_x, int req_y, int req_w, int req_h) { XWindowChanges xwc; unsigned int mask; - + mask = CWX|CWY; xwc.x = req_x; xwc.y = req_y; - - if (req_w <= 0) - req_w = core->width; + + if (req_w <= 0) + req_w = core->width; if (req_h <= 0) - req_h = core->height; - + req_h = core->height; + if (req_w != core->width || req_h != core->height) { - mask |= CWWidth | CWHeight; - xwc.width = req_w; - xwc.height = req_h; - core->width = req_w; - core->height = req_h; + mask |= CWWidth | CWHeight; + xwc.width = req_w; + xwc.height = req_h; + core->width = req_w; + core->height = req_h; } XConfigureWindow(dpy, core->window, mask, &xwc); } diff --git a/src/wcore.h b/src/wcore.h index 2b5f73f7..25f6b6c7 100644 --- a/src/wcore.h +++ b/src/wcore.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -37,21 +37,21 @@ typedef struct _WCoreWindow { int width; /* size of the window */ int height; WScreen *screen_ptr; /* ptr to screen of the window */ - + WObjDescriptor descriptor; WStacking *stacking; /* window stacking information */ } WCoreWindow; #include "pixmap.h" -WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, - int height, int bwidth); +WCoreWindow *wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, + int height, int bwidth); -WCoreWindow *wCoreCreate(WCoreWindow *parent, int x, int y, - int width, int height); +WCoreWindow *wCoreCreate(WCoreWindow *parent, int x, int y, + int width, int height); void wCoreDestroy(WCoreWindow *core); -void wCoreConfigure(WCoreWindow *core, int req_x, int req_y, - int req_w, int req_h); +void wCoreConfigure(WCoreWindow *core, int req_x, int req_y, + int req_w, int req_h); #endif diff --git a/src/wdefaults.c b/src/wdefaults.c index 7a481c8d..ea7f8383 100644 --- a/src/wdefaults.c +++ b/src/wdefaults.c @@ -1,9 +1,9 @@ /* wdefaults.c - window specific defaults - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -27,7 +27,7 @@ #include #include #include - + #include #include #include @@ -102,7 +102,7 @@ static void init_wdefaults(WScreen *scr) { AIcon = WMCreatePLString("Icon"); - + ANoTitlebar = WMCreatePLString("NoTitlebar"); ANoResizebar = WMCreatePLString("NoResizebar"); ANoMiniaturizeButton = WMCreatePLString("NoMiniaturizeButton"); @@ -131,50 +131,50 @@ init_wdefaults(WScreen *scr) #endif AStartWorkspace = WMCreatePLString("StartWorkspace"); - + AnyWindow = WMCreatePLString("*"); No = WMCreatePLString("No"); /* - if (!scr->wattribs) { - scr->wattribs = PLGetDomain(wAttributeDomainName); - }*/ + if (!scr->wattribs) { + scr->wattribs = PLGetDomain(wAttributeDomainName); + }*/ } static WMPropList* -get_value(WMPropList *dict_win, WMPropList *dict_class, WMPropList *dict_name, - WMPropList *dict_any, WMPropList *option, WMPropList *default_value, - Bool useGlobalDefault) +get_value(WMPropList *dict_win, WMPropList *dict_class, WMPropList *dict_name, + WMPropList *dict_any, WMPropList *option, WMPropList *default_value, + Bool useGlobalDefault) { WMPropList *value; if (dict_win) { - value = WMGetFromPLDictionary(dict_win, option); - if (value) - return value; + value = WMGetFromPLDictionary(dict_win, option); + if (value) + return value; } - + if (dict_name) { - value = WMGetFromPLDictionary(dict_name, option); - if (value) - return value; + value = WMGetFromPLDictionary(dict_name, option); + if (value) + return value; } if (dict_class) { - value = WMGetFromPLDictionary(dict_class, option); - if (value) - return value; + value = WMGetFromPLDictionary(dict_class, option); + if (value) + return value; } if (!useGlobalDefault) - return NULL; + return NULL; if (dict_any) { - value = WMGetFromPLDictionary(dict_any, option); - if (value) - return value; + value = WMGetFromPLDictionary(dict_any, option); + if (value) + return value; } return default_value; @@ -188,15 +188,15 @@ get_value(WMPropList *dict_win, WMPropList *dict_class, WMPropList *dict_name, * fills attr with it. Values that are actually defined are also * set in mask. If useGlobalDefault is True, the default for * all windows ("*") will be used for when no values are found - * for that instance/class. - * + * for that instance/class. + * *---------------------------------------------------------------------- */ void -wDefaultFillAttributes(WScreen *scr, char *instance, char *class, - WWindowAttributes *attr, - WWindowAttributes *mask, - Bool useGlobalDefault) +wDefaultFillAttributes(WScreen *scr, char *instance, char *class, + WWindowAttributes *attr, + WWindowAttributes *mask, + Bool useGlobalDefault) { WMPropList *value, *key1, *key2, *key3, *dw, *dc, *dn, *da; @@ -213,45 +213,45 @@ wDefaultFillAttributes(WScreen *scr, char *instance, char *class, } if (instance) - key2 = WMCreatePLString(instance); + key2 = WMCreatePLString(instance); else - key2 = NULL; + key2 = NULL; if (class) - key3 = WMCreatePLString(class); + key3 = WMCreatePLString(class); else - key3 = NULL; - + key3 = NULL; + if (!ANoTitlebar) { - init_wdefaults(scr); + init_wdefaults(scr); } WMPLSetCaseSensitive(True); if (WDWindowAttributes->dictionary) { - dw = key1 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key1) : NULL; - dn = key2 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key2) : NULL; - dc = key3 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key3) : NULL; - if (useGlobalDefault) - da = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow); - else - da = NULL; + dw = key1 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key1) : NULL; + dn = key2 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key2) : NULL; + dc = key3 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key3) : NULL; + if (useGlobalDefault) + da = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow); + else + da = NULL; } else { - dw = NULL; - dn = NULL; - dc = NULL; - da = NULL; + dw = NULL; + dn = NULL; + dc = NULL; + da = NULL; } if (key1) - WMReleasePropList(key1); + WMReleasePropList(key1); if (key2) - WMReleasePropList(key2); + WMReleasePropList(key2); if (key3) - WMReleasePropList(key3); + WMReleasePropList(key3); #define APPLY_VAL(value, flag, attrib) \ - if (value) {attr->flag = getBool(attrib, value); \ - if (mask) mask->flag = 1;} + if (value) {attr->flag = getBool(attrib, value); \ + if (mask) mask->flag = 1;} /* get the data */ value = get_value(dw, dc, dn, da, ANoTitlebar, No, useGlobalDefault); @@ -295,7 +295,7 @@ wDefaultFillAttributes(WScreen *scr, char *instance, char *class, value = get_value(dw, dc, dn, da, ASkipWindowList, No, useGlobalDefault); APPLY_VAL(value, skip_window_list, ASkipWindowList); - + value = get_value(dw, dc, dn, da, AKeepInsideScreen, No, useGlobalDefault); APPLY_VAL(value, dont_move_off, AKeepInsideScreen); @@ -307,7 +307,7 @@ wDefaultFillAttributes(WScreen *scr, char *instance, char *class, value = get_value(dw, dc, dn, da, AStartMiniaturized, No, useGlobalDefault); APPLY_VAL(value, start_miniaturized, AStartMiniaturized); - + value = get_value(dw, dc, dn, da, AStartHidden, No, useGlobalDefault); APPLY_VAL(value, start_hidden, AStartHidden); @@ -336,10 +336,10 @@ wDefaultFillAttributes(WScreen *scr, char *instance, char *class, WMPropList* get_generic_value(WScreen *scr, char *instance, char *class, WMPropList *option, - Bool noDefault) + Bool noDefault) { WMPropList *value, *key, *dict; - + value = NULL; WMPLSetCaseSensitive(True); @@ -349,46 +349,46 @@ get_generic_value(WScreen *scr, char *instance, char *class, WMPropList *option, buffer = wmalloc(strlen(class)+strlen(instance)+2); sprintf(buffer, "%s.%s", instance, class); - key = WMCreatePLString(buffer); - wfree(buffer); + key = WMCreatePLString(buffer); + wfree(buffer); - dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key); - WMReleasePropList(key); + dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key); + WMReleasePropList(key); - if (dict) { - value = WMGetFromPLDictionary(dict, option); - } + if (dict) { + value = WMGetFromPLDictionary(dict, option); + } } if (!value && instance) { - key = WMCreatePLString(instance); - - dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key); - WMReleasePropList(key); - if (dict) { - value = WMGetFromPLDictionary(dict, option); - } + key = WMCreatePLString(instance); + + dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key); + WMReleasePropList(key); + if (dict) { + value = WMGetFromPLDictionary(dict, option); + } } if (!value && class) { - key = WMCreatePLString(class); - - dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key); - WMReleasePropList(key); - - if (dict) { - value = WMGetFromPLDictionary(dict, option); - } + key = WMCreatePLString(class); + + dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key); + WMReleasePropList(key); + + if (dict) { + value = WMGetFromPLDictionary(dict, option); + } } if (!value && !noDefault) { - dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow); - - if (dict) { - value = WMGetFromPLDictionary(dict, option); - } + dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow); + + if (dict) { + value = WMGetFromPLDictionary(dict, option); + } } - + WMPLSetCaseSensitive(False); return value; @@ -396,23 +396,23 @@ get_generic_value(WScreen *scr, char *instance, char *class, WMPropList *option, char* -wDefaultGetIconFile(WScreen *scr, char *instance, char *class, - Bool noDefault) +wDefaultGetIconFile(WScreen *scr, char *instance, char *class, + Bool noDefault) { WMPropList *value; char *tmp; if (!ANoTitlebar) { - init_wdefaults(scr); + init_wdefaults(scr); } if (!WDWindowAttributes->dictionary) - return NULL; + return NULL; value = get_generic_value(scr, instance, class, AIcon, noDefault); if (!value) - return NULL; + return NULL; tmp = getString(AIcon, value); @@ -429,18 +429,18 @@ wDefaultGetImage(WScreen *scr, char *winstance, char *wclass) file_name = wDefaultGetIconFile(scr, winstance, wclass, False); if (!file_name) - return NULL; - + return NULL; + path = FindImage(wPreferences.icon_path, file_name); - + if (!path) { - wwarning(_("could not find icon file \"%s\""), file_name); - return NULL; + wwarning(_("could not find icon file \"%s\""), file_name); + return NULL; } - + image = RLoadImage(scr->rcontext, path, 0); if (!image) { - wwarning(_("error loading image file \"%s\""), path, RMessageForError(RErrorCode)); + wwarning(_("error loading image file \"%s\""), path, RMessageForError(RErrorCode)); } wfree(path); @@ -458,33 +458,33 @@ wDefaultGetStartWorkspace(WScreen *scr, char *instance, char *class) char *tmp; if (!ANoTitlebar) { - init_wdefaults(scr); + init_wdefaults(scr); } if (!WDWindowAttributes->dictionary) - return -1; + return -1; + + value = get_generic_value(scr, instance, class, AStartWorkspace, + False); - value = get_generic_value(scr, instance, class, AStartWorkspace, - False); - if (!value) - return -1; + return -1; tmp = getString(AStartWorkspace, value); if (!tmp || strlen(tmp)==0) - return -1; + return -1; if (sscanf(tmp, "%i", &w)!=1) { - w = -1; - for (i=0; i < scr->workspace_count; i++) { - if (strcmp(scr->workspaces[i]->name, tmp)==0) { - w = i; - break; - } - } + w = -1; + for (i=0; i < scr->workspace_count; i++) { + if (strcmp(scr->workspaces[i]->name, tmp)==0) { + w = i; + break; + } + } } else { - w--; + w--; } return w; @@ -511,7 +511,7 @@ wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file) WMPLSetCaseSensitive(True); if (instance && class) { - char *buffer; + char *buffer; buffer = wmalloc(strlen(instance) + strlen(class) + 2); sprintf(buffer, "%s.%s", instance, class); key = WMCreatePLString(buffer); @@ -562,31 +562,31 @@ wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file) /* --------------------------- Local ----------------------- */ -static int +static int getBool(WMPropList *key, WMPropList *value) { char *val; if (!WMIsPLString(value)) { - wwarning(_("Wrong option format for key \"%s\". Should be %s."), - WMGetFromPLString(key), "Boolean"); - return 0; + wwarning(_("Wrong option format for key \"%s\". Should be %s."), + WMGetFromPLString(key), "Boolean"); + return 0; } val = WMGetFromPLString(value); - - if ((val[1]=='\0' && (val[0]=='y' || val[0]=='Y' || val[0]=='T' - || val[0]=='t' || val[0]=='1')) - || (strcasecmp(val, "YES")==0 || strcasecmp(val, "TRUE")==0)) { - - return 1; - } else if ((val[1]=='\0' - && (val[0]=='n' || val[0]=='N' || val[0]=='F' - || val[0]=='f' || val[0]=='0')) - || (strcasecmp(val, "NO")==0 || strcasecmp(val, "FALSE")==0)) { - - return 0; + + if ((val[1]=='\0' && (val[0]=='y' || val[0]=='Y' || val[0]=='T' + || val[0]=='t' || val[0]=='1')) + || (strcasecmp(val, "YES")==0 || strcasecmp(val, "TRUE")==0)) { + + return 1; + } else if ((val[1]=='\0' + && (val[0]=='n' || val[0]=='N' || val[0]=='F' + || val[0]=='f' || val[0]=='0')) + || (strcasecmp(val, "NO")==0 || strcasecmp(val, "FALSE")==0)) { + + return 0; } else { - wwarning(_("can't convert \"%s\" to boolean"), val); + wwarning(_("can't convert \"%s\" to boolean"), val); /* We return False if we can't convert to BOOLEAN. * This is because all options defaults to False. * -1 is not checked and thus is interpreted as True, @@ -596,18 +596,16 @@ getBool(WMPropList *key, WMPropList *value) } - -/* - * WARNING: Do not free value returned by this!! - */ +/* WARNING: Do not free the value returned by this function!! */ static char* getString(WMPropList *key, WMPropList *value) -{ +{ if (!WMIsPLString(value)) { - wwarning(_("Wrong option format for key \"%s\". Should be %s."), - WMGetFromPLString(key), "String"); - return NULL; + wwarning(_("Wrong option format for key \"%s\". Should be %s."), + WMGetFromPLString(key), "String"); + return NULL; } - + return WMGetFromPLString(value); } + diff --git a/src/wdefaults.h b/src/wdefaults.h index a69c3c73..7954f21f 100644 --- a/src/wdefaults.h +++ b/src/wdefaults.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ diff --git a/src/window.c b/src/window.c index 9cc51af9..d93a4fc2 100644 --- a/src/window.c +++ b/src/window.c @@ -149,13 +149,13 @@ appearanceObserver(void *self, WMNotification *notif) int flags = (int)WMGetNotificationClientData(notif); if (!wwin->frame || (!wwin->frame->titlebar && !wwin->frame->resizebar)) - return; + return; if (flags & WFontSettings) { wWindowConfigureBorders(wwin); if(wwin->flags.shaded) { wFrameWindowResize(wwin->frame, wwin->frame->core->width, - wwin->frame->top_width - 1); + wwin->frame->top_width - 1); wwin->client.y = wwin->frame_y - wwin->client.height + wwin->frame->top_width; @@ -163,13 +163,13 @@ appearanceObserver(void *self, WMNotification *notif) } } if (flags & WTextureSettings) { - wwin->frame->flags.need_texture_remake = 1; + wwin->frame->flags.need_texture_remake = 1; } if (flags & (WTextureSettings | WColorSettings)) { - if (wwin->frame->titlebar) - XClearWindow(dpy, wwin->frame->titlebar->window); + if (wwin->frame->titlebar) + XClearWindow(dpy, wwin->frame->titlebar->window); - wFrameWindowPaint(wwin->frame); + wFrameWindowPaint(wwin->frame); } } @@ -181,17 +181,17 @@ wWindowFor(Window window) WObjDescriptor *desc; if (window==None) - return NULL; + return NULL; if (XFindContext(dpy, window, wWinContext, (XPointer*)&desc)==XCNOENT) - return NULL; + return NULL; if (desc->parent_type==WCLASS_WINDOW) - return desc->parent; + return desc->parent; else if (desc->parent_type==WCLASS_FRAME) { - WFrameWindow *frame = (WFrameWindow*)desc->parent; - if (frame->flags.is_client_window_frame) - return frame->child; + WFrameWindow *frame = (WFrameWindow*)desc->parent; + if (frame->flags.is_client_window_frame) + return frame->child; } return NULL; @@ -223,7 +223,7 @@ wWindowDestroy(WWindow *wwin) int i; if (wwin->screen_ptr->cmap_window == wwin) { - wwin->screen_ptr->cmap_window = NULL; + wwin->screen_ptr->cmap_window = NULL; } WMRemoveNotificationObserver(wwin); @@ -231,15 +231,15 @@ wWindowDestroy(WWindow *wwin) wwin->flags.destroyed = 1; for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) { - if (!wwin->screen_ptr->shortcutWindows[i]) - continue; + if (!wwin->screen_ptr->shortcutWindows[i]) + continue; - WMRemoveFromArray(wwin->screen_ptr->shortcutWindows[i], wwin); + WMRemoveFromArray(wwin->screen_ptr->shortcutWindows[i], wwin); - if (!WMGetArrayItemCount(wwin->screen_ptr->shortcutWindows[i])) { - WMFreeArray(wwin->screen_ptr->shortcutWindows[i]); - wwin->screen_ptr->shortcutWindows[i] = NULL; - } + if (!WMGetArrayItemCount(wwin->screen_ptr->shortcutWindows[i])) { + WMFreeArray(wwin->screen_ptr->shortcutWindows[i]); + wwin->screen_ptr->shortcutWindows[i] = NULL; + } } if (wwin->fake_group && wwin->fake_group->retainCount>0) { @@ -273,10 +273,10 @@ wWindowDestroy(WWindow *wwin) XDeleteContext(dpy, wwin->client_win, wWinContext); if (wwin->frame) - wFrameWindowDestroy(wwin->frame); + wFrameWindowDestroy(wwin->frame); if (wwin->icon) { - RemoveFromStackList(wwin->icon->core); + RemoveFromStackList(wwin->icon->core); wIconDestroy(wwin->icon); if (wPreferences.auto_arrange_icons) wArrangeIcons(wwin->screen_ptr, True); @@ -284,7 +284,7 @@ wWindowDestroy(WWindow *wwin) #ifdef NETWM_HINTS if (wwin->net_icon_image) - RReleaseImage(wwin->net_icon_image); + RReleaseImage(wwin->net_icon_image); #endif wrelease(wwin); @@ -295,81 +295,81 @@ static void setupGNUstepHints(WWindow *wwin, GNUstepWMAttributes *gs_hints) { if (gs_hints->flags & GSWindowStyleAttr) { - if (gs_hints->window_style == WMBorderlessWindowMask) { - wwin->client_flags.no_border = 1; - wwin->client_flags.no_titlebar = 1; - wwin->client_flags.no_closable = 1; - wwin->client_flags.no_miniaturizable = 1; - wwin->client_flags.no_resizable = 1; - wwin->client_flags.no_close_button = 1; - wwin->client_flags.no_miniaturize_button = 1; - wwin->client_flags.no_resizebar = 1; - } else { - wwin->client_flags.no_close_button = - ((gs_hints->window_style & WMClosableWindowMask)?0:1); - - wwin->client_flags.no_closable = - ((gs_hints->window_style & WMClosableWindowMask)?0:1); - - wwin->client_flags.no_miniaturize_button = - ((gs_hints->window_style & WMMiniaturizableWindowMask)?0:1); - - wwin->client_flags.no_miniaturizable = - wwin->client_flags.no_miniaturize_button; - - wwin->client_flags.no_resizebar = - ((gs_hints->window_style & WMResizableWindowMask)?0:1); - - wwin->client_flags.no_resizable = wwin->client_flags.no_resizebar; - - /* these attributes supposedly imply in the existence - * of a titlebar */ - if (gs_hints->window_style & (WMResizableWindowMask| - WMClosableWindowMask| - WMMiniaturizableWindowMask)) { - wwin->client_flags.no_titlebar = 0; - } else { - wwin->client_flags.no_titlebar = - ((gs_hints->window_style & WMTitledWindowMask)?0:1); - } - - } + if (gs_hints->window_style == WMBorderlessWindowMask) { + wwin->client_flags.no_border = 1; + wwin->client_flags.no_titlebar = 1; + wwin->client_flags.no_closable = 1; + wwin->client_flags.no_miniaturizable = 1; + wwin->client_flags.no_resizable = 1; + wwin->client_flags.no_close_button = 1; + wwin->client_flags.no_miniaturize_button = 1; + wwin->client_flags.no_resizebar = 1; + } else { + wwin->client_flags.no_close_button = + ((gs_hints->window_style & WMClosableWindowMask)?0:1); + + wwin->client_flags.no_closable = + ((gs_hints->window_style & WMClosableWindowMask)?0:1); + + wwin->client_flags.no_miniaturize_button = + ((gs_hints->window_style & WMMiniaturizableWindowMask)?0:1); + + wwin->client_flags.no_miniaturizable = + wwin->client_flags.no_miniaturize_button; + + wwin->client_flags.no_resizebar = + ((gs_hints->window_style & WMResizableWindowMask)?0:1); + + wwin->client_flags.no_resizable = wwin->client_flags.no_resizebar; + + /* these attributes supposedly imply in the existence + * of a titlebar */ + if (gs_hints->window_style & (WMResizableWindowMask| + WMClosableWindowMask| + WMMiniaturizableWindowMask)) { + wwin->client_flags.no_titlebar = 0; + } else { + wwin->client_flags.no_titlebar = + ((gs_hints->window_style & WMTitledWindowMask)?0:1); + } + + } } else { - /* setup the defaults */ - wwin->client_flags.no_border = 0; - wwin->client_flags.no_titlebar = 0; - wwin->client_flags.no_closable = 0; - wwin->client_flags.no_miniaturizable = 0; - wwin->client_flags.no_resizable = 0; - wwin->client_flags.no_close_button = 0; - wwin->client_flags.no_miniaturize_button = 0; - wwin->client_flags.no_resizebar = 0; + /* setup the defaults */ + wwin->client_flags.no_border = 0; + wwin->client_flags.no_titlebar = 0; + wwin->client_flags.no_closable = 0; + wwin->client_flags.no_miniaturizable = 0; + wwin->client_flags.no_resizable = 0; + wwin->client_flags.no_close_button = 0; + wwin->client_flags.no_miniaturize_button = 0; + wwin->client_flags.no_resizebar = 0; } if (gs_hints->extra_flags & GSNoApplicationIconFlag) { - wwin->client_flags.no_appicon = 1; + wwin->client_flags.no_appicon = 1; } } void wWindowCheckAttributeSanity(WWindow *wwin, WWindowAttributes *wflags, - WWindowAttributes *mask) + WWindowAttributes *mask) { if (wflags->no_appicon && mask->no_appicon) - wflags->emulate_appicon = 0; + wflags->emulate_appicon = 0; if (wwin->main_window!=None) { - WApplication *wapp = wApplicationOf(wwin->main_window); - if (wapp && !wapp->flags.emulated) - wflags->emulate_appicon = 0; + WApplication *wapp = wApplicationOf(wwin->main_window); + if (wapp && !wapp->flags.emulated) + wflags->emulate_appicon = 0; } if (wwin->transient_for!=None - && wwin->transient_for!=wwin->screen_ptr->root_win) - wflags->emulate_appicon = 0; + && wwin->transient_for!=wwin->screen_ptr->root_win) + wflags->emulate_appicon = 0; if (wflags->sunken && mask->sunken && wflags->floating && mask->floating) - wflags->sunken = 0; + wflags->sunken = 0; } @@ -381,7 +381,7 @@ wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace) /* sets global default stuff */ wDefaultFillAttributes(scr, wwin->wm_instance, wwin->wm_class, - &wwin->client_flags, NULL, True); + &wwin->client_flags, NULL, True); /* * Decoration setting is done in this precedence (lower to higher) * - use global default in the resource database @@ -393,14 +393,14 @@ wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace) WSETUFLAG(wwin, broken_close, 0); if (wwin->protocols.DELETE_WINDOW) - WSETUFLAG(wwin, kill_close, 0); + WSETUFLAG(wwin, kill_close, 0); else - WSETUFLAG(wwin, kill_close, 1); + WSETUFLAG(wwin, kill_close, 1); /* transients can't be iconified or maximized */ if (wwin->transient_for!=None && wwin->transient_for!=scr->root_win) { WSETUFLAG(wwin, no_miniaturizable, 1); - WSETUFLAG(wwin, no_miniaturize_button, 1); + WSETUFLAG(wwin, no_miniaturize_button, 1); } /* if the window can't be resized, remove the resizebar */ @@ -413,75 +413,75 @@ wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace) /* set GNUstep window attributes */ if (wwin->wm_gnustep_attr) { - setupGNUstepHints(wwin, wwin->wm_gnustep_attr); - - if (wwin->wm_gnustep_attr->flags & GSWindowLevelAttr) { - - *level = wwin->wm_gnustep_attr->window_level; - /* - * INT_MIN is the only illegal window level. - */ - if (*level == INT_MIN) - *level = INT_MIN + 1; - } else { - /* setup defaults */ - *level = WMNormalLevel; - } + setupGNUstepHints(wwin, wwin->wm_gnustep_attr); + + if (wwin->wm_gnustep_attr->flags & GSWindowLevelAttr) { + + *level = wwin->wm_gnustep_attr->window_level; + /* + * INT_MIN is the only illegal window level. + */ + if (*level == INT_MIN) + *level = INT_MIN + 1; + } else { + /* setup defaults */ + *level = WMNormalLevel; + } } else { - int tmp_workspace = -1; - int tmp_level = INT_MIN; /* INT_MIN is never used by the window levels */ - Bool check; + int tmp_workspace = -1; + int tmp_level = INT_MIN; /* INT_MIN is never used by the window levels */ + Bool check; - check = False; + check = False; #ifdef MWM_HINTS - wMWMCheckClientHints(wwin); + wMWMCheckClientHints(wwin); #endif /* MWM_HINTS */ #ifdef NETWM_HINTS - if (!check) - check = wNETWMCheckClientHints(wwin, &tmp_level, &tmp_workspace); + if (!check) + check = wNETWMCheckClientHints(wwin, &tmp_level, &tmp_workspace); #endif #ifdef GNOME_STUFF - if (!check) + if (!check) check = wGNOMECheckClientHints(wwin, &tmp_level, &tmp_workspace); #endif /* GNOME_STUFF */ #ifdef KWM_HINTS - if (!check) - check = wKWMCheckClientHints(wwin, &tmp_level, &tmp_workspace); + if (!check) + check = wKWMCheckClientHints(wwin, &tmp_level, &tmp_workspace); #endif /* KWM_HINTS */ #ifdef OLWM_HINTS - wOLWMCheckClientHints(wwin); + wOLWMCheckClientHints(wwin); #endif /* OLWM_HINTS */ /* window levels are between INT_MIN+1 and INT_MAX, so if we still * have INT_MIN that means that no window level was requested. -Dan */ - if (tmp_level == INT_MIN) { - if (WFLAGP(wwin, floating)) - *level = WMFloatingLevel; - else if (WFLAGP(wwin, sunken)) - *level = WMSunkenLevel; - else - *level = WMNormalLevel; - } else { - *level = tmp_level; - } - - if (wwin->transient_for!=None && wwin->transient_for != scr->root_win) { - WWindow * transientOwner = wWindowFor(wwin->transient_for); - if (transientOwner) { - int ownerLevel = transientOwner->frame->core->stacking->window_level; - if (ownerLevel > *level) *level = ownerLevel; - } - } - - if (tmp_workspace >= 0) { - *workspace = tmp_workspace % scr->workspace_count; - } + if (tmp_level == INT_MIN) { + if (WFLAGP(wwin, floating)) + *level = WMFloatingLevel; + else if (WFLAGP(wwin, sunken)) + *level = WMSunkenLevel; + else + *level = WMNormalLevel; + } else { + *level = tmp_level; + } + + if (wwin->transient_for!=None && wwin->transient_for != scr->root_win) { + WWindow * transientOwner = wWindowFor(wwin->transient_for); + if (transientOwner) { + int ownerLevel = transientOwner->frame->core->stacking->window_level; + if (ownerLevel > *level) *level = ownerLevel; + } + } + + if (tmp_workspace >= 0) { + *workspace = tmp_workspace % scr->workspace_count; + } } /* @@ -489,34 +489,34 @@ wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace) * This might do duplicate work with the 1st wDefaultFillAttributes(). */ wDefaultFillAttributes(scr, wwin->wm_instance, wwin->wm_class, - &wwin->user_flags, &wwin->defined_user_flags, - False); + &wwin->user_flags, &wwin->defined_user_flags, + False); /* * Sanity checks for attributes that depend on other attributes */ if (wwin->user_flags.no_appicon && wwin->defined_user_flags.no_appicon) - wwin->user_flags.emulate_appicon = 0; + wwin->user_flags.emulate_appicon = 0; if (wwin->main_window!=None) { - WApplication *wapp = wApplicationOf(wwin->main_window); - if (wapp && !wapp->flags.emulated) - wwin->user_flags.emulate_appicon = 0; + WApplication *wapp = wApplicationOf(wwin->main_window); + if (wapp && !wapp->flags.emulated) + wwin->user_flags.emulate_appicon = 0; } if (wwin->transient_for!=None - && wwin->transient_for!=wwin->screen_ptr->root_win) - wwin->user_flags.emulate_appicon = 0; + && wwin->transient_for!=wwin->screen_ptr->root_win) + wwin->user_flags.emulate_appicon = 0; if (wwin->user_flags.sunken && wwin->defined_user_flags.sunken - && wwin->user_flags.floating && wwin->defined_user_flags.floating) - wwin->user_flags.sunken = 0; + && wwin->user_flags.floating && wwin->defined_user_flags.floating) + wwin->user_flags.sunken = 0; WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar)); /* windows that have takefocus=False shouldn't take focus at all */ if (wwin->focus_mode == WFM_NO_INPUT) { - wwin->client_flags.no_focusable = 1; + wwin->client_flags.no_focusable = 1; } } @@ -527,11 +527,11 @@ Bool wWindowCanReceiveFocus(WWindow *wwin) { if (!wwin->flags.mapped && (!wwin->flags.shaded || wwin->flags.hidden)) - return False; + return False; if (WFLAGP(wwin, no_focusable) || wwin->flags.miniaturized) - return False; + return False; if (wwin->frame->workspace != wwin->screen_ptr->current_workspace) - return False; + return False; return True; } @@ -548,14 +548,14 @@ wWindowObscuresWindow(WWindow *wwin, WWindow *obscured) h2 = obscured->frame->core->height; if (!IS_OMNIPRESENT(wwin) && !IS_OMNIPRESENT(obscured) - && wwin->frame->workspace != obscured->frame->workspace) - return False; + && wwin->frame->workspace != obscured->frame->workspace) + return False; if (wwin->frame_x + w1 < obscured->frame_x - || wwin->frame_y + h1 < obscured->frame_y - || wwin->frame_x > obscured->frame_x + w2 - || wwin->frame_y > obscured->frame_y + h2) { - return False; + || wwin->frame_y + h1 < obscured->frame_y + || wwin->frame_x > obscured->frame_x + w2 + || wwin->frame_y > obscured->frame_y + h2) { + return False; } return True; @@ -727,33 +727,33 @@ wManageWindow(WScreen *scr, Window window) XSync(dpy, False); /* make sure the window is still there */ if (!XGetWindowAttributes(dpy, window, &wattribs)) { - XUngrabServer(dpy); - return NULL; + XUngrabServer(dpy); + return NULL; } /* if it's an override-redirect, ignore it */ if (wattribs.override_redirect) { - XUngrabServer(dpy); - return NULL; + XUngrabServer(dpy); + return NULL; } wm_state = PropGetWindowState(window); /* if it's startup and the window is unmapped, don't manage it */ if (scr->flags.startup && wm_state < 0 && wattribs.map_state==IsUnmapped) { - XUngrabServer(dpy); - return NULL; + XUngrabServer(dpy); + return NULL; } if (!wFetchName(dpy, window, &title)) { - title = NULL; + title = NULL; } #ifdef KWM_HINTS if (title && !wKWMManageableClient(scr, window, title)) { - XFree(title); - XUngrabServer(dpy); - return NULL; + XFree(title); + XUngrabServer(dpy); + return NULL; } #endif /* KWM_HINTS */ @@ -768,14 +768,14 @@ wManageWindow(WScreen *scr, Window window) #ifdef SHAPE if (wShapeSupported) { - int junk; - unsigned int ujunk; - int b_shaped; + int junk; + unsigned int ujunk; + int b_shaped; - XShapeSelectInput(dpy, window, ShapeNotifyMask); - XShapeQueryExtents(dpy, window, &b_shaped, &junk, &junk, &ujunk, - &ujunk, &junk, &junk, &junk, &ujunk, &ujunk); - wwin->flags.shaped = b_shaped; + XShapeSelectInput(dpy, window, ShapeNotifyMask); + XShapeQueryExtents(dpy, window, &b_shaped, &junk, &junk, &ujunk, + &ujunk, &junk, &junk, &junk, &ujunk, &ujunk); + wwin->flags.shaped = b_shaped; } #endif @@ -799,65 +799,65 @@ wManageWindow(WScreen *scr, Window window) attribs.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask; attribs.save_under = False; XChangeWindowAttributes(dpy, window, CWEventMask|CWDontPropagate - |CWSaveUnder, &attribs); + |CWSaveUnder, &attribs); XSetWindowBorderWidth(dpy, window, 0); /* get hints from GNUstep app */ if (wwin->wm_class != 0 && strcmp(wwin->wm_class, "GNUstep") == 0) { - wwin->flags.is_gnustep = 1; + wwin->flags.is_gnustep = 1; } if (!PropGetGNUstepWMAttr(window, &wwin->wm_gnustep_attr)) { - wwin->wm_gnustep_attr = NULL; + wwin->wm_gnustep_attr = NULL; } wwin->client_leader = PropGetClientLeader(window); if (wwin->client_leader!=None) - wwin->main_window = wwin->client_leader; + wwin->main_window = wwin->client_leader; wwin->wm_hints = XGetWMHints(dpy, window); if (wwin->wm_hints) { - if (wwin->wm_hints->flags & StateHint) { + if (wwin->wm_hints->flags & StateHint) { - if (wwin->wm_hints->initial_state == IconicState) { + if (wwin->wm_hints->initial_state == IconicState) { - wwin->flags.miniaturized = 1; + wwin->flags.miniaturized = 1; - } else if (wwin->wm_hints->initial_state == WithdrawnState) { + } else if (wwin->wm_hints->initial_state == WithdrawnState) { - withdraw = True; - } - } + withdraw = True; + } + } - if (wwin->wm_hints->flags & WindowGroupHint) { - wwin->group_id = wwin->wm_hints->window_group; - /* window_group has priority over CLIENT_LEADER */ - wwin->main_window = wwin->group_id; - } else { - wwin->group_id = None; - } + if (wwin->wm_hints->flags & WindowGroupHint) { + wwin->group_id = wwin->wm_hints->window_group; + /* window_group has priority over CLIENT_LEADER */ + wwin->main_window = wwin->group_id; + } else { + wwin->group_id = None; + } - if (wwin->wm_hints->flags & UrgencyHint) - wwin->flags.urgent = 1; + if (wwin->wm_hints->flags & UrgencyHint) + wwin->flags.urgent = 1; } else { - wwin->group_id = None; + wwin->group_id = None; } PropGetProtocols(window, &wwin->protocols); if (!XGetTransientForHint(dpy, window, &wwin->transient_for)) { - wwin->transient_for = None; + wwin->transient_for = None; } else { - if (wwin->transient_for==None || wwin->transient_for==window) { - wwin->transient_for = scr->root_win; - } else { - transientOwner = wWindowFor(wwin->transient_for); - if (transientOwner && transientOwner->main_window!=None) { - wwin->main_window = transientOwner->main_window; + if (wwin->transient_for==None || wwin->transient_for==window) { + wwin->transient_for = scr->root_win; + } else { + transientOwner = wWindowFor(wwin->transient_for); + if (transientOwner && transientOwner->main_window!=None) { + wwin->main_window = transientOwner->main_window; } /*else { - wwin->main_window = None; + wwin->main_window = None; }*/ - } + } } /* guess the focus mode */ @@ -866,7 +866,7 @@ wManageWindow(WScreen *scr, Window window) /* get geometry stuff */ wClientGetNormalHints(wwin, &wattribs, True, &x, &y, &width, &height); -/* printf("wManageWindow: %d %d %d %d\n", x, y, width, height);*/ + /* printf("wManageWindow: %d %d %d %d\n", x, y, width, height);*/ /* get colormap windows */ GetColormapWindows(wwin); @@ -884,25 +884,25 @@ wManageWindow(WScreen *scr, Window window) #ifdef OLWM_HINTS if (wwin->client_flags.olwm_transient && wwin->transient_for==None - && wwin->group_id != None && wwin->group_id != window) { + && wwin->group_id != None && wwin->group_id != window) { - transientOwner = wWindowFor(wwin->group_id); + transientOwner = wWindowFor(wwin->group_id); - if (transientOwner) { - wwin->transient_for = wwin->group_id; + if (transientOwner) { + wwin->transient_for = wwin->group_id; - /* transients can't be iconified or maximized */ - if (wwin->transient_for) { - WSETUFLAG(wwin, no_miniaturizable, 1); - WSETUFLAG(wwin, no_miniaturize_button, 1); - } - } + /* transients can't be iconified or maximized */ + if (wwin->transient_for) { + WSETUFLAG(wwin, no_miniaturizable, 1); + WSETUFLAG(wwin, no_miniaturize_button, 1); + } + } } #endif /* OLWM_HINTS */ /* Make broken apps behave as a nice app. */ if (WFLAGP(wwin, emulate_appicon)) { - wwin->main_window = wwin->client_win; + wwin->main_window = wwin->client_win; } fixLeaderProperties(wwin); @@ -932,7 +932,7 @@ wManageWindow(WScreen *scr, Window window) // only enter here if PropGetWMClass() succeds PropGetWMClass(wwin->main_window, &class, &instance); - buffer = StrConcatDot(instance, class); + buffer = StrConcatDot(instance, class); index = WMFindInArray(scr->fakeGroupLeaders, matchIdentifier, (void*)buffer); if (index != WANotFound) { @@ -1016,11 +1016,11 @@ wManageWindow(WScreen *scr, Window window) */ if (WFLAGP(wwin, start_miniaturized) && !WFLAGP(wwin, no_miniaturizable)) { - wwin->flags.miniaturized = 1; + wwin->flags.miniaturized = 1; } if (WFLAGP(wwin, start_maximized) && IS_RESIZABLE(wwin)) { - wwin->flags.maximized = MAX_VERTICAL|MAX_HORIZONTAL; + wwin->flags.maximized = MAX_VERTICAL|MAX_HORIZONTAL; } { @@ -1029,30 +1029,30 @@ wManageWindow(WScreen *scr, Window window) #endif #ifdef NETWM_HINTS - if (!bla) - bla = wNETWMCheckInitialClientState(wwin); + if (!bla) + bla = wNETWMCheckInitialClientState(wwin); #endif #ifdef GNOME_STUFF - if (!bla) + if (!bla) bla = wGNOMECheckInitialClientState(wwin); #endif #ifdef KWM_HINTS - if (!bla) - bla = wKWMCheckClientInitialState(wwin); + if (!bla) + bla = wKWMCheckClientInitialState(wwin); #endif } /* apply previous state if it exists and we're in startup */ if (scr->flags.startup && wm_state >= 0) { - if (wm_state == IconicState) { + if (wm_state == IconicState) { - wwin->flags.miniaturized = 1; + wwin->flags.miniaturized = 1; - } else if (wm_state == WithdrawnState) { + } else if (wm_state == WithdrawnState) { - withdraw = True; - } + withdraw = True; + } } /* if there is a saved state (from file), restore it */ @@ -1071,7 +1071,7 @@ wManageWindow(WScreen *scr, Window window) wwin->flags.shaded = win_state->state->shaded; if (win_state->state->miniaturized>0 && - !WFLAGP(wwin, no_miniaturizable)) { + !WFLAGP(wwin, no_miniaturizable)) { wwin->flags.miniaturized = win_state->state->miniaturized; } @@ -1093,84 +1093,84 @@ wManageWindow(WScreen *scr, Window window) /* if we're restarting, restore saved state (from hints). * This will overwrite previous */ { - WSavedState *wstate; - - if (getSavedState(window, &wstate)) { - wwin->flags.shaded = wstate->shaded; - wwin->flags.hidden = wstate->hidden; - wwin->flags.miniaturized = wstate->miniaturized; - wwin->flags.maximized = wstate->maximized; - if (wwin->flags.maximized) { - wwin->old_geometry.x = wstate->x; - wwin->old_geometry.y = wstate->y; - wwin->old_geometry.width = wstate->w; - wwin->old_geometry.height = wstate->h; - } - - workspace = wstate->workspace; - } else { - wstate = NULL; - } - - /* restore window shortcut */ - if (wstate != NULL || win_state != NULL) { - unsigned mask = 0; - - if (win_state != NULL) - mask = win_state->state->window_shortcuts; - - if (wstate != NULL && mask == 0) - mask = wstate->window_shortcuts; - - if (mask > 0) { - int i; - - for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) { - if (mask & (1<shortcutWindows[i]) - scr->shortcutWindows[i] = WMCreateArray(4); - - WMAddToArray(scr->shortcutWindows[i], wwin); - } - } - } - } - if (wstate != NULL) { - wfree(wstate); - } + WSavedState *wstate; + + if (getSavedState(window, &wstate)) { + wwin->flags.shaded = wstate->shaded; + wwin->flags.hidden = wstate->hidden; + wwin->flags.miniaturized = wstate->miniaturized; + wwin->flags.maximized = wstate->maximized; + if (wwin->flags.maximized) { + wwin->old_geometry.x = wstate->x; + wwin->old_geometry.y = wstate->y; + wwin->old_geometry.width = wstate->w; + wwin->old_geometry.height = wstate->h; + } + + workspace = wstate->workspace; + } else { + wstate = NULL; + } + + /* restore window shortcut */ + if (wstate != NULL || win_state != NULL) { + unsigned mask = 0; + + if (win_state != NULL) + mask = win_state->state->window_shortcuts; + + if (wstate != NULL && mask == 0) + mask = wstate->window_shortcuts; + + if (mask > 0) { + int i; + + for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) { + if (mask & (1<shortcutWindows[i]) + scr->shortcutWindows[i] = WMCreateArray(4); + + WMAddToArray(scr->shortcutWindows[i], wwin); + } + } + } + } + if (wstate != NULL) { + wfree(wstate); + } } /* don't let transients start miniaturized if their owners are not */ if (transientOwner && !transientOwner->flags.miniaturized - && wwin->flags.miniaturized && !withdraw) { - wwin->flags.miniaturized = 0; - if (wwin->wm_hints) - wwin->wm_hints->initial_state = NormalState; + && wwin->flags.miniaturized && !withdraw) { + wwin->flags.miniaturized = 0; + if (wwin->wm_hints) + wwin->wm_hints->initial_state = NormalState; } /* set workspace on which the window starts */ if (workspace >= 0) { - if (workspace > scr->workspace_count-1) { - workspace = workspace % scr->workspace_count; - } + if (workspace > scr->workspace_count-1) { + workspace = workspace % scr->workspace_count; + } } else { - int w; + int w; - w = wDefaultGetStartWorkspace(scr, wwin->wm_instance, wwin->wm_class); + w = wDefaultGetStartWorkspace(scr, wwin->wm_instance, wwin->wm_class); if (w >= 0 && w < scr->workspace_count && !(IS_OMNIPRESENT(wwin))) { workspace = w; } else { - if (wPreferences.open_transients_with_parent && transientOwner) { + if (wPreferences.open_transients_with_parent && transientOwner) { - workspace = transientOwner->frame->workspace; + workspace = transientOwner->frame->workspace; - } else { + } else { - workspace = scr->current_workspace; - } + workspace = scr->current_workspace; + } } } @@ -1186,132 +1186,132 @@ wManageWindow(WScreen *scr, Window window) * or if the window wants to start iconic. * If geometry was saved, restore it. */ { - Bool dontBring = False; - - if (win_state && win_state->state->w > 0) { - x = win_state->state->x; - y = win_state->state->y; - } else if ((wwin->transient_for==None - || wPreferences.window_placement!=WPM_MANUAL) - && !scr->flags.startup - && workspace == scr->current_workspace - && !wwin->flags.miniaturized - && !wwin->flags.maximized - && !(wwin->normal_hints->flags & (USPosition|PPosition))) { - - if (transientOwner && transientOwner->flags.mapped) { - int offs = WMAX(20, 2*transientOwner->frame->top_width); - WMRect rect; - int head; - - x = transientOwner->frame_x + - abs((transientOwner->frame->core->width - width)/2) + offs; - y = transientOwner->frame_y + - abs((transientOwner->frame->core->height - height)/3) + offs; - - /* - * limit transient windows to be inside their parent's head - */ - rect.pos.x = transientOwner->frame_x; - rect.pos.y = transientOwner->frame_y; - rect.size.width = transientOwner->frame->core->width; - rect.size.height = transientOwner->frame->core->height; - - head = wGetHeadForRect(scr, rect); - rect = wGetRectForHead(scr, head); - - if (x < rect.pos.x) - x = rect.pos.x; - else if (x + width > rect.pos.x + rect.size.width) - x = rect.pos.x + rect.size.width - width; - - if (y < rect.pos.y) - y = rect.pos.y; - else if (y + height > rect.pos.y + rect.size.height) - y = rect.pos.y + rect.size.height - height; - - } else { - PlaceWindow(wwin, &x, &y, width, height); - } + Bool dontBring = False; + + if (win_state && win_state->state->w > 0) { + x = win_state->state->x; + y = win_state->state->y; + } else if ((wwin->transient_for==None + || wPreferences.window_placement!=WPM_MANUAL) + && !scr->flags.startup + && workspace == scr->current_workspace + && !wwin->flags.miniaturized + && !wwin->flags.maximized + && !(wwin->normal_hints->flags & (USPosition|PPosition))) { + + if (transientOwner && transientOwner->flags.mapped) { + int offs = WMAX(20, 2*transientOwner->frame->top_width); + WMRect rect; + int head; + + x = transientOwner->frame_x + + abs((transientOwner->frame->core->width - width)/2) + offs; + y = transientOwner->frame_y + + abs((transientOwner->frame->core->height - height)/3) + offs; + + /* + * limit transient windows to be inside their parent's head + */ + rect.pos.x = transientOwner->frame_x; + rect.pos.y = transientOwner->frame_y; + rect.size.width = transientOwner->frame->core->width; + rect.size.height = transientOwner->frame->core->height; + + head = wGetHeadForRect(scr, rect); + rect = wGetRectForHead(scr, head); + + if (x < rect.pos.x) + x = rect.pos.x; + else if (x + width > rect.pos.x + rect.size.width) + x = rect.pos.x + rect.size.width - width; + + if (y < rect.pos.y) + y = rect.pos.y; + else if (y + height > rect.pos.y + rect.size.height) + y = rect.pos.y + rect.size.height - height; + + } else { + PlaceWindow(wwin, &x, &y, width, height); + } if (wPreferences.window_placement == WPM_MANUAL) { dontBring = True; } } else if (scr->xine_info.count && (wwin->normal_hints->flags & PPosition)) { - int head, flags; - WMRect rect; - int reposition = 0; - - /* - * Make spash screens come out in the center of a head - * trouble is that most splashies never get here - * they are managed trough atoms but god knows where. - * Dan, do you know ? -peter - * - * Most of them are not managed, they have set - * OverrideRedirect, which means we can't do anything about - * them. -alfredo - */ + int head, flags; + WMRect rect; + int reposition = 0; + + /* + * Make spash screens come out in the center of a head + * trouble is that most splashies never get here + * they are managed trough atoms but god knows where. + * Dan, do you know ? -peter + * + * Most of them are not managed, they have set + * OverrideRedirect, which means we can't do anything about + * them. -alfredo + */ #if 0 - printf("xinerama PPosition: x: %d %d\n", x, (scr->scr_width - width)/2); - printf("xinerama PPosition: y: %d %d\n", y, (scr->scr_height - height)/2); + printf("xinerama PPosition: x: %d %d\n", x, (scr->scr_width - width)/2); + printf("xinerama PPosition: y: %d %d\n", y, (scr->scr_height - height)/2); - if ((unsigned)(x + (width - scr->scr_width)/2 + 10) < 20 && + if ((unsigned)(x + (width - scr->scr_width)/2 + 10) < 20 && (unsigned)(y + (height - scr->scr_height)/2 + 10) < 20) { - reposition = 1; + reposition = 1; - } else + } else #endif - { - /* - * xinerama checks for: across head and dead space - */ - rect.pos.x = x; - rect.pos.y = y; - rect.size.width = width; - rect.size.height = height; - - head = wGetRectPlacementInfo(scr, rect, &flags); - - if (flags & XFLAG_DEAD) - reposition = 1; - - if (flags & XFLAG_MULTIPLE) - reposition = 2; - } + { + /* + * xinerama checks for: across head and dead space + */ + rect.pos.x = x; + rect.pos.y = y; + rect.size.width = width; + rect.size.height = height; + + head = wGetRectPlacementInfo(scr, rect, &flags); + + if (flags & XFLAG_DEAD) + reposition = 1; + + if (flags & XFLAG_MULTIPLE) + reposition = 2; + } - switch (reposition) { - case 1: - head = wGetHeadForPointerLocation(scr); - rect = wGetRectForHead(scr, head); + switch (reposition) { + case 1: + head = wGetHeadForPointerLocation(scr); + rect = wGetRectForHead(scr, head); - x = rect.pos.x + (x * rect.size.width)/scr->scr_width; - y = rect.pos.y + (y * rect.size.height)/scr->scr_height; - break; + x = rect.pos.x + (x * rect.size.width)/scr->scr_width; + y = rect.pos.y + (y * rect.size.height)/scr->scr_height; + break; - case 2: - rect = wGetRectForHead(scr, head); + case 2: + rect = wGetRectForHead(scr, head); - if (x < rect.pos.x) - x = rect.pos.x; - else if (x + width > rect.pos.x + rect.size.width) - x = rect.pos.x + rect.size.width - width; + if (x < rect.pos.x) + x = rect.pos.x; + else if (x + width > rect.pos.x + rect.size.width) + x = rect.pos.x + rect.size.width - width; - if (y < rect.pos.y) - y = rect.pos.y; - else if (y + height > rect.pos.y + rect.size.height) - y = rect.pos.y + rect.size.height - height; + if (y < rect.pos.y) + y = rect.pos.y; + else if (y + height > rect.pos.y + rect.size.height) + y = rect.pos.y + rect.size.height - height; - break; + break; - default: - break; - } - } + default: + break; + } + } - if (WFLAGP(wwin, dont_move_off) && dontBring) - wScreenBringInside(scr, &x, &y, width, height); + if (WFLAGP(wwin, dont_move_off) && dontBring) + wScreenBringInside(scr, &x, &y, width, height); } #ifdef NETWM_HINTS @@ -1319,8 +1319,8 @@ wManageWindow(WScreen *scr, Window window) #endif if (wwin->flags.urgent) { - if (!IS_OMNIPRESENT(wwin)) - wwin->flags.omnipresent ^= 1; + if (!IS_OMNIPRESENT(wwin)) + wwin->flags.omnipresent ^= 1; } /* @@ -1336,19 +1336,19 @@ wManageWindow(WScreen *scr, Window window) foo |= WFF_LANGUAGE_BUTTON; #endif if (HAS_TITLEBAR(wwin)) - foo |= WFF_TITLEBAR; + foo |= WFF_TITLEBAR; if (HAS_RESIZEBAR(wwin)) - foo |= WFF_RESIZEBAR; + foo |= WFF_RESIZEBAR; if (HAS_BORDER(wwin)) - foo |= WFF_BORDER; + foo |= WFF_BORDER; wwin->frame = wFrameWindowCreate(scr, window_level, - x, y, width, height, - &wPreferences.window_title_clearance, foo, - scr->window_title_texture, - scr->resizebar_texture, - scr->window_title_color, - &scr->title_font); + x, y, width, height, + &wPreferences.window_title_clearance, foo, + scr->window_title_texture, + scr->resizebar_texture, + scr->window_title_color, + &scr->title_font); wwin->frame->flags.is_client_window_frame = 1; wwin->frame->flags.justification = wPreferences.title_justification; @@ -1359,15 +1359,15 @@ wManageWindow(WScreen *scr, Window window) /* hide unused buttons */ foo = 0; if (WFLAGP(wwin, no_close_button)) - foo |= WFF_RIGHT_BUTTON; + foo |= WFF_RIGHT_BUTTON; if (WFLAGP(wwin, no_miniaturize_button)) - foo |= WFF_LEFT_BUTTON; + foo |= WFF_LEFT_BUTTON; #ifdef XKB_BUTTON_HINT if (WFLAGP(wwin, no_language_button) || WFLAGP(wwin, no_focusable)) foo |= WFF_LANGUAGE_BUTTON; #endif if (foo!=0) - wFrameWindowHideButton(wwin->frame, foo); + wFrameWindowHideButton(wwin->frame, foo); wwin->frame->child = wwin; @@ -1377,7 +1377,7 @@ wManageWindow(WScreen *scr, Window window) * revert to the normal position, which means the pin is pinned-in. */ if (wwin->flags.olwm_push_pin_out) - wFrameWindowUpdatePushButton(wwin->frame, True); + wFrameWindowUpdatePushButton(wwin->frame, True); #endif /* OLWM_HINTS */ @@ -1399,22 +1399,22 @@ wManageWindow(WScreen *scr, Window window) XSelectInput(dpy, wwin->client_win, - wwin->event_mask & ~StructureNotifyMask); + wwin->event_mask & ~StructureNotifyMask); XReparentWindow(dpy, wwin->client_win, wwin->frame->core->window, - 0, wwin->frame->top_width); + 0, wwin->frame->top_width); XSelectInput(dpy, wwin->client_win, wwin->event_mask); { - int gx, gy; + int gx, gy; - wClientGetGravityOffsets(wwin, &gx, &gy); + wClientGetGravityOffsets(wwin, &gx, &gy); - /* if gravity is to the south, account for the border sizes */ - if (gy > 0) - y -= wwin->frame->top_width + wwin->frame->bottom_width; + /* if gravity is to the south, account for the border sizes */ + if (gy > 0) + y -= wwin->frame->top_width + wwin->frame->bottom_width; } /* @@ -1437,17 +1437,17 @@ wManageWindow(WScreen *scr, Window window) */ if (wwin->main_window!=None) { - WApplication *app; - WWindow *leader; - - /* Leader windows do not necessary set themselves as leaders. - * If this is the case, point the leader of this window to - * itself */ - leader = wWindowFor(wwin->main_window); - if (leader && leader->main_window==None) { - leader->main_window = leader->client_win; - } - app = wApplicationCreate(wwin); + WApplication *app; + WWindow *leader; + + /* Leader windows do not necessary set themselves as leaders. + * If this is the case, point the leader of this window to + * itself */ + leader = wWindowFor(wwin->main_window); + if (leader && leader->main_window==None) { + leader->main_window = leader->client_win; + } + app = wApplicationCreate(wwin); if (app) { app->last_workspace = workspace; @@ -1483,7 +1483,7 @@ wManageWindow(WScreen *scr, Window window) /* if window is in this workspace and should be mapped, then map it */ if (!wwin->flags.miniaturized - && (workspace == scr->current_workspace || IS_OMNIPRESENT(wwin)) + && (workspace == scr->current_workspace || IS_OMNIPRESENT(wwin)) && !wwin->flags.hidden && !withdraw) { /* The following "if" is to avoid crashing of clients that expect @@ -1497,48 +1497,48 @@ wManageWindow(WScreen *scr, Window window) } #if 0 - /* if not auto focus, then map the window under the currently - * focused window */ + /* if not auto focus, then map the window under the currently + * focused window */ #define _WIDTH(w) (w)->frame->core->width #define _HEIGHT(w) (w)->frame->core->height - if (!wPreferences.auto_focus && scr->focused_window - && !scr->flags.startup && !transientOwner - && ((wWindowObscuresWindow(wwin, scr->focused_window) - && (_WIDTH(wwin) > (_WIDTH(scr->focused_window)*5)/3 - || _HEIGHT(wwin) > (_HEIGHT(scr->focused_window)*5)/3) - && WINDOW_LEVEL(scr->focused_window) == WINDOW_LEVEL(wwin)) - || wwin->flags.maximized)) { - MoveInStackListUnder(scr->focused_window->frame->core, - wwin->frame->core); - } + if (!wPreferences.auto_focus && scr->focused_window + && !scr->flags.startup && !transientOwner + && ((wWindowObscuresWindow(wwin, scr->focused_window) + && (_WIDTH(wwin) > (_WIDTH(scr->focused_window)*5)/3 + || _HEIGHT(wwin) > (_HEIGHT(scr->focused_window)*5)/3) + && WINDOW_LEVEL(scr->focused_window) == WINDOW_LEVEL(wwin)) + || wwin->flags.maximized)) { + MoveInStackListUnder(scr->focused_window->frame->core, + wwin->frame->core); + } #undef _WIDTH #undef _HEIGHT #endif - if (wPreferences.superfluous && !wPreferences.no_animations + if (wPreferences.superfluous && !wPreferences.no_animations && !scr->flags.startup && (wwin->transient_for==None || wwin->transient_for==scr->root_win) - /* - * The brain damaged idiotic non-click to focus modes will - * have trouble with this because: - * - * 1. window is created and mapped by the client - * 2. window is mapped by wmaker in small size - * 3. window is animated to grow to normal size - * 4. this function returns to normal event loop - * 5. eventually, the EnterNotify event that would trigger - * the window focusing (if the mouse is over that window) - * will be processed by wmaker. - * But since this event will be rather delayed - * (step 3 has a large delay) the time when the event ocurred - * and when it is processed, the client that owns that window - * will reject the XSetInputFocus() for it. - */ - && (wPreferences.focus_mode==WKF_CLICK - || wPreferences.auto_focus)) { - DoWindowBirth(wwin); - } + /* + * The brain damaged idiotic non-click to focus modes will + * have trouble with this because: + * + * 1. window is created and mapped by the client + * 2. window is mapped by wmaker in small size + * 3. window is animated to grow to normal size + * 4. this function returns to normal event loop + * 5. eventually, the EnterNotify event that would trigger + * the window focusing (if the mouse is over that window) + * will be processed by wmaker. + * But since this event will be rather delayed + * (step 3 has a large delay) the time when the event ocurred + * and when it is processed, the client that owns that window + * will reject the XSetInputFocus() for it. + */ + && (wPreferences.focus_mode==WKF_CLICK + || wPreferences.auto_focus)) { + DoWindowBirth(wwin); + } wWindowMap(wwin); } @@ -1547,25 +1547,25 @@ wManageWindow(WScreen *scr, Window window) if (transientOwner) { wwin->frame->core->stacking->child_of = transientOwner->frame->core; } else { - wwin->frame->core->stacking->child_of = NULL; + wwin->frame->core->stacking->child_of = NULL; } if (!scr->focused_window) { - /* first window on the list */ - wwin->next = NULL; - wwin->prev = NULL; - scr->focused_window = wwin; + /* first window on the list */ + wwin->next = NULL; + wwin->prev = NULL; + scr->focused_window = wwin; } else { - WWindow *tmp; + WWindow *tmp; - /* add window at beginning of focus window list */ - tmp = scr->focused_window; - while (tmp->prev) - tmp = tmp->prev; - tmp->prev = wwin; - wwin->next = tmp; - wwin->prev = NULL; + /* add window at beginning of focus window list */ + tmp = scr->focused_window; + while (tmp->prev) + tmp = tmp->prev; + tmp->prev = wwin; + wwin->next = tmp; + wwin->prev = NULL; } /* raise is set to true if we un-hid the app when this window was born. @@ -1577,7 +1577,7 @@ wManageWindow(WScreen *scr, Window window) /* Update name must come after WApplication stuff is done */ wWindowUpdateName(wwin, title); if (title) - XFree(title); + XFree(title); XUngrabServer(dpy); @@ -1593,15 +1593,15 @@ wManageWindow(WScreen *scr, Window window) if (!wwin->flags.miniaturized && workspace == scr->current_workspace - && !wwin->flags.hidden) { - if (((transientOwner && transientOwner->flags.focused) - || wPreferences.auto_focus) && !WFLAGP(wwin, no_focusable)) - wSetFocusTo(scr, wwin); + && !wwin->flags.hidden) { + if (((transientOwner && transientOwner->flags.focused) + || wPreferences.auto_focus) && !WFLAGP(wwin, no_focusable)) + wSetFocusTo(scr, wwin); } wWindowResetMouseGrabs(wwin); if (!WFLAGP(wwin, no_bind_keys)) { - wWindowSetKeyGrabs(wwin); + wWindowSetKeyGrabs(wwin); } @@ -1613,11 +1613,11 @@ wManageWindow(WScreen *scr, Window window) #ifdef OLWM_HINTS if (wwin->client_flags.olwm_warp_to_pin && wwin->frame->titlebar != NULL - && !WFLAGP(wwin, no_close_button) && !withdraw) { + && !WFLAGP(wwin, no_close_button) && !withdraw) { - XWarpPointer(dpy, None, None, 0, 0, 0, 0, - wwin->frame_x + width - wwin->frame->titlebar->height * 2, - wwin->frame_y); + XWarpPointer(dpy, None, None, 0, 0, 0, 0, + wwin->frame_x + width - wwin->frame->titlebar->height * 2, + wwin->frame_y); } #endif @@ -1627,7 +1627,7 @@ wManageWindow(WScreen *scr, Window window) *------------------------------------------------------------ */ WMAddNotificationObserver(appearanceObserver, wwin, - WNWindowAppearanceSettingsChanged, wwin); + WNWindowAppearanceSettingsChanged, wwin); /* @@ -1644,10 +1644,10 @@ wManageWindow(WScreen *scr, Window window) /* If the window must be withdrawed, then do it now. * Must do some optimization, 'though */ if (withdraw) { - wwin->flags.mapped = 0; - wClientSetState(wwin, WithdrawnState, None); - wUnmanageWindow(wwin, True, False); - wwin = NULL; + wwin->flags.mapped = 0; + wClientSetState(wwin, WithdrawnState, None); + wUnmanageWindow(wwin, True, False); + wwin = NULL; } return wwin; @@ -1659,7 +1659,7 @@ wManageWindow(WScreen *scr, Window window) WWindow* wManageInternalWindow(WScreen *scr, Window window, Window owner, - char *title, int x, int y, int width, int height) + char *title, int x, int y, int width, int height) { WWindow *wwin; int foo; @@ -1667,7 +1667,7 @@ wManageInternalWindow(WScreen *scr, Window window, Window owner, wwin = wWindowCreate(); WMAddNotificationObserver(appearanceObserver, wwin, - WNWindowAppearanceSettingsChanged, wwin); + WNWindowAppearanceSettingsChanged, wwin); wwin->flags.internal_window = 1; @@ -1699,13 +1699,13 @@ wManageInternalWindow(WScreen *scr, Window window, Window owner, #endif wwin->frame = wFrameWindowCreate(scr, WMFloatingLevel, - wwin->frame_x, wwin->frame_y, - width, height, - &wPreferences.window_title_clearance, foo, - scr->window_title_texture, - scr->resizebar_texture, - scr->window_title_color, - &scr->title_font); + wwin->frame_x, wwin->frame_y, + width, height, + &wPreferences.window_title_clearance, foo, + scr->window_title_texture, + scr->resizebar_texture, + scr->window_title_color, + &scr->title_font); XSaveContext(dpy, window, wWinContext, (XPointer)&wwin->client_descriptor); @@ -1738,10 +1738,10 @@ wManageInternalWindow(WScreen *scr, Window window, Window owner, wwin->client.y += wwin->frame->top_width; XReparentWindow(dpy, wwin->client_win, wwin->frame->core->window, - 0, wwin->frame->top_width); + 0, wwin->frame->top_width); wWindowConfigure(wwin, wwin->frame_x, wwin->frame_y, - wwin->client.width, wwin->client.height); + wwin->client.width, wwin->client.height); /* setup the frame descriptor */ wwin->frame->core->descriptor.handle_mousedown = frameMouseDown; @@ -1754,37 +1754,37 @@ wManageInternalWindow(WScreen *scr, Window window, Window owner, /* setup stacking descriptor */ if (wwin->transient_for!=None && wwin->transient_for!=scr->root_win) { - WWindow *tmp; - tmp = wWindowFor(wwin->transient_for); - if (tmp) - wwin->frame->core->stacking->child_of = tmp->frame->core; + WWindow *tmp; + tmp = wWindowFor(wwin->transient_for); + if (tmp) + wwin->frame->core->stacking->child_of = tmp->frame->core; } else { - wwin->frame->core->stacking->child_of = NULL; + wwin->frame->core->stacking->child_of = NULL; } if (!scr->focused_window) { - /* first window on the list */ - wwin->next = NULL; - wwin->prev = NULL; - scr->focused_window = wwin; + /* first window on the list */ + wwin->next = NULL; + wwin->prev = NULL; + scr->focused_window = wwin; } else { - WWindow *tmp; + WWindow *tmp; - /* add window at beginning of focus window list */ - tmp = scr->focused_window; - while (tmp->prev) - tmp = tmp->prev; - tmp->prev = wwin; - wwin->next = tmp; - wwin->prev = NULL; + /* add window at beginning of focus window list */ + tmp = scr->focused_window; + while (tmp->prev) + tmp = tmp->prev; + tmp->prev = wwin; + wwin->next = tmp; + wwin->prev = NULL; } if (wwin->flags.is_gnustep == 0) - wFrameWindowChangeState(wwin->frame, WS_UNFOCUSED); + wFrameWindowChangeState(wwin->frame, WS_UNFOCUSED); -/* if (wPreferences.auto_focus)*/ - wSetFocusTo(scr, wwin); + /* if (wPreferences.auto_focus)*/ + wSetFocusTo(scr, wwin); wWindowResetMouseGrabs(wwin); @@ -1819,22 +1819,22 @@ wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed) /* First close attribute editor window if open */ if (wwin->flags.inspector_open) { - wCloseInspectorForWindow(wwin); + wCloseInspectorForWindow(wwin); } /* Close window menu if it's open for this window */ if (wwin->flags.menu_open_for_me) { - CloseWindowMenu(scr); + CloseWindowMenu(scr); } if (!destroyed) { - if (!wwin->flags.internal_window) - XRemoveFromSaveSet(dpy, wwin->client_win); + if (!wwin->flags.internal_window) + XRemoveFromSaveSet(dpy, wwin->client_win); - XSelectInput(dpy, wwin->client_win, NoEventMask); + XSelectInput(dpy, wwin->client_win, NoEventMask); - XUngrabButton(dpy, AnyButton, AnyModifier, wwin->client_win); - XUngrabKey(dpy, AnyKey, AnyModifier, wwin->client_win); + XUngrabButton(dpy, AnyButton, AnyModifier, wwin->client_win); + XUngrabKey(dpy, AnyKey, AnyModifier, wwin->client_win); } XUnmapWindow(dpy, frame->window); @@ -1847,79 +1847,79 @@ wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed) /* remove all pending events on window */ /* I think this only matters for autoraise */ if (wPreferences.raise_delay) - WMDeleteTimerWithClientData(wwin->frame->core); + WMDeleteTimerWithClientData(wwin->frame->core); XFlush(dpy); /* reparent the window back to the root */ if (restore) - wClientRestore(wwin); + wClientRestore(wwin); if (wwin->transient_for!=scr->root_win) { - owner = wWindowFor(wwin->transient_for); - if (owner) { - if (!owner->flags.semi_focused) { - owner = NULL; - } else { - owner->flags.semi_focused = 0; - } - } + owner = wWindowFor(wwin->transient_for); + if (owner) { + if (!owner->flags.semi_focused) { + owner = NULL; + } else { + owner->flags.semi_focused = 0; + } + } } wasFocused = wwin->flags.focused; /* remove from window focus list */ if (!wwin->prev && !wwin->next) { - /* was the only window */ - scr->focused_window = NULL; - newFocusedWindow = NULL; + /* was the only window */ + scr->focused_window = NULL; + newFocusedWindow = NULL; } else { - WWindow *tmp; - - if (wwin->prev) - wwin->prev->next = wwin->next; - if (wwin->next) - wwin->next->prev = wwin->prev; - else { - scr->focused_window = wwin->prev; - scr->focused_window->next = NULL; - } - - if (wPreferences.focus_mode==WKF_CLICK) { - - /* if in click to focus mode and the window - * was a transient, focus the owner window - */ - tmp = NULL; - if (wPreferences.focus_mode==WKF_CLICK) { - tmp = wWindowFor(wwin->transient_for); - if (tmp && (!tmp->flags.mapped || WFLAGP(tmp, no_focusable))) { - tmp = NULL; - } - } - /* otherwise, focus the next one in the focus list */ - if (!tmp) { - tmp = scr->focused_window; - while (tmp) { /* look for one in the window list first */ - if (!WFLAGP(tmp, no_focusable) && !WFLAGP(tmp, skip_window_list) - && (tmp->flags.mapped || tmp->flags.shaded)) - break; - tmp = tmp->prev; - } - if (!tmp) { /* if unsuccessful, choose any focusable window */ - tmp = scr->focused_window; - while (tmp) { - if (!WFLAGP(tmp, no_focusable) - && (tmp->flags.mapped || tmp->flags.shaded)) - break; + WWindow *tmp; + + if (wwin->prev) + wwin->prev->next = wwin->next; + if (wwin->next) + wwin->next->prev = wwin->prev; + else { + scr->focused_window = wwin->prev; + scr->focused_window->next = NULL; + } + + if (wPreferences.focus_mode==WKF_CLICK) { + + /* if in click to focus mode and the window + * was a transient, focus the owner window + */ + tmp = NULL; + if (wPreferences.focus_mode==WKF_CLICK) { + tmp = wWindowFor(wwin->transient_for); + if (tmp && (!tmp->flags.mapped || WFLAGP(tmp, no_focusable))) { + tmp = NULL; + } + } + /* otherwise, focus the next one in the focus list */ + if (!tmp) { + tmp = scr->focused_window; + while (tmp) { /* look for one in the window list first */ + if (!WFLAGP(tmp, no_focusable) && !WFLAGP(tmp, skip_window_list) + && (tmp->flags.mapped || tmp->flags.shaded)) + break; tmp = tmp->prev; - } - } - } + } + if (!tmp) { /* if unsuccessful, choose any focusable window */ + tmp = scr->focused_window; + while (tmp) { + if (!WFLAGP(tmp, no_focusable) + && (tmp->flags.mapped || tmp->flags.shaded)) + break; + tmp = tmp->prev; + } + } + } - newFocusedWindow = tmp; + newFocusedWindow = tmp; - } else if (wPreferences.focus_mode==WKF_SLOPPY) { + } else if (wPreferences.focus_mode==WKF_SLOPPY) { unsigned int mask; int foo; Window bar, win; @@ -1934,27 +1934,27 @@ wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed) tmp = wWindowFor(win); if (tmp == wwin) tmp = NULL; - newFocusedWindow = tmp; + newFocusedWindow = tmp; } else { - newFocusedWindow = NULL; - } + newFocusedWindow = NULL; + } } if (!wwin->flags.internal_window) { - WMPostNotificationName(WMNUnmanaged, wwin, NULL); + WMPostNotificationName(WMNUnmanaged, wwin, NULL); } #ifdef DEBUG printf("destroying window %x frame %x\n", (unsigned)wwin->client_win, - (unsigned)frame->window); + (unsigned)frame->window); #endif if (wasFocused) { - if (newFocusedWindow != owner && owner) { - if (wwin->flags.is_gnustep == 0) - wFrameWindowChangeState(owner->frame, WS_UNFOCUSED); - } - wSetFocusTo(scr, newFocusedWindow); + if (newFocusedWindow != owner && owner) { + if (wwin->flags.is_gnustep == 0) + wFrameWindowChangeState(owner->frame, WS_UNFOCUSED); + } + wSetFocusTo(scr, newFocusedWindow); } wWindowDestroy(wwin); XFlush(dpy); @@ -1966,13 +1966,13 @@ wWindowMap(WWindow *wwin) { XMapWindow(dpy, wwin->frame->core->window); if (!wwin->flags.shaded) { - /* window will be remapped when getting MapNotify */ - XSelectInput(dpy, wwin->client_win, - wwin->event_mask & ~StructureNotifyMask); - XMapWindow(dpy, wwin->client_win); - XSelectInput(dpy, wwin->client_win, wwin->event_mask); + /* window will be remapped when getting MapNotify */ + XSelectInput(dpy, wwin->client_win, + wwin->event_mask & ~StructureNotifyMask); + XMapWindow(dpy, wwin->client_win); + XSelectInput(dpy, wwin->client_win, wwin->event_mask); - wwin->flags.mapped = 1; + wwin->flags.mapped = 1; } } @@ -1984,7 +1984,7 @@ wWindowUnmap(WWindow *wwin) /* prevent window withdrawal when getting UnmapNotify */ XSelectInput(dpy, wwin->client_win, - wwin->event_mask & ~StructureNotifyMask); + wwin->event_mask & ~StructureNotifyMask); XUnmapWindow(dpy, wwin->client_win); XSelectInput(dpy, wwin->client_win, wwin->event_mask); @@ -2008,7 +2008,7 @@ wWindowFocus(WWindow *wwin, WWindow *owin) wwin->flags.semi_focused = 0; if (wwin->flags.is_gnustep == 0) - wFrameWindowChangeState(wwin->frame, WS_FOCUSED); + wFrameWindowChangeState(wwin->frame, WS_FOCUSED); wwin->flags.focused = 1; @@ -2017,38 +2017,38 @@ wWindowFocus(WWindow *wwin, WWindow *owin) WMPostNotificationName(WMNChangedFocus, wwin, (void*)True); if (owin == wwin || !owin) - return; + return; nowner = wWindowFor(wwin->transient_for); /* new window is a transient for the old window */ if (nowner == owin) { - owin->flags.semi_focused = 1; - wWindowUnfocus(nowner); - return; + owin->flags.semi_focused = 1; + wWindowUnfocus(nowner); + return; } oowner = wWindowFor(owin->transient_for); /* new window is owner of old window */ if (wwin == oowner) { - wWindowUnfocus(owin); - return; + wWindowUnfocus(owin); + return; } if (!nowner) { - wWindowUnfocus(owin); - return; + wWindowUnfocus(owin); + return; } /* new window has same owner of old window */ if (oowner == nowner) { - /* prevent unfocusing of owner */ - oowner->flags.semi_focused = 0; - wWindowUnfocus(owin); - oowner->flags.semi_focused = 1; + /* prevent unfocusing of owner */ + oowner->flags.semi_focused = 0; + wWindowUnfocus(owin); + oowner->flags.semi_focused = 1; - return; + return; } /* nowner != NULL && oowner != nowner */ @@ -2064,20 +2064,20 @@ wWindowUnfocus(WWindow *wwin) CloseWindowMenu(wwin->screen_ptr); if (wwin->flags.is_gnustep == 0) - wFrameWindowChangeState(wwin->frame, wwin->flags.semi_focused - ? WS_PFOCUSED : WS_UNFOCUSED); + wFrameWindowChangeState(wwin->frame, wwin->flags.semi_focused + ? WS_PFOCUSED : WS_UNFOCUSED); if (wwin->transient_for!=None - && wwin->transient_for!=wwin->screen_ptr->root_win) { - WWindow *owner; - owner = wWindowFor(wwin->transient_for); - if (owner && owner->flags.semi_focused) { - owner->flags.semi_focused = 0; - if (owner->flags.mapped || owner->flags.shaded) { - wWindowUnfocus(owner); - wFrameWindowPaint(owner->frame); - } - } + && wwin->transient_for!=wwin->screen_ptr->root_win) { + WWindow *owner; + owner = wWindowFor(wwin->transient_for); + if (owner && owner->flags.semi_focused) { + owner->flags.semi_focused = 0; + if (owner->flags.mapped || owner->flags.shaded) { + wWindowUnfocus(owner); + wFrameWindowPaint(owner->frame); + } + } } wwin->flags.focused = 0; @@ -2093,19 +2093,19 @@ wWindowUpdateName(WWindow *wwin, char *newTitle) char *title; if (!wwin->frame) - return; + return; wwin->flags.wm_name_changed = 1; if (!newTitle) { - /* the hint was removed */ - title = DEF_WINDOW_TITLE; + /* the hint was removed */ + title = DEF_WINDOW_TITLE; } else { - title = newTitle; + title = newTitle; } if (wFrameWindowChangeTitle(wwin->frame, title)) { - WMPostNotificationName(WMNChangedName, wwin, NULL); + WMPostNotificationName(WMNChangedName, wwin, NULL); } } @@ -2140,110 +2140,110 @@ wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight) int baseH = 0; if (wwin->normal_hints) { - winc = wwin->normal_hints->width_inc; - hinc = wwin->normal_hints->height_inc; - minW = wwin->normal_hints->min_width; - minH = wwin->normal_hints->min_height; - maxW = wwin->normal_hints->max_width; - maxH = wwin->normal_hints->max_height; - if (wwin->normal_hints->flags & PAspect) { - minAX = wwin->normal_hints->min_aspect.x; - minAY = wwin->normal_hints->min_aspect.y; - maxAX = wwin->normal_hints->max_aspect.x; - maxAY = wwin->normal_hints->max_aspect.y; - } - - baseW = wwin->normal_hints->base_width; - baseH = wwin->normal_hints->base_height; + winc = wwin->normal_hints->width_inc; + hinc = wwin->normal_hints->height_inc; + minW = wwin->normal_hints->min_width; + minH = wwin->normal_hints->min_height; + maxW = wwin->normal_hints->max_width; + maxH = wwin->normal_hints->max_height; + if (wwin->normal_hints->flags & PAspect) { + minAX = wwin->normal_hints->min_aspect.x; + minAY = wwin->normal_hints->min_aspect.y; + maxAX = wwin->normal_hints->max_aspect.x; + maxAY = wwin->normal_hints->max_aspect.y; + } + + baseW = wwin->normal_hints->base_width; + baseH = wwin->normal_hints->base_height; } if (width < minW) - width = minW; + width = minW; if (height < minH) - height = minH; + height = minH; if (width > maxW) - width = maxW; + width = maxW; if (height > maxH) - height = maxH; + height = maxH; /* aspect ratio code borrowed from olwm */ if (minAX > 0) { - /* adjust max aspect ratio */ - if (!(maxAX == 1 && maxAY == 1) && width * maxAY > height * maxAX) { - if (maxAX > maxAY) { - height = (width * maxAY) / maxAX; - if (height > maxH) { - height = maxH; - width = (height * maxAX) / maxAY; - } - } else { - width = (height * maxAX) / maxAY; - if (width > maxW) { - width = maxW; - height = (width * maxAY) / maxAX; - } - } - } - - /* adjust min aspect ratio */ - if (!(minAX == 1 && minAY == 1) && width * minAY < height * minAX) { - if (minAX > minAY) { - height = (width * minAY) / minAX; - if (height < minH) { - height = minH; - width = (height * minAX) / minAY; - } - } else { - width = (height * minAX) / minAY; - if (width < minW) { - width = minW; - height = (width * minAY) / minAX; - } - } - } + /* adjust max aspect ratio */ + if (!(maxAX == 1 && maxAY == 1) && width * maxAY > height * maxAX) { + if (maxAX > maxAY) { + height = (width * maxAY) / maxAX; + if (height > maxH) { + height = maxH; + width = (height * maxAX) / maxAY; + } + } else { + width = (height * maxAX) / maxAY; + if (width > maxW) { + width = maxW; + height = (width * maxAY) / maxAX; + } + } + } + + /* adjust min aspect ratio */ + if (!(minAX == 1 && minAY == 1) && width * minAY < height * minAX) { + if (minAX > minAY) { + height = (width * minAY) / minAX; + if (height < minH) { + height = minH; + width = (height * minAX) / minAY; + } + } else { + width = (height * minAX) / minAY; + if (width < minW) { + width = minW; + height = (width * minAY) / minAX; + } + } + } } if (baseW != 0) { - width = (((width - baseW) / winc) * winc) + baseW; + width = (((width - baseW) / winc) * winc) + baseW; } else { - width = (((width - minW) / winc) * winc) + minW; + width = (((width - minW) / winc) * winc) + minW; } if (baseH != 0) { - height = (((height - baseH) / hinc) * hinc) + baseH; + height = (((height - baseH) / hinc) * hinc) + baseH; } else { - height = (((height - minH) / hinc) * hinc) + minH; + height = (((height - minH) / hinc) * hinc) + minH; } /* broken stupid apps may cause preposterous values for these.. */ if (width > 0) - *nwidth = width; + *nwidth = width; if (height > 0) - *nheight = height; + *nheight = height; } void wWindowCropSize(WWindow *wwin, int maxW, int maxH, - int *width, int *height) + int *width, int *height) { int baseW = 0, baseH = 0; int winc = 1, hinc = 1; if (wwin->normal_hints) { - baseW = wwin->normal_hints->base_width; - baseH = wwin->normal_hints->base_height; + baseW = wwin->normal_hints->base_width; + baseH = wwin->normal_hints->base_height; - winc = wwin->normal_hints->width_inc; - hinc = wwin->normal_hints->height_inc; + winc = wwin->normal_hints->width_inc; + hinc = wwin->normal_hints->height_inc; } if (*width > maxW) - *width = maxW - (maxW - baseW) % winc; + *width = maxW - (maxW - baseW) % winc; if (*height > maxH) - *height = maxH - (maxH - baseH) % hinc; + *height = maxH - (maxH - baseH) % hinc; } @@ -2255,52 +2255,52 @@ wWindowChangeWorkspace(WWindow *wwin, int workspace) int unmap = 0; if (workspace >= scr->workspace_count || workspace < 0 - || workspace == wwin->frame->workspace) - return; + || workspace == wwin->frame->workspace) + return; if (workspace != scr->current_workspace) { - /* Sent to other workspace. Unmap window */ - if ((wwin->flags.mapped - || wwin->flags.shaded - || (wwin->flags.miniaturized && !wPreferences.sticky_icons)) - && !IS_OMNIPRESENT(wwin) && !wwin->flags.changing_workspace) { - - wapp = wApplicationOf(wwin->main_window); - if (wapp) { - wapp->last_workspace = workspace; - } - if (wwin->flags.miniaturized) { - if (wwin->icon) { - XUnmapWindow(dpy, wwin->icon->core->window); - wwin->icon->mapped = 0; - } - } else { - unmap = 1; - wSetFocusTo(scr, NULL); - } - } + /* Sent to other workspace. Unmap window */ + if ((wwin->flags.mapped + || wwin->flags.shaded + || (wwin->flags.miniaturized && !wPreferences.sticky_icons)) + && !IS_OMNIPRESENT(wwin) && !wwin->flags.changing_workspace) { + + wapp = wApplicationOf(wwin->main_window); + if (wapp) { + wapp->last_workspace = workspace; + } + if (wwin->flags.miniaturized) { + if (wwin->icon) { + XUnmapWindow(dpy, wwin->icon->core->window); + wwin->icon->mapped = 0; + } + } else { + unmap = 1; + wSetFocusTo(scr, NULL); + } + } } else { - /* brought to current workspace. Map window */ - if (wwin->flags.miniaturized && !wPreferences.sticky_icons) { - if (wwin->icon) { - XMapWindow(dpy, wwin->icon->core->window); - wwin->icon->mapped = 1; - } - } else if (!wwin->flags.mapped && - !(wwin->flags.miniaturized || wwin->flags.hidden)) { - wWindowMap(wwin); - } + /* brought to current workspace. Map window */ + if (wwin->flags.miniaturized && !wPreferences.sticky_icons) { + if (wwin->icon) { + XMapWindow(dpy, wwin->icon->core->window); + wwin->icon->mapped = 1; + } + } else if (!wwin->flags.mapped && + !(wwin->flags.miniaturized || wwin->flags.hidden)) { + wWindowMap(wwin); + } } if (!IS_OMNIPRESENT(wwin)) { - int oldWorkspace = wwin->frame->workspace; + int oldWorkspace = wwin->frame->workspace; - wwin->frame->workspace = workspace; + wwin->frame->workspace = workspace; - WMPostNotificationName(WMNChangedWorkspace, wwin, (void*)oldWorkspace); + WMPostNotificationName(WMNChangedWorkspace, wwin, (void*)oldWorkspace); } if (unmap) { - wWindowUnmap(wwin); + wWindowUnmap(wwin); } } @@ -2322,7 +2322,7 @@ wWindowSynthConfigureNotify(WWindow *wwin) sevent.xconfigure.border_width = wwin->old_border_width; if (!HAS_TITLEBAR(wwin)) - sevent.xconfigure.above = None; + sevent.xconfigure.above = None; else sevent.xconfigure.above = wwin->frame->titlebar->window; @@ -2364,74 +2364,74 @@ int req_width, req_height; /* new size of the client */ int resize; resize = (req_width!=wwin->client.width - || req_height!=wwin->client.height); + || req_height!=wwin->client.height); /* * if the window is being moved but not resized then * send a synthetic ConfigureNotify */ if ((req_x!=wwin->frame_x || req_y!=wwin->frame_y) && !resize) { - synth_notify = True; + synth_notify = True; } if (WFLAGP(wwin, dont_move_off)) - wScreenBringInside(wwin->screen_ptr, &req_x, &req_y, - req_width, req_height); + wScreenBringInside(wwin->screen_ptr, &req_x, &req_y, + req_width, req_height); if (resize) { - if (req_width < MIN_WINDOW_SIZE) - req_width = MIN_WINDOW_SIZE; - if (req_height < MIN_WINDOW_SIZE) - req_height = MIN_WINDOW_SIZE; - - /* If growing, resize inner part before frame, - * if shrinking, resize frame before. - * This will prevent the frame (that can have a different color) - * to be exposed, causing flicker */ - if (req_height > wwin->frame->core->height - || req_width > wwin->frame->core->width) - XResizeWindow(dpy, wwin->client_win, req_width, req_height); - - if (wwin->flags.shaded) { - wFrameWindowConfigure(wwin->frame, req_x, req_y, - req_width, wwin->frame->core->height); - wwin->old_geometry.height = req_height; - } else { - int h; - - h = req_height + wwin->frame->top_width - + wwin->frame->bottom_width; - - wFrameWindowConfigure(wwin->frame, req_x, req_y, req_width, h); - } - - if (!(req_height > wwin->frame->core->height - || req_width > wwin->frame->core->width)) - XResizeWindow(dpy, wwin->client_win, req_width, req_height); - - wwin->client.x = req_x; - wwin->client.y = req_y + wwin->frame->top_width; - wwin->client.width = req_width; - wwin->client.height = req_height; + if (req_width < MIN_WINDOW_SIZE) + req_width = MIN_WINDOW_SIZE; + if (req_height < MIN_WINDOW_SIZE) + req_height = MIN_WINDOW_SIZE; + + /* If growing, resize inner part before frame, + * if shrinking, resize frame before. + * This will prevent the frame (that can have a different color) + * to be exposed, causing flicker */ + if (req_height > wwin->frame->core->height + || req_width > wwin->frame->core->width) + XResizeWindow(dpy, wwin->client_win, req_width, req_height); + + if (wwin->flags.shaded) { + wFrameWindowConfigure(wwin->frame, req_x, req_y, + req_width, wwin->frame->core->height); + wwin->old_geometry.height = req_height; + } else { + int h; + + h = req_height + wwin->frame->top_width + + wwin->frame->bottom_width; + + wFrameWindowConfigure(wwin->frame, req_x, req_y, req_width, h); + } + + if (!(req_height > wwin->frame->core->height + || req_width > wwin->frame->core->width)) + XResizeWindow(dpy, wwin->client_win, req_width, req_height); + + wwin->client.x = req_x; + wwin->client.y = req_y + wwin->frame->top_width; + wwin->client.width = req_width; + wwin->client.height = req_height; } else { - wwin->client.x = req_x; - wwin->client.y = req_y + wwin->frame->top_width; + wwin->client.x = req_x; + wwin->client.y = req_y + wwin->frame->top_width; - XMoveWindow(dpy, wwin->frame->core->window, req_x, req_y); + XMoveWindow(dpy, wwin->frame->core->window, req_x, req_y); } wwin->frame_x = req_x; wwin->frame_y = req_y; if (HAS_BORDER(wwin)) { - wwin->client.x += FRAME_BORDER_WIDTH; - wwin->client.y += FRAME_BORDER_WIDTH; + wwin->client.x += FRAME_BORDER_WIDTH; + wwin->client.y += FRAME_BORDER_WIDTH; } #ifdef SHAPE if (wShapeSupported && wwin->flags.shaped && resize) { - wWindowSetShape(wwin); + wWindowSetShape(wwin); } #endif if (synth_notify) - wWindowSynthConfigureNotify(wwin); + wWindowSynthConfigureNotify(wwin); XFlush(dpy); } @@ -2446,7 +2446,7 @@ int req_x, req_y; /* new position of the frame */ /* Send a synthetic ConfigureNotify event for every window movement. */ if ((req_x!=wwin->frame_x || req_y!=wwin->frame_y)) { - synth_notify = True; + synth_notify = True; } #else /* A single synthetic ConfigureNotify event is sent at the end of @@ -2454,14 +2454,14 @@ int req_x, req_y; /* new position of the frame */ #endif if (WFLAGP(wwin, dont_move_off)) - wScreenBringInside(wwin->screen_ptr, &req_x, &req_y, - wwin->frame->core->width, wwin->frame->core->height); + wScreenBringInside(wwin->screen_ptr, &req_x, &req_y, + wwin->frame->core->width, wwin->frame->core->height); wwin->client.x = req_x; wwin->client.y = req_y + wwin->frame->top_width; if (HAS_BORDER(wwin)) { - wwin->client.x += FRAME_BORDER_WIDTH; - wwin->client.y += FRAME_BORDER_WIDTH; + wwin->client.x += FRAME_BORDER_WIDTH; + wwin->client.y += FRAME_BORDER_WIDTH; } XMoveWindow(dpy, wwin->frame->core->window, req_x, req_y); @@ -2471,7 +2471,7 @@ int req_x, req_y; /* new position of the frame */ #ifdef CONFIGURE_WINDOW_WHILE_MOVING if (synth_notify) - wWindowSynthConfigureNotify(wwin); + wWindowSynthConfigureNotify(wwin); #endif } @@ -2484,39 +2484,39 @@ wWindowUpdateButtonImages(WWindow *wwin) WFrameWindow *fwin = wwin->frame; if (!HAS_TITLEBAR(wwin)) - return; + return; /* miniaturize button */ if (!WFLAGP(wwin, no_miniaturize_button)) { - if (wwin->wm_gnustep_attr - && wwin->wm_gnustep_attr->flags & GSMiniaturizePixmapAttr) { - pixmap = wwin->wm_gnustep_attr->miniaturize_pixmap; - - if (wwin->wm_gnustep_attr->flags&GSMiniaturizeMaskAttr) { - mask = wwin->wm_gnustep_attr->miniaturize_mask; - } else { - mask = None; - } - - if (fwin->lbutton_image - && (fwin->lbutton_image->image != pixmap - || fwin->lbutton_image->mask != mask)) { - wPixmapDestroy(fwin->lbutton_image); - fwin->lbutton_image = NULL; - } - - if (!fwin->lbutton_image) { - fwin->lbutton_image = wPixmapCreate(scr, pixmap, mask); - fwin->lbutton_image->client_owned = 1; - fwin->lbutton_image->client_owned_mask = 1; - } - } else { - if (fwin->lbutton_image && !fwin->lbutton_image->shared) { - wPixmapDestroy(fwin->lbutton_image); - } - fwin->lbutton_image = scr->b_pixmaps[WBUT_ICONIFY]; - } + if (wwin->wm_gnustep_attr + && wwin->wm_gnustep_attr->flags & GSMiniaturizePixmapAttr) { + pixmap = wwin->wm_gnustep_attr->miniaturize_pixmap; + + if (wwin->wm_gnustep_attr->flags&GSMiniaturizeMaskAttr) { + mask = wwin->wm_gnustep_attr->miniaturize_mask; + } else { + mask = None; + } + + if (fwin->lbutton_image + && (fwin->lbutton_image->image != pixmap + || fwin->lbutton_image->mask != mask)) { + wPixmapDestroy(fwin->lbutton_image); + fwin->lbutton_image = NULL; + } + + if (!fwin->lbutton_image) { + fwin->lbutton_image = wPixmapCreate(scr, pixmap, mask); + fwin->lbutton_image->client_owned = 1; + fwin->lbutton_image->client_owned_mask = 1; + } + } else { + if (fwin->lbutton_image && !fwin->lbutton_image->shared) { + wPixmapDestroy(fwin->lbutton_image); + } + fwin->lbutton_image = scr->b_pixmaps[WBUT_ICONIFY]; + } } #ifdef XKB_BUTTON_HINT @@ -2537,47 +2537,47 @@ wWindowUpdateButtonImages(WWindow *wwin) if (!WFLAGP(wwin, no_close_button)) { if (wwin->wm_gnustep_attr - && wwin->wm_gnustep_attr->flags & GSClosePixmapAttr) { + && wwin->wm_gnustep_attr->flags & GSClosePixmapAttr) { pixmap = wwin->wm_gnustep_attr->close_pixmap; if (wwin->wm_gnustep_attr->flags&GSCloseMaskAttr) - mask = wwin->wm_gnustep_attr->close_mask; + mask = wwin->wm_gnustep_attr->close_mask; else - mask = None; + mask = None; - if (fwin->rbutton_image && (fwin->rbutton_image->image != pixmap - || fwin->rbutton_image->mask != mask)) { - wPixmapDestroy(fwin->rbutton_image); - fwin->rbutton_image = NULL; - } + if (fwin->rbutton_image && (fwin->rbutton_image->image != pixmap + || fwin->rbutton_image->mask != mask)) { + wPixmapDestroy(fwin->rbutton_image); + fwin->rbutton_image = NULL; + } - if (!fwin->rbutton_image) { - fwin->rbutton_image = wPixmapCreate(scr, pixmap, mask); - fwin->rbutton_image->client_owned = 1; - fwin->rbutton_image->client_owned_mask = 1; - } + if (!fwin->rbutton_image) { + fwin->rbutton_image = wPixmapCreate(scr, pixmap, mask); + fwin->rbutton_image->client_owned = 1; + fwin->rbutton_image->client_owned_mask = 1; + } - } else if (WFLAGP(wwin, kill_close)) { + } else if (WFLAGP(wwin, kill_close)) { - if (fwin->rbutton_image && !fwin->rbutton_image->shared) - wPixmapDestroy(fwin->rbutton_image); + if (fwin->rbutton_image && !fwin->rbutton_image->shared) + wPixmapDestroy(fwin->rbutton_image); - fwin->rbutton_image = scr->b_pixmaps[WBUT_KILL]; + fwin->rbutton_image = scr->b_pixmaps[WBUT_KILL]; - } else if (MGFLAGP(wwin, broken_close)) { + } else if (MGFLAGP(wwin, broken_close)) { - if (fwin->rbutton_image && !fwin->rbutton_image->shared) - wPixmapDestroy(fwin->rbutton_image); + if (fwin->rbutton_image && !fwin->rbutton_image->shared) + wPixmapDestroy(fwin->rbutton_image); - fwin->rbutton_image = scr->b_pixmaps[WBUT_BROKENCLOSE]; + fwin->rbutton_image = scr->b_pixmaps[WBUT_BROKENCLOSE]; - } else { + } else { - if (fwin->rbutton_image && !fwin->rbutton_image->shared) - wPixmapDestroy(fwin->rbutton_image); + if (fwin->rbutton_image && !fwin->rbutton_image->shared) + wPixmapDestroy(fwin->rbutton_image); - fwin->rbutton_image = scr->b_pixmaps[WBUT_CLOSE]; - } + fwin->rbutton_image = scr->b_pixmaps[WBUT_CLOSE]; + } } /* force buttons to be redrawn */ @@ -2597,38 +2597,38 @@ void wWindowConfigureBorders(WWindow *wwin) { if (wwin->frame) { - int flags; - int newy, oldh; + int flags; + int newy, oldh; - flags = WFF_LEFT_BUTTON|WFF_RIGHT_BUTTON; + flags = WFF_LEFT_BUTTON|WFF_RIGHT_BUTTON; #ifdef XKB_BUTTON_HINT flags |= WFF_LANGUAGE_BUTTON; #endif if (HAS_TITLEBAR(wwin)) - flags |= WFF_TITLEBAR; - if (HAS_RESIZEBAR(wwin) && IS_RESIZABLE(wwin)) - flags |= WFF_RESIZEBAR; - if (HAS_BORDER(wwin)) - flags |= WFF_BORDER; - if (wwin->flags.shaded) - flags |= WFF_IS_SHADED; - - oldh = wwin->frame->top_width; - wFrameWindowUpdateBorders(wwin->frame, flags); - if (oldh != wwin->frame->top_width) { - newy = wwin->frame_y + oldh - wwin->frame->top_width; - - XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width); - wWindowConfigure(wwin, wwin->frame_x, newy, - wwin->client.width, wwin->client.height); - } - - flags = 0; - if (!WFLAGP(wwin, no_miniaturize_button) - && wwin->frame->flags.hide_left_button) - flags |= WFF_LEFT_BUTTON; + flags |= WFF_TITLEBAR; + if (HAS_RESIZEBAR(wwin) && IS_RESIZABLE(wwin)) + flags |= WFF_RESIZEBAR; + if (HAS_BORDER(wwin)) + flags |= WFF_BORDER; + if (wwin->flags.shaded) + flags |= WFF_IS_SHADED; + + oldh = wwin->frame->top_width; + wFrameWindowUpdateBorders(wwin->frame, flags); + if (oldh != wwin->frame->top_width) { + newy = wwin->frame_y + oldh - wwin->frame->top_width; + + XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width); + wWindowConfigure(wwin, wwin->frame_x, newy, + wwin->client.width, wwin->client.height); + } + + flags = 0; + if (!WFLAGP(wwin, no_miniaturize_button) + && wwin->frame->flags.hide_left_button) + flags |= WFF_LEFT_BUTTON; #ifdef XKB_BUTTON_HINT if (!WFLAGP(wwin, no_language_button) @@ -2637,37 +2637,37 @@ wWindowConfigureBorders(WWindow *wwin) } #endif - if (!WFLAGP(wwin, no_close_button) - && wwin->frame->flags.hide_right_button) - flags |= WFF_RIGHT_BUTTON; + if (!WFLAGP(wwin, no_close_button) + && wwin->frame->flags.hide_right_button) + flags |= WFF_RIGHT_BUTTON; - if (flags!=0) { - wWindowUpdateButtonImages(wwin); - wFrameWindowShowButton(wwin->frame, flags); - } + if (flags!=0) { + wWindowUpdateButtonImages(wwin); + wFrameWindowShowButton(wwin->frame, flags); + } - flags = 0; - if (WFLAGP(wwin, no_miniaturize_button) - && !wwin->frame->flags.hide_left_button) - flags |= WFF_LEFT_BUTTON; + flags = 0; + if (WFLAGP(wwin, no_miniaturize_button) + && !wwin->frame->flags.hide_left_button) + flags |= WFF_LEFT_BUTTON; #ifdef XKB_BUTTON_HINT - if (WFLAGP(wwin, no_language_button) - && !wwin->frame->flags.hide_language_button) - flags |= WFF_LANGUAGE_BUTTON; + if (WFLAGP(wwin, no_language_button) + && !wwin->frame->flags.hide_language_button) + flags |= WFF_LANGUAGE_BUTTON; #endif - if (WFLAGP(wwin, no_close_button) - && !wwin->frame->flags.hide_right_button) - flags |= WFF_RIGHT_BUTTON; + if (WFLAGP(wwin, no_close_button) + && !wwin->frame->flags.hide_right_button) + flags |= WFF_RIGHT_BUTTON; - if (flags!=0) - wFrameWindowHideButton(wwin->frame, flags); + if (flags!=0) + wFrameWindowHideButton(wwin->frame, flags); #ifdef SHAPE - if (wShapeSupported && wwin->flags.shaped) { - wWindowSetShape(wwin); - } + if (wShapeSupported && wwin->flags.shaped) { + wWindowSetShape(wwin); + } #endif } } @@ -2686,25 +2686,25 @@ wWindowSaveState(WWindow *wwin) data[3] = wwin->flags.hidden; data[4] = wwin->flags.maximized; if (wwin->flags.maximized == 0) { - data[5] = wwin->frame_x; - data[6] = wwin->frame_y; - data[7] = wwin->frame->core->width; - data[8] = wwin->frame->core->height; + data[5] = wwin->frame_x; + data[6] = wwin->frame_y; + data[7] = wwin->frame->core->width; + data[8] = wwin->frame->core->height; } else { - data[5] = wwin->old_geometry.x; - data[6] = wwin->old_geometry.y; - data[7] = wwin->old_geometry.width; - data[8] = wwin->old_geometry.height; + data[5] = wwin->old_geometry.x; + data[6] = wwin->old_geometry.y; + data[7] = wwin->old_geometry.width; + data[8] = wwin->old_geometry.height; } for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) { - if (wwin->screen_ptr->shortcutWindows[i] && - WMCountInArray(wwin->screen_ptr->shortcutWindows[i], wwin)) - data[9] |= 1<screen_ptr->shortcutWindows[i] && + WMCountInArray(wwin->screen_ptr->shortcutWindows[i], wwin)) + data[9] |= 1<client_win, _XA_WINDOWMAKER_STATE, - _XA_WINDOWMAKER_STATE, 32, PropModeReplace, - (unsigned char *)data, 10); + _XA_WINDOWMAKER_STATE, 32, PropModeReplace, + (unsigned char *)data, 10); } @@ -2718,9 +2718,9 @@ getSavedState(Window window, WSavedState **state) CARD32 *data; if (XGetWindowProperty(dpy, window, _XA_WINDOWMAKER_STATE, 0, 10, - True, _XA_WINDOWMAKER_STATE, - &type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret, - (unsigned char **)&data)!=Success || !data) + True, _XA_WINDOWMAKER_STATE, + &type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret, + (unsigned char **)&data)!=Success || !data) return 0; *state = wmalloc(sizeof(WSavedState)); @@ -2750,7 +2750,7 @@ void wWindowClearShape(WWindow *wwin) { XShapeCombineMask(dpy, wwin->frame->core->window, ShapeBounding, - 0, wwin->frame->top_width, None, ShapeSet); + 0, wwin->frame->top_width, None, ShapeSet); XFlush(dpy); } @@ -2766,20 +2766,20 @@ wWindowSetShape(WWindow *wwin) /* only shape is the client's */ if (!HAS_TITLEBAR(wwin) && !HAS_RESIZEBAR(wwin)) { - goto alt_code; + goto alt_code; } /* Get array of rectangles describing the shape mask */ rects = XShapeGetRectangles(dpy, wwin->client_win, ShapeBounding, - &count, &ordering); + &count, &ordering); if (!rects) { - goto alt_code; + goto alt_code; } urec = malloc(sizeof(XRectangle)*(count+2)); if (!urec) { - XFree(rects); - goto alt_code; + XFree(rects); + goto alt_code; } /* insert our decoration rectangles in the rect list */ @@ -2787,25 +2787,25 @@ wWindowSetShape(WWindow *wwin) XFree(rects); if (HAS_TITLEBAR(wwin)) { - urec[count].x = -1; - urec[count].y = -1 - wwin->frame->top_width; - urec[count].width = wwin->frame->core->width + 2; - urec[count].height = wwin->frame->top_width + 1; - count++; + urec[count].x = -1; + urec[count].y = -1 - wwin->frame->top_width; + urec[count].width = wwin->frame->core->width + 2; + urec[count].height = wwin->frame->top_width + 1; + count++; } if (HAS_RESIZEBAR(wwin)) { - urec[count].x = -1; - urec[count].y = wwin->frame->core->height - - wwin->frame->bottom_width - wwin->frame->top_width; - urec[count].width = wwin->frame->core->width + 2; - urec[count].height = wwin->frame->bottom_width + 1; - count++; + urec[count].x = -1; + urec[count].y = wwin->frame->core->height + - wwin->frame->bottom_width - wwin->frame->top_width; + urec[count].width = wwin->frame->core->width + 2; + urec[count].height = wwin->frame->bottom_width + 1; + count++; } /* shape our frame window */ XShapeCombineRectangles(dpy, wwin->frame->core->window, ShapeBounding, - 0, wwin->frame->top_width, urec, count, - ShapeSet, Unsorted); + 0, wwin->frame->top_width, urec, count, + ShapeSet, Unsorted); XFlush(dpy); wfree(urec); return; @@ -2816,24 +2816,24 @@ alt_code: if (HAS_TITLEBAR(wwin)) { rect[count].x = -1; rect[count].y = -1; - rect[count].width = wwin->frame->core->width + 2; - rect[count].height = wwin->frame->top_width + 1; + rect[count].width = wwin->frame->core->width + 2; + rect[count].height = wwin->frame->top_width + 1; count++; } if (HAS_RESIZEBAR(wwin)) { - rect[count].x = -1; - rect[count].y = wwin->frame->core->height - wwin->frame->bottom_width; - rect[count].width = wwin->frame->core->width + 2; - rect[count].height = wwin->frame->bottom_width + 1; - count++; + rect[count].x = -1; + rect[count].y = wwin->frame->core->height - wwin->frame->bottom_width; + rect[count].width = wwin->frame->core->width + 2; + rect[count].height = wwin->frame->bottom_width + 1; + count++; } if (count > 0) { - XShapeCombineRectangles(dpy, wwin->frame->core->window, ShapeBounding, - 0, 0, rect, count, ShapeSet, Unsorted); + XShapeCombineRectangles(dpy, wwin->frame->core->window, ShapeBounding, + 0, 0, rect, count, ShapeSet, Unsorted); } XShapeCombineShape(dpy, wwin->frame->core->window, ShapeBounding, - 0, wwin->frame->top_width, wwin->client_win, - ShapeBounding, (count > 0 ? ShapeUnion : ShapeSet)); + 0, wwin->frame->top_width, wwin->client_win, + ShapeBounding, (count > 0 ? ShapeUnion : ShapeSet)); XFlush(dpy); } #endif /* SHAPE */ @@ -2846,19 +2846,19 @@ getFocusMode(WWindow *wwin) FocusMode mode; if ((wwin->wm_hints) && (wwin->wm_hints->flags & InputHint)) { - if (wwin->wm_hints->input == True) { - if (wwin->protocols.TAKE_FOCUS) - mode = WFM_LOCALLY_ACTIVE; - else - mode = WFM_PASSIVE; - } else { - if (wwin->protocols.TAKE_FOCUS) - mode = WFM_GLOBALLY_ACTIVE; - else - mode = WFM_NO_INPUT; - } + if (wwin->wm_hints->input == True) { + if (wwin->protocols.TAKE_FOCUS) + mode = WFM_LOCALLY_ACTIVE; + else + mode = WFM_PASSIVE; + } else { + if (wwin->protocols.TAKE_FOCUS) + mode = WFM_GLOBALLY_ACTIVE; + else + mode = WFM_NO_INPUT; + } } else { - mode = WFM_PASSIVE; + mode = WFM_PASSIVE; } return mode; } @@ -2871,25 +2871,25 @@ wWindowSetKeyGrabs(WWindow *wwin) WShortKey *key; for (i=0; ikeycode==0) - continue; - if (key->modifier!=AnyModifier) { - XGrabKey(dpy, key->keycode, key->modifier|LockMask, - wwin->frame->core->window, True, GrabModeAsync, GrabModeAsync); + if (key->keycode==0) + continue; + if (key->modifier!=AnyModifier) { + XGrabKey(dpy, key->keycode, key->modifier|LockMask, + wwin->frame->core->window, True, GrabModeAsync, GrabModeAsync); #ifdef NUMLOCK_HACK - /* Also grab all modifier combinations possible that include, - * LockMask, ScrollLockMask and NumLockMask, so that keygrabs - * work even if the NumLock/ScrollLock key is on. - */ - wHackedGrabKey(key->keycode, key->modifier, - wwin->frame->core->window, True, GrabModeAsync, - GrabModeAsync); + /* Also grab all modifier combinations possible that include, + * LockMask, ScrollLockMask and NumLockMask, so that keygrabs + * work even if the NumLock/ScrollLock key is on. + */ + wHackedGrabKey(key->keycode, key->modifier, + wwin->frame->core->window, True, GrabModeAsync, + GrabModeAsync); #endif - } - XGrabKey(dpy, key->keycode, key->modifier, - wwin->frame->core->window, True, GrabModeAsync, GrabModeAsync); + } + XGrabKey(dpy, key->keycode, key->modifier, + wwin->frame->core->window, True, GrabModeAsync, GrabModeAsync); } #ifndef LITE @@ -2913,19 +2913,19 @@ wWindowResetMouseGrabs(WWindow *wwin) XUngrabButton(dpy, AnyButton, AnyModifier, wwin->client_win); if (!WFLAGP(wwin, no_bind_mouse)) { - /* grabs for Meta+drag */ - wHackedGrabButton(AnyButton, MOD_MASK, wwin->client_win, + /* grabs for Meta+drag */ + wHackedGrabButton(AnyButton, MOD_MASK, wwin->client_win, True, ButtonPressMask|ButtonReleaseMask, GrabModeSync, GrabModeAsync, None, None); } if (!wwin->flags.focused && !WFLAGP(wwin, no_focusable) - && !wwin->flags.is_gnustep) { - /* the passive grabs to focus the window */ - /* if (wPreferences.focus_mode == WKF_CLICK) */ - XGrabButton(dpy, AnyButton, AnyModifier, wwin->client_win, - True, ButtonPressMask|ButtonReleaseMask, - GrabModeSync, GrabModeAsync, None, None); + && !wwin->flags.is_gnustep) { + /* the passive grabs to focus the window */ + /* if (wPreferences.focus_mode == WKF_CLICK) */ + XGrabButton(dpy, AnyButton, AnyModifier, wwin->client_win, + True, ButtonPressMask|ButtonReleaseMask, + GrabModeSync, GrabModeAsync, None, None); } XFlush(dpy); } @@ -2934,13 +2934,13 @@ wWindowResetMouseGrabs(WWindow *wwin) void wWindowUpdateGNUstepAttr(WWindow *wwin, GNUstepWMAttributes *attr) { - if (attr->flags & GSExtraFlagsAttr) { - if (MGFLAGP(wwin, broken_close) != - (attr->extra_flags & GSDocumentEditedFlag)) { - wwin->client_flags.broken_close = !MGFLAGP(wwin, broken_close); - wWindowUpdateButtonImages(wwin); - } - } + if (attr->flags & GSExtraFlagsAttr) { + if (MGFLAGP(wwin, broken_close) != + (attr->extra_flags & GSDocumentEditedFlag)) { + wwin->client_flags.broken_close = !MGFLAGP(wwin, broken_close); + wWindowUpdateButtonImages(wwin); + } + } } @@ -3039,9 +3039,9 @@ wWindowDeleteSavedState(WMagicNumber id) wfree(wstate->state); wfree(wstate); } else { - while (tmp->next) { - if (tmp->next==wstate) { - tmp->next=wstate->next; + while (tmp->next) { + if (tmp->next==wstate) { + tmp->next=wstate->next; #ifdef DEBUG printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n", wstate, wstate->instance, wstate->class, wstate->command); @@ -3051,10 +3051,10 @@ wWindowDeleteSavedState(WMagicNumber id) if (wstate->command) wfree(wstate->command); wfree(wstate->state); wfree(wstate); - break; - } - tmp = tmp->next; - } + break; + } + tmp = tmp->next; + } } } @@ -3069,7 +3069,7 @@ wWindowDeleteSavedStatesForPID(pid_t pid) tmp = windowState; if (tmp->pid == pid) { - wstate = windowState; + wstate = windowState; windowState = tmp->next; #ifdef DEBUG printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n", @@ -3081,10 +3081,10 @@ wWindowDeleteSavedStatesForPID(pid_t pid) wfree(wstate->state); wfree(wstate); } else { - while (tmp->next) { - if (tmp->next->pid==pid) { - wstate = tmp->next; - tmp->next = wstate->next; + while (tmp->next) { + if (tmp->next->pid==pid) { + wstate = tmp->next; + tmp->next = wstate->next; #ifdef DEBUG printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n", wstate, wstate->instance, wstate->class, wstate->command); @@ -3094,10 +3094,10 @@ wWindowDeleteSavedStatesForPID(pid_t pid) if (wstate->command) wfree(wstate->command); wfree(wstate->state); wfree(wstate); - break; - } - tmp = tmp->next; - } + break; + } + tmp = tmp->next; + } } } @@ -3122,9 +3122,9 @@ resizebarMouseDown(WCoreWindow *sender, void *data, XEvent *event) #ifndef NUMLOCK_HACK if ((event->xbutton.state & ValidModMask) - != (event->xbutton.state & ~LockMask)) { - wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\ - "Turn it off or some mouse actions and keyboard shortcuts will not work.")); + != (event->xbutton.state & ~LockMask)) { + wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\ + "Turn it off or some mouse actions and keyboard shortcuts will not work.")); } #endif @@ -3133,30 +3133,30 @@ resizebarMouseDown(WCoreWindow *sender, void *data, XEvent *event) CloseWindowMenu(wwin->screen_ptr); if (wPreferences.focus_mode==WKF_CLICK - && !(event->xbutton.state&ControlMask) - && !WFLAGP(wwin, no_focusable)) { - wSetFocusTo(wwin->screen_ptr, wwin); + && !(event->xbutton.state&ControlMask) + && !WFLAGP(wwin, no_focusable)) { + wSetFocusTo(wwin->screen_ptr, wwin); } if (event->xbutton.button == Button1) - wRaiseFrame(wwin->frame->core); + wRaiseFrame(wwin->frame->core); if (event->xbutton.window != wwin->frame->resizebar->window) { - if (XGrabPointer(dpy, wwin->frame->resizebar->window, True, - ButtonMotionMask|ButtonReleaseMask|ButtonPressMask, - GrabModeAsync, GrabModeAsync, None, - None, CurrentTime)!=GrabSuccess) { + if (XGrabPointer(dpy, wwin->frame->resizebar->window, True, + ButtonMotionMask|ButtonReleaseMask|ButtonPressMask, + GrabModeAsync, GrabModeAsync, None, + None, CurrentTime)!=GrabSuccess) { #ifdef DEBUG0 - wwarning("pointer grab failed for window move"); + wwarning("pointer grab failed for window move"); #endif - return; - } + return; + } } if (event->xbutton.state & MOD_MASK) { - /* move the window */ - wMouseMoveWindow(wwin, event); - XUngrabPointer(dpy, CurrentTime); + /* move the window */ + wMouseMoveWindow(wwin, event); + XUngrabPointer(dpy, CurrentTime); } else { wMouseResizeWindow(wwin, event); XUngrabPointer(dpy, CurrentTime); @@ -3173,43 +3173,43 @@ titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event) event->xbutton.state &= ValidModMask; if (event->xbutton.button==Button1) { - if (event->xbutton.state == 0) { - if (!WFLAGP(wwin, no_shadeable)) { - /* shade window */ - if (wwin->flags.shaded) - wUnshadeWindow(wwin); - else - wShadeWindow(wwin); - } - } else { - int dir = 0; - - if (event->xbutton.state & ControlMask) - dir |= MAX_VERTICAL; + if (event->xbutton.state == 0) { + if (!WFLAGP(wwin, no_shadeable)) { + /* shade window */ + if (wwin->flags.shaded) + wUnshadeWindow(wwin); + else + wShadeWindow(wwin); + } + } else { + int dir = 0; + + if (event->xbutton.state & ControlMask) + dir |= MAX_VERTICAL; if (event->xbutton.state & ShiftMask) { - dir |= MAX_HORIZONTAL; + dir |= MAX_HORIZONTAL; if (!(event->xbutton.state & ControlMask)) wSelectWindow(wwin, !wwin->flags.selected); } - /* maximize window */ - if (dir!=0 && IS_RESIZABLE(wwin)) { - int ndir = dir ^ wwin->flags.maximized; + /* maximize window */ + if (dir!=0 && IS_RESIZABLE(wwin)) { + int ndir = dir ^ wwin->flags.maximized; if (ndir != 0) { wMaximizeWindow(wwin, ndir); } else { wUnmaximizeWindow(wwin); } - } - } + } + } } else if (event->xbutton.button==Button3) { - if (event->xbutton.state & MOD_MASK) { - wHideOtherApplications(wwin); - } + if (event->xbutton.state & MOD_MASK) { + wHideOtherApplications(wwin); + } } else if (event->xbutton.button==Button2) { - wSelectWindow(wwin, !wwin->flags.selected); + wSelectWindow(wwin, !wwin->flags.selected); } else if (event->xbutton.button == WINGsConfiguration.mouseWheelUp) { wShadeWindow(wwin); } else if (event->xbutton.button == WINGsConfiguration.mouseWheelDown) { @@ -3228,30 +3228,30 @@ frameMouseDown(WObjDescriptor *desc, XEvent *event) CloseWindowMenu(wwin->screen_ptr); if (/*wPreferences.focus_mode==WKF_CLICK - &&*/ !(event->xbutton.state&ControlMask) - && !WFLAGP(wwin, no_focusable)) { - wSetFocusTo(wwin->screen_ptr, wwin); + &&*/ !(event->xbutton.state&ControlMask) + && !WFLAGP(wwin, no_focusable)) { + wSetFocusTo(wwin->screen_ptr, wwin); } if (event->xbutton.button == Button1) { - wRaiseFrame(wwin->frame->core); + wRaiseFrame(wwin->frame->core); } if (event->xbutton.state & MOD_MASK) { - /* move the window */ - if (XGrabPointer(dpy, wwin->client_win, False, - ButtonMotionMask|ButtonReleaseMask|ButtonPressMask, - GrabModeAsync, GrabModeAsync, None, - None, CurrentTime)!=GrabSuccess) { + /* move the window */ + if (XGrabPointer(dpy, wwin->client_win, False, + ButtonMotionMask|ButtonReleaseMask|ButtonPressMask, + GrabModeAsync, GrabModeAsync, None, + None, CurrentTime)!=GrabSuccess) { #ifdef DEBUG0 - wwarning("pointer grab failed for window move"); + wwarning("pointer grab failed for window move"); #endif - return; - } - if (event->xbutton.button == Button3) - wMouseResizeWindow(wwin, event); - else if (event->xbutton.button==Button1 || event->xbutton.button==Button2) - wMouseMoveWindow(wwin, event); - XUngrabPointer(dpy, CurrentTime); + return; + } + if (event->xbutton.button == Button3) + wMouseResizeWindow(wwin, event); + else if (event->xbutton.button==Button1 || event->xbutton.button==Button2) + wMouseMoveWindow(wwin, event); + XUngrabPointer(dpy, CurrentTime); } } @@ -3263,9 +3263,9 @@ titlebarMouseDown(WCoreWindow *sender, void *data, XEvent *event) #ifndef NUMLOCK_HACK if ((event->xbutton.state & ValidModMask) - != (event->xbutton.state & ~LockMask)) { - wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\ - "Turn it off or some mouse actions and keyboard shortcuts will not work.")); + != (event->xbutton.state & ~LockMask)) { + wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\ + "Turn it off or some mouse actions and keyboard shortcuts will not work.")); } #endif event->xbutton.state &= ValidModMask; @@ -3273,66 +3273,66 @@ titlebarMouseDown(WCoreWindow *sender, void *data, XEvent *event) CloseWindowMenu(wwin->screen_ptr); if (wPreferences.focus_mode==WKF_CLICK - && !(event->xbutton.state&ControlMask) - && !WFLAGP(wwin, no_focusable)) { - wSetFocusTo(wwin->screen_ptr, wwin); + && !(event->xbutton.state&ControlMask) + && !WFLAGP(wwin, no_focusable)) { + wSetFocusTo(wwin->screen_ptr, wwin); } if (event->xbutton.button == Button1 - || event->xbutton.button == Button2) { - - if (event->xbutton.button == Button1) { - if (event->xbutton.state & MOD_MASK) { - wLowerFrame(wwin->frame->core); - } else { - wRaiseFrame(wwin->frame->core); - } - } - if ((event->xbutton.state & ShiftMask) - && !(event->xbutton.state & ControlMask)) { - wSelectWindow(wwin, !wwin->flags.selected); - return; - } - if (event->xbutton.window != wwin->frame->titlebar->window - && XGrabPointer(dpy, wwin->frame->titlebar->window, False, - ButtonMotionMask|ButtonReleaseMask|ButtonPressMask, - GrabModeAsync, GrabModeAsync, None, - None, CurrentTime)!=GrabSuccess) { + || event->xbutton.button == Button2) { + + if (event->xbutton.button == Button1) { + if (event->xbutton.state & MOD_MASK) { + wLowerFrame(wwin->frame->core); + } else { + wRaiseFrame(wwin->frame->core); + } + } + if ((event->xbutton.state & ShiftMask) + && !(event->xbutton.state & ControlMask)) { + wSelectWindow(wwin, !wwin->flags.selected); + return; + } + if (event->xbutton.window != wwin->frame->titlebar->window + && XGrabPointer(dpy, wwin->frame->titlebar->window, False, + ButtonMotionMask|ButtonReleaseMask|ButtonPressMask, + GrabModeAsync, GrabModeAsync, None, + None, CurrentTime)!=GrabSuccess) { #ifdef DEBUG0 - wwarning("pointer grab failed for window move"); + wwarning("pointer grab failed for window move"); #endif - return; - } + return; + } - /* move the window */ - wMouseMoveWindow(wwin, event); + /* move the window */ + wMouseMoveWindow(wwin, event); - XUngrabPointer(dpy, CurrentTime); + XUngrabPointer(dpy, CurrentTime); } else if (event->xbutton.button == Button3 && event->xbutton.state==0 - && !wwin->flags.internal_window - && !WCHECK_STATE(WSTATE_MODAL)) { - WObjDescriptor *desc; - - if (event->xbutton.window != wwin->frame->titlebar->window - && XGrabPointer(dpy, wwin->frame->titlebar->window, False, - ButtonMotionMask|ButtonReleaseMask|ButtonPressMask, - GrabModeAsync, GrabModeAsync, None, - None, CurrentTime)!=GrabSuccess) { + && !wwin->flags.internal_window + && !WCHECK_STATE(WSTATE_MODAL)) { + WObjDescriptor *desc; + + if (event->xbutton.window != wwin->frame->titlebar->window + && XGrabPointer(dpy, wwin->frame->titlebar->window, False, + ButtonMotionMask|ButtonReleaseMask|ButtonPressMask, + GrabModeAsync, GrabModeAsync, None, + None, CurrentTime)!=GrabSuccess) { #ifdef DEBUG0 - wwarning("pointer grab failed for window move"); + wwarning("pointer grab failed for window move"); #endif - return; - } + return; + } - OpenWindowMenu(wwin, event->xbutton.x_root, - wwin->frame_y+wwin->frame->top_width, False); + OpenWindowMenu(wwin, event->xbutton.x_root, + wwin->frame_y+wwin->frame->top_width, False); - /* allow drag select */ - desc = &wwin->screen_ptr->window_menu->menu->descriptor; - event->xany.send_event = True; - (*desc->handle_mousedown)(desc, event); + /* allow drag select */ + desc = &wwin->screen_ptr->window_menu->menu->descriptor; + event->xany.send_event = True; + (*desc->handle_mousedown)(desc, event); - XUngrabPointer(dpy, CurrentTime); + XUngrabPointer(dpy, CurrentTime); } } @@ -3348,28 +3348,28 @@ windowCloseClick(WCoreWindow *sender, void *data, XEvent *event) CloseWindowMenu(wwin->screen_ptr); if (event->xbutton.button < Button1 || event->xbutton.button > Button3) - return; + return; /* if control-click, kill the client */ if (event->xbutton.state & ControlMask) { - wClientKill(wwin); + wClientKill(wwin); } else { #ifdef OLWM_HINTS - if (wwin->flags.olwm_push_pin_out) { + if (wwin->flags.olwm_push_pin_out) { - wwin->flags.olwm_push_pin_out = 0; + wwin->flags.olwm_push_pin_out = 0; - wOLWMChangePushpinState(wwin, True); + wOLWMChangePushpinState(wwin, True); - wFrameWindowUpdatePushButton(wwin->frame, False); + wFrameWindowUpdatePushButton(wwin->frame, False); - return; - } + return; + } #endif - if (wwin->protocols.DELETE_WINDOW && event->xbutton.state==0) { - /* send delete message */ - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); - } + if (wwin->protocols.DELETE_WINDOW && event->xbutton.state==0) { + /* send delete message */ + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + } } } @@ -3382,13 +3382,13 @@ windowCloseDblClick(WCoreWindow *sender, void *data, XEvent *event) CloseWindowMenu(wwin->screen_ptr); if (event->xbutton.button < Button1 || event->xbutton.button > Button3) - return; + return; /* send delete message */ if (wwin->protocols.DELETE_WINDOW) { - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); } else { - wClientKill(wwin); + wClientKill(wwin); } } @@ -3411,10 +3411,10 @@ windowLanguageClick(WCoreWindow *sender, void *data, XEvent *event) wSetFocusTo(scr, wwin); wwin->frame->languagebutton_image = wwin->frame->screen_ptr->b_pixmaps[WBUT_XKBGROUP1 + - wwin->frame->languagemode]; + wwin->frame->languagemode]; wFrameWindowUpdateLanguageButton(wwin->frame); if (event->xbutton.button == Button3) - return; + return; wRaiseFrame(fwin->core); } #endif @@ -3430,21 +3430,22 @@ windowIconifyClick(WCoreWindow *sender, void *data, XEvent *event) CloseWindowMenu(wwin->screen_ptr); if (event->xbutton.button < Button1 || event->xbutton.button > Button3) - return; + return; if (wwin->protocols.MINIATURIZE_WINDOW && event->xbutton.state==0) { - wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, - LastTimestamp); + wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, + LastTimestamp); } else { - WApplication *wapp; - if ((event->xbutton.state & ControlMask) || - (event->xbutton.button == Button3)) { - - wapp = wApplicationOf(wwin->main_window); - if (wapp && !WFLAGP(wwin, no_appicon)) - wHideApplication(wapp); - } else if (event->xbutton.state==0) { - wIconifyWindow(wwin); - } + WApplication *wapp; + if ((event->xbutton.state & ControlMask) || + (event->xbutton.button == Button3)) { + + wapp = wApplicationOf(wwin->main_window); + if (wapp && !WFLAGP(wwin, no_appicon)) + wHideApplication(wapp); + } else if (event->xbutton.state==0) { + wIconifyWindow(wwin); + } } } + diff --git a/src/window.h b/src/window.h index a8b359db..5d7651be 100644 --- a/src/window.h +++ b/src/window.h @@ -1,6 +1,6 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima * * This program is free software; you can redistribute it and/or modify @@ -15,7 +15,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. */ @@ -44,8 +44,8 @@ #define CLIENT_EVENTS (StructureNotifyMask | PropertyChangeMask\ - | EnterWindowMask | LeaveWindowMask | ColormapChangeMask \ - | FocusChangeMask | VisibilityChangeMask) + | EnterWindowMask | LeaveWindowMask | ColormapChangeMask \ + | FocusChangeMask | VisibilityChangeMask) typedef enum { WFM_PASSIVE, WFM_NO_INPUT, WFM_LOCALLY_ACTIVE, WFM_GLOBALLY_ACTIVE @@ -54,36 +54,36 @@ typedef enum { /* * window attribute flags. - * + * * Note: attributes that should apply to the application as a * whole should only access the flags from app->main_window_desc->window_flags * This is to make sure that the application doesn't have many different - * values for the same option. For example, imagine xfoo, which has + * values for the same option. For example, imagine xfoo, which has * foo.bar as leader and it a child window named foo.baz. If you set * StartHidden YES for foo.bar and NO for foo.baz we must *always* guarantee * that the value that will be used will be that of the leader foo.bar. * The attributes inspector must always save application wide options * in the name of the leader window, not the child. - * + * */ /* * All flags must have their default values = 0 - * + * * New flag scheme: - * + * * user_flags, defined_flags * client_flags - * + * * if defined window_flag then window_flag else client_flag - * + * */ #define WFLAGP(wwin, FLAG) ((wwin)->defined_user_flags.FLAG \ - ? (wwin)->user_flags.FLAG \ - : (wwin)->client_flags.FLAG) + ? (wwin)->user_flags.FLAG \ + : (wwin)->client_flags.FLAG) #define WSETUFLAG(wwin, FLAG, VAL) (wwin)->user_flags.FLAG = (VAL),\ - (wwin)->defined_user_flags.FLAG = 1 + (wwin)->defined_user_flags.FLAG = 1 typedef struct { /* OpenStep */ @@ -101,7 +101,7 @@ typedef struct { unsigned int no_resizebar:1; /* draw the bottom handle? */ unsigned int no_close_button:1; /* draw a close button? */ unsigned int no_miniaturize_button:1; /* draw an iconify button? */ - + unsigned int broken_close:1; /* is the close button broken? */ /* ours */ @@ -113,10 +113,10 @@ typedef struct { unsigned int floating:1; /* put in WMFloatingLevel */ unsigned int sunken:1; /* put in WMSunkenLevel */ unsigned int no_bind_keys:1; /* intercept wm kbd binds - * while window is focused */ + * while window is focused */ unsigned int no_bind_mouse:1; /* intercept mouse events - * on client area while window - * is focused */ + * on client area while window + * is focused */ unsigned int no_hide_others:1; /* hide window when doing hideothers */ unsigned int no_appicon:1; /* make app icon */ @@ -125,9 +125,9 @@ typedef struct { unsigned int dont_move_off:1; unsigned int no_focusable:1; - + unsigned int always_user_icon:1; /* ignore client IconPixmap or - * IconWindow */ + * IconWindow */ unsigned int start_miniaturized:1; unsigned int start_hidden:1; @@ -165,7 +165,7 @@ typedef struct { unsigned int SAVE_YOURSELF:1; /* WindowMaker specific */ unsigned int MINIATURIZE_WINDOW:1; -#ifdef MONITOR_HEARTBEAT +#ifdef MONITOR_HEARTBEAT unsigned int HEARTBEAT:1; #endif } WProtocols; @@ -194,7 +194,7 @@ typedef struct WWindow { WWindowAttributes user_flags; /* window attribute flags set by user */ WWindowAttributes defined_user_flags;/* mask for user_flags */ WWindowAttributes client_flags; /* window attribute flags set by app - * initialized with global defaults */ + * initialized with global defaults */ struct InspectorPanel *inspector; /* pointer to attribute editor panel */ @@ -202,23 +202,23 @@ typedef struct WWindow { int frame_x, frame_y; /* position of the frame in root*/ struct { - int x, y; - unsigned int width, height; /* original geometry of the window */ + int x, y; + unsigned int width, height; /* original geometry of the window */ } old_geometry; /* (before things like maximize) */ struct { - int x, y; - unsigned int width, height; /* original geometry of the window */ + int x, y; + unsigned int width, height; /* original geometry of the window */ } bfs_geometry; /* (before fullscreen) */ /* client window info */ short old_border_width; /* original border width of client_win*/ Window client_win; /* the window we're managing */ - WObjDescriptor client_descriptor; /* dummy descriptor for client */ + WObjDescriptor client_descriptor; /* dummy descriptor for client */ struct { - int x, y; /* position of *client* relative - * to root */ - unsigned int width, height; /* size of the client window */ + int x, y; /* position of *client* relative + * to root */ + unsigned int width, height; /* size of the client window */ } client; XSizeHints *normal_hints; /* WM_NORMAL_HINTS */ @@ -235,7 +235,7 @@ typedef struct WWindow { a single appicon */ Window group_id; /* the leader window of the group */ Window client_leader; /* WM_CLIENT_LEADER if not - internal_window */ + internal_window */ Window main_window; /* main window for the application */ @@ -260,69 +260,69 @@ typedef struct WWindow { time_t last_beat; #endif struct { - /* state flags */ - unsigned int mapped:1; - unsigned int focused:1; - unsigned int miniaturized:1; - unsigned int hidden:1; - unsigned int shaded:1; - unsigned int maximized:2; - unsigned int fullscreen:1; - unsigned int omnipresent:1; - - unsigned int semi_focused:1; - /* window type flags */ - unsigned int urgent:1; /* if wm_hints says this is urgent */ + /* state flags */ + unsigned int mapped:1; + unsigned int focused:1; + unsigned int miniaturized:1; + unsigned int hidden:1; + unsigned int shaded:1; + unsigned int maximized:2; + unsigned int fullscreen:1; + unsigned int omnipresent:1; + + unsigned int semi_focused:1; + /* window type flags */ + unsigned int urgent:1; /* if wm_hints says this is urgent */ #ifdef SHAPE - unsigned int shaped:1; + unsigned int shaped:1; #endif - /* info flags */ - unsigned int is_gnustep:1; /* 1 if the window belongs to a GNUstep - app */ - - unsigned int buttons_dont_fit:1; - unsigned int rebuild_texture:1;/* the window was resized and - * gradients should be re-rendered */ - unsigned int needs_full_repaint:1;/* does a full repaint of the - * window next time it's painted */ - unsigned int icon_moved:1; /* icon for this window was moved - * by the user */ - unsigned int selected:1; /* multiple window selection */ - unsigned int skip_next_animation:1; - unsigned int internal_window:1; - unsigned int changing_workspace:1; + /* info flags */ + unsigned int is_gnustep:1; /* 1 if the window belongs to a GNUstep + app */ + + unsigned int buttons_dont_fit:1; + unsigned int rebuild_texture:1; /* the window was resized and + * gradients should be re-rendered */ + unsigned int needs_full_repaint:1;/* does a full repaint of the + * window next time it's painted */ + unsigned int icon_moved:1; /* icon for this window was moved + * by the user */ + unsigned int selected:1; /* multiple window selection */ + unsigned int skip_next_animation:1; + unsigned int internal_window:1; + unsigned int changing_workspace:1; unsigned int inspector_open:1; /* attrib inspector is already open */ - unsigned int destroyed:1; /* window was already destroyed */ + unsigned int destroyed:1; /* window was already destroyed */ - unsigned int menu_open_for_me:1; /* window commands menu */ + unsigned int menu_open_for_me:1; /* window commands menu */ - unsigned int waiting_save_ack:1; /* waiting for SAVE_YOURSELF ack */ + unsigned int waiting_save_ack:1; /* waiting for SAVE_YOURSELF ack */ - unsigned int obscured:1; /* window is obscured */ + unsigned int obscured:1; /* window is obscured */ - unsigned int dragged_while_fmaximized; + unsigned int dragged_while_fmaximized; - unsigned int user_changed_width:1; - unsigned int user_changed_height:1; - unsigned int wm_name_changed:1; + unsigned int user_changed_width:1; + unsigned int user_changed_height:1; + unsigned int wm_name_changed:1; #ifdef KWM_HINTS - unsigned int kwm_hidden_for_modules:1; - unsigned int kwm_managed:1; - unsigned int kwm_menubar:1; + unsigned int kwm_hidden_for_modules:1; + unsigned int kwm_managed:1; + unsigned int kwm_menubar:1; #endif #ifdef OLWM_HINTS - unsigned int olwm_push_pin_out:1;/* emulate pushpin behaviour */ - unsigned int olwm_limit_menu:1; + unsigned int olwm_push_pin_out:1;/* emulate pushpin behaviour */ + unsigned int olwm_limit_menu:1; #endif #ifdef NETWM_HINTS - unsigned int net_state_from_client:1; /* state hint was set by client */ - unsigned int net_skip_pager:1; - unsigned int net_handle_icon:1; - unsigned int net_show_desktop:1; + unsigned int net_state_from_client:1; /* state hint was set by client */ + unsigned int net_skip_pager:1; + unsigned int net_handle_icon:1; + unsigned int net_show_desktop:1; #endif } flags; /* state of the window */ @@ -355,7 +355,7 @@ typedef struct WWindow { /* * Changes to this must update wWindowSaveState/getSavedState - * + * */ typedef struct WSavedState { int workspace; @@ -403,9 +403,9 @@ void wWindowUnfocus(WWindow *wwin); void wWindowUpdateName(WWindow *wwin, char *newTitle); void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight); void wWindowCropSize(WWindow *wwin, int maxw, int maxh, - int *nwidth, int *nheight); -void wWindowConfigure(WWindow *wwin, int req_x, int req_y, - int req_width, int req_height); + int *nwidth, int *nheight); +void wWindowConfigure(WWindow *wwin, int req_x, int req_y, + int req_width, int req_height); void wWindowMove(WWindow *wwin, int req_x, int req_y); @@ -427,8 +427,8 @@ void wWindowSetKeyGrabs(WWindow *wwin); void wWindowResetMouseGrabs(WWindow *wwin); WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner, - char *title, int x, int y, - int width, int height); + char *title, int x, int y, + int width, int height); void wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace); diff --git a/src/winmenu.c b/src/winmenu.c index fe8f7215..ec700d59 100644 --- a/src/winmenu.c +++ b/src/winmenu.c @@ -1,9 +1,9 @@ /* winmenu.c - command menu for windows - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -33,7 +33,7 @@ #include "WindowMaker.h" #include "actions.h" #include "menu.h" -#include "funcs.h" +#include "funcs.h" #include "window.h" #include "client.h" #include "application.h" @@ -82,25 +82,25 @@ static void execWindowOptionCommand(WMenu *menu, WMenuEntry *entry) { WWindow *wwin = (WWindow*)entry->clientdata; - + switch (entry->order) { - case WO_KEEP_ON_TOP: - if(wwin->frame->core->stacking->window_level!=WMFloatingLevel) - ChangeStackingLevel(wwin->frame->core, WMFloatingLevel); - else - ChangeStackingLevel(wwin->frame->core, WMNormalLevel); - break; - - case WO_KEEP_AT_BOTTOM: - if(wwin->frame->core->stacking->window_level!=WMSunkenLevel) - ChangeStackingLevel(wwin->frame->core, WMSunkenLevel); - else - ChangeStackingLevel(wwin->frame->core, WMNormalLevel); - break; - - case WO_OMNIPRESENT: - wWindowSetOmnipresent(wwin, !wwin->flags.omnipresent); - break; + case WO_KEEP_ON_TOP: + if(wwin->frame->core->stacking->window_level!=WMFloatingLevel) + ChangeStackingLevel(wwin->frame->core, WMFloatingLevel); + else + ChangeStackingLevel(wwin->frame->core, WMNormalLevel); + break; + + case WO_KEEP_AT_BOTTOM: + if(wwin->frame->core->stacking->window_level!=WMSunkenLevel) + ChangeStackingLevel(wwin->frame->core, WMSunkenLevel); + else + ChangeStackingLevel(wwin->frame->core, WMNormalLevel); + break; + + case WO_OMNIPRESENT: + wWindowSetOmnipresent(wwin, !wwin->flags.omnipresent); + break; } } @@ -110,77 +110,77 @@ execMenuCommand(WMenu *menu, WMenuEntry *entry) { WWindow *wwin = (WWindow*)entry->clientdata; WApplication *wapp; - + CloseWindowMenu(menu->frame->screen_ptr); switch (entry->order) { - case MC_CLOSE: - /* send delete message */ - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); - break; - - case MC_KILL: - wretain(wwin); - if (wPreferences.dont_confirm_kill - || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"), - _("This will kill the application.\nAny unsaved changes will be lost.\nPlease confirm."), - _("Yes"), _("No"), NULL)==WAPRDefault) { - if (!wwin->flags.destroyed) - wClientKill(wwin); - } - wrelease(wwin); - break; - - case MC_MINIATURIZE: - if (wwin->flags.miniaturized) { - wDeiconifyWindow(wwin); - } else{ - if (wwin->protocols.MINIATURIZE_WINDOW) { - wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, - LastTimestamp); - } else { - wIconifyWindow(wwin); - } - } - break; - - case MC_MAXIMIZE: - if (wwin->flags.maximized) - wUnmaximizeWindow(wwin); - else - wMaximizeWindow(wwin, MAX_VERTICAL|MAX_HORIZONTAL); - break; - - case MC_SHADE: - if (wwin->flags.shaded) - wUnshadeWindow(wwin); - else - wShadeWindow(wwin); - break; - - case MC_SELECT: - if (!wwin->flags.miniaturized) - wSelectWindow(wwin, !wwin->flags.selected); - else - wIconSelect(wwin->icon); - break; - - case MC_MOVERESIZE: + case MC_CLOSE: + /* send delete message */ + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + break; + + case MC_KILL: + wretain(wwin); + if (wPreferences.dont_confirm_kill + || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"), + _("This will kill the application.\nAny unsaved changes will be lost.\nPlease confirm."), + _("Yes"), _("No"), NULL)==WAPRDefault) { + if (!wwin->flags.destroyed) + wClientKill(wwin); + } + wrelease(wwin); + break; + + case MC_MINIATURIZE: + if (wwin->flags.miniaturized) { + wDeiconifyWindow(wwin); + } else{ + if (wwin->protocols.MINIATURIZE_WINDOW) { + wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, + LastTimestamp); + } else { + wIconifyWindow(wwin); + } + } + break; + + case MC_MAXIMIZE: + if (wwin->flags.maximized) + wUnmaximizeWindow(wwin); + else + wMaximizeWindow(wwin, MAX_VERTICAL|MAX_HORIZONTAL); + break; + + case MC_SHADE: + if (wwin->flags.shaded) + wUnshadeWindow(wwin); + else + wShadeWindow(wwin); + break; + + case MC_SELECT: + if (!wwin->flags.miniaturized) + wSelectWindow(wwin, !wwin->flags.selected); + else + wIconSelect(wwin->icon); + break; + + case MC_MOVERESIZE: wKeyboardMoveResizeWindow(wwin); - break; + break; - case MC_PROPERTIES: - wShowInspectorForWindow(wwin); - break; + case MC_PROPERTIES: + wShowInspectorForWindow(wwin); + break; - case MC_HIDE: - wapp = wApplicationOf(wwin->main_window); - wHideApplication(wapp); - break; + case MC_HIDE: + wapp = wApplicationOf(wwin->main_window); + wHideApplication(wapp); + break; - case MC_HIDE_OTHERS: - wHideOtherApplications(wwin); - break; + case MC_HIDE_OTHERS: + wHideOtherApplications(wwin); + break; } } @@ -204,17 +204,17 @@ makeShortcutCommand(WMenu *menu, WMenuEntry *entry) int index = entry->order-WO_ENTRIES; if (scr->shortcutWindows[index]) { - WMFreeArray(scr->shortcutWindows[index]); - scr->shortcutWindows[index] = NULL; + WMFreeArray(scr->shortcutWindows[index]); + scr->shortcutWindows[index] = NULL; } if (wwin->flags.selected && scr->selected_windows) { scr->shortcutWindows[index] = WMDuplicateArray(scr->selected_windows); /*WMRemoveFromArray(scr->shortcutWindows[index], wwin); - WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/ + WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/ } else { - scr->shortcutWindows[index] = WMCreateArray(4); - WMAddToArray(scr->shortcutWindows[index], wwin); + scr->shortcutWindows[index] = WMCreateArray(4); + WMAddToArray(scr->shortcutWindows[index], wwin); } wSelectWindow(wwin, !wwin->flags.selected); @@ -231,31 +231,31 @@ updateWorkspaceMenu(WMenu *menu) WScreen *scr = menu->frame->screen_ptr; char title[MAX_WORKSPACENAME_WIDTH+1]; int i; - + if (!menu) - return; - + return; + for (i=0; iworkspace_count; i++) { - if (i < menu->entry_no) { - if (strcmp(menu->entries[i]->text,scr->workspaces[i]->name)!=0) { - wfree(menu->entries[i]->text); - strncpy(title, scr->workspaces[i]->name, MAX_WORKSPACENAME_WIDTH); - title[MAX_WORKSPACENAME_WIDTH] = 0; - menu->entries[i]->text = wstrdup(title); - menu->flags.realized = 0; - } - } else { - strncpy(title, scr->workspaces[i]->name, MAX_WORKSPACENAME_WIDTH); - title[MAX_WORKSPACENAME_WIDTH] = 0; - - wMenuAddCallback(menu, title, switchWSCommand, NULL); - - menu->flags.realized = 0; - } + if (i < menu->entry_no) { + if (strcmp(menu->entries[i]->text,scr->workspaces[i]->name)!=0) { + wfree(menu->entries[i]->text); + strncpy(title, scr->workspaces[i]->name, MAX_WORKSPACENAME_WIDTH); + title[MAX_WORKSPACENAME_WIDTH] = 0; + menu->entries[i]->text = wstrdup(title); + menu->flags.realized = 0; + } + } else { + strncpy(title, scr->workspaces[i]->name, MAX_WORKSPACENAME_WIDTH); + title[MAX_WORKSPACENAME_WIDTH] = 0; + + wMenuAddCallback(menu, title, switchWSCommand, NULL); + + menu->flags.realized = 0; + } } - + if (!menu->flags.realized) - wMenuRealize(menu); + wMenuRealize(menu); } @@ -269,85 +269,85 @@ updateMakeShortcutMenu(WMenu *menu, WWindow *wwin) KeyCode kcode; if (!smenu) - return; - + return; + buflen = strlen(_("Set Shortcut"))+16; buffer = wmalloc(buflen); for (i=WO_ENTRIES; ientry_no; i++) { - char *tmp; - int shortcutNo = i-WO_ENTRIES; - WMenuEntry *entry = smenu->entries[i]; - WMArray *shortSelWindows = wwin->screen_ptr->shortcutWindows[shortcutNo]; - - snprintf(buffer, buflen, "%s %i", _("Set Shortcut"), shortcutNo+1); - - if (!shortSelWindows) { - entry->flags.indicator_on = 0; - } else { - entry->flags.indicator_on = 1; - if (WMCountInArray(shortSelWindows, wwin)) - entry->flags.indicator_type = MI_DIAMOND; - else - entry->flags.indicator_type = MI_CHECK; - } - - if (strcmp(buffer, entry->text)!=0) { - wfree(entry->text); - entry->text = wstrdup(buffer); - smenu->flags.realized = 0; - } - - kcode = wKeyBindings[WKBD_WINDOW1+shortcutNo].keycode; - - if (kcode) { - if ((tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0))) - && (!entry->rtext || strcmp(tmp, entry->rtext)!=0)) { - if (entry->rtext) - wfree(entry->rtext); - entry->rtext = wstrdup(tmp); - smenu->flags.realized = 0; - } - wMenuSetEnabled(smenu, i, True); - } else { - wMenuSetEnabled(smenu, i, False); - if (entry->rtext) { - wfree(entry->rtext); - entry->rtext = NULL; - smenu->flags.realized = 0; - } - } - entry->clientdata = wwin; + char *tmp; + int shortcutNo = i-WO_ENTRIES; + WMenuEntry *entry = smenu->entries[i]; + WMArray *shortSelWindows = wwin->screen_ptr->shortcutWindows[shortcutNo]; + + snprintf(buffer, buflen, "%s %i", _("Set Shortcut"), shortcutNo+1); + + if (!shortSelWindows) { + entry->flags.indicator_on = 0; + } else { + entry->flags.indicator_on = 1; + if (WMCountInArray(shortSelWindows, wwin)) + entry->flags.indicator_type = MI_DIAMOND; + else + entry->flags.indicator_type = MI_CHECK; + } + + if (strcmp(buffer, entry->text)!=0) { + wfree(entry->text); + entry->text = wstrdup(buffer); + smenu->flags.realized = 0; + } + + kcode = wKeyBindings[WKBD_WINDOW1+shortcutNo].keycode; + + if (kcode) { + if ((tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0))) + && (!entry->rtext || strcmp(tmp, entry->rtext)!=0)) { + if (entry->rtext) + wfree(entry->rtext); + entry->rtext = wstrdup(tmp); + smenu->flags.realized = 0; + } + wMenuSetEnabled(smenu, i, True); + } else { + wMenuSetEnabled(smenu, i, False); + if (entry->rtext) { + wfree(entry->rtext); + entry->rtext = NULL; + smenu->flags.realized = 0; + } + } + entry->clientdata = wwin; } wfree(buffer); if (!smenu->flags.realized) - wMenuRealize(smenu); + wMenuRealize(smenu); } static void updateOptionsMenu(WMenu *menu, WWindow *wwin) -{ +{ WMenu *smenu = menu->cascades[menu->entries[MC_OPTIONS]->cascade]; /* keep on top check */ smenu->entries[WO_KEEP_ON_TOP]->clientdata = wwin; - smenu->entries[WO_KEEP_ON_TOP]->flags.indicator_on = - (wwin->frame->core->stacking->window_level == WMFloatingLevel)?1:0; + smenu->entries[WO_KEEP_ON_TOP]->flags.indicator_on = + (wwin->frame->core->stacking->window_level == WMFloatingLevel)?1:0; wMenuSetEnabled(smenu, WO_KEEP_ON_TOP, !wwin->flags.miniaturized); /* keep at bottom check */ smenu->entries[WO_KEEP_AT_BOTTOM]->clientdata = wwin; smenu->entries[WO_KEEP_AT_BOTTOM]->flags.indicator_on = - (wwin->frame->core->stacking->window_level == WMSunkenLevel)?1:0; + (wwin->frame->core->stacking->window_level == WMSunkenLevel)?1:0; wMenuSetEnabled(smenu, WO_KEEP_AT_BOTTOM, !wwin->flags.miniaturized); /* omnipresent check */ smenu->entries[WO_OMNIPRESENT]->clientdata = wwin; smenu->entries[WO_OMNIPRESENT]->flags.indicator_on = IS_OMNIPRESENT(wwin); - + smenu->flags.realized = 0; - wMenuRealize(smenu); + wMenuRealize(smenu); } @@ -355,15 +355,15 @@ static WMenu* makeWorkspaceMenu(WScreen *scr) { WMenu *menu; - + menu = wMenuCreate(scr, NULL, False); if (!menu) { - wwarning(_("could not create submenu for window menu")); - return NULL; + wwarning(_("could not create submenu for window menu")); + return NULL; } updateWorkspaceMenu(menu); - + return menu; } @@ -372,22 +372,22 @@ static WMenu* makeMakeShortcutMenu(WScreen *scr, WMenu *menu) { /* - WMenu *menu; + WMenu *menu; */ int i; -/* - menu = wMenuCreate(scr, NULL, False); - if (!menu) { - wwarning(_("could not create submenu for window menu")); - return NULL; - } - */ + /* + menu = wMenuCreate(scr, NULL, False); + if (!menu) { + wwarning(_("could not create submenu for window menu")); + return NULL; + } + */ for (i=0; iflags.indicator = 1; + entry->flags.indicator = 1; } return menu; @@ -403,22 +403,22 @@ makeOptionsMenu(WScreen *scr) menu = wMenuCreate(scr, NULL, False); if (!menu) { - wwarning(_("could not create submenu for window menu")); - return NULL; + wwarning(_("could not create submenu for window menu")); + return NULL; } - entry = wMenuAddCallback(menu, _("Keep on top"), execWindowOptionCommand, - NULL); + entry = wMenuAddCallback(menu, _("Keep on top"), execWindowOptionCommand, + NULL); entry->flags.indicator = 1; entry->flags.indicator_type = MI_CHECK; entry = wMenuAddCallback(menu, _("Keep at bottom"), execWindowOptionCommand, - NULL); + NULL); entry->flags.indicator = 1; entry->flags.indicator_type = MI_CHECK; - entry = wMenuAddCallback(menu, _("Omnipresent"), execWindowOptionCommand, - NULL); + entry = wMenuAddCallback(menu, _("Omnipresent"), execWindowOptionCommand, + NULL); entry->flags.indicator = 1; entry->flags.indicator_type = MI_CHECK; @@ -435,90 +435,90 @@ createWindowMenu(WScreen *scr) char *tmp; menu = wMenuCreate(scr, NULL, False); - /* - * Warning: If you make some change that affects the order of the + /* + * Warning: If you make some change that affects the order of the * entries, you must update the command #defines in the top of * this file. */ entry = wMenuAddCallback(menu, _("Maximize"), execMenuCommand, NULL); if (wKeyBindings[WKBD_MAXIMIZE].keycode!=0) { - kcode = wKeyBindings[WKBD_MAXIMIZE].keycode; - - if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) - entry->rtext = wstrdup(tmp); + kcode = wKeyBindings[WKBD_MAXIMIZE].keycode; + + if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) + entry->rtext = wstrdup(tmp); } entry = wMenuAddCallback(menu, _("Miniaturize"), execMenuCommand, NULL); if (wKeyBindings[WKBD_MINIATURIZE].keycode!=0) { - kcode = wKeyBindings[WKBD_MINIATURIZE].keycode; - - if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) - entry->rtext = wstrdup(tmp); + kcode = wKeyBindings[WKBD_MINIATURIZE].keycode; + + if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) + entry->rtext = wstrdup(tmp); } - + entry = wMenuAddCallback(menu, _("Shade"), execMenuCommand, NULL); if (wKeyBindings[WKBD_SHADE].keycode!=0) { - kcode = wKeyBindings[WKBD_SHADE].keycode; - - if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) - entry->rtext = wstrdup(tmp); + kcode = wKeyBindings[WKBD_SHADE].keycode; + + if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) + entry->rtext = wstrdup(tmp); } - + entry = wMenuAddCallback(menu, _("Hide"), execMenuCommand, NULL); if (wKeyBindings[WKBD_HIDE].keycode!=0) { - kcode = wKeyBindings[WKBD_HIDE].keycode; - - if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) - entry->rtext = wstrdup(tmp); + kcode = wKeyBindings[WKBD_HIDE].keycode; + + if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) + entry->rtext = wstrdup(tmp); } entry = wMenuAddCallback(menu, _("Hide Others"), execMenuCommand, NULL); if (wKeyBindings[WKBD_HIDE_OTHERS].keycode!=0) { - kcode = wKeyBindings[WKBD_HIDE_OTHERS].keycode; - - if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) - entry->rtext = wstrdup(tmp); + kcode = wKeyBindings[WKBD_HIDE_OTHERS].keycode; + + if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) + entry->rtext = wstrdup(tmp); } entry = wMenuAddCallback(menu, _("Resize/Move"), execMenuCommand, NULL); if (wKeyBindings[WKBD_MOVERESIZE].keycode!=0) { - kcode = wKeyBindings[WKBD_MOVERESIZE].keycode; + kcode = wKeyBindings[WKBD_MOVERESIZE].keycode; - if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) - entry->rtext = wstrdup(tmp); + if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) + entry->rtext = wstrdup(tmp); } entry = wMenuAddCallback(menu, _("Select"), execMenuCommand, NULL); if (wKeyBindings[WKBD_SELECT].keycode!=0) { - kcode = wKeyBindings[WKBD_SELECT].keycode; + kcode = wKeyBindings[WKBD_SELECT].keycode; - if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) - entry->rtext = wstrdup(tmp); + if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) + entry->rtext = wstrdup(tmp); } entry = wMenuAddCallback(menu, _("Move To"), NULL, NULL); scr->workspace_submenu = makeWorkspaceMenu(scr); if (scr->workspace_submenu) - wMenuEntrySetCascade(menu, entry, scr->workspace_submenu); + wMenuEntrySetCascade(menu, entry, scr->workspace_submenu); entry = wMenuAddCallback(menu, _("Attributes..."), execMenuCommand, NULL); entry = wMenuAddCallback(menu, _("Options"), NULL, NULL); - wMenuEntrySetCascade(menu, entry, - makeMakeShortcutMenu(scr, makeOptionsMenu(scr))); + wMenuEntrySetCascade(menu, entry, + makeMakeShortcutMenu(scr, makeOptionsMenu(scr))); -/* - entry = wMenuAddCallback(menu, _("Select Shortcut"), NULL, NULL); - wMenuEntrySetCascade(menu, entry, makeMakeShortcutMenu(scr)); - */ + /* + entry = wMenuAddCallback(menu, _("Select Shortcut"), NULL, NULL); + wMenuEntrySetCascade(menu, entry, makeMakeShortcutMenu(scr)); + */ entry = wMenuAddCallback(menu, _("Close"), execMenuCommand, NULL); if (wKeyBindings[WKBD_CLOSE].keycode!=0) { - kcode = wKeyBindings[WKBD_CLOSE].keycode; - if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) - entry->rtext = wstrdup(tmp); + kcode = wKeyBindings[WKBD_CLOSE].keycode; + if (kcode && (tmp = XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0)))) + entry->rtext = wstrdup(tmp); } - + entry = wMenuAddCallback(menu, _("Kill"), execMenuCommand, NULL); return menu; @@ -529,15 +529,15 @@ void CloseWindowMenu(WScreen *scr) { if (scr->window_menu) { - if (scr->window_menu->flags.mapped) - wMenuUnmap(scr->window_menu); - - if (scr->window_menu->entries[0]->clientdata) { - WWindow *wwin = (WWindow*)scr->window_menu->entries[0]->clientdata; - - wwin->flags.menu_open_for_me = 0; - } - scr->window_menu->entries[0]->clientdata = NULL; + if (scr->window_menu->flags.mapped) + wMenuUnmap(scr->window_menu); + + if (scr->window_menu->entries[0]->clientdata) { + WWindow *wwin = (WWindow*)scr->window_menu->entries[0]->clientdata; + + wwin->flags.menu_open_for_me = 0; + } + scr->window_menu->entries[0]->clientdata = NULL; } } @@ -554,83 +554,83 @@ updateMenuForWindow(WMenu *menu, WWindow *wwin) updateMakeShortcutMenu(menu, wwin); - wMenuSetEnabled(menu, MC_HIDE, wapp!=NULL - && !WFLAGP(wapp->main_window_desc, no_appicon)); - - wMenuSetEnabled(menu, MC_CLOSE, - (wwin->protocols.DELETE_WINDOW - && !WFLAGP(wwin, no_closable))); + wMenuSetEnabled(menu, MC_HIDE, wapp!=NULL + && !WFLAGP(wapp->main_window_desc, no_appicon)); + + wMenuSetEnabled(menu, MC_CLOSE, + (wwin->protocols.DELETE_WINDOW + && !WFLAGP(wwin, no_closable))); if (wwin->flags.miniaturized) { - static char *text = NULL; - if (!text) text = _("Deminiaturize"); + static char *text = NULL; + if (!text) text = _("Deminiaturize"); - menu->entries[MC_MINIATURIZE]->text = text; + menu->entries[MC_MINIATURIZE]->text = text; } else { - static char *text = NULL; - if (!text) text = _("Miniaturize"); + static char *text = NULL; + if (!text) text = _("Miniaturize"); - menu->entries[MC_MINIATURIZE]->text = text; + menu->entries[MC_MINIATURIZE]->text = text; } wMenuSetEnabled(menu, MC_MINIATURIZE, !WFLAGP(wwin, no_miniaturizable)); if (wwin->flags.maximized) { - static char *text = NULL; - if (!text) text = _("Unmaximize"); + static char *text = NULL; + if (!text) text = _("Unmaximize"); - menu->entries[MC_MAXIMIZE]->text = text; + menu->entries[MC_MAXIMIZE]->text = text; } else { - static char *text = NULL; - if (!text) text = _("Maximize"); + static char *text = NULL; + if (!text) text = _("Maximize"); - menu->entries[MC_MAXIMIZE]->text = text; + menu->entries[MC_MAXIMIZE]->text = text; } wMenuSetEnabled(menu, MC_MAXIMIZE, IS_RESIZABLE(wwin)); - wMenuSetEnabled(menu, MC_MOVERESIZE, IS_RESIZABLE(wwin) - && !wwin->flags.miniaturized); + wMenuSetEnabled(menu, MC_MOVERESIZE, IS_RESIZABLE(wwin) + && !wwin->flags.miniaturized); if (wwin->flags.shaded) { - static char *text = NULL; - if (!text) text = _("Unshade"); + static char *text = NULL; + if (!text) text = _("Unshade"); - menu->entries[MC_SHADE]->text = text; + menu->entries[MC_SHADE]->text = text; } else { - static char *text = NULL; - if (!text) text = _("Shade"); + static char *text = NULL; + if (!text) text = _("Shade"); - menu->entries[MC_SHADE]->text = text; + menu->entries[MC_SHADE]->text = text; } wMenuSetEnabled(menu, MC_SHADE, !WFLAGP(wwin, no_shadeable) - && !wwin->flags.miniaturized); + && !wwin->flags.miniaturized); wMenuSetEnabled(menu, MC_DUMMY_MOVETO, !IS_OMNIPRESENT(wwin)); - + if (!wwin->flags.inspector_open) { - wMenuSetEnabled(menu, MC_PROPERTIES, True); + wMenuSetEnabled(menu, MC_PROPERTIES, True); } else { - wMenuSetEnabled(menu, MC_PROPERTIES, False); + wMenuSetEnabled(menu, MC_PROPERTIES, False); } - + /* set the client data of the entries to the window */ for (i = 0; i < menu->entry_no; i++) { - menu->entries[i]->clientdata = wwin; + menu->entries[i]->clientdata = wwin; } for (i = 0; i < scr->workspace_submenu->entry_no; i++) { - scr->workspace_submenu->entries[i]->clientdata = wwin; - if (i == scr->current_workspace) { - wMenuSetEnabled(scr->workspace_submenu, i, False); - } else { - wMenuSetEnabled(scr->workspace_submenu, i, True); - } + scr->workspace_submenu->entries[i]->clientdata = wwin; + if (i == scr->current_workspace) { + wMenuSetEnabled(scr->workspace_submenu, i, False); + } else { + wMenuSetEnabled(scr->workspace_submenu, i, True); + } } menu->flags.realized = 0; - wMenuRealize(menu); + wMenuRealize(menu); } @@ -643,34 +643,34 @@ OpenWindowMenu(WWindow *wwin, int x, int y, int keyboard) wwin->flags.menu_open_for_me = 1; if (!scr->window_menu) { - scr->window_menu = createWindowMenu(scr); - - /* hack to save some memory allocation/deallocation */ - wfree(scr->window_menu->entries[MC_MINIATURIZE]->text); - wfree(scr->window_menu->entries[MC_MAXIMIZE]->text); - wfree(scr->window_menu->entries[MC_SHADE]->text); + scr->window_menu = createWindowMenu(scr); + + /* hack to save some memory allocation/deallocation */ + wfree(scr->window_menu->entries[MC_MINIATURIZE]->text); + wfree(scr->window_menu->entries[MC_MAXIMIZE]->text); + wfree(scr->window_menu->entries[MC_SHADE]->text); } else { - updateWorkspaceMenu(scr->workspace_submenu); + updateWorkspaceMenu(scr->workspace_submenu); } menu = scr->window_menu; if (menu->flags.mapped) { - wMenuUnmap(menu); - if (menu->entries[0]->clientdata==wwin) { - return; - } + wMenuUnmap(menu); + if (menu->entries[0]->clientdata==wwin) { + return; + } } updateMenuForWindow(menu, wwin); - + x -= menu->frame->core->width/2; if (x + menu->frame->core->width > wwin->frame_x+wwin->frame->core->width) - x = wwin->frame_x+wwin->frame->core->width - menu->frame->core->width; - if (x < wwin->frame_x) - x = wwin->frame_x; + x = wwin->frame_x+wwin->frame->core->width - menu->frame->core->width; + if (x < wwin->frame_x) + x = wwin->frame_x; if (!wwin->flags.internal_window) - wMenuMapAt(menu, x, y, keyboard); + wMenuMapAt(menu, x, y, keyboard); } @@ -683,26 +683,26 @@ OpenMiniwindowMenu(WWindow *wwin, int x, int y) wwin->flags.menu_open_for_me = 1; if (!scr->window_menu) { - scr->window_menu = createWindowMenu(scr); - - /* hack to save some memory allocation/deallocation */ - wfree(scr->window_menu->entries[MC_MINIATURIZE]->text); - wfree(scr->window_menu->entries[MC_MAXIMIZE]->text); - wfree(scr->window_menu->entries[MC_SHADE]->text); + scr->window_menu = createWindowMenu(scr); + + /* hack to save some memory allocation/deallocation */ + wfree(scr->window_menu->entries[MC_MINIATURIZE]->text); + wfree(scr->window_menu->entries[MC_MAXIMIZE]->text); + wfree(scr->window_menu->entries[MC_SHADE]->text); } else { - updateWorkspaceMenu(scr->workspace_submenu); + updateWorkspaceMenu(scr->workspace_submenu); } menu = scr->window_menu; if (menu->flags.mapped) { - wMenuUnmap(menu); - if (menu->entries[0]->clientdata==wwin) { - return; - } + wMenuUnmap(menu); + if (menu->entries[0]->clientdata==wwin) { + return; + } } updateMenuForWindow(menu, wwin); - + x -= menu->frame->core->width/2; wMenuMapAt(menu, x, y, False); diff --git a/src/winspector.c b/src/winspector.c index 9e52df36..1e57ac60 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -1,10 +1,10 @@ /* winspector.c - window attribute inspector - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima * Copyright (c) 1998-2003 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. */ @@ -69,7 +69,7 @@ typedef struct InspectorPanel { WWindow *inspected; /* the window that's being inspected */ WMWindow *win; - + Window parent; /* common stuff */ @@ -80,7 +80,7 @@ typedef struct InspectorPanel { WMPopUpButton *pagePopUp; /* first page. general stuff */ - + WMFrame *specFrm; WMButton *instRb; WMButton *clsRb; @@ -88,9 +88,9 @@ typedef struct InspectorPanel { WMButton *defaultRb; WMButton *selWinB; - + WMLabel *specLbl; - + /* second page. attributes */ WMFrame *attrFrm; @@ -111,13 +111,13 @@ typedef struct InspectorPanel { WMTextField *fileText; WMButton *alwChk; /* - WMButton *updateIconBtn; + WMButton *updateIconBtn; */ WMButton *browseIconBtn; - + WMFrame *wsFrm; WMPopUpButton *wsP; - + /* 5th page. application wide attributes */ WMFrame *appFrm; WMButton *appChk[3]; @@ -192,9 +192,9 @@ static void applySettings(WMButton *button, InspectorPanel *panel); #define UNDEFINED_POS 0xffffff -static InspectorPanel *createInspectorForWindow(WWindow *wwin, - int xpos, int ypos, - Bool showSelectPanel); +static InspectorPanel *createInspectorForWindow(WWindow *wwin, + int xpos, int ypos, + Bool showSelectPanel); @@ -202,14 +202,14 @@ static void make_keys() { if (ANoTitlebar!=NULL) - return; + return; AIcon = WMCreatePLString("Icon"); ANoTitlebar = WMCreatePLString("NoTitlebar"); ANoResizebar = WMCreatePLString("NoResizebar"); ANoMiniaturizeButton = WMCreatePLString("NoMiniaturizeButton"); ANoCloseButton = WMCreatePLString("NoCloseButton"); - ANoBorder = WMCreatePLString("NoBorder"); + ANoBorder = WMCreatePLString("NoBorder"); ANoHideOthers = WMCreatePLString("NoHideOthers"); ANoMouseBindings = WMCreatePLString("NoMouseBindings"); ANoKeyBindings = WMCreatePLString("NoKeyBindings"); @@ -247,7 +247,7 @@ freeInspector(InspectorPanel *panel) { panel->destroyed = 1; if (panel->choosingIcon) - return; + return; WMDestroyWidget(panel->win); @@ -265,16 +265,16 @@ destroyInspector(WCoreWindow *foo, void *data, XEvent *event) panel = panelList; while (panel->frame!=data) - panel = panel->nextPtr; - - if (panelList == panel) - panelList = panel->nextPtr; + panel = panel->nextPtr; + + if (panelList == panel) + panelList = panel->nextPtr; else { - tmp = panelList; - while (tmp->nextPtr!=panel) { - tmp = tmp->nextPtr; - } - tmp->nextPtr = panel->nextPtr; + tmp = panelList; + while (tmp->nextPtr!=panel) { + tmp = tmp->nextPtr; + } + tmp->nextPtr = panel->nextPtr; } panel->inspected->flags.inspector_open = 0; panel->inspected->inspector = NULL; @@ -312,37 +312,37 @@ static void changePage(WMPopUpButton *bPtr, InspectorPanel *panel) { int page; - + page = WMGetPopUpButtonSelectedItem(bPtr); - + if (page == 0) { - WMMapWidget(panel->specFrm); - WMMapWidget(panel->specLbl); + WMMapWidget(panel->specFrm); + WMMapWidget(panel->specLbl); } else if (page == 1) { - WMMapWidget(panel->attrFrm); - } else if (page == 2) { - WMMapWidget(panel->moreFrm); + WMMapWidget(panel->attrFrm); + } else if (page == 2) { + WMMapWidget(panel->moreFrm); } else if (page == 3) { - WMMapWidget(panel->iconFrm); - WMMapWidget(panel->wsFrm); + WMMapWidget(panel->iconFrm); + WMMapWidget(panel->wsFrm); } else { - WMMapWidget(panel->appFrm); + WMMapWidget(panel->appFrm); } - + if (page != 0) { - WMUnmapWidget(panel->specFrm); - WMUnmapWidget(panel->specLbl); + WMUnmapWidget(panel->specFrm); + WMUnmapWidget(panel->specLbl); } if (page != 1) - WMUnmapWidget(panel->attrFrm); + WMUnmapWidget(panel->attrFrm); if (page != 2) - WMUnmapWidget(panel->moreFrm); + WMUnmapWidget(panel->moreFrm); if (page != 3) { - WMUnmapWidget(panel->iconFrm); - WMUnmapWidget(panel->wsFrm); + WMUnmapWidget(panel->iconFrm); + WMUnmapWidget(panel->wsFrm); } if (page != 4 && panel->appFrm) - WMUnmapWidget(panel->appFrm); + WMUnmapWidget(panel->appFrm); } @@ -372,8 +372,8 @@ showIconFor(WMScreen *scrPtr, InspectorPanel *panel, file = wstrdup(db_icon); } if (db_icon!=NULL && (flags & REVERT_TO_DEFAULT)!=0) { - if (file) - file = wstrdup(db_icon); + if (file) + file = wstrdup(db_icon); flags |= UPDATE_TEXT_FIELD; } @@ -385,16 +385,16 @@ showIconFor(WMScreen *scrPtr, InspectorPanel *panel, path = FindImage(wPreferences.icon_path, file); if (!path) { - char *buf; - int len = strlen(file)+80; - - buf = wmalloc(len); - snprintf(buf, len, _("Could not find icon \"%s\" specified for this window"), - file); - wMessageDialog(panel->frame->screen_ptr, _("Error"), buf, - _("OK"), NULL, NULL); - wfree(buf); - wfree(file); + char *buf; + int len = strlen(file)+80; + + buf = wmalloc(len); + snprintf(buf, len, _("Could not find icon \"%s\" specified for this window"), + file); + wMessageDialog(panel->frame->screen_ptr, _("Error"), buf, + _("OK"), NULL, NULL); + wfree(buf); + wfree(file); return -1; } @@ -402,16 +402,16 @@ showIconFor(WMScreen *scrPtr, InspectorPanel *panel, wfree(path); if (!pixmap) { - char *buf; - int len = strlen(file)+80; - - buf = wmalloc(len); - snprintf(buf, len, _("Could not open specified icon \"%s\":%s"), - file, RMessageForError(RErrorCode)); + char *buf; + int len = strlen(file)+80; + + buf = wmalloc(len); + snprintf(buf, len, _("Could not open specified icon \"%s\":%s"), + file, RMessageForError(RErrorCode)); wMessageDialog(panel->frame->screen_ptr, _("Error"), buf, - _("OK"), NULL, NULL); - wfree(buf); - wfree(file); + _("OK"), NULL, NULL); + wfree(buf); + wfree(file); return -1; } wfree(file); @@ -432,7 +432,7 @@ updateIcon(WMButton *button, InspectorPanel *panel) } #endif -static int +static int getBool(WMPropList *value) { char *val; @@ -532,7 +532,7 @@ saveSettings(WMButton *button, InspectorPanel *panel) else if (WMGetButtonSelected(panel->bothRb) != 0) { char *buffer; - buffer = StrConcatDot(wwin->wm_instance, wwin->wm_class); + buffer = StrConcatDot(wwin->wm_instance, wwin->wm_class); key = WMCreatePLString(buffer); wfree(buffer); } else if (WMGetButtonSelected(panel->defaultRb) != 0) { @@ -555,7 +555,7 @@ saveSettings(WMButton *button, InspectorPanel *panel) } if (showIconFor(WMWidgetScreen(button), panel, NULL, NULL, - USE_TEXT_FIELD) < 0) + USE_TEXT_FIELD) < 0) return; WMPLSetCaseSensitive(True); @@ -576,15 +576,15 @@ saveSettings(WMButton *button, InspectorPanel *panel) } { - int i = WMGetPopUpButtonSelectedItem(panel->wsP); + int i = WMGetPopUpButtonSelectedItem(panel->wsP); - i--; + i--; - if (i>=0 && i < panel->frame->screen_ptr->workspace_count) { - value = WMCreatePLString(panel->frame->screen_ptr->workspaces[i]->name); - different |= insertAttribute(dict, winDic, AStartWorkspace, value, - flags); - WMReleasePropList(value); + if (i>=0 && i < panel->frame->screen_ptr->workspace_count) { + value = WMCreatePLString(panel->frame->screen_ptr->workspaces[i]->name); + different |= insertAttribute(dict, winDic, AStartWorkspace, value, + flags); + WMReleasePropList(value); } } @@ -683,13 +683,13 @@ saveSettings(WMButton *button, InspectorPanel *panel) } else if (wwin->main_window != wwin->client_win) { WApplication *wapp = wApplicationOf(wwin->main_window); - if (wapp) { + if (wapp) { char *instance = wapp->main_window_desc->wm_instance; char *class = wapp->main_window_desc->wm_class; char *buffer; - buffer = StrConcatDot(instance, class); - key2 = WMCreatePLString(buffer); + buffer = StrConcatDot(instance, class); + key2 = WMCreatePLString(buffer); wfree(buffer); if (WMIsPropListEqualTo(key, key2)) { @@ -715,7 +715,7 @@ saveSettings(WMButton *button, InspectorPanel *panel) WMPutInPLDictionary(dict, key, winDic); } - WMReleasePropList(key); + WMReleasePropList(key); WMReleasePropList(winDic); UpdateDomainFile(db); @@ -747,17 +747,17 @@ makeAppIconFor(WApplication *wapp) if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) { wapp->app_icon->attracted = 1; - if (!wapp->app_icon->icon->shadowed) { - wapp->app_icon->icon->shadowed = 1; - wapp->app_icon->icon->force_paint = 1; - } + if (!wapp->app_icon->icon->shadowed) { + wapp->app_icon->icon->shadowed = 1; + wapp->app_icon->icon->force_paint = 1; + } wDockAttachIcon(clip, wapp->app_icon, x, y); } else { PlaceIcon(scr, &x, &y, wGetHeadForWindow(wapp->main_window_desc)); - wAppIconMove(wapp->app_icon, x, y); + wAppIconMove(wapp->app_icon, x, y); } if (!clip || !wapp->app_icon->attracted || !clip->collapsed) - XMapWindow(dpy, icon->core->window); + XMapWindow(dpy, icon->core->window); if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted) wArrangeIcons(wapp->main_window_desc->screen_ptr, True); @@ -775,7 +775,7 @@ removeAppIconFor(WApplication *wapp) wapp->app_icon->running = 0; /* since we keep it, we don't care if it was attracted or not */ wapp->app_icon->attracted = 0; - wapp->app_icon->icon->shadowed = 0; + wapp->app_icon->icon->shadowed = 0; wapp->app_icon->main_window = None; wapp->app_icon->pid = 0; wapp->app_icon->icon->owner = NULL; @@ -841,14 +841,14 @@ applySettings(WMButton *button, InspectorPanel *panel) WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar)); if (floating) { - if (!WFLAGP(wwin, floating)) - ChangeStackingLevel(wwin->frame->core, WMFloatingLevel); + if (!WFLAGP(wwin, floating)) + ChangeStackingLevel(wwin->frame->core, WMFloatingLevel); } else if (sunken) { - if (!WFLAGP(wwin, sunken)) - ChangeStackingLevel(wwin->frame->core, WMSunkenLevel); + if (!WFLAGP(wwin, sunken)) + ChangeStackingLevel(wwin->frame->core, WMSunkenLevel); } else { - if (WFLAGP(wwin, floating) || WFLAGP(wwin, sunken)) - ChangeStackingLevel(wwin->frame->core, WMNormalLevel); + if (WFLAGP(wwin, floating) || WFLAGP(wwin, sunken)) + ChangeStackingLevel(wwin->frame->core, WMNormalLevel); } WSETUFLAG(wwin, sunken, sunken); @@ -856,25 +856,25 @@ applySettings(WMButton *button, InspectorPanel *panel) wwin->flags.omnipresent = 0; if (WFLAGP(wwin, skip_window_list) != skip_window_list) { - WSETUFLAG(wwin, skip_window_list, skip_window_list); - UpdateSwitchMenu(wwin->screen_ptr, wwin, - skip_window_list ? ACTION_REMOVE : ACTION_ADD); + WSETUFLAG(wwin, skip_window_list, skip_window_list); + UpdateSwitchMenu(wwin->screen_ptr, wwin, + skip_window_list ? ACTION_REMOVE : ACTION_ADD); } else { - if (WFLAGP(wwin, omnipresent) != old_omnipresent) { - WMPostNotificationName(WMNChangedState, wwin, "omnipresent"); - } + if (WFLAGP(wwin, omnipresent) != old_omnipresent) { + WMPostNotificationName(WMNChangedState, wwin, "omnipresent"); + } } - + if (WFLAGP(wwin, no_bind_keys) != old_no_bind_keys) { - if (WFLAGP(wwin, no_bind_keys)) { - XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window); - } else { - wWindowSetKeyGrabs(wwin); - } + if (WFLAGP(wwin, no_bind_keys)) { + XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window); + } else { + wWindowSetKeyGrabs(wwin); + } } - + if (WFLAGP(wwin, no_bind_mouse) != old_no_bind_mouse) { - wWindowResetMouseGrabs(wwin); + wWindowResetMouseGrabs(wwin); } wwin->frame->flags.need_texture_change = 1; @@ -887,34 +887,34 @@ applySettings(WMButton *button, InspectorPanel *panel) /* * Can't apply emulate_appicon because it will probably cause problems. */ - + if (wapp) { - /* do application wide stuff */ - WSETUFLAG(wapp->main_window_desc, start_hidden, - WMGetButtonSelected(panel->appChk[0])); + /* do application wide stuff */ + WSETUFLAG(wapp->main_window_desc, start_hidden, + WMGetButtonSelected(panel->appChk[0])); + + WSETUFLAG(wapp->main_window_desc, no_appicon, + WMGetButtonSelected(panel->appChk[1])); - WSETUFLAG(wapp->main_window_desc, no_appicon, - WMGetButtonSelected(panel->appChk[1])); + WSETUFLAG(wapp->main_window_desc, shared_appicon, + WMGetButtonSelected(panel->appChk[2])); - WSETUFLAG(wapp->main_window_desc, shared_appicon, - WMGetButtonSelected(panel->appChk[2])); - if (WFLAGP(wapp->main_window_desc, no_appicon)) removeAppIconFor(wapp); - else + else makeAppIconFor(wapp); if (wapp->app_icon && wapp->main_window == wwin->client_win) { char *file = WMGetTextFieldText(panel->fileText); - if (file[0] == 0) { - wfree(file); - file = NULL; - } - wIconChangeImageFile(wapp->app_icon->icon, file); - if (file) - wfree(file); - wAppIconPaint(wapp->app_icon); + if (file[0] == 0) { + wfree(file); + file = NULL; + } + wIconChangeImageFile(wapp->app_icon->icon, file); + if (file) + wfree(file); + wAppIconPaint(wapp->app_icon); } } } @@ -947,112 +947,112 @@ revertSettings(WMButton *button, InspectorPanel *panel) wWindowSetupInitialAttributes(wwin, &level, &workspace); for (i=0; i < 11; i++) { - int flag = 0; - - switch (i) { - case 0: + int flag = 0; + + switch (i) { + case 0: flag = WFLAGP(wwin, no_titlebar); - break; - case 1: - flag = WFLAGP(wwin, no_resizebar); - break; - case 2: - flag = WFLAGP(wwin, no_close_button); - break; - case 3: - flag = WFLAGP(wwin, no_miniaturize_button); - break; - case 4: - flag = WFLAGP(wwin, no_border); - break; - case 5: + break; + case 1: + flag = WFLAGP(wwin, no_resizebar); + break; + case 2: + flag = WFLAGP(wwin, no_close_button); + break; + case 3: + flag = WFLAGP(wwin, no_miniaturize_button); + break; + case 4: + flag = WFLAGP(wwin, no_border); + break; + case 5: flag = WFLAGP(wwin, floating); - break; - case 6: + break; + case 6: flag = WFLAGP(wwin, sunken); - break; - case 7: - flag = WFLAGP(wwin, omnipresent); - break; - case 8: - flag = WFLAGP(wwin, start_miniaturized); - break; - case 9: - flag = WFLAGP(wwin, start_maximized!=0); - break; - case 10: - flag = WFLAGP(wwin, full_maximize); - break; - } + break; + case 7: + flag = WFLAGP(wwin, omnipresent); + break; + case 8: + flag = WFLAGP(wwin, start_miniaturized); + break; + case 9: + flag = WFLAGP(wwin, start_maximized!=0); + break; + case 10: + flag = WFLAGP(wwin, full_maximize); + break; + } WMSetButtonSelected(panel->attrChk[i], flag); } for (i=0; i < 8; i++) { - int flag = 0; - - switch (i) { - case 0: - flag = WFLAGP(wwin, no_bind_keys); - break; - case 1: - flag = WFLAGP(wwin, no_bind_mouse); - break; - case 2: - flag = WFLAGP(wwin, skip_window_list); - break; - case 3: - flag = WFLAGP(wwin, no_focusable); - break; - case 4: - flag = WFLAGP(wwin, dont_move_off); - break; - case 5: - flag = WFLAGP(wwin, no_hide_others); - break; - case 6: - flag = WFLAGP(wwin, dont_save_session); - break; - case 7: - flag = WFLAGP(wwin, emulate_appicon); - break; + int flag = 0; + + switch (i) { + case 0: + flag = WFLAGP(wwin, no_bind_keys); + break; + case 1: + flag = WFLAGP(wwin, no_bind_mouse); + break; + case 2: + flag = WFLAGP(wwin, skip_window_list); + break; + case 3: + flag = WFLAGP(wwin, no_focusable); + break; + case 4: + flag = WFLAGP(wwin, dont_move_off); + break; + case 5: + flag = WFLAGP(wwin, no_hide_others); + break; + case 6: + flag = WFLAGP(wwin, dont_save_session); + break; + case 7: + flag = WFLAGP(wwin, emulate_appicon); + break; #ifdef XKB_BUTTON_HINT - case 8: - flag = WFLAGP(wwin, no_language_button); - break; + case 8: + flag = WFLAGP(wwin, no_language_button); + break; #endif - } - WMSetButtonSelected(panel->moreChk[i], flag); + } + WMSetButtonSelected(panel->moreChk[i], flag); } if (panel->appFrm && wapp) { - for (i=0; i < 2; i++) { - int flag = 0; - - switch (i) { - case 0: - flag = WFLAGP(wapp->main_window_desc, start_hidden); - break; - case 1: - flag = WFLAGP(wapp->main_window_desc, no_appicon); - break; - case 2: - flag = WFLAGP(wapp->main_window_desc, shared_appicon); - break; - } - WMSetButtonSelected(panel->appChk[i], flag); - } + for (i=0; i < 2; i++) { + int flag = 0; + + switch (i) { + case 0: + flag = WFLAGP(wapp->main_window_desc, start_hidden); + break; + case 1: + flag = WFLAGP(wapp->main_window_desc, no_appicon); + break; + case 2: + flag = WFLAGP(wapp->main_window_desc, shared_appicon); + break; + } + WMSetButtonSelected(panel->appChk[i], flag); + } } WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon)); showIconFor(WMWidgetScreen(panel->alwChk), panel, wm_instance, wm_class, - REVERT_TO_DEFAULT); + REVERT_TO_DEFAULT); n = wDefaultGetStartWorkspace(wwin->screen_ptr, wm_instance, wm_class); if (n >= 0 && n < wwin->screen_ptr->workspace_count) { - WMSetPopUpButtonSelectedItem(panel->wsP, n+1); + WMSetPopUpButtonSelectedItem(panel->wsP, n+1); } else { - WMSetPopUpButtonSelectedItem(panel->wsP, 0); + WMSetPopUpButtonSelectedItem(panel->wsP, 0); } - + /* must auto apply, so that there wno't be internal * inconsistencies between the state in the flags and * the actual state of the window */ @@ -1068,25 +1068,25 @@ chooseIconCallback(WMWidget *self, void *clientData) int result; panel->choosingIcon = 1; - + WMSetButtonEnabled(panel->browseIconBtn, False); - + result = wIconChooserDialog(panel->frame->screen_ptr, &file, - panel->inspected->wm_instance, - panel->inspected->wm_class); - + panel->inspected->wm_instance, + panel->inspected->wm_class); + panel->choosingIcon = 0; - if (!panel->destroyed) { /* kluge */ - if (result) { - WMSetTextFieldText(panel->fileText, file); - showIconFor(WMWidgetScreen(self), panel, NULL, NULL, - USE_TEXT_FIELD); - wfree(file); - } - WMSetButtonEnabled(panel->browseIconBtn, True); + if (!panel->destroyed) { /* kluge */ + if (result) { + WMSetTextFieldText(panel->fileText, file); + showIconFor(WMWidgetScreen(self), panel, NULL, NULL, + USE_TEXT_FIELD); + wfree(file); + } + WMSetButtonEnabled(panel->browseIconBtn, True); } else { - freeInspector(panel); + freeInspector(panel); } } @@ -1097,10 +1097,10 @@ textEditedObserver(void *observerData, WMNotification *notification) InspectorPanel *panel = (InspectorPanel*)observerData; if ((long)WMGetNotificationClientData(notification) != WMReturnTextMovement) - return; + return; - showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL, - USE_TEXT_FIELD); + showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL, + USE_TEXT_FIELD); /* WMPerformButtonClick(panel->updateIconBtn); */ @@ -1116,19 +1116,19 @@ selectSpecification(WMWidget *bPtr, void *data) int len; if (bPtr == panel->defaultRb && (wwin->wm_instance || wwin->wm_class)) { - WMSetButtonEnabled(panel->applyBtn, False); + WMSetButtonEnabled(panel->applyBtn, False); } else { - WMSetButtonEnabled(panel->applyBtn, True); + WMSetButtonEnabled(panel->applyBtn, True); } - + len = 16 + strlen(wwin->wm_instance ? wwin->wm_instance : "?") - + strlen(wwin->wm_class ? wwin->wm_class : "?"); + + strlen(wwin->wm_class ? wwin->wm_class : "?"); str = wmalloc(len); snprintf(str, len, _("Inspecting %s.%s"), - wwin->wm_instance ? wwin->wm_instance : "?", - wwin->wm_class ? wwin->wm_class : "?"); + wwin->wm_instance ? wwin->wm_instance : "?", + wwin->wm_class ? wwin->wm_class : "?"); wFrameWindowChangeTitle(panel->frame->frame, str); @@ -1144,14 +1144,14 @@ selectWindow(WMWidget *bPtr, void *data) WScreen *scr = wwin->screen_ptr; XEvent event; WWindow *iwin; - + if (XGrabPointer(dpy, scr->root_win, True, - ButtonPressMask, GrabModeAsync, GrabModeAsync, None, - wCursor[WCUR_SELECT], CurrentTime)!=GrabSuccess) { - wwarning("could not grab mouse pointer"); - return; + ButtonPressMask, GrabModeAsync, GrabModeAsync, None, + wCursor[WCUR_SELECT], CurrentTime)!=GrabSuccess) { + wwarning("could not grab mouse pointer"); + return; } - + WMSetLabelText(panel->specLbl, _("Click in the window you wish to inspect.")); WMMaskEvent(dpy, ButtonPressMask, &event); @@ -1159,26 +1159,26 @@ selectWindow(WMWidget *bPtr, void *data) XUngrabPointer(dpy, CurrentTime); iwin = wWindowFor(event.xbutton.subwindow); - + if (iwin && !iwin->flags.internal_window && iwin != wwin - && !iwin->flags.inspector_open) { - - iwin->flags.inspector_open = 1; - iwin->inspector = createInspectorForWindow(iwin, - panel->frame->frame_x, - panel->frame->frame_y, - True); - wCloseInspectorForWindow(wwin); + && !iwin->flags.inspector_open) { + + iwin->flags.inspector_open = 1; + iwin->inspector = createInspectorForWindow(iwin, + panel->frame->frame_x, + panel->frame->frame_y, + True); + wCloseInspectorForWindow(wwin); } else { - WMSetLabelText(panel->specLbl, spec_text); + WMSetLabelText(panel->specLbl, spec_text); } } static InspectorPanel* -createInspectorForWindow(WWindow *wwin, int xpos, int ypos, - Bool showSelectPanel) +createInspectorForWindow(WWindow *wwin, int xpos, int ypos, + Bool showSelectPanel) { WScreen *scr = wwin->screen_ptr; InspectorPanel *panel; @@ -1198,10 +1198,10 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, panel = wmalloc(sizeof(InspectorPanel)); memset(panel, 0, sizeof(InspectorPanel)); - + panel->destroyed = 0; - + panel->inspected = wwin; panel->nextPtr = panelList; @@ -1210,7 +1210,7 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, panel->win = WMCreateWindow(scr->wmscreen, "windowInspector"); WMResizeWidget(panel->win, PWIDTH, PHEIGHT); - + /**** create common stuff ****/ @@ -1223,7 +1223,7 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, WMSetButtonText(panel->saveBtn, _("Save")); WMResizeWidget(panel->saveBtn, btn_width, 28); if (wPreferences.flags.noupdates || !(wwin->wm_class || wwin->wm_instance)) - WMSetButtonEnabled(panel->saveBtn, False); + WMSetButtonEnabled(panel->saveBtn, False); panel->applyBtn = WMCreateCommandButton(panel->win); WMSetButtonAction(panel->applyBtn, (WMAction*)applySettings, panel); @@ -1266,67 +1266,67 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, WMSetButtonAction(panel->defaultRb, selectSpecification, panel); if (wwin->wm_class && wwin->wm_instance) { - char *str, *tmp; + char *str, *tmp; tmp = wstrconcat(wwin->wm_instance, "."); str = wstrconcat(tmp, wwin->wm_class); - panel->bothRb = WMCreateRadioButton(panel->specFrm); - WMMoveWidget(panel->bothRb, 10, 18); - WMResizeWidget(panel->bothRb, frame_width - (2 * 10), 20); - WMSetButtonText(panel->bothRb, str); + panel->bothRb = WMCreateRadioButton(panel->specFrm); + WMMoveWidget(panel->bothRb, 10, 18); + WMResizeWidget(panel->bothRb, frame_width - (2 * 10), 20); + WMSetButtonText(panel->bothRb, str); wfree(tmp); wfree(str); - WMGroupButtons(panel->defaultRb, panel->bothRb); + WMGroupButtons(panel->defaultRb, panel->bothRb); - if (!selectedBtn) - selectedBtn = panel->bothRb; + if (!selectedBtn) + selectedBtn = panel->bothRb; - WMSetButtonAction(panel->bothRb, selectSpecification, panel); + WMSetButtonAction(panel->bothRb, selectSpecification, panel); } if (wwin->wm_instance) { - panel->instRb = WMCreateRadioButton(panel->specFrm); - WMMoveWidget(panel->instRb, 10, 38); - WMResizeWidget(panel->instRb, frame_width - (2 * 10), 20); - WMSetButtonText(panel->instRb, wwin->wm_instance); - WMGroupButtons(panel->defaultRb, panel->instRb); + panel->instRb = WMCreateRadioButton(panel->specFrm); + WMMoveWidget(panel->instRb, 10, 38); + WMResizeWidget(panel->instRb, frame_width - (2 * 10), 20); + WMSetButtonText(panel->instRb, wwin->wm_instance); + WMGroupButtons(panel->defaultRb, panel->instRb); - if (!selectedBtn) - selectedBtn = panel->instRb; + if (!selectedBtn) + selectedBtn = panel->instRb; - WMSetButtonAction(panel->instRb, selectSpecification, panel); + WMSetButtonAction(panel->instRb, selectSpecification, panel); } if (wwin->wm_class) { - panel->clsRb = WMCreateRadioButton(panel->specFrm); - WMMoveWidget(panel->clsRb, 10, 58); - WMResizeWidget(panel->clsRb, frame_width - (2 * 10), 20); - WMSetButtonText(panel->clsRb, wwin->wm_class); - WMGroupButtons(panel->defaultRb, panel->clsRb); + panel->clsRb = WMCreateRadioButton(panel->specFrm); + WMMoveWidget(panel->clsRb, 10, 58); + WMResizeWidget(panel->clsRb, frame_width - (2 * 10), 20); + WMSetButtonText(panel->clsRb, wwin->wm_class); + WMGroupButtons(panel->defaultRb, panel->clsRb); - if (!selectedBtn) - selectedBtn = panel->clsRb; + if (!selectedBtn) + selectedBtn = panel->clsRb; - WMSetButtonAction(panel->clsRb, selectSpecification, panel); + WMSetButtonAction(panel->clsRb, selectSpecification, panel); } - + panel->selWinB = WMCreateCommandButton(panel->specFrm); WMMoveWidget(panel->selWinB, 20, 145-24 - 10); WMResizeWidget(panel->selWinB, frame_width - 2*10 - 20, 24); WMSetButtonText(panel->selWinB, _("Select window")); WMSetButtonAction(panel->selWinB, selectWindow, panel); - - + + panel->specLbl = WMCreateLabel(panel->win); WMMoveWidget(panel->specLbl, 15, 210); WMResizeWidget(panel->specLbl, frame_width, 100); WMSetLabelText(panel->specLbl, spec_text); WMSetLabelWraps(panel->specLbl, True); - + WMSetLabelTextAlignment(panel->specLbl, WALeft); - + /**** attributes ****/ panel->attrFrm = WMCreateFrame(panel->win); WMSetFrameTitle(panel->attrFrm, _("Attributes")); @@ -1334,83 +1334,83 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, WMResizeWidget(panel->attrFrm, frame_width, 250); for (i=0; i < 11; i++) { - char *caption = NULL; - int flag = 0; - char *descr = NULL; + char *caption = NULL; + int flag = 0; + char *descr = NULL; - switch (i) { - case 0: - caption = _("Disable titlebar"); + switch (i) { + case 0: + caption = _("Disable titlebar"); flag = WFLAGP(wwin, no_titlebar); - descr = _("Remove the titlebar of this window.\n" - "To access the window commands menu of a window\n" - "without it's titlebar, press Control+Esc (or the\n" - "equivalent shortcut, if you changed the default\n" - "settings)."); - break; - case 1: - caption = _("Disable resizebar"); - flag = WFLAGP(wwin, no_resizebar); - descr = _("Remove the resizebar of this window."); - break; - case 2: - caption = _("Disable close button"); - flag = WFLAGP(wwin, no_close_button); - descr = _("Remove the `close window' button of this window."); - break; - case 3: - caption = _("Disable miniaturize button"); - flag = WFLAGP(wwin, no_miniaturize_button); - descr = _("Remove the `miniaturize window' button of the window."); - break; - case 4: - caption = _("Disable border"); - flag = WFLAGP(wwin, no_border); - descr = _("Remove the 1 pixel black border around the window."); - break; - case 5: - caption = _("Keep on top (floating)"); - flag = WFLAGP(wwin, floating); - descr = _("Keep the window over other windows, not allowing\n" - "them to cover it."); - break; - case 6: - caption = _("Keep at bottom (sunken)"); - flag = WFLAGP(wwin, sunken); - descr = _("Keep the window under all other windows."); - break; - case 7: - caption = _("Omnipresent"); - flag = WFLAGP(wwin, omnipresent); - descr = _("Make window present in all workspaces."); - break; - case 8: - caption = _("Start miniaturized"); - flag = WFLAGP(wwin, start_miniaturized); - descr = _("Make the window be automatically miniaturized when it's\n" - "first shown."); - break; - case 9: - caption = _("Start maximized"); - flag = WFLAGP(wwin, start_maximized!=0); - descr = _("Make the window be automatically maximized when it's\n" - "first shown."); - break; - case 10: - caption = _("Full screen maximization"); - flag = WFLAGP(wwin, full_maximize); - descr = _("Make the window use the whole screen space when it's\n" - "maximized. The titlebar and resizebar will be moved\n" - "to outside the screen."); - break; - } - panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm); - WMMoveWidget(panel->attrChk[i], 10, 20*(i+1)); - WMResizeWidget(panel->attrChk[i], frame_width-15, 20); - WMSetButtonSelected(panel->attrChk[i], flag); - WMSetButtonText(panel->attrChk[i], caption); - - WMSetBalloonTextForView(descr, WMWidgetView(panel->attrChk[i])); + descr = _("Remove the titlebar of this window.\n" + "To access the window commands menu of a window\n" + "without it's titlebar, press Control+Esc (or the\n" + "equivalent shortcut, if you changed the default\n" + "settings)."); + break; + case 1: + caption = _("Disable resizebar"); + flag = WFLAGP(wwin, no_resizebar); + descr = _("Remove the resizebar of this window."); + break; + case 2: + caption = _("Disable close button"); + flag = WFLAGP(wwin, no_close_button); + descr = _("Remove the `close window' button of this window."); + break; + case 3: + caption = _("Disable miniaturize button"); + flag = WFLAGP(wwin, no_miniaturize_button); + descr = _("Remove the `miniaturize window' button of the window."); + break; + case 4: + caption = _("Disable border"); + flag = WFLAGP(wwin, no_border); + descr = _("Remove the 1 pixel black border around the window."); + break; + case 5: + caption = _("Keep on top (floating)"); + flag = WFLAGP(wwin, floating); + descr = _("Keep the window over other windows, not allowing\n" + "them to cover it."); + break; + case 6: + caption = _("Keep at bottom (sunken)"); + flag = WFLAGP(wwin, sunken); + descr = _("Keep the window under all other windows."); + break; + case 7: + caption = _("Omnipresent"); + flag = WFLAGP(wwin, omnipresent); + descr = _("Make window present in all workspaces."); + break; + case 8: + caption = _("Start miniaturized"); + flag = WFLAGP(wwin, start_miniaturized); + descr = _("Make the window be automatically miniaturized when it's\n" + "first shown."); + break; + case 9: + caption = _("Start maximized"); + flag = WFLAGP(wwin, start_maximized!=0); + descr = _("Make the window be automatically maximized when it's\n" + "first shown."); + break; + case 10: + caption = _("Full screen maximization"); + flag = WFLAGP(wwin, full_maximize); + descr = _("Make the window use the whole screen space when it's\n" + "maximized. The titlebar and resizebar will be moved\n" + "to outside the screen."); + break; + } + panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm); + WMMoveWidget(panel->attrChk[i], 10, 20*(i+1)); + WMResizeWidget(panel->attrChk[i], frame_width-15, 20); + WMSetButtonSelected(panel->attrChk[i], flag); + WMSetButtonText(panel->attrChk[i], caption); + + WMSetBalloonTextForView(descr, WMWidgetView(panel->attrChk[i])); } @@ -1422,84 +1422,84 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, for (i=0; #ifdef XKB_BUTTON_HINT - i < 9; + i < 9; #else - i < 8; + i < 8; #endif - i++) { - char *caption = NULL; - int flag = 0; - char *descr = NULL; - - switch (i) { - case 0: - caption = _("Do not bind keyboard shortcuts"); - flag = WFLAGP(wwin, no_bind_keys); - descr = _("Do not bind keyboard shortcuts from Window Maker\n" - "when this window is focused. This will allow the\n" - "window to receive all key combinations regardless\n" - "of your shortcut configuration."); - break; - case 1: - caption = _("Do not bind mouse clicks"); - flag = WFLAGP(wwin, no_bind_mouse); - descr = _("Do not bind mouse actions, such as `Alt'+drag\n" - "in the window (when alt is the modifier you have" - "configured)."); - break; - case 2: - caption = _("Do not show in the window list"); - flag = WFLAGP(wwin, skip_window_list); - descr = _("Do not list the window in the window list menu."); - break; - case 3: - caption = _("Do not let it take focus"); - flag = WFLAGP(wwin, no_focusable); - descr = _("Do not let the window take keyboard focus when you\n" - "click on it."); - break; - case 4: - caption = _("Keep inside screen"); - flag = WFLAGP(wwin, dont_move_off); - descr = _("Do not allow the window to move itself completely\n" - "outside the screen. For bug compatibility.\n"); - break; - case 5: - caption = _("Ignore 'Hide Others'"); - flag = WFLAGP(wwin, no_hide_others); - descr = _("Do not hide the window when issuing the\n" - "`HideOthers' command."); - break; - case 6: - caption = _("Ignore 'Save Session'"); - flag = WFLAGP(wwin, dont_save_session); - descr = _("Do not save the associated application in the\n" - "session's state, so that it won't be restarted\n" - "together with other applications when Window Maker\n" - "starts."); - break; - case 7: - caption = _("Emulate application icon"); - flag = WFLAGP(wwin, emulate_appicon); - descr = _("Make this window act as an application that provides\n" - "enough information to Window Maker for a dockable\n" - "application icon to be created."); - break; + i++) { + char *caption = NULL; + int flag = 0; + char *descr = NULL; + + switch (i) { + case 0: + caption = _("Do not bind keyboard shortcuts"); + flag = WFLAGP(wwin, no_bind_keys); + descr = _("Do not bind keyboard shortcuts from Window Maker\n" + "when this window is focused. This will allow the\n" + "window to receive all key combinations regardless\n" + "of your shortcut configuration."); + break; + case 1: + caption = _("Do not bind mouse clicks"); + flag = WFLAGP(wwin, no_bind_mouse); + descr = _("Do not bind mouse actions, such as `Alt'+drag\n" + "in the window (when alt is the modifier you have" + "configured)."); + break; + case 2: + caption = _("Do not show in the window list"); + flag = WFLAGP(wwin, skip_window_list); + descr = _("Do not list the window in the window list menu."); + break; + case 3: + caption = _("Do not let it take focus"); + flag = WFLAGP(wwin, no_focusable); + descr = _("Do not let the window take keyboard focus when you\n" + "click on it."); + break; + case 4: + caption = _("Keep inside screen"); + flag = WFLAGP(wwin, dont_move_off); + descr = _("Do not allow the window to move itself completely\n" + "outside the screen. For bug compatibility.\n"); + break; + case 5: + caption = _("Ignore 'Hide Others'"); + flag = WFLAGP(wwin, no_hide_others); + descr = _("Do not hide the window when issuing the\n" + "`HideOthers' command."); + break; + case 6: + caption = _("Ignore 'Save Session'"); + flag = WFLAGP(wwin, dont_save_session); + descr = _("Do not save the associated application in the\n" + "session's state, so that it won't be restarted\n" + "together with other applications when Window Maker\n" + "starts."); + break; + case 7: + caption = _("Emulate application icon"); + flag = WFLAGP(wwin, emulate_appicon); + descr = _("Make this window act as an application that provides\n" + "enough information to Window Maker for a dockable\n" + "application icon to be created."); + break; #ifdef XKB_BUTTON_HINT - case 8: - caption = _("Disable language button"); - flag = WFLAGP(wwin, no_language_button); - descr = _("Remove the `toggle language' button of the window."); - break; + case 8: + caption = _("Disable language button"); + flag = WFLAGP(wwin, no_language_button); + descr = _("Remove the `toggle language' button of the window."); + break; #endif - } - panel->moreChk[i] = WMCreateSwitchButton(panel->moreFrm); - WMMoveWidget(panel->moreChk[i], 10, 20*(i+1)); - WMResizeWidget(panel->moreChk[i], frame_width-15, 20); - WMSetButtonSelected(panel->moreChk[i], flag); - WMSetButtonText(panel->moreChk[i], caption); - - WMSetBalloonTextForView(descr, WMWidgetView(panel->moreChk[i])); + } + panel->moreChk[i] = WMCreateSwitchButton(panel->moreFrm); + WMMoveWidget(panel->moreChk[i], 10, 20*(i+1)); + WMResizeWidget(panel->moreChk[i], frame_width-15, 20); + WMSetButtonSelected(panel->moreChk[i], flag); + WMSetButtonText(panel->moreChk[i], caption); + + WMSetBalloonTextForView(descr, WMWidgetView(panel->moreChk[i])); } /* miniwindow/workspace */ @@ -1513,7 +1513,7 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, WMResizeWidget(panel->iconLbl, 64, 64); WMSetLabelRelief(panel->iconLbl, WRGroove); WMSetLabelImagePosition(panel->iconLbl, WIPImageOnly); - + panel->browseIconBtn = WMCreateCommandButton(panel->iconFrm); WMSetButtonAction(panel->browseIconBtn, chooseIconCallback, panel); WMMoveWidget(panel->browseIconBtn, 22, 32); @@ -1539,9 +1539,9 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, WMMoveWidget(panel->fileText, 20, 105); WMResizeWidget(panel->fileText, PWIDTH - (2 * 20) - (2 * 15), 20); WMSetTextFieldText(panel->fileText, NULL); - WMAddNotificationObserver(textEditedObserver, panel, - WMTextDidEndEditingNotification, - panel->fileText); + WMAddNotificationObserver(textEditedObserver, panel, + WMTextDidEndEditingNotification, + panel->fileText); panel->alwChk = WMCreateSwitchButton(panel->iconFrm); WMMoveWidget(panel->alwChk, 20, 130); @@ -1556,102 +1556,102 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, WMSetFrameTitle(panel->wsFrm, _("Initial Workspace")); WMSetBalloonTextForView(_("The workspace to place the window when it's" - "first shown."), WMWidgetView(panel->wsFrm)); + "first shown."), WMWidgetView(panel->wsFrm)); panel->wsP = WMCreatePopUpButton(panel->wsFrm); WMMoveWidget(panel->wsP, 20, 30); WMResizeWidget(panel->wsP, PWIDTH - (2 * 15) - (2 * 20), 20); WMAddPopUpButtonItem(panel->wsP, _("Nowhere in particular")); for (i = 0; i < wwin->screen_ptr->workspace_count; i++) { - WMAddPopUpButtonItem(panel->wsP, scr->workspaces[i]->name); + WMAddPopUpButtonItem(panel->wsP, scr->workspaces[i]->name); } i = wDefaultGetStartWorkspace(wwin->screen_ptr, wwin->wm_instance, wwin->wm_class); if (i >= 0 && i <= wwin->screen_ptr->workspace_count) { - WMSetPopUpButtonSelectedItem(panel->wsP, i + 1); + WMSetPopUpButtonSelectedItem(panel->wsP, i + 1); } else { - WMSetPopUpButtonSelectedItem(panel->wsP, 0); + WMSetPopUpButtonSelectedItem(panel->wsP, 0); } /* application wide attributes */ if (wwin->main_window != None) { - WApplication *wapp = wApplicationOf(wwin->main_window); - - panel->appFrm = WMCreateFrame(panel->win); - WMSetFrameTitle(panel->appFrm, _("Application Attributes")); - WMMoveWidget(panel->appFrm, 15, 50); - WMResizeWidget(panel->appFrm, frame_width, 240); - - for (i=0; i < 3; i++) { - char *caption = NULL; - int flag = 0; - char *descr = NULL; - - switch (i) { - case 0: - caption = _("Start hidden"); - flag = WFLAGP(wapp->main_window_desc, start_hidden); - descr = _("Automatically hide application when it's started."); - break; - case 1: - caption = _("No application icon"); - flag = WFLAGP(wapp->main_window_desc, no_appicon); - descr = _("Disable the application icon for the application.\n" - "Note that you won't be able to dock it anymore,\n" - "and any icons that are already docked will stop\n" - "working correctly."); - break; - case 2: - caption = _("Shared application icon"); - flag = WFLAGP(wapp->main_window_desc, shared_appicon); + WApplication *wapp = wApplicationOf(wwin->main_window); + + panel->appFrm = WMCreateFrame(panel->win); + WMSetFrameTitle(panel->appFrm, _("Application Attributes")); + WMMoveWidget(panel->appFrm, 15, 50); + WMResizeWidget(panel->appFrm, frame_width, 240); + + for (i=0; i < 3; i++) { + char *caption = NULL; + int flag = 0; + char *descr = NULL; + + switch (i) { + case 0: + caption = _("Start hidden"); + flag = WFLAGP(wapp->main_window_desc, start_hidden); + descr = _("Automatically hide application when it's started."); + break; + case 1: + caption = _("No application icon"); + flag = WFLAGP(wapp->main_window_desc, no_appicon); + descr = _("Disable the application icon for the application.\n" + "Note that you won't be able to dock it anymore,\n" + "and any icons that are already docked will stop\n" + "working correctly."); + break; + case 2: + caption = _("Shared application icon"); + flag = WFLAGP(wapp->main_window_desc, shared_appicon); descr = _("Use a single shared application icon for all of\n" "the instances of this application.\n"); - break; - } - panel->appChk[i] = WMCreateSwitchButton(panel->appFrm); - WMMoveWidget(panel->appChk[i], 10, 20*(i+1)); - WMResizeWidget(panel->appChk[i], 205, 20); - WMSetButtonSelected(panel->appChk[i], flag); - WMSetButtonText(panel->appChk[i], caption); - - WMSetBalloonTextForView(descr, WMWidgetView(panel->appChk[i])); - } - - if (WFLAGP(wwin, emulate_appicon)) { - WMSetButtonEnabled(panel->appChk[1], False); - WMSetButtonEnabled(panel->moreChk[7], True); - } else { - WMSetButtonEnabled(panel->appChk[1], True); - WMSetButtonEnabled(panel->moreChk[7], False); - } + break; + } + panel->appChk[i] = WMCreateSwitchButton(panel->appFrm); + WMMoveWidget(panel->appChk[i], 10, 20*(i+1)); + WMResizeWidget(panel->appChk[i], 205, 20); + WMSetButtonSelected(panel->appChk[i], flag); + WMSetButtonText(panel->appChk[i], caption); + + WMSetBalloonTextForView(descr, WMWidgetView(panel->appChk[i])); + } + + if (WFLAGP(wwin, emulate_appicon)) { + WMSetButtonEnabled(panel->appChk[1], False); + WMSetButtonEnabled(panel->moreChk[7], True); + } else { + WMSetButtonEnabled(panel->appChk[1], True); + WMSetButtonEnabled(panel->moreChk[7], False); + } } else { - int tmp; - - if ((wwin->transient_for!=None && wwin->transient_for!=scr->root_win) - || !wwin->wm_class || !wwin->wm_instance) - tmp = False; - else - tmp = True; - WMSetButtonEnabled(panel->moreChk[7], tmp); - - WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False); - panel->appFrm = NULL; + int tmp; + + if ((wwin->transient_for!=None && wwin->transient_for!=scr->root_win) + || !wwin->wm_class || !wwin->wm_instance) + tmp = False; + else + tmp = True; + WMSetButtonEnabled(panel->moreChk[7], tmp); + + WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False); + panel->appFrm = NULL; } - + /* if the window is a transient, don't let it have a miniaturize * button */ if (wwin->transient_for!=None && wwin->transient_for!=scr->root_win) - WMSetButtonEnabled(panel->attrChk[3], False); + WMSetButtonEnabled(panel->attrChk[3], False); else - WMSetButtonEnabled(panel->attrChk[3], True); + WMSetButtonEnabled(panel->attrChk[3], True); + - if (!wwin->wm_class && !wwin->wm_instance) { - WMSetPopUpButtonItemEnabled(panel->pagePopUp, 0, False); + WMSetPopUpButtonItemEnabled(panel->pagePopUp, 0, False); } - + WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win); @@ -1661,19 +1661,19 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, WMMapSubwidgets(panel->iconFrm); WMMapSubwidgets(panel->wsFrm); if (panel->appFrm) - WMMapSubwidgets(panel->appFrm); + WMMapSubwidgets(panel->appFrm); if (showSelectPanel) { - WMSetPopUpButtonSelectedItem(panel->pagePopUp, 0); - changePage(panel->pagePopUp, panel); + WMSetPopUpButtonSelectedItem(panel->pagePopUp, 0); + changePage(panel->pagePopUp, panel); } else { - WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1); - changePage(panel->pagePopUp, panel); + WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1); + changePage(panel->pagePopUp, panel); } - - parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT, - 0, 0, 0); + + parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT, + 0, 0, 0); XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask); panel->parent = parent; XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0); @@ -1683,22 +1683,22 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, XSetTransientForHint(dpy, parent, wwin->client_win); if (xpos == UNDEFINED_POS) { - x = wwin->frame_x+wwin->frame->core->width/2; - y = wwin->frame_y+wwin->frame->top_width*2; - if (y + PHEIGHT > scr->scr_height) - y = scr->scr_height - PHEIGHT - 30; - if (x + PWIDTH > scr->scr_width) - x = scr->scr_width - PWIDTH; + x = wwin->frame_x+wwin->frame->core->width/2; + y = wwin->frame_y+wwin->frame->top_width*2; + if (y + PHEIGHT > scr->scr_height) + y = scr->scr_height - PHEIGHT - 30; + if (x + PWIDTH > scr->scr_width) + x = scr->scr_width - PWIDTH; } else { - x = xpos; - y = ypos; + x = xpos; + y = ypos; } - panel->frame = wManageInternalWindow(scr, parent, wwin->client_win, - "Inspector", x, y, PWIDTH, PHEIGHT); + panel->frame = wManageInternalWindow(scr, parent, wwin->client_win, + "Inspector", x, y, PWIDTH, PHEIGHT); if (!selectedBtn) - selectedBtn = panel->defaultRb; + selectedBtn = panel->defaultRb; WMSetButtonSelected(selectedBtn, True); @@ -1715,8 +1715,8 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos, wWindowMap(panel->frame); - showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance, - wwin->wm_class, UPDATE_TEXT_FIELD); + showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance, + wwin->wm_class, UPDATE_TEXT_FIELD); return panel; } @@ -1726,19 +1726,19 @@ void wShowInspectorForWindow(WWindow *wwin) { if (wwin->flags.inspector_open) - return; + return; WMSetBalloonEnabled(wwin->screen_ptr->wmscreen, wPreferences.help_balloon); make_keys(); wwin->flags.inspector_open = 1; wwin->inspector = createInspectorForWindow(wwin, UNDEFINED_POS, - UNDEFINED_POS, False); + UNDEFINED_POS, False); } - + void wHideInspectorForWindow(WWindow *wwin) { @@ -1768,13 +1768,13 @@ wUnhideInspectorForWindow(WWindow *wwin) WWindow* wGetWindowOfInspectorForWindow(WWindow *wwin) -{ +{ if (wwin->inspector) { - assert(wwin->flags.inspector_open != 0); - - return wwin->inspector->frame; + assert(wwin->flags.inspector_open != 0); + + return wwin->inspector->frame; } else - return NULL; + return NULL; } diff --git a/src/winspector.h b/src/winspector.h index 268541dd..08159784 100644 --- a/src/winspector.h +++ b/src/winspector.h @@ -1,9 +1,9 @@ /* winspector.h - window attribute inspector header file - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ diff --git a/src/wmspec.h b/src/wmspec.h index 39890875..dc0ea705 100644 --- a/src/wmspec.h +++ b/src/wmspec.h @@ -1,9 +1,9 @@ /* wmspec.h-- support for the wm-spec Hints - * + * * Window Maker window manager - * + * * Copyright (c) 1998-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ diff --git a/src/workspace.c b/src/workspace.c index 85cb2281..961354ac 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -75,7 +75,7 @@ static void make_keys() { if (dWorkspaces!=NULL) - return; + return; dWorkspaces = WMCreatePLString("Workspaces"); dName = WMCreatePLString("Name"); @@ -87,8 +87,8 @@ void wWorkspaceMake(WScreen *scr, int count) { while (count>0) { - wWorkspaceNew(scr); - count--; + wWorkspaceNew(scr); + count--; } } @@ -161,14 +161,14 @@ wWorkspaceDelete(WScreen *scr, int workspace) int i, j; if (workspace<=0) - return False; + return False; /* verify if workspace is in use by some window */ tmp = scr->focused_window; while (tmp) { - if (!IS_OMNIPRESENT(tmp) && tmp->frame->workspace==workspace) - return False; - tmp = tmp->prev; + if (!IS_OMNIPRESENT(tmp) && tmp->frame->workspace==workspace) + return False; + tmp = tmp->prev; } if (!wPreferences.flags.noclip) { @@ -180,12 +180,12 @@ wWorkspaceDelete(WScreen *scr, int workspace) j = 0; for (i=0; iworkspace_count; i++) { if (i!=workspace) { - list[j++] = scr->workspaces[i]; + list[j++] = scr->workspaces[i]; } else { - if (scr->workspaces[i]->name) - wfree(scr->workspaces[i]->name); - wfree(scr->workspaces[i]); - } + if (scr->workspaces[i]->name) + wfree(scr->workspaces[i]->name); + wfree(scr->workspaces[i]); + } } wfree(scr->workspaces); scr->workspaces = list; @@ -200,12 +200,12 @@ wWorkspaceDelete(WScreen *scr, int workspace) /* update also window menu */ if (scr->workspace_submenu) { - WMenu *menu = scr->workspace_submenu; + WMenu *menu = scr->workspace_submenu; i = menu->entry_no; while (i>scr->workspace_count) wMenuRemoveItem(menu, --i); - wMenuRealize(menu); + wMenuRealize(menu); } /* and clip menu */ if (scr->clip_submenu) { @@ -214,7 +214,7 @@ wWorkspaceDelete(WScreen *scr, int workspace) i = menu->entry_no; while (i>scr->workspace_count) wMenuRemoveItem(menu, --i); - wMenuRealize(menu); + wMenuRealize(menu); } #ifdef NETWM_HINTS @@ -222,10 +222,10 @@ wWorkspaceDelete(WScreen *scr, int workspace) #endif WMPostNotificationName(WMNWorkspaceDestroyed, scr, - (void*)(scr->workspace_count-1)); + (void*)(scr->workspace_count-1)); if (scr->current_workspace >= scr->workspace_count) - wWorkspaceChange(scr, scr->workspace_count-1); + wWorkspaceChange(scr, scr->workspace_count-1); return True; } @@ -245,37 +245,37 @@ hideWorkspaceName(void *data) WScreen *scr = (WScreen*)data; if (!scr->workspace_name_data || scr->workspace_name_data->count == 0 - || time(NULL) > scr->workspace_name_data->timeout) { - XUnmapWindow(dpy, scr->workspace_name); + || time(NULL) > scr->workspace_name_data->timeout) { + XUnmapWindow(dpy, scr->workspace_name); - if (scr->workspace_name_data) { - RReleaseImage(scr->workspace_name_data->back); - RReleaseImage(scr->workspace_name_data->text); - wfree(scr->workspace_name_data); + if (scr->workspace_name_data) { + RReleaseImage(scr->workspace_name_data->back); + RReleaseImage(scr->workspace_name_data->text); + wfree(scr->workspace_name_data); - scr->workspace_name_data = NULL; - } - scr->workspace_name_timer = NULL; + scr->workspace_name_data = NULL; + } + scr->workspace_name_timer = NULL; } else { - RImage *img = RCloneImage(scr->workspace_name_data->back); - Pixmap pix; + RImage *img = RCloneImage(scr->workspace_name_data->back); + Pixmap pix; - scr->workspace_name_timer = - WMAddTimerHandler(WORKSPACE_NAME_FADE_DELAY, hideWorkspaceName, scr); + scr->workspace_name_timer = + WMAddTimerHandler(WORKSPACE_NAME_FADE_DELAY, hideWorkspaceName, scr); - RCombineImagesWithOpaqueness(img, scr->workspace_name_data->text, - scr->workspace_name_data->count*255/10); + RCombineImagesWithOpaqueness(img, scr->workspace_name_data->text, + scr->workspace_name_data->count*255/10); - RConvertImage(scr->rcontext, img, &pix); + RConvertImage(scr->rcontext, img, &pix); - RReleaseImage(img); + RReleaseImage(img); - XSetWindowBackgroundPixmap(dpy, scr->workspace_name, pix); - XClearWindow(dpy, scr->workspace_name); - XFreePixmap(dpy, pix); - XFlush(dpy); + XSetWindowBackgroundPixmap(dpy, scr->workspace_name, pix); + XClearWindow(dpy, scr->workspace_name); + XFreePixmap(dpy, pix); + XFlush(dpy); - scr->workspace_name_data->count--; + scr->workspace_name_data->count--; } } @@ -298,17 +298,17 @@ showWorkspaceName(WScreen *scr, int workspace) } if (scr->workspace_name_timer) { - WMDeleteTimerHandler(scr->workspace_name_timer); - XUnmapWindow(dpy, scr->workspace_name); - XFlush(dpy); + WMDeleteTimerHandler(scr->workspace_name_timer); + XUnmapWindow(dpy, scr->workspace_name); + XFlush(dpy); } scr->workspace_name_timer = WMAddTimerHandler(WORKSPACE_NAME_DELAY, - hideWorkspaceName, scr); + hideWorkspaceName, scr); if (scr->workspace_name_data) { - RReleaseImage(scr->workspace_name_data->back); - RReleaseImage(scr->workspace_name_data->text); - wfree(scr->workspace_name_data); + RReleaseImage(scr->workspace_name_data->back); + RReleaseImage(scr->workspace_name_data->text); + wfree(scr->workspace_name_data); } data = wmalloc(sizeof(WorkspaceNameData)); @@ -318,35 +318,35 @@ showWorkspaceName(WScreen *scr, int workspace) h = WMFontHeight(scr->workspace_name_font); switch (wPreferences.workspace_name_display_position) { - case WD_TOP: - px = (scr->scr_width - (w+4))/2; - py = 0; - break; - case WD_BOTTOM: - px = (scr->scr_width - (w+4))/2; - py = scr->scr_height - (h+4); - break; - case WD_TOPLEFT: - px = 0; - py = 0; - break; - case WD_TOPRIGHT: - px = scr->scr_width - (w+4); - py = 0; - break; - case WD_BOTTOMLEFT: - px = 0; - py = scr->scr_height - (h+4); - break; - case WD_BOTTOMRIGHT: - px = scr->scr_width - (w+4); - py = scr->scr_height - (h+4); - break; - case WD_CENTER: - default: - px = (scr->scr_width - (w+4))/2; - py = (scr->scr_height - (h+4))/2; - break; + case WD_TOP: + px = (scr->scr_width - (w+4))/2; + py = 0; + break; + case WD_BOTTOM: + px = (scr->scr_width - (w+4))/2; + py = scr->scr_height - (h+4); + break; + case WD_TOPLEFT: + px = 0; + py = 0; + break; + case WD_TOPRIGHT: + px = scr->scr_width - (w+4); + py = 0; + break; + case WD_BOTTOMLEFT: + px = 0; + py = scr->scr_height - (h+4); + break; + case WD_BOTTOMRIGHT: + px = scr->scr_width - (w+4); + py = scr->scr_height - (h+4); + break; + case WD_CENTER: + default: + px = (scr->scr_width - (w+4))/2; + py = (scr->scr_height - (h+4))/2; + break; } XResizeWindow(dpy, scr->workspace_name, w+4, h+4); XMoveWindow(dpy, scr->workspace_name, px, py); @@ -355,13 +355,13 @@ showWorkspaceName(WScreen *scr, int workspace) mask = XCreatePixmap(dpy, scr->w_win, w+4, h+4, 1); /*XSetForeground(dpy, scr->mono_gc, 0); - XFillRectangle(dpy, mask, scr->mono_gc, 0, 0, w+4, h+4);*/ + XFillRectangle(dpy, mask, scr->mono_gc, 0, 0, w+4, h+4);*/ XFillRectangle(dpy, text, WMColorGC(scr->black), 0, 0, w+4, h+4); for (x = 0; x <= 4; x++) { - for (y = 0; y <= 4; y++) { - WMDrawString(scr->wmscreen, text, scr->white, + for (y = 0; y <= 4; y++) { + WMDrawString(scr->wmscreen, text, scr->white, scr->workspace_name_font, x, y, name, len); } } @@ -381,7 +381,7 @@ showWorkspaceName(WScreen *scr, int workspace) #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); @@ -392,17 +392,17 @@ showWorkspaceName(WScreen *scr, int workspace) XFreePixmap(dpy, mask); if (!data->text) { - XMapRaised(dpy, scr->workspace_name); - XFlush(dpy); + XMapRaised(dpy, scr->workspace_name); + XFlush(dpy); - goto erro; + goto erro; } ximg = RGetXImage(scr->rcontext, scr->root_win, px, py, - data->text->width, data->text->height); + data->text->width, data->text->height); if (!ximg || !ximg->image) { - goto erro; + goto erro; } XMapRaised(dpy, scr->workspace_name); @@ -412,7 +412,7 @@ showWorkspaceName(WScreen *scr, int workspace) RDestroyXImage(scr->rcontext, ximg); if (!data->back) { - goto erro; + goto erro; } data->count = 10; @@ -428,19 +428,19 @@ showWorkspaceName(WScreen *scr, int workspace) erro: if (scr->workspace_name_timer) - WMDeleteTimerHandler(scr->workspace_name_timer); + WMDeleteTimerHandler(scr->workspace_name_timer); if (data->text) - RReleaseImage(data->text); + RReleaseImage(data->text); if (data->back) - RReleaseImage(data->back); + RReleaseImage(data->back); wfree(data); scr->workspace_name_data = NULL; scr->workspace_name_timer = WMAddTimerHandler(WORKSPACE_NAME_DELAY + - 10*WORKSPACE_NAME_FADE_DELAY, - hideWorkspaceName, scr); + 10*WORKSPACE_NAME_FADE_DELAY, + hideWorkspaceName, scr); } @@ -448,13 +448,13 @@ void wWorkspaceChange(WScreen *scr, int workspace) { if (scr->flags.startup || scr->flags.startup2) { - return; + return; } if (workspace != scr->current_workspace) { wWorkspaceForceChange(scr, workspace); } /*else { - showWorkspaceName(scr, workspace); + showWorkspaceName(scr, workspace); }*/ } @@ -468,15 +468,15 @@ wWorkspaceRelativeChange(WScreen *scr, int amount) if (amount < 0) { if (w >= 0) { - wWorkspaceChange(scr, w); + wWorkspaceChange(scr, w); } else if (wPreferences.ws_cycle) { - wWorkspaceChange(scr, scr->workspace_count + w); + wWorkspaceChange(scr, scr->workspace_count + w); } } else if (amount > 0) { if (w < scr->workspace_count) { - wWorkspaceChange(scr, w); + wWorkspaceChange(scr, w); } else if (wPreferences.ws_advance) { - wWorkspaceChange(scr, WMIN(w, MAX_WORKSPACES-1)); + wWorkspaceChange(scr, WMIN(w, MAX_WORKSPACES-1)); } else if (wPreferences.ws_cycle) { wWorkspaceChange(scr, w % scr->workspace_count); } @@ -490,12 +490,12 @@ wWorkspaceForceChange(WScreen *scr, int workspace) WWindow *tmp, *foc=NULL, *foc2=NULL; if (workspace >= MAX_WORKSPACES || workspace < 0) - return; + return; SendHelperMessage(scr, 'C', workspace+1, NULL); if (workspace > scr->workspace_count-1) { - wWorkspaceMake(scr, workspace - scr->workspace_count + 1); + wWorkspaceMake(scr, workspace - scr->workspace_count + 1); } wClipUpdateForWorkspaceChange(scr, workspace); @@ -509,92 +509,92 @@ wWorkspaceForceChange(WScreen *scr, int workspace) if ((tmp = scr->focused_window)!= NULL) { if ((IS_OMNIPRESENT(tmp) && (tmp->flags.mapped || tmp->flags.shaded) && !WFLAGP(tmp, no_focusable)) || tmp->flags.changing_workspace) { - foc = tmp; - } - - /* foc2 = tmp; will fix annoyance with gnome panel - * but will create annoyance for every other application - */ - while (tmp) { - if (tmp->frame->workspace!=workspace && !tmp->flags.selected) { - /* unmap windows not on this workspace */ + foc = tmp; + } + + /* foc2 = tmp; will fix annoyance with gnome panel + * but will create annoyance for every other application + */ + while (tmp) { + if (tmp->frame->workspace!=workspace && !tmp->flags.selected) { + /* unmap windows not on this workspace */ if ((tmp->flags.mapped||tmp->flags.shaded) && !IS_OMNIPRESENT(tmp) && !tmp->flags.changing_workspace) { - wWindowUnmap(tmp); - } + wWindowUnmap(tmp); + } /* also unmap miniwindows not on this workspace */ if (!wPreferences.sticky_icons && tmp->flags.miniaturized && tmp->icon && !IS_OMNIPRESENT(tmp)) { XUnmapWindow(dpy, tmp->icon->core->window); tmp->icon->mapped = 0; } - /* update current workspace of omnipresent windows */ + /* update current workspace of omnipresent windows */ if (IS_OMNIPRESENT(tmp)) { - WApplication *wapp = wApplicationOf(tmp->main_window); + WApplication *wapp = wApplicationOf(tmp->main_window); - tmp->frame->workspace = workspace; + tmp->frame->workspace = workspace; - if (wapp) { - wapp->last_workspace = workspace; - } + if (wapp) { + wapp->last_workspace = workspace; + } if (!foc2 && (tmp->flags.mapped || tmp->flags.shaded)) { foc2 = tmp; } - } + } } else { - /* change selected windows' workspace */ - if (tmp->flags.selected) { - wWindowChangeWorkspace(tmp, workspace); + /* change selected windows' workspace */ + if (tmp->flags.selected) { + wWindowChangeWorkspace(tmp, workspace); if (!tmp->flags.miniaturized && !foc) { foc = tmp; } } else { - if (!tmp->flags.hidden) { - if (!(tmp->flags.mapped || tmp->flags.miniaturized)) { - /* remap windows that are on this workspace */ - wWindowMap(tmp); + if (!tmp->flags.hidden) { + if (!(tmp->flags.mapped || tmp->flags.miniaturized)) { + /* remap windows that are on this workspace */ + wWindowMap(tmp); if (!foc && !WFLAGP(tmp, no_focusable)) { foc = tmp; } - } - /* Also map miniwindow if not omnipresent */ - if (!wPreferences.sticky_icons && - tmp->flags.miniaturized && - !IS_OMNIPRESENT(tmp) && tmp->icon) { - tmp->icon->mapped = 1; - XMapWindow(dpy, tmp->icon->core->window); - } - } + } + /* Also map miniwindow if not omnipresent */ + if (!wPreferences.sticky_icons && + tmp->flags.miniaturized && + !IS_OMNIPRESENT(tmp) && tmp->icon) { + tmp->icon->mapped = 1; + XMapWindow(dpy, tmp->icon->core->window); + } + } } - } - tmp = tmp->prev; - } - - /* Gobble up events unleashed by our mapping & unmapping. - * These may trigger various grab-initiated focus & - * crossing events. However, we don't care about them, - * and ignore their focus implications altogether to avoid - * flicker. - */ - scr->flags.ignore_focus_events = 1; - ProcessPendingEvents(); - scr->flags.ignore_focus_events = 0; - - if (!foc) - foc = foc2; - - if (scr->focused_window->flags.mapped && !foc) { - foc = scr->focused_window; - } - if (wPreferences.focus_mode == WKF_CLICK) { - wSetFocusTo(scr, foc); - } else { + } + tmp = tmp->prev; + } + + /* Gobble up events unleashed by our mapping & unmapping. + * These may trigger various grab-initiated focus & + * crossing events. However, we don't care about them, + * and ignore their focus implications altogether to avoid + * flicker. + */ + scr->flags.ignore_focus_events = 1; + ProcessPendingEvents(); + scr->flags.ignore_focus_events = 0; + + if (!foc) + foc = foc2; + + if (scr->focused_window->flags.mapped && !foc) { + foc = scr->focused_window; + } + if (wPreferences.focus_mode == WKF_CLICK) { + wSetFocusTo(scr, foc); + } else { unsigned int mask; int foo; Window bar, win; - WWindow *tmp; + WWindow *tmp; - tmp = NULL; + tmp = NULL; if (XQueryPointer(dpy, scr->root_win, &bar, &win, &foo, &foo, &foo, &foo, &mask)) { tmp = wWindowFor(win); @@ -610,7 +610,7 @@ wWorkspaceForceChange(WScreen *scr, int workspace) } else { wSetFocusTo(scr, tmp); } - } + } } /* We need to always arrange icons when changing workspace, even if @@ -646,7 +646,7 @@ wWorkspaceForceChange(WScreen *scr, int workspace) WMPostNotificationName(WMNWorkspaceChanged, scr, (void*)workspace); -/* XSync(dpy, False); */ + /* XSync(dpy, False); */ } @@ -690,39 +690,39 @@ getClosestEdge(WScreen * scr, WMPoint direction, Bool (*cmp)(int)) WWindow * wwin; for (wwin=scr->focused_window; wwin; wwin=wwin->prev) { - if (wwin->frame->workspace == scr->current_workspace) { - if (!wwin->flags.miniaturized && - !IS_VSTUCK(wwin) && - !wwin->flags.hidden) { - int border = 2*HAS_BORDER(wwin); - int len; - int x1,x2,y1,y2; - int head = wGetHeadForWindow(wwin); - WArea area = wGetUsableAreaForHead(scr, head, NULL, False); - WMPoint p; - - x1 = wwin->frame_x - area.x1; - y1 = wwin->frame_y - area.y1; - x2 = wwin->frame_x + wwin->frame->core->width + border - area.x2; - y2 = wwin->frame_y + wwin->frame->core->height + border - area.y2; - - p = wmkpoint(x1,y1); - len = vec_dot(direction, p); - updateMinimum(len, p, closest_len, closest); - - p = wmkpoint(x1,y2); - len = vec_dot(direction, p); - updateMinimum(len, p, closest_len, closest); - - p = wmkpoint(x2,y1); - len = vec_dot(direction, p); - updateMinimum(len, p, closest_len, closest); - - p = wmkpoint(x2,y2); - len = vec_dot(direction, p); - updateMinimum(len, p, closest_len, closest); - } - } + if (wwin->frame->workspace == scr->current_workspace) { + if (!wwin->flags.miniaturized && + !IS_VSTUCK(wwin) && + !wwin->flags.hidden) { + int border = 2*HAS_BORDER(wwin); + int len; + int x1,x2,y1,y2; + int head = wGetHeadForWindow(wwin); + WArea area = wGetUsableAreaForHead(scr, head, NULL, False); + WMPoint p; + + x1 = wwin->frame_x - area.x1; + y1 = wwin->frame_y - area.y1; + x2 = wwin->frame_x + wwin->frame->core->width + border - area.x2; + y2 = wwin->frame_y + wwin->frame->core->height + border - area.y2; + + p = wmkpoint(x1,y1); + len = vec_dot(direction, p); + updateMinimum(len, p, closest_len, closest); + + p = wmkpoint(x1,y2); + len = vec_dot(direction, p); + updateMinimum(len, p, closest_len, closest); + + p = wmkpoint(x2,y1); + len = vec_dot(direction, p); + updateMinimum(len, p, closest_len, closest); + + p = wmkpoint(x2,y2); + len = vec_dot(direction, p); + updateMinimum(len, p, closest_len, closest); + } + } } return closest; @@ -764,18 +764,18 @@ vdMouseMoveDesktop(XEvent *event, WMPoint direction) scr->root_win, wCursor[WCUR_EMPTY], CurrentTime) != GrabSuccess) { - /* if the grab fails, do it the old fashioned way */ - step = vec_scale2(direction, wPreferences.vedge_hscrollspeed, - wPreferences.vedge_vscrollspeed); - wWorkspaceGetViewPosition(scr, scr->current_workspace, &x, &y); - if (wWorkspaceSetViewPort(scr, scr->current_workspace, - x+step.x, y+step.y)) { - step = vec_scale(direction, wPreferences.vedge_thickness + 1); - XWarpPointer(dpy, None, scr->root_win, 0,0,0,0, + /* if the grab fails, do it the old fashioned way */ + step = vec_scale2(direction, wPreferences.vedge_hscrollspeed, + wPreferences.vedge_vscrollspeed); + wWorkspaceGetViewPosition(scr, scr->current_workspace, &x, &y); + if (wWorkspaceSetViewPort(scr, scr->current_workspace, + x+step.x, y+step.y)) { + step = vec_scale(direction, wPreferences.vedge_thickness + 1); + XWarpPointer(dpy, None, scr->root_win, 0,0,0,0, event->xcrossing.x_root - step.x, event->xcrossing.y_root - step.y); - } - goto exit; + } + goto exit; } XSync(dpy, True); @@ -789,61 +789,61 @@ vdMouseMoveDesktop(XEvent *event, WMPoint direction) old_pos.y = scr->scr_height; while (!done) { - XEvent ev; - if (moved) { - XWarpPointer(dpy, None, scr->root_win, 0, 0, 0, 0, + XEvent ev; + if (moved) { + XWarpPointer(dpy, None, scr->root_win, 0, 0, 0, 0, scr->scr_width/2, scr->scr_height/2); - moved = False; - } - WMMaskEvent(dpy, PointerMotionMask, &ev); - - switch (ev.type) { - case MotionNotify: - { - int step_len; - step = wmkpoint(ev.xmotion.x_root-scr->scr_width/2, - ev.xmotion.y_root-scr->scr_height/2); - step_len = vec_dot(step, direction); - if (step_len < 0) { - done = True; - break; - } - - if (step_len > 0) { - Bool do_move = True; - int resist = wPreferences.vedge_resistance; - WMPoint closest; - int closest_len = INT_MAX; - if (resist) { - closest = getClosestEdge(scr, direction, cmp_gez); - closest_len = vec_dot(direction, closest); - } - - if (!closest_len) { - resisted += step_len; - do_move = resisted >= resist; - if (do_move) { - closest_len = INT_MAX; - step_len = resisted - resist; - resisted = 0; - } - } - if (do_move) { - if (closest_len <= wPreferences.vedge_attraction) { - step = vec_scale(direction, closest_len); - } else { - step = vec_scale(direction, step_len); - } - - wWorkspaceGetViewPosition(scr, scr->current_workspace, &x, &y); - wWorkspaceSetViewPort(scr, scr->current_workspace, - x+step.x, y+step.y); - moved = True; - } - } - } - break; - } + moved = False; + } + WMMaskEvent(dpy, PointerMotionMask, &ev); + + switch (ev.type) { + case MotionNotify: + { + int step_len; + step = wmkpoint(ev.xmotion.x_root-scr->scr_width/2, + ev.xmotion.y_root-scr->scr_height/2); + step_len = vec_dot(step, direction); + if (step_len < 0) { + done = True; + break; + } + + if (step_len > 0) { + Bool do_move = True; + int resist = wPreferences.vedge_resistance; + WMPoint closest; + int closest_len = INT_MAX; + if (resist) { + closest = getClosestEdge(scr, direction, cmp_gez); + closest_len = vec_dot(direction, closest); + } + + if (!closest_len) { + resisted += step_len; + do_move = resisted >= resist; + if (do_move) { + closest_len = INT_MAX; + step_len = resisted - resist; + resisted = 0; + } + } + if (do_move) { + if (closest_len <= wPreferences.vedge_attraction) { + step = vec_scale(direction, closest_len); + } else { + step = vec_scale(direction, step_len); + } + + wWorkspaceGetViewPosition(scr, scr->current_workspace, &x, &y); + wWorkspaceSetViewPort(scr, scr->current_workspace, + x+step.x, y+step.y); + moved = True; + } + } + } + break; + } } step = vec_add(old_pos, vec_scale(direction, -1)); @@ -913,29 +913,29 @@ void wWorkspaceManageEdge(WScreen *scr) { if (!initVDesk && wPreferences.vedge_thickness) { - int i, j, w; + int i, j, w; int vmask; XSetWindowAttributes attribs; - int heads = wXineramaHeads(scr); - int *hasEdges = (int*)wmalloc(sizeof(int)*heads); + int heads = wXineramaHeads(scr); + int *hasEdges = (int*)wmalloc(sizeof(int)*heads); - int thickness = wPreferences.vedge_thickness; - int nr_edges = 0; - int max_edges = 4*heads; - int head; - Window * edges = (Window *)wmalloc(sizeof(Window)*max_edges); + int thickness = wPreferences.vedge_thickness; + int nr_edges = 0; + int max_edges = 4*heads; + int head; + Window * edges = (Window *)wmalloc(sizeof(Window)*max_edges); initVDesk = True; for (i=0; i 0 && hlen == 0) { /* horz alignment, vert edges touch */ - if (i_rect.pos.x < j_rect.pos.x) { /* i left of j */ - hasEdges[i] &= ~RIGHT_EDGE; - hasEdges[j] &= ~LEFT_EDGE; - } else { /* j left of i */ - hasEdges[j] &= ~RIGHT_EDGE; - hasEdges[i] &= ~LEFT_EDGE; - } - } else if (vlen == 0 && hlen > 0) { /* vert alignment, horz edges touch */ - if (i_rect.pos.y < j_rect.pos.y) { /* i top of j */ - hasEdges[i] &= ~BOTTOM_EDGE; - hasEdges[j] &= ~TOP_EDGE; - } else { /* j top of i */ - hasEdges[j] &= ~BOTTOM_EDGE; - hasEdges[i] &= ~TOP_EDGE; - } - } - } - } + if (vlen > 0 && hlen == 0) { /* horz alignment, vert edges touch */ + if (i_rect.pos.x < j_rect.pos.x) { /* i left of j */ + hasEdges[i] &= ~RIGHT_EDGE; + hasEdges[j] &= ~LEFT_EDGE; + } else { /* j left of i */ + hasEdges[j] &= ~RIGHT_EDGE; + hasEdges[i] &= ~LEFT_EDGE; + } + } else if (vlen == 0 && hlen > 0) { /* vert alignment, horz edges touch */ + if (i_rect.pos.y < j_rect.pos.y) { /* i top of j */ + hasEdges[i] &= ~BOTTOM_EDGE; + hasEdges[j] &= ~TOP_EDGE; + } else { /* j top of i */ + hasEdges[j] &= ~BOTTOM_EDGE; + hasEdges[i] &= ~TOP_EDGE; + } + } + } + } for (w = 0; w < scr->workspace_count; w++) { /* puts("reset workspace"); */ @@ -972,10 +972,10 @@ wWorkspaceManageEdge(WScreen *scr) attribs.event_mask = (EnterWindowMask | LeaveWindowMask | VisibilityChangeMask); attribs.override_redirect = True; - for (head=0; headroot_win, rect.pos.x, rect.pos.y, rect.size.width, thickness, 0, @@ -983,52 +983,52 @@ wWorkspaceManageEdge(WScreen *scr) vmask, &attribs); XSaveContext(dpy, edges[nr_edges], wVEdgeContext, (XPointer)vdHandleEnter_u); - ++nr_edges; - } + ++nr_edges; + } - if (hasEdges[head] & BOTTOM_EDGE) { - edges[nr_edges] = - XCreateWindow(dpy, scr->root_win, rect.pos.x, + if (hasEdges[head] & BOTTOM_EDGE) { + edges[nr_edges] = + XCreateWindow(dpy, scr->root_win, rect.pos.x, rect.pos.y+rect.size.height-thickness, rect.size.width, thickness, 0, CopyFromParent, InputOnly, CopyFromParent, vmask, &attribs); - XSaveContext(dpy, edges[nr_edges], wVEdgeContext, + XSaveContext(dpy, edges[nr_edges], wVEdgeContext, (XPointer)vdHandleEnter_d); - ++nr_edges; - } + ++nr_edges; + } - if (hasEdges[head] & LEFT_EDGE) { - edges[nr_edges] = - XCreateWindow(dpy, scr->root_win, rect.pos.x, rect.pos.y, + if (hasEdges[head] & LEFT_EDGE) { + edges[nr_edges] = + XCreateWindow(dpy, scr->root_win, rect.pos.x, rect.pos.y, thickness, rect.pos.y+rect.size.height, 0, CopyFromParent, InputOnly, CopyFromParent, vmask, &attribs); - XSaveContext(dpy, edges[nr_edges], wVEdgeContext, + XSaveContext(dpy, edges[nr_edges], wVEdgeContext, (XPointer)vdHandleEnter_l); - ++nr_edges; - } - - if (hasEdges[head] & RIGHT_EDGE) { - edges[nr_edges] = - XCreateWindow(dpy, scr->root_win, - rect.pos.x + rect.size.width - thickness, rect.pos.y, - thickness, rect.size.height, 0, - CopyFromParent, InputOnly, CopyFromParent, vmask, - &attribs); - XSaveContext(dpy, edges[nr_edges], wVEdgeContext, + ++nr_edges; + } + + if (hasEdges[head] & RIGHT_EDGE) { + edges[nr_edges] = + XCreateWindow(dpy, scr->root_win, + rect.pos.x + rect.size.width - thickness, rect.pos.y, + thickness, rect.size.height, 0, + CopyFromParent, InputOnly, CopyFromParent, vmask, + &attribs); + XSaveContext(dpy, edges[nr_edges], wVEdgeContext, (XPointer)vdHandleEnter_r); - ++nr_edges; - } - } + ++nr_edges; + } + } - scr->virtual_nr_edges = nr_edges; - scr->virtual_edges = edges; + scr->virtual_nr_edges = nr_edges; + scr->virtual_edges = edges; wWorkspaceMapEdge(scr); wWorkspaceRaiseEdge(scr); - wfree(hasEdges); + wfree(hasEdges); } } @@ -1037,10 +1037,10 @@ void wWorkspaceUpdateEdge(WScreen *scr) { if (!initVDesk && wPreferences.vedge_thickness) { - wWorkspaceManageEdge(scr); + wWorkspaceManageEdge(scr); } else if (initVDesk) { if (wPreferences.vedge_thickness) { - wWorkspaceMapEdge(scr); + wWorkspaceMapEdge(scr); } else { wWorkspaceUnmapEdge(scr); } @@ -1052,18 +1052,18 @@ void wWorkspaceDestroyEdge(WScreen *scr) { if (!initVDesk) { - int i; + int i; - for (i=0; ivirtual_nr_edges; ++i) { - XDeleteContext(dpy, scr->virtual_edges[i], wVEdgeContext); - XDestroyWindow(dpy, scr->virtual_edges[i]); - } + for (i=0; ivirtual_nr_edges; ++i) { + XDeleteContext(dpy, scr->virtual_edges[i], wVEdgeContext); + XDestroyWindow(dpy, scr->virtual_edges[i]); + } wfree(scr->virtual_edges); scr->virtual_edges = NULL; - scr->virtual_nr_edges = 0; + scr->virtual_nr_edges = 0; - initVDesk = False; + initVDesk = False; } } @@ -1075,17 +1075,17 @@ wWorkspaceRaiseEdge(WScreen *scr) int i; if (wPreferences.vedge_thickness && initVDesk) { - if (toggle) { + if (toggle) { for (i=0; ivirtual_nr_edges; ++i) { XRaiseWindow(dpy, scr->virtual_edges[i]); } - } else { + } else { for (i=scr->virtual_nr_edges-1; i>=0; --i) { XRaiseWindow(dpy, scr->virtual_edges[i]); } - } + } - toggle ^= 1; + toggle ^= 1; } } @@ -1122,12 +1122,12 @@ updateWorkspaceGeometry(WScreen *scr, int workspace, int *view_x, int *view_y) int head, i; for (head=0; headflags.miniaturized && !IS_VSTUCK(wwin) && !wwin->flags.hidden) { - head = wGetHeadForWindow(wwin); + head = wGetHeadForWindow(wwin); - i = wwin->frame_x - strut[head][0]; + i = wwin->frame_x - strut[head][0]; if (i < most_left) /* record positions, should this be cached? */ most_left = i; - i = wwin->frame_x + wwin->frame->core->width + strut[head][1]; + i = wwin->frame_x + wwin->frame->core->width + strut[head][1]; if (HAS_BORDER(wwin)) i+=2; if (i > most_right) most_right = i; - i = wwin->frame_y - strut[head][2]; + i = wwin->frame_y - strut[head][2]; if (i < most_top) most_top = i; - i = wwin->frame_y + wwin->frame->core->height + strut[head][3]; + i = wwin->frame_y + wwin->frame->core->height + strut[head][3]; if (HAS_BORDER(wwin)) i+=2; if (i > most_bottom) { @@ -1247,7 +1247,7 @@ wWorkspaceSetViewPort(WScreen *scr, int workspace, int view_x, int view_y) for (wwin = scr->focused_window; wwin; wwin = wwin->prev) { if (wwin->frame->workspace == workspace && !IS_VSTUCK(wwin)) { wWindowMove(wwin, wwin->frame_x + diff_x, wwin->frame_y + diff_y); - adjust_flag = True; + adjust_flag = True; } } if (1) { /* if delay*/ @@ -1292,18 +1292,18 @@ newWSCommand(WMenu *menu, WMenuEntry *foo) ws = wWorkspaceNew(menu->frame->screen_ptr); /* autochange workspace*/ if (ws>=0) - wWorkspaceChange(menu->frame->screen_ptr, ws); + wWorkspaceChange(menu->frame->screen_ptr, ws); /* - if (ws<9) { - int kcode; - if (wKeyBindings[WKBD_WORKSPACE1+ws]) { - kcode = wKeyBindings[WKBD_WORKSPACE1+ws]->keycode; - entry->rtext = - wstrdup(XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0))); - } - }*/ + if (ws<9) { + int kcode; + if (wKeyBindings[WKBD_WORKSPACE1+ws]) { + kcode = wKeyBindings[WKBD_WORKSPACE1+ws]->keycode; + entry->rtext = + wstrdup(XKeysymToString(XKeycodeToKeysym(dpy, kcode, 0))); + } + }*/ } @@ -1313,14 +1313,14 @@ cropline(char *line) char *start, *end; if (strlen(line)==0) - return line; + return line; start = line; end = &(line[strlen(line)])-1; while (isspace(*line) && *line!=0) line++; while (isspace(*end) && end!=line) { - *end=0; - end--; + *end=0; + end--; } return line; } @@ -1333,15 +1333,15 @@ wWorkspaceRename(WScreen *scr, int workspace, char *name) char *tmp; if (workspace >= scr->workspace_count) - return; + return; /* trim white spaces */ tmp = cropline(name); if (strlen(tmp)==0) { - sprintf(buf, _("Workspace %i"), workspace+1); + sprintf(buf, _("Workspace %i"), workspace+1); } else { - strncpy(buf, tmp, MAX_WORKSPACENAME_WIDTH); + strncpy(buf, tmp, MAX_WORKSPACENAME_WIDTH); } buf[MAX_WORKSPACENAME_WIDTH] = 0; @@ -1350,18 +1350,18 @@ wWorkspaceRename(WScreen *scr, int workspace, char *name) scr->workspaces[workspace]->name = wstrdup(buf); if (scr->clip_ws_menu) { - if (strcmp(scr->clip_ws_menu->entries[workspace+2]->text, buf)!=0) { - wfree(scr->clip_ws_menu->entries[workspace+2]->text); - scr->clip_ws_menu->entries[workspace+2]->text = wstrdup(buf); - wMenuRealize(scr->clip_ws_menu); - } + if (strcmp(scr->clip_ws_menu->entries[workspace+2]->text, buf)!=0) { + wfree(scr->clip_ws_menu->entries[workspace+2]->text); + scr->clip_ws_menu->entries[workspace+2]->text = wstrdup(buf); + wMenuRealize(scr->clip_ws_menu); + } } if (scr->workspace_menu) { - if (strcmp(scr->workspace_menu->entries[workspace+2]->text, buf)!=0) { - wfree(scr->workspace_menu->entries[workspace+2]->text); - scr->workspace_menu->entries[workspace+2]->text = wstrdup(buf); - wMenuRealize(scr->workspace_menu); - } + if (strcmp(scr->workspace_menu->entries[workspace+2]->text, buf)!=0) { + wfree(scr->workspace_menu->entries[workspace+2]->text); + scr->workspace_menu->entries[workspace+2]->text = wstrdup(buf); + wMenuRealize(scr->workspace_menu); + } } if (scr->clip_icon) @@ -1391,8 +1391,8 @@ wWorkspaceMenuMake(WScreen *scr, Bool titled) wsmenu = wMenuCreate(scr, titled ? _("Workspaces") : NULL, False); if (!wsmenu) { - wwarning(_("could not create Workspace menu")); - return NULL; + wwarning(_("could not create Workspace menu")); + return NULL; } /* callback to be called when an entry is edited */ @@ -1416,46 +1416,46 @@ wWorkspaceMenuUpdate(WScreen *scr, WMenu *menu) int tmp; if (!menu) - return; + return; if (menu->entry_no < scr->workspace_count+2) { - /* new workspace(s) added */ - i = scr->workspace_count-(menu->entry_no-2); - ws = menu->entry_no - 2; - while (i>0) { - strcpy(title, scr->workspaces[ws]->name); - - entry = wMenuAddCallback(menu, title, switchWSCommand, (void*)ws); - entry->flags.indicator = 1; - entry->flags.editable = 1; - - i--; - ws++; - } + /* new workspace(s) added */ + i = scr->workspace_count-(menu->entry_no-2); + ws = menu->entry_no - 2; + while (i>0) { + strcpy(title, scr->workspaces[ws]->name); + + entry = wMenuAddCallback(menu, title, switchWSCommand, (void*)ws); + entry->flags.indicator = 1; + entry->flags.editable = 1; + + i--; + ws++; + } } else if (menu->entry_no > scr->workspace_count+2) { - /* removed workspace(s) */ - for (i = menu->entry_no-1; i >= scr->workspace_count+2; i--) { - wMenuRemoveItem(menu, i); - } + /* removed workspace(s) */ + for (i = menu->entry_no-1; i >= scr->workspace_count+2; i--) { + wMenuRemoveItem(menu, i); + } } wMenuRealize(menu); for (i=0; iworkspace_count; i++) { - menu->entries[i+2]->flags.indicator_on = 0; + menu->entries[i+2]->flags.indicator_on = 0; } menu->entries[scr->current_workspace+2]->flags.indicator_on = 1; /* don't let user destroy current workspace */ if (scr->current_workspace == scr->workspace_count-1) { - wMenuSetEnabled(menu, 1, False); + wMenuSetEnabled(menu, 1, False); } else { - wMenuSetEnabled(menu, 1, True); + wMenuSetEnabled(menu, 1, True); } tmp = menu->frame->top_width + 5; /* if menu got unreachable, bring it to a visible place */ if (menu->frame_x < tmp - (int)menu->frame->core->width) - wMenuMove(menu, tmp - (int)menu->frame->core->width, menu->frame_y, False); + wMenuMove(menu, tmp - (int)menu->frame->core->width, menu->frame_y, False); wMenuPaint(menu); } @@ -1508,7 +1508,7 @@ wWorkspaceRestoreState(WScreen *scr) parr = WMGetFromPLDictionary(scr->session_state, dWorkspaces); if (!parr) - return; + return; wscount = scr->workspace_count; for (i=0; i < WMIN(WMGetPropListItemCount(parr), MAX_WORKSPACES); i++) { @@ -1517,14 +1517,14 @@ wWorkspaceRestoreState(WScreen *scr) pstr = WMGetFromPLDictionary(wks_state, dName); else pstr = wks_state; - if (i >= scr->workspace_count) - wWorkspaceNew(scr); - if (scr->workspace_menu) { - wfree(scr->workspace_menu->entries[i+2]->text); - scr->workspace_menu->entries[i+2]->text = wstrdup(WMGetFromPLString(pstr)); - scr->workspace_menu->flags.realized = 0; - } - wfree(scr->workspaces[i]->name); + if (i >= scr->workspace_count) + wWorkspaceNew(scr); + if (scr->workspace_menu) { + wfree(scr->workspace_menu->entries[i+2]->text); + scr->workspace_menu->entries[i+2]->text = wstrdup(WMGetFromPLString(pstr)); + scr->workspace_menu->flags.realized = 0; + } + wfree(scr->workspaces[i]->name); scr->workspaces[i]->name = wstrdup(WMGetFromPLString(pstr)); if (!wPreferences.flags.noclip) { clip_state = WMGetFromPLDictionary(wks_state, dClip); @@ -1551,7 +1551,7 @@ wWorkspaceRestoreState(WScreen *scr) } } - WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void*)i); + WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void*)i); } } diff --git a/src/workspace.h b/src/workspace.h index 7d0760de..54f9f309 100644 --- a/src/workspace.h +++ b/src/workspace.h @@ -1,9 +1,9 @@ /* workspace.c- Workspace management - * + * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -39,7 +39,7 @@ int wWorkspaceNew(WScreen *scr); Bool wWorkspaceDelete(WScreen *scr, int workspace); void wWorkspaceChange(WScreen *scr, int workspace); void wWorkspaceForceChange(WScreen *scr, int workspace); -#ifdef VIRTUAL_DESKTOP +#ifdef VIRTUAL_DESKTOP void wWorkspaceManageEdge(WScreen *scr); void wWorkspaceUpdateEdge(WScreen *scr); void wWorkspaceDestroyEdge(WScreen *scr); diff --git a/src/wsound.c b/src/wsound.c index 53f10ac3..51218b15 100644 --- a/src/wsound.c +++ b/src/wsound.c @@ -23,11 +23,11 @@ wSoundPlay(long event_sound) XEvent sound_event; if (!atom) { - atom = XInternAtom(dpy, "_WINDOWMAKER_EVENT", False); + atom = XInternAtom(dpy, "_WINDOWMAKER_EVENT", False); } if(!wPreferences.no_sound) { - Window win = wScreenWithNumber(0)->info_window; + Window win = wScreenWithNumber(0)->info_window; sound_event.xclient.type = ClientMessage; sound_event.xclient.message_type = atom; @@ -36,7 +36,7 @@ wSoundPlay(long event_sound) sound_event.xclient.window = win; sound_event.xclient.data.l[0] = event_sound; XSendEvent(dpy, win, False, StructureNotifyMask, &sound_event); - XFlush(dpy); + XFlush(dpy); } } diff --git a/src/wsound.h b/src/wsound.h index 2eab2542..83664469 100644 --- a/src/wsound.h +++ b/src/wsound.h @@ -1,8 +1,8 @@ /* * Window Maker Sound Server - * + * * Copyright (c) 1997 Anthony P. Quinn - * + * * 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 @@ -15,7 +15,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. */ diff --git a/src/xdnd.c b/src/xdnd.c index b9a11dff..7de2a408 100644 --- a/src/xdnd.c +++ b/src/xdnd.c @@ -33,13 +33,14 @@ Atom _XA_XdndFinished; Atom _XA_WINDOWMAKER_XDNDEXCHANGE; /* -Atom _XA_MOTIF_DRAG_RECEIVER_INFO; -Atom _XA_MOTIF_DRAG_AND_DROP_MESSAGE; -*/ + Atom _XA_MOTIF_DRAG_RECEIVER_INFO; + Atom _XA_MOTIF_DRAG_AND_DROP_MESSAGE; + */ Atom atom_support; -void wXDNDInitializeAtoms() +void +wXDNDInitializeAtoms() { _XA_XdndAware = XInternAtom(dpy, "XdndAware", False); @@ -55,37 +56,41 @@ void wXDNDInitializeAtoms() _XA_WINDOWMAKER_XDNDEXCHANGE = XInternAtom(dpy, "_WINDOWMAKER_XDNDEXCHANGE", False); /* - _XA_MOTIF_DRAG_RECEIVER_INFO = XInternAtom(dpy, "_MOTIF_DRAG_RECEIVER_INFO",False); - _XA_MOTIF_DRAG_AND_DROP_MESSAGE = XInternAtom(dpy, "_MOTIF_DRAG_AND_DROP_MESSAGE", False); - */ + _XA_MOTIF_DRAG_RECEIVER_INFO = XInternAtom(dpy, "_MOTIF_DRAG_RECEIVER_INFO",False); + _XA_MOTIF_DRAG_AND_DROP_MESSAGE = XInternAtom(dpy, "_MOTIF_DRAG_AND_DROP_MESSAGE", False); + */ } -void wXDNDMakeAwareness(Window window) { +void +wXDNDMakeAwareness(Window window) +{ long int xdnd_version = 3; /* - MotifDragReceiverInfo info; - */ + MotifDragReceiverInfo info; + */ XChangeProperty (dpy, window, _XA_XdndAware, XA_ATOM, - 32, PropModeAppend, (char *)&xdnd_version, 1); + 32, PropModeAppend, (char *)&xdnd_version, 1); /*** MOTIF *** - info.byte_order = '\0'; - info.protocol_version = 0; - info.protocol_style = XmDRAG_DYNAMIC; - info.proxy_window = 0; - info.num_drop_sites = 0; - info.total_size = sizeof(info); - - XChangeProperty (dpy, window, - _XA_MOTIF_DRAG_RECEIVER_INFO, - _XA_MOTIF_DRAG_RECEIVER_INFO, - 8, PropModeReplace, - (unsigned char *)&info, - sizeof (info)); - */ + info.byte_order = '\0'; + info.protocol_version = 0; + info.protocol_style = XmDRAG_DYNAMIC; + info.proxy_window = 0; + info.num_drop_sites = 0; + info.total_size = sizeof(info); + + XChangeProperty (dpy, window, + _XA_MOTIF_DRAG_RECEIVER_INFO, + _XA_MOTIF_DRAG_RECEIVER_INFO, + 8, PropModeReplace, + (unsigned char *)&info, + sizeof (info)); + */ } -void wXDNDClearAwareness(Window window) { +void +wXDNDClearAwareness(Window window) +{ //long int xdnd_version = 3; XDeleteProperty (dpy, window, _XA_XdndAware); } @@ -106,11 +111,11 @@ wXDNDProcessSelection(XEvent *event) XGetWindowProperty(dpy, event->xselection.requestor, - _XA_WINDOWMAKER_XDNDEXCHANGE, - 0, 65536, True, atom_support, &ret_type, &ret_format, - &ret_item, &remain_byte, (unsigned char **)&delme); + _XA_WINDOWMAKER_XDNDEXCHANGE, + 0, 65536, True, atom_support, &ret_type, &ret_format, + &ret_item, &remain_byte, (unsigned char **)&delme); if (delme){ - scr->xdestring=delme; + scr->xdestring=delme; } /*send finished*/ @@ -147,7 +152,7 @@ wXDNDProcessSelection(XEvent *event) WMAddToArray(items, wstrdup(&retain[length + 1])); total_size += str_size + 3; /* reserve for " \"\"" */ /* this is nonsense -- if (length) - WMAppendArray(items, WMCreateArray(1));*/ + WMAppendArray(items, WMCreateArray(1));*/ } retain[length] = 0; } @@ -175,9 +180,9 @@ wXDNDProcessSelection(XEvent *event) WMFreeArray(items); wDockReceiveDNDDrop(scr,event); /* - printf("free "); - puts(scr->xdestring); - */ + printf("free "); + puts(scr->xdestring); + */ wfree(scr->xdestring); /* this xdestring is not from Xlib (no XFree) */ } @@ -194,9 +199,9 @@ isAwareXDND(Window window) if (!window) return False; XGetWindowProperty (dpy, window, _XA_XdndAware, - 0, 0x8000000L, False, XA_ATOM, - &actual, &format, - &count, &remaining, &data); + 0, 0x8000000L, False, XA_ATOM, + &actual, &format, + &count, &remaining, &data); if (actual != XA_ATOM || format != 32 || count == 0 || !data) { if (data) XFree (data); @@ -213,7 +218,7 @@ acceptXDND(Window window) WScreen *scr = wScreenForWindow(window); WDock *dock; int icon_pos,i; - + icon_pos = -1; if ((dock = scr->dock)!=NULL) { for (i=0; imax_icons; i++) { @@ -236,9 +241,9 @@ acceptXDND(Window window) if (icon_pos<0) return False; if (!dock) return False; if (isAwareXDND(dock->icon_array[icon_pos]->icon->icon_win)) return False; - + if (dock->icon_array[icon_pos]->dnd_command!=NULL) return True; - + return False; } @@ -247,62 +252,62 @@ wXDNDProcessClientMessage(XClientMessageEvent *event) { /* test */ { - char * name = XGetAtomName(dpy, event->message_type); - /* - printf("Get %s\n",name); - */ - XFree(name); + char * name = XGetAtomName(dpy, event->message_type); + /* + printf("Get %s\n",name); + */ + XFree(name); } /* - if (event->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) { - printf("motif dnd msg %d\n",event->data.b[0]); - if (event->data.b[0] == XmDROP_START){ - unsigned x_root, y_root, flags; - unsigned char reason; - unsigned long timestamp; - Atom atom; - Window source_window; - MotifDragInitiatorInfo *initiator_info; - Atom ret_type; - int ret_format; - unsigned long ret_item; - unsigned long remain_byte; - - reason = event->data.b[0]; - flags = event->data.s[1]; - timestamp = event->data.l[1]; - x_root = event->data.s[4]; - y_root = event->data.s[5]; - atom = event->data.l[3]; - source_window = event->data.l[4]; - - XGetWindowProperty(dpy, source_window, atom, - 0, sizeof(*initiator_info), True, atom_support, - &ret_type, &ret_format, - &ret_item, &remain_byte, (unsigned char **)&initiator_info); - } - } - else */ + if (event->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) { + printf("motif dnd msg %d\n",event->data.b[0]); + if (event->data.b[0] == XmDROP_START){ + unsigned x_root, y_root, flags; + unsigned char reason; + unsigned long timestamp; + Atom atom; + Window source_window; + MotifDragInitiatorInfo *initiator_info; + Atom ret_type; + int ret_format; + unsigned long ret_item; + unsigned long remain_byte; + + reason = event->data.b[0]; + flags = event->data.s[1]; + timestamp = event->data.l[1]; + x_root = event->data.s[4]; + y_root = event->data.s[5]; + atom = event->data.l[3]; + source_window = event->data.l[4]; + + XGetWindowProperty(dpy, source_window, atom, + 0, sizeof(*initiator_info), True, atom_support, + &ret_type, &ret_format, + &ret_item, &remain_byte, (unsigned char **)&initiator_info); + } + } + else */ if (event->message_type == _XA_XdndEnter) { if ((event->data.l[1] & 1) == 0){ atom_support = event->data.l[2]; } /* - else puts("enter more than 3 types"); - */ + else puts("enter more than 3 types"); + */ return True; } else if (event->message_type == _XA_XdndLeave) { return True; } else if (event->message_type == _XA_XdndDrop) { if (event->data.l[0] == XGetSelectionOwner(dpy, _XA_XdndSelection)){ XConvertSelection(dpy, _XA_XdndSelection, atom_support, - _XA_WINDOWMAKER_XDNDEXCHANGE, event->window, CurrentTime); + _XA_WINDOWMAKER_XDNDEXCHANGE, event->window, CurrentTime); } else { puts("wierd selection owner? QT?"); XConvertSelection(dpy, _XA_XdndSelection, atom_support, - _XA_WINDOWMAKER_XDNDEXCHANGE, event->window, CurrentTime); + _XA_WINDOWMAKER_XDNDEXCHANGE, event->window, CurrentTime); } return True; } else if (event->message_type == _XA_XdndPosition) { @@ -317,7 +322,7 @@ wXDNDProcessClientMessage(XClientMessageEvent *event) xevent.xany.display = dpy; xevent.xclient.window = srcwin; xevent.xclient.message_type = _XA_XdndStatus; - xevent.xclient.format = 32; + xevent.xclient.format = 32; XDND_STATUS_TARGET_WIN (&xevent) = event->window; XDND_STATUS_WILL_ACCEPT_SET (&xevent, acceptXDND(event->window)); @@ -333,3 +338,4 @@ wXDNDProcessClientMessage(XClientMessageEvent *event) } #endif + diff --git a/src/xinerama.c b/src/xinerama.c index 2877ed42..7be437b4 100644 --- a/src/xinerama.c +++ b/src/xinerama.c @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ @@ -72,11 +72,11 @@ wInitXinerama(WScreen *scr) XineramaScreenInfo *xine_screens; WXineramaInfo *info = &scr->xine_info; int i; - + xine_screens = XineramaQueryScreens(dpy, &info->count); info->screens = wmalloc(sizeof(WMRect)*(info->count+1)); - + for (i=0; icount; i++) { info->screens[i].pos.x = xine_screens[i].x_org; info->screens[i].pos.y = xine_screens[i].y_org; @@ -110,47 +110,47 @@ wGetRectPlacementInfo(WScreen *scr, WMRect rect, int *flags) *flags = XFLAG_NONE; if (scr->xine_info.count <= 1) { - unsigned long a; - - a = calcIntersectionArea(rx, ry, rw, rh, - 0, 0, scr->scr_width, scr->scr_height); - - if (a == 0) { - *flags |= XFLAG_DEAD; - } else if (a != rw*rh) { - *flags |= XFLAG_PARTIAL; - } - - return scr->xine_info.primary_head; + unsigned long a; + + a = calcIntersectionArea(rx, ry, rw, rh, + 0, 0, scr->scr_width, scr->scr_height); + + if (a == 0) { + *flags |= XFLAG_DEAD; + } else if (a != rw*rh) { + *flags |= XFLAG_PARTIAL; + } + + return scr->xine_info.primary_head; } for (i = 0; i < wXineramaHeads(scr); i++) { - unsigned long a; - - a = calcIntersectionArea(rx, ry, rw, rh, - scr->xine_info.screens[i].pos.x, - scr->xine_info.screens[i].pos.y, - scr->xine_info.screens[i].size.width, - scr->xine_info.screens[i].size.height); - - totalArea += a; - if (a > area) { - if (best != -1) - *flags |= XFLAG_MULTIPLE; - area = a; - best = i; - } + unsigned long a; + + a = calcIntersectionArea(rx, ry, rw, rh, + scr->xine_info.screens[i].pos.x, + scr->xine_info.screens[i].pos.y, + scr->xine_info.screens[i].size.width, + scr->xine_info.screens[i].size.height); + + totalArea += a; + if (a > area) { + if (best != -1) + *flags |= XFLAG_MULTIPLE; + area = a; + best = i; + } } if (best == -1) { - *flags |= XFLAG_DEAD; - best = wGetHeadForPointerLocation(scr); + *flags |= XFLAG_DEAD; + best = wGetHeadForPointerLocation(scr); } else if (totalArea != rw*rh) - *flags |= XFLAG_PARTIAL; + *flags |= XFLAG_PARTIAL; return best; } - + /* get the head that covers most of the rectangle */ @@ -166,31 +166,31 @@ wGetHeadForRect(WScreen *scr, WMRect rect) int rh = rect.size.height; if (!scr->xine_info.count) - return scr->xine_info.primary_head; + return scr->xine_info.primary_head; best = -1; area = 0; for (i = 0; i < wXineramaHeads(scr); i++) { - unsigned long a; - - a = calcIntersectionArea(rx, ry, rw, rh, - scr->xine_info.screens[i].pos.x, - scr->xine_info.screens[i].pos.y, - scr->xine_info.screens[i].size.width, - scr->xine_info.screens[i].size.height); - - if (a > area) { - area = a; - best = i; - } + unsigned long a; + + a = calcIntersectionArea(rx, ry, rw, rh, + scr->xine_info.screens[i].pos.x, + scr->xine_info.screens[i].pos.y, + scr->xine_info.screens[i].size.width, + scr->xine_info.screens[i].size.height); + + if (a > area) { + area = a; + best = i; + } } /* * in case rect is in dead space, return valid head */ if (best == -1) - best = wGetHeadForPointerLocation(scr); + best = wGetHeadForPointerLocation(scr); return best; } @@ -236,57 +236,57 @@ wGetHeadForWindow(WWindow *wwin) /* -int -wGetHeadForPoint(WScreen *scr, WMPoint point, int *flags) -{ - int i; - - // paranoia - if (flags == NULL) { - static int tmp; - flags = &tmp; - } - *flags = XFLAG_NONE; - - for (i = 0; i < scr->xine_info.count; i++) { -#if 0 - int yy, xx; - - xx = scr->xine_info.screens[i].pos.x + scr->xine_info.screens[i].size.width; - yy = scr->xine_info.screens[i].pos.y + scr->xine_info.screens[i].size.height; - if (point.x >= scr->xine_info.screens[i].pos.x && - point.y >= scr->xine_info.screens[i].pos.y && - point.x < xx && point.y < yy) { - return i; - } -#else - XineramaScreenInfo *xsi = &scr->xine_info.screens[i]; - - if ((unsigned)(point.x - xsi->x_org) < xsi->width && - (unsigned)(point.y - xsi->y_org) < xsi->height) - return i; -#endif - } - - *flags |= XFLAG_DEAD; - - return scr->xine_primary_head; -} -*/ + int + wGetHeadForPoint(WScreen *scr, WMPoint point, int *flags) + { + int i; + + // paranoia + if (flags == NULL) { + static int tmp; + flags = &tmp; + } + *flags = XFLAG_NONE; + + for (i = 0; i < scr->xine_info.count; i++) { + #if 0 + int yy, xx; + + xx = scr->xine_info.screens[i].pos.x + scr->xine_info.screens[i].size.width; + yy = scr->xine_info.screens[i].pos.y + scr->xine_info.screens[i].size.height; + if (point.x >= scr->xine_info.screens[i].pos.x && + point.y >= scr->xine_info.screens[i].pos.y && + point.x < xx && point.y < yy) { + return i; + } + #else + XineramaScreenInfo *xsi = &scr->xine_info.screens[i]; + + if ((unsigned)(point.x - xsi->x_org) < xsi->width && + (unsigned)(point.y - xsi->y_org) < xsi->height) + return i; + #endif + } + + *flags |= XFLAG_DEAD; + + return scr->xine_primary_head; + } + */ int wGetHeadForPoint(WScreen *scr, WMPoint point) { - int i; + int i; for (i = 0; i < scr->xine_info.count; i++) { - WMRect *rect = &scr->xine_info.screens[i]; + WMRect *rect = &scr->xine_info.screens[i]; - if ((unsigned)(point.x - rect->pos.x) < rect->size.width && - (unsigned)(point.y - rect->pos.y) < rect->size.height) - return i; + if ((unsigned)(point.x - rect->pos.x) < rect->size.width && + (unsigned)(point.y - rect->pos.y) < rect->size.height) + return i; } return scr->xine_info.primary_head; } @@ -301,13 +301,13 @@ wGetHeadForPointerLocation(WScreen *scr) unsigned int blo; if (!scr->xine_info.count) - return scr->xine_info.primary_head; + return scr->xine_info.primary_head; if (!XQueryPointer(dpy, scr->root_win, &bla, &bla, - &point.x, &point.y, - &ble, &ble, - &blo)) - return scr->xine_info.primary_head; + &point.x, &point.y, + &ble, &ble, + &blo)) + return scr->xine_info.primary_head; return wGetHeadForPoint(scr, point); } @@ -319,15 +319,15 @@ wGetRectForHead(WScreen *scr, int head) WMRect rect; if (head < scr->xine_info.count) { - rect.pos.x = scr->xine_info.screens[head].pos.x; - rect.pos.y = scr->xine_info.screens[head].pos.y; - rect.size.width = scr->xine_info.screens[head].size.width; + rect.pos.x = scr->xine_info.screens[head].pos.x; + rect.pos.y = scr->xine_info.screens[head].pos.y; + rect.size.width = scr->xine_info.screens[head].size.width; rect.size.height = scr->xine_info.screens[head].size.height; } else { - rect.pos.x = 0; - rect.pos.y = 0; - rect.size.width = scr->scr_width; - rect.size.height = scr->scr_height; + rect.pos.x = 0; + rect.pos.y = 0; + rect.size.width = scr->scr_width; + rect.size.height = scr->scr_height; } return rect; @@ -348,9 +348,9 @@ wGetUsableAreaForHead(WScreen *scr, int head, WArea *totalAreaPtr, Bool noicons) if (totalAreaPtr != NULL) *totalAreaPtr = totalArea; if (head < wXineramaHeads(scr)) { - usableArea = noicons ? scr->totalUsableArea[head] : scr->usableArea[head]; + usableArea = noicons ? scr->totalUsableArea[head] : scr->usableArea[head]; } else - usableArea = totalArea; + usableArea = totalArea; return usableArea; } diff --git a/src/xinerama.h b/src/xinerama.h index 29f4e4e8..284e41ad 100644 --- a/src/xinerama.h +++ b/src/xinerama.h @@ -1,8 +1,8 @@ /* * Window Maker window manager - * + * * Copyright (c) 1997-2001 Alfredo K. Kojima - * + * * 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 @@ -15,7 +15,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. */ diff --git a/src/xmodifier.c b/src/xmodifier.c dissimilarity index 73% index 8807feed..833b6747 100644 --- a/src/xmodifier.c +++ b/src/xmodifier.c @@ -1,298 +1,299 @@ -/* Grok X modifier mappings for shortcuts. - - Most of this code was taken from src/event-Xt.c in XEmacs 20.3-b17. - The copyright(s) from the original XEmacs code are included below. - - Perpetrator: Sudish Joseph , Sept. 1997. */ - -/* The event_stream interface for X11 with Xt, and/or tty frames. - Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. - Copyright (C) 1995 Sun Microsystems, Inc. - Copyright (C) 1996 Ben Wing. - -This file is part of XEmacs. - -XEmacs 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, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include "wconfig.h" - -#include -#include -#include - -#include - - -extern Display *dpy; - -/************************************************************************/ -/* keymap handling */ -/************************************************************************/ - -/* X bogusly doesn't define the interpretations of any bits besides - ModControl, ModShift, and ModLock; so the Interclient Communication - Conventions Manual says that we have to bend over backwards to figure - out what the other modifier bits mean. According to ICCCM: - - - Any keycode which is assigned ModControl is a "control" key. - - - Any modifier bit which is assigned to a keycode which generates Meta_L - or Meta_R is the modifier bit meaning "meta". Likewise for Super, Hyper, - etc. - - - Any keypress event which contains ModControl in its state should be - interpreted as a "control" character. - - - Any keypress event which contains a modifier bit in its state which is - generated by a keycode whose corresponding keysym is Meta_L or Meta_R - should be interpreted as a "meta" character. Likewise for Super, Hyper, - etc. - - - It is illegal for a keysym to be associated with more than one modifier - bit. - - This means that the only thing that emacs can reasonably interpret as a - "meta" key is a key whose keysym is Meta_L or Meta_R, and which generates - one of the modifier bits Mod1-Mod5. - - Unfortunately, many keyboards don't have Meta keys in their default - configuration. So, if there are no Meta keys, but there are "Alt" keys, - emacs will interpret Alt as Meta. If there are both Meta and Alt keys, - then the Meta keys mean "Meta", and the Alt keys mean "Alt" (it used to - mean "Symbol," but that just confused the hell out of way too many people). - - This works with the default configurations of the 19 keyboard-types I've - checked. - - Emacs detects keyboard configurations which violate the above rules, and - prints an error message on the standard-error-output. (Perhaps it should - use a pop-up-window instead.) - */ - -static int MetaMask, HyperMask, SuperMask, AltMask, ModeMask; - -static const char * -index_to_name (int indice) -{ - switch (indice) - { - case ShiftMapIndex: return "ModShift"; - case LockMapIndex: return "ModLock"; - case ControlMapIndex: return "ModControl"; - case Mod1MapIndex: return "Mod1"; - case Mod2MapIndex: return "Mod2"; - case Mod3MapIndex: return "Mod3"; - case Mod4MapIndex: return "Mod4"; - case Mod5MapIndex: return "Mod5"; - default: return "???"; - } -} - -static void -x_reset_modifier_mapping (Display *display) -{ - int modifier_index, modifier_key, column, mkpm; - int warned_about_overlapping_modifiers = 0; - int warned_about_predefined_modifiers = 0; - int warned_about_duplicate_modifiers = 0; - int meta_bit = 0; - int hyper_bit = 0; - int super_bit = 0; - int alt_bit = 0; - int mode_bit = 0; - XModifierKeymap *x_modifier_keymap = XGetModifierMapping (display); - -#define modwarn(name,old,other) \ - wwarning ("%s (0x%x) generates %s, which is generated by %s.\n\n", \ - name, code, index_to_name (old), other), \ - warned_about_overlapping_modifiers = 1 - -#define modbarf(name,other) \ - wwarning ("%s (0x%x) generates %s, which is nonsensical.\n\n", \ - name, code, other), \ - warned_about_predefined_modifiers = 1 - -#define check_modifier(name,mask) \ - if ((1<max_keypermod; - for (modifier_index = 0; modifier_index < 8; modifier_index++) - for (modifier_key = 0; modifier_key < mkpm; modifier_key++) { - KeySym last_sym = 0; - for (column = 0; column < 4; column += 2) { - KeyCode code = x_modifier_keymap->modifiermap[modifier_index * mkpm - + modifier_key]; - KeySym sym = (code ? XKeycodeToKeysym (display, code, column) : 0); - if (sym == last_sym) continue; - last_sym = sym; - switch (sym) { - case XK_Mode_switch:store_modifier ("Mode_switch", mode_bit); break; - case XK_Meta_L: store_modifier ("Meta_L", meta_bit); break; - case XK_Meta_R: store_modifier ("Meta_R", meta_bit); break; - case XK_Super_L: store_modifier ("Super_L", super_bit); break; - case XK_Super_R: store_modifier ("Super_R", super_bit); break; - case XK_Hyper_L: store_modifier ("Hyper_L", hyper_bit); break; - case XK_Hyper_R: store_modifier ("Hyper_R", hyper_bit); break; - case XK_Alt_L: store_modifier ("Alt_L", alt_bit); break; - case XK_Alt_R: store_modifier ("Alt_R", alt_bit); break; - case XK_Control_L: check_modifier ("Control_L", ControlMask); break; - case XK_Control_R: check_modifier ("Control_R", ControlMask); break; - case XK_Shift_L: check_modifier ("Shift_L", ShiftMask); break; - case XK_Shift_R: check_modifier ("Shift_R", ShiftMask); break; - case XK_Shift_Lock: check_modifier ("Shift_Lock", LockMask); break; - case XK_Caps_Lock: check_modifier ("Caps_Lock", LockMask); break; - - /* It probably doesn't make any sense for a modifier bit to be - assigned to a key that is not one of the above, but OpenWindows - assigns modifier bits to a couple of random function keys for - no reason that I can discern, so printing a warning here would - be annoying. */ - } - } - } -#undef store_modifier -#undef check_modifier -#undef modwarn -#undef modbarf - - /* If there was no Meta key, then try using the Alt key instead. - If there is both a Meta key and an Alt key, then the Alt key - is not disturbed and remains an Alt key. */ - if (! meta_bit && alt_bit) - meta_bit = alt_bit, alt_bit = 0; - - /* mode_bit overrides everything, since it's processed down inside of - XLookupString() instead of by us. If Meta and Mode_switch both - generate the same modifier bit (which is an error), then we don't - interpret that bit as Meta, because we can't make XLookupString() - not interpret it as Mode_switch; and interpreting it as both would - be totally wrong. */ - if (mode_bit) - { - const char *warn = 0; - if (mode_bit == meta_bit) warn = "Meta", meta_bit = 0; - else if (mode_bit == hyper_bit) warn = "Hyper", hyper_bit = 0; - else if (mode_bit == super_bit) warn = "Super", super_bit = 0; - else if (mode_bit == alt_bit) warn = "Alt", alt_bit = 0; - if (warn) - { - wwarning - ("%s is being used for both Mode_switch and %s.\n\n", - index_to_name (mode_bit), warn), - warned_about_overlapping_modifiers = 1; - } - } - - MetaMask = (meta_bit ? (1 << meta_bit) : 0); - HyperMask = (hyper_bit ? (1 << hyper_bit) : 0); - SuperMask = (super_bit ? (1 << super_bit) : 0); - AltMask = (alt_bit ? (1 << alt_bit) : 0); - ModeMask = (mode_bit ? (1 << mode_bit) : 0); /* unused */ - -#if 0 - if (warned_about_overlapping_modifiers) - wwarning ("\n" -" Two distinct modifier keys (such as Meta and Hyper) cannot generate\n" -" the same modifier bit, because Emacs won't be able to tell which\n" -" modifier was actually held down when some other key is pressed. It\n" -" won't be able to tell Meta-x and Hyper-x apart, for example. Change\n" -" one of these keys to use some other modifier bit. If you intend for\n" -" these keys to have the same behavior, then change them to have the\n" -" same keysym as well as the same modifier bit.\n"); - - if (warned_about_predefined_modifiers) - wwarning ("\n" -" The semantics of the modifier bits ModShift, ModLock, and ModControl\n" -" are predefined. It does not make sense to assign ModControl to any\n" -" keysym other than Control_L or Control_R, or to assign any modifier\n" -" bits to the \"control\" keysyms other than ModControl. You can't\n" -" turn a \"control\" key into a \"meta\" key (or vice versa) by simply\n" -" assigning the key a different modifier bit. You must also make that\n" -" key generate an appropriate keysym (Control_L, Meta_L, etc).\n"); - - /* No need to say anything more for warned_about_duplicate_modifiers. */ - - if (warned_about_overlapping_modifiers || warned_about_predefined_modifiers) - wwarning ("\n" -" The meanings of the modifier bits Mod1 through Mod5 are determined\n" -" by the keysyms used to control those bits. Mod1 does NOT always\n" -" mean Meta, although some non-ICCCM-compliant programs assume that.\n"); -#endif - XFreeModifiermap(x_modifier_keymap); -} - - -int -wXModifierFromKey(char *key) -{ - if (strcasecmp(key, "SHIFT")==0 && ShiftMask!=0) - return ShiftMask; - else if (strcasecmp(key, "CONTROL")==0 && ControlMask!=0) - return ControlMask; - else if (strcasecmp(key, "ALT")==0 && AltMask!=0) - return AltMask; - else if (strcasecmp(key, "META")==0 && MetaMask!=0) - return MetaMask; - else if (strcasecmp(key, "SUPER")==0 && SuperMask!=0) - return SuperMask; - else if (strcasecmp(key, "HYPER")==0 && HyperMask!=0) - return HyperMask; - else if (strcasecmp(key, "MOD1")==0 && Mod1Mask!=0) - return Mod1Mask; - else if (strcasecmp(key, "MOD2")==0 && Mod2Mask!=0) - return Mod2Mask; - else if (strcasecmp(key, "MOD3")==0 && Mod3Mask!=0) - return Mod3Mask; - else if (strcasecmp(key, "MOD4")==0 && Mod4Mask!=0) - return Mod4Mask; - else if (strcasecmp(key, "MOD5")==0 && Mod5Mask!=0) - return Mod5Mask; - else - return -1; -} - -/* Wrapper so that we may fit the WM naming conventions, yet leave the - original XEmacs function name in place. */ -void -wXModifierInitialize(void) -{ - x_reset_modifier_mapping(dpy); -} +/* Grok X modifier mappings for shortcuts. + +Most of this code was taken from src/event-Xt.c in XEmacs 20.3-b17. +The copyright(s) from the original XEmacs code are included below. + +Perpetrator: Sudish Joseph , Sept. 1997. */ + +/* The event_stream interface for X11 with Xt, and/or tty frames. + Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1995 Sun Microsystems, Inc. + Copyright (C) 1996 Ben Wing. + + This file is part of XEmacs. + + XEmacs 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, or (at your option) any + later version. + + XEmacs is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with XEmacs; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "wconfig.h" + +#include +#include +#include + +#include + + +extern Display *dpy; + +/************************************************************************/ +/* keymap handling */ +/************************************************************************/ + +/* X bogusly doesn't define the interpretations of any bits besides + ModControl, ModShift, and ModLock; so the Interclient Communication + Conventions Manual says that we have to bend over backwards to figure + out what the other modifier bits mean. According to ICCCM: + + - Any keycode which is assigned ModControl is a "control" key. + + - Any modifier bit which is assigned to a keycode which generates Meta_L + or Meta_R is the modifier bit meaning "meta". Likewise for Super, Hyper, + etc. + + - Any keypress event which contains ModControl in its state should be + interpreted as a "control" character. + + - Any keypress event which contains a modifier bit in its state which is + generated by a keycode whose corresponding keysym is Meta_L or Meta_R + should be interpreted as a "meta" character. Likewise for Super, Hyper, + etc. + + - It is illegal for a keysym to be associated with more than one modifier + bit. + + This means that the only thing that emacs can reasonably interpret as a + "meta" key is a key whose keysym is Meta_L or Meta_R, and which generates + one of the modifier bits Mod1-Mod5. + + Unfortunately, many keyboards don't have Meta keys in their default + configuration. So, if there are no Meta keys, but there are "Alt" keys, + emacs will interpret Alt as Meta. If there are both Meta and Alt keys, + then the Meta keys mean "Meta", and the Alt keys mean "Alt" (it used to + mean "Symbol," but that just confused the hell out of way too many people). + + This works with the default configurations of the 19 keyboard-types I've + checked. + + Emacs detects keyboard configurations which violate the above rules, and + prints an error message on the standard-error-output. (Perhaps it should + use a pop-up-window instead.) + */ + +static int MetaMask, HyperMask, SuperMask, AltMask, ModeMask; + +static const char * +index_to_name (int indice) +{ + switch (indice) + { + case ShiftMapIndex: return "ModShift"; + case LockMapIndex: return "ModLock"; + case ControlMapIndex: return "ModControl"; + case Mod1MapIndex: return "Mod1"; + case Mod2MapIndex: return "Mod2"; + case Mod3MapIndex: return "Mod3"; + case Mod4MapIndex: return "Mod4"; + case Mod5MapIndex: return "Mod5"; + default: return "???"; + } +} + +static void +x_reset_modifier_mapping (Display *display) +{ + int modifier_index, modifier_key, column, mkpm; + int warned_about_overlapping_modifiers = 0; + int warned_about_predefined_modifiers = 0; + int warned_about_duplicate_modifiers = 0; + int meta_bit = 0; + int hyper_bit = 0; + int super_bit = 0; + int alt_bit = 0; + int mode_bit = 0; + XModifierKeymap *x_modifier_keymap = XGetModifierMapping (display); + +#define modwarn(name,old,other) \ + wwarning ("%s (0x%x) generates %s, which is generated by %s.\n\n", \ + name, code, index_to_name (old), other), \ + warned_about_overlapping_modifiers = 1 + +#define modbarf(name,other) \ + wwarning ("%s (0x%x) generates %s, which is nonsensical.\n\n", \ + name, code, other), \ + warned_about_predefined_modifiers = 1 + +#define check_modifier(name,mask) \ + if ((1<max_keypermod; + for (modifier_index = 0; modifier_index < 8; modifier_index++) + for (modifier_key = 0; modifier_key < mkpm; modifier_key++) { + KeySym last_sym = 0; + for (column = 0; column < 4; column += 2) { + KeyCode code = x_modifier_keymap->modifiermap[modifier_index * mkpm + + modifier_key]; + KeySym sym = (code ? XKeycodeToKeysym (display, code, column) : 0); + if (sym == last_sym) continue; + last_sym = sym; + switch (sym) { + case XK_Mode_switch:store_modifier ("Mode_switch", mode_bit); break; + case XK_Meta_L: store_modifier ("Meta_L", meta_bit); break; + case XK_Meta_R: store_modifier ("Meta_R", meta_bit); break; + case XK_Super_L: store_modifier ("Super_L", super_bit); break; + case XK_Super_R: store_modifier ("Super_R", super_bit); break; + case XK_Hyper_L: store_modifier ("Hyper_L", hyper_bit); break; + case XK_Hyper_R: store_modifier ("Hyper_R", hyper_bit); break; + case XK_Alt_L: store_modifier ("Alt_L", alt_bit); break; + case XK_Alt_R: store_modifier ("Alt_R", alt_bit); break; + case XK_Control_L: check_modifier ("Control_L", ControlMask); break; + case XK_Control_R: check_modifier ("Control_R", ControlMask); break; + case XK_Shift_L: check_modifier ("Shift_L", ShiftMask); break; + case XK_Shift_R: check_modifier ("Shift_R", ShiftMask); break; + case XK_Shift_Lock: check_modifier ("Shift_Lock", LockMask); break; + case XK_Caps_Lock: check_modifier ("Caps_Lock", LockMask); break; + + /* It probably doesn't make any sense for a modifier bit to be + assigned to a key that is not one of the above, but OpenWindows + assigns modifier bits to a couple of random function keys for + no reason that I can discern, so printing a warning here would + be annoying. */ + } + } + } +#undef store_modifier +#undef check_modifier +#undef modwarn +#undef modbarf + + /* If there was no Meta key, then try using the Alt key instead. + If there is both a Meta key and an Alt key, then the Alt key + is not disturbed and remains an Alt key. */ + if (! meta_bit && alt_bit) + meta_bit = alt_bit, alt_bit = 0; + + /* mode_bit overrides everything, since it's processed down inside of + XLookupString() instead of by us. If Meta and Mode_switch both + generate the same modifier bit (which is an error), then we don't + interpret that bit as Meta, because we can't make XLookupString() + not interpret it as Mode_switch; and interpreting it as both would + be totally wrong. */ + if (mode_bit) + { + const char *warn = 0; + if (mode_bit == meta_bit) warn = "Meta", meta_bit = 0; + else if (mode_bit == hyper_bit) warn = "Hyper", hyper_bit = 0; + else if (mode_bit == super_bit) warn = "Super", super_bit = 0; + else if (mode_bit == alt_bit) warn = "Alt", alt_bit = 0; + if (warn) + { + wwarning + ("%s is being used for both Mode_switch and %s.\n\n", + index_to_name (mode_bit), warn), + warned_about_overlapping_modifiers = 1; + } + } + + MetaMask = (meta_bit ? (1 << meta_bit) : 0); + HyperMask = (hyper_bit ? (1 << hyper_bit) : 0); + SuperMask = (super_bit ? (1 << super_bit) : 0); + AltMask = (alt_bit ? (1 << alt_bit) : 0); + ModeMask = (mode_bit ? (1 << mode_bit) : 0); /* unused */ + +#if 0 + if (warned_about_overlapping_modifiers) + wwarning ("\n" + " Two distinct modifier keys (such as Meta and Hyper) cannot generate\n" + " the same modifier bit, because Emacs won't be able to tell which\n" + " modifier was actually held down when some other key is pressed. It\n" + " won't be able to tell Meta-x and Hyper-x apart, for example. Change\n" + " one of these keys to use some other modifier bit. If you intend for\n" + " these keys to have the same behavior, then change them to have the\n" + " same keysym as well as the same modifier bit.\n"); + + if (warned_about_predefined_modifiers) + wwarning ("\n" + " The semantics of the modifier bits ModShift, ModLock, and ModControl\n" + " are predefined. It does not make sense to assign ModControl to any\n" + " keysym other than Control_L or Control_R, or to assign any modifier\n" + " bits to the \"control\" keysyms other than ModControl. You can't\n" + " turn a \"control\" key into a \"meta\" key (or vice versa) by simply\n" + " assigning the key a different modifier bit. You must also make that\n" + " key generate an appropriate keysym (Control_L, Meta_L, etc).\n"); + + /* No need to say anything more for warned_about_duplicate_modifiers. */ + + if (warned_about_overlapping_modifiers || warned_about_predefined_modifiers) + wwarning ("\n" + " The meanings of the modifier bits Mod1 through Mod5 are determined\n" + " by the keysyms used to control those bits. Mod1 does NOT always\n" + " mean Meta, although some non-ICCCM-compliant programs assume that.\n"); +#endif + XFreeModifiermap(x_modifier_keymap); +} + + +int +wXModifierFromKey(char *key) +{ + if (strcasecmp(key, "SHIFT")==0 && ShiftMask!=0) + return ShiftMask; + else if (strcasecmp(key, "CONTROL")==0 && ControlMask!=0) + return ControlMask; + else if (strcasecmp(key, "ALT")==0 && AltMask!=0) + return AltMask; + else if (strcasecmp(key, "META")==0 && MetaMask!=0) + return MetaMask; + else if (strcasecmp(key, "SUPER")==0 && SuperMask!=0) + return SuperMask; + else if (strcasecmp(key, "HYPER")==0 && HyperMask!=0) + return HyperMask; + else if (strcasecmp(key, "MOD1")==0 && Mod1Mask!=0) + return Mod1Mask; + else if (strcasecmp(key, "MOD2")==0 && Mod2Mask!=0) + return Mod2Mask; + else if (strcasecmp(key, "MOD3")==0 && Mod3Mask!=0) + return Mod3Mask; + else if (strcasecmp(key, "MOD4")==0 && Mod4Mask!=0) + return Mod4Mask; + else if (strcasecmp(key, "MOD5")==0 && Mod5Mask!=0) + return Mod5Mask; + else + return -1; +} + +/* Wrapper so that we may fit the WM naming conventions, yet leave the + original XEmacs function name in place. */ +void +wXModifierInitialize(void) +{ + x_reset_modifier_mapping(dpy); +} + diff --git a/src/xmodifier.h b/src/xmodifier.h index b3b43bf4..38b7e6fa 100644 --- a/src/xmodifier.h +++ b/src/xmodifier.h @@ -1,4 +1,4 @@ -/* xmodifier.h +/* xmodifier.h * * Sudish Joseph , Sept. 1997 * @@ -14,7 +14,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. */ diff --git a/src/xutil.c b/src/xutil.c dissimilarity index 64% index 964d602e..1e46d2ea 100644 --- a/src/xutil.c +++ b/src/xutil.c @@ -1,196 +1,197 @@ -/* - * WindowMaker miscelaneous functions - * - * Copyright (c) 1997-2003 Alfredo K. Kojima - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -#include -#include -#include -#include -#include -#include - -#include "wconfig.h" - -#include "xutil.h" - -#include -#if 0 -static Atom Clipboard=0; -#endif - -static char *requestCodes[] = { - "DUMMY", - "X_CreateWindow", - "X_ChangeWindowAttributes", - "X_GetWindowAttributes", - "X_DestroyWindow", - "X_DestroySubwindows", - "X_ChangeSaveSet", - "X_ReparentWindow", - "X_MapWindow", - "X_MapSubwindows", - "X_UnmapWindow", - "X_UnmapSubwindows", - "X_ConfigureWindow", - "X_CirculateWindow", - "X_GetGeometry", - "X_QueryTree", - "X_InternAtom", - "X_GetAtomName", - "X_ChangeProperty", - "X_DeleteProperty", - "X_GetProperty", - "X_ListProperties", - "X_SetSelectionOwner", - "X_GetSelectionOwner", - "X_ConvertSelection", - "X_SendEvent", - "X_GrabPointer", - "X_UngrabPointer", - "X_GrabButton", - "X_UngrabButton", - "X_ChangeActivePointerGrab", - "X_GrabKeyboard", - "X_UngrabKeyboard", - "X_GrabKey", - "X_UngrabKey", - "X_AllowEvents", - "X_GrabServer", - "X_UngrabServer", - "X_QueryPointer", - "X_GetMotionEvents", - "X_TranslateCoords", - "X_WarpPointer", - "X_SetInputFocus", - "X_GetInputFocus", - "X_QueryKeymap", - "X_OpenFont", - "X_CloseFont", - "X_QueryFont", - "X_QueryTextExtents", - "X_ListFonts", - "X_ListFontsWithInfo", - "X_SetFontPath", - "X_GetFontPath", - "X_CreatePixmap", - "X_FreePixmap", - "X_CreateGC", - "X_ChangeGC", - "X_CopyGC", - "X_SetDashes", - "X_SetClipRectangles", - "X_FreeGC", - "X_ClearArea", - "X_CopyArea", - "X_CopyPlane", - "X_PolyPoint", - "X_PolyLine", - "X_PolySegment", - "X_PolyRectangle", - "X_PolyArc", - "X_FillPoly", - "X_PolyFillRectangle", - "X_PolyFillArc", - "X_PutImage", - "X_GetImage", - "X_PolyText8", - "X_PolyText16", - "X_ImageText8", - "X_ImageText16", - "X_CreateColormap", - "X_FreeColormap", - "X_CopyColormapAndFree", - "X_InstallColormap", - "X_UninstallColormap", - "X_ListInstalledColormaps", - "X_AllocColor", - "X_AllocNamedColor", - "X_AllocColorCells", - "X_AllocColorPlanes", - "X_FreeColors", - "X_StoreColors", - "X_StoreNamedColor", - "X_QueryColors", - "X_LookupColor", - "X_CreateCursor", - "X_CreateGlyphCursor", - "X_FreeCursor", - "X_RecolorCursor", - "X_QueryBestSize", - "X_QueryExtension", - "X_ListExtensions", - "X_ChangeKeyboardMapping", - "X_GetKeyboardMapping", - "X_ChangeKeyboardControl", - "X_GetKeyboardControl", - "X_Bell", - "X_ChangePointerControl", - "X_GetPointerControl", - "X_SetScreenSaver", - "X_GetScreenSaver", - "X_ChangeHosts", - "X_ListHosts", - "X_SetAccessControl", - "X_SetCloseDownMode", - "X_KillClient", - "X_RotateProperties", - "X_ForceScreenSaver", - "X_SetPointerMapping", - "X_GetPointerMapping", - "X_SetModifierMapping", - "X_GetModifierMapping", - "X_NoOperation" -}; - - -void -FormatXError(Display *dpy, XErrorEvent *error, char *buffer, int size) -{ - int i, p; - - XGetErrorText(dpy, error->error_code, buffer, size); - i = strlen(buffer); - if (i > size-100) - return; - buffer += i; - if (error->request_code >= sizeof(requestCodes)/sizeof(char*)) { - sprintf(buffer, "\n Request code: %i\n", - error->request_code); - } else { - sprintf(buffer, "\n Request code: %i %s\n", error->request_code, - requestCodes[error->request_code]); - } - i += p = strlen(buffer); - if (i > size - 40) - return; - buffer += p; - sprintf(buffer, " Request minor code: %i\n", error->minor_code); - i += p = strlen(buffer); - if (i > size - 30) - return; - buffer += p; - sprintf(buffer, " Resource ID: 0x%x\n", (unsigned int)error->resourceid); - i += p = strlen(buffer); - if (i > size - 30) - return; - buffer += p; - sprintf(buffer, " Error serial: %li\n", error->serial); - return; -} +/* + * WindowMaker miscelaneous functions + * + * Copyright (c) 1997-2003 Alfredo K. Kojima + * + * 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include +#include +#include +#include +#include +#include + +#include "wconfig.h" + +#include "xutil.h" + +#include +#if 0 +static Atom Clipboard=0; +#endif + +static char *requestCodes[] = { + "DUMMY", + "X_CreateWindow", + "X_ChangeWindowAttributes", + "X_GetWindowAttributes", + "X_DestroyWindow", + "X_DestroySubwindows", + "X_ChangeSaveSet", + "X_ReparentWindow", + "X_MapWindow", + "X_MapSubwindows", + "X_UnmapWindow", + "X_UnmapSubwindows", + "X_ConfigureWindow", + "X_CirculateWindow", + "X_GetGeometry", + "X_QueryTree", + "X_InternAtom", + "X_GetAtomName", + "X_ChangeProperty", + "X_DeleteProperty", + "X_GetProperty", + "X_ListProperties", + "X_SetSelectionOwner", + "X_GetSelectionOwner", + "X_ConvertSelection", + "X_SendEvent", + "X_GrabPointer", + "X_UngrabPointer", + "X_GrabButton", + "X_UngrabButton", + "X_ChangeActivePointerGrab", + "X_GrabKeyboard", + "X_UngrabKeyboard", + "X_GrabKey", + "X_UngrabKey", + "X_AllowEvents", + "X_GrabServer", + "X_UngrabServer", + "X_QueryPointer", + "X_GetMotionEvents", + "X_TranslateCoords", + "X_WarpPointer", + "X_SetInputFocus", + "X_GetInputFocus", + "X_QueryKeymap", + "X_OpenFont", + "X_CloseFont", + "X_QueryFont", + "X_QueryTextExtents", + "X_ListFonts", + "X_ListFontsWithInfo", + "X_SetFontPath", + "X_GetFontPath", + "X_CreatePixmap", + "X_FreePixmap", + "X_CreateGC", + "X_ChangeGC", + "X_CopyGC", + "X_SetDashes", + "X_SetClipRectangles", + "X_FreeGC", + "X_ClearArea", + "X_CopyArea", + "X_CopyPlane", + "X_PolyPoint", + "X_PolyLine", + "X_PolySegment", + "X_PolyRectangle", + "X_PolyArc", + "X_FillPoly", + "X_PolyFillRectangle", + "X_PolyFillArc", + "X_PutImage", + "X_GetImage", + "X_PolyText8", + "X_PolyText16", + "X_ImageText8", + "X_ImageText16", + "X_CreateColormap", + "X_FreeColormap", + "X_CopyColormapAndFree", + "X_InstallColormap", + "X_UninstallColormap", + "X_ListInstalledColormaps", + "X_AllocColor", + "X_AllocNamedColor", + "X_AllocColorCells", + "X_AllocColorPlanes", + "X_FreeColors", + "X_StoreColors", + "X_StoreNamedColor", + "X_QueryColors", + "X_LookupColor", + "X_CreateCursor", + "X_CreateGlyphCursor", + "X_FreeCursor", + "X_RecolorCursor", + "X_QueryBestSize", + "X_QueryExtension", + "X_ListExtensions", + "X_ChangeKeyboardMapping", + "X_GetKeyboardMapping", + "X_ChangeKeyboardControl", + "X_GetKeyboardControl", + "X_Bell", + "X_ChangePointerControl", + "X_GetPointerControl", + "X_SetScreenSaver", + "X_GetScreenSaver", + "X_ChangeHosts", + "X_ListHosts", + "X_SetAccessControl", + "X_SetCloseDownMode", + "X_KillClient", + "X_RotateProperties", + "X_ForceScreenSaver", + "X_SetPointerMapping", + "X_GetPointerMapping", + "X_SetModifierMapping", + "X_GetModifierMapping", + "X_NoOperation" +}; + + +void +FormatXError(Display *dpy, XErrorEvent *error, char *buffer, int size) +{ + int i, p; + + XGetErrorText(dpy, error->error_code, buffer, size); + i = strlen(buffer); + if (i > size-100) + return; + buffer += i; + if (error->request_code >= sizeof(requestCodes)/sizeof(char*)) { + sprintf(buffer, "\n Request code: %i\n", + error->request_code); + } else { + sprintf(buffer, "\n Request code: %i %s\n", error->request_code, + requestCodes[error->request_code]); + } + i += p = strlen(buffer); + if (i > size - 40) + return; + buffer += p; + sprintf(buffer, " Request minor code: %i\n", error->minor_code); + i += p = strlen(buffer); + if (i > size - 30) + return; + buffer += p; + sprintf(buffer, " Resource ID: 0x%x\n", (unsigned int)error->resourceid); + i += p = strlen(buffer); + if (i > size - 30) + return; + buffer += p; + sprintf(buffer, " Error serial: %li\n", error->serial); + return; +} + diff --git a/test/notest.c b/test/notest.c index 174691a8..f517313c 100644 --- a/test/notest.c +++ b/test/notest.c @@ -33,28 +33,29 @@ hide(void *foo, int item, Time time) } -int notify_print( int id, XEvent *event, void *data ) +int +notify_print( int id, XEvent *event, void *data ) { printf( "Got notification 0x%x, window 0x%lx, data '%s'\n", - id, event->xclient.data.l[1], (char *) data ); + id, event->xclient.data.l[1], (char *) data ); return True; } -static void +static void newwin(void *foo, int item, Time time) { Window win; XClassHint classhint; char title[100]; - win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), - 0, 0, 200, 100, 0, 0, 0); + win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), + 0, 0, 200, 100, 0, 0, 0); prots[0] = delete_win; XSetWMProtocols(dpy, win, prots, 1); sprintf(title, "Notify Test Window"); XStoreName(dpy, win, title); - + /* set class hint */ classhint.res_name = "notest"; classhint.res_class = "Notest"; @@ -65,24 +66,24 @@ newwin(void *foo, int item, Time time) hints->window_group = leader; hints->flags = WindowGroupHint; XSetWMHints(dpy, win, hints); - - WMAppAddWindow(app, win); + + WMAppAddWindow(app, win); XMapWindow(dpy, win); } int main(int argc, char **argv) -{ +{ XClassHint classhint; dpy = XOpenDisplay(""); if (!dpy) { - puts("could not open display!"); - exit(1); + puts("could not open display!"); + exit(1); } delete_win = XInternAtom(dpy, "WM_DELETE_WINDOW", False); leader = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 10, 10, - 0, 0, 0); + 0, 0, 0); /* set class hint */ classhint.res_name = "notest"; classhint.res_class = "Notest"; @@ -99,7 +100,7 @@ int main(int argc, char **argv) menu = WMMenuCreate(app, "Notify Test Menu"); WMMenuAddItem(menu, "Hide", (WMMenuAction)hide, NULL, NULL, NULL); WMMenuAddItem(menu, "Quit", (WMMenuAction)quit, NULL, NULL, NULL); - + WMAppSetMainMenu(app, menu); WMRealizeMenus(app); @@ -113,22 +114,22 @@ int main(int argc, char **argv) /* set command to use to startup this */ XSetCommand(dpy, leader, argv, argc); - + /* create first window */ newwin(NULL, 0, 0); XFlush(dpy); while( 1 ) { - XEvent ev; - XNextEvent(dpy, &ev); - if (ev.type==ClientMessage) { - if (ev.xclient.data.l[0]==delete_win) { - XDestroyWindow(dpy,ev.xclient.window); - break; - } - } - WMProcessEvent(app, &ev); + XEvent ev; + XNextEvent(dpy, &ev); + if (ev.type==ClientMessage) { + if (ev.xclient.data.l[0]==delete_win) { + XDestroyWindow(dpy,ev.xclient.window); + break; + } + } + WMProcessEvent(app, &ev); } exit(0); } diff --git a/test/wtest.c b/test/wtest.c index 692a5341..71feeb1f 100644 --- a/test/wtest.c +++ b/test/wtest.c @@ -1,8 +1,8 @@ /* quick and dirty test application that demonstrates: application hiding, * application defined titlebar button images, application defined * titlebar button actions, application menus, docking and - * window manager commands - * + * window manager commands + * * Note that the windows don't have a window command menu. * * TODO: remake @@ -16,12 +16,12 @@ #include static unsigned char bits[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; static unsigned char mbits[] = { - 0xff, 0x03, 0xff, 0x01, 0xff, 0x00, 0x7f, 0x00, 0x3f, 0x00, 0x1f, 0x00, - 0x0f, 0x00, 0x07, 0x00, 0x03, 0x00, 0x01, 0x00}; + 0xff, 0x03, 0xff, 0x01, 0xff, 0x00, 0x7f, 0x00, 0x3f, 0x00, 0x1f, 0x00, + 0x0f, 0x00, 0x07, 0x00, 0x03, 0x00, 0x01, 0x00}; Display *dpy; @@ -29,7 +29,7 @@ Window leader; WMAppContext *app; -static void +static void callback(void *foo, int item, Time time) { printf("pushed item %i\n", item); @@ -58,7 +58,7 @@ WMMenu *menu; WMMenu *submenu; int wincount=0; -static void +static void newwin(void *foo, int item, Time time) { Window win; @@ -66,14 +66,14 @@ newwin(void *foo, int item, Time time) char title[100]; wincount++; - win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), - 10*wincount, 10*wincount, 200, 100, 0, 0, 0); + win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), + 10*wincount, 10*wincount, 200, 100, 0, 0, 0); prots[0] = delete_win; prots[1] = miniaturize_win; XSetWMProtocols(dpy, win, prots, 2); sprintf(title, "Test Window %i", wincount); XStoreName(dpy, win, title); - + /* set class hint */ classhint.res_name = "test"; classhint.res_class = "Test"; @@ -81,16 +81,16 @@ newwin(void *foo, int item, Time time) /* set WindowMaker hints */ attr.flags = GSMiniaturizePixmapAttr|GSMiniaturizeMaskAttr; - attr.miniaturize_pixmap = - XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), bits, 10, 10); - + attr.miniaturize_pixmap = + XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), bits, 10, 10); + attr.miniaturize_mask = - XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), mbits, 10, 10); - /* - attr.flags |= GSWindowStyleAttr; - attr.window_style = NSTitledWindowMask|NSClosableWindowMask; -*/ - + XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), mbits, 10, 10); + /* + attr.flags |= GSWindowStyleAttr; + attr.window_style = NSTitledWindowMask|NSClosableWindowMask; + */ + WMSetWindowAttributes(dpy, win, &attr); hints = XAllocWMHints(); @@ -98,26 +98,26 @@ newwin(void *foo, int item, Time time) hints->window_group = leader; hints->flags = WindowGroupHint; XSetWMHints(dpy, win, hints); - - WMAppAddWindow(app, win); + + WMAppAddWindow(app, win); XMapWindow(dpy, win); } int main(int argc, char **argv) -{ +{ XClassHint classhint; dpy = XOpenDisplay(""); if (!dpy) { - puts("could not open display!"); - exit(1); + puts("could not open display!"); + exit(1); } delete_win = XInternAtom(dpy, "WM_DELETE_WINDOW", False); - miniaturize_win = XInternAtom(dpy, "_GNUSTEP_WM_MINIATURIZE_WINDOW", - False); + miniaturize_win = XInternAtom(dpy, "_GNUSTEP_WM_MINIATURIZE_WINDOW", + False); leader = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 10, 10, - 0, 0, 0); + 0, 0, 0); /* set class hint */ classhint.res_name = "test"; classhint.res_class = "Test"; @@ -134,21 +134,21 @@ int main(int argc, char **argv) menu = WMMenuCreate(app, "Test Menu"); submenu = WMMenuCreate(app, "File"); WMMenuAddSubmenu(menu, "File", submenu); - + WMMenuAddItem(menu, "Hide", (WMMenuAction)hide, NULL, NULL, NULL); WMMenuAddItem(menu, "Quit", (WMMenuAction)quit, NULL, NULL, NULL); WMMenuAddItem(submenu, "New", (WMMenuAction)newwin, NULL, NULL, NULL); WMMenuAddItem(submenu, "Open", (WMMenuAction)callback, NULL, NULL, NULL); WMMenuAddItem(submenu, "Save", (WMMenuAction)callback, NULL, NULL, NULL); WMMenuAddItem(submenu, "Save As...", (WMMenuAction)callback, NULL, NULL, NULL); - + WMAppSetMainMenu(app, menu); - + WMRealizeMenus(app); /* set command to use to startup this */ XSetCommand(dpy, leader, argv, argc); - + /* create first window */ newwin(NULL, 0, 0); @@ -156,17 +156,17 @@ int main(int argc, char **argv) XFlush(dpy); puts("Run xprop on the test window to see the properties defined"); while (wincount>0) { - XEvent ev; - XNextEvent(dpy, &ev); - if (ev.type==ClientMessage) { - if (ev.xclient.data.l[0]==delete_win) { - XDestroyWindow(dpy,ev.xclient.window); - wincount--; - } else if (ev.xclient.data.l[0]==miniaturize_win) { - puts("You've pushed the maximize window button"); - } - } - WMProcessEvent(app, &ev); + XEvent ev; + XNextEvent(dpy, &ev); + if (ev.type==ClientMessage) { + if (ev.xclient.data.l[0]==delete_win) { + XDestroyWindow(dpy,ev.xclient.window); + wincount--; + } else if (ev.xclient.data.l[0]==miniaturize_win) { + puts("You've pushed the maximize window button"); + } + } + WMProcessEvent(app, &ev); } exit(0); } diff --git a/util/directjpeg.c b/util/directjpeg.c index 1508bea0..5fea400b 100644 --- a/util/directjpeg.c +++ b/util/directjpeg.c @@ -1,9 +1,9 @@ /* directjpeg.c- loads a jpeg file directly into a XImage * * WindowMaker window manager - * + * * Copyright (c) 1999-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -39,9 +39,9 @@ struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ + struct jpeg_error_mgr pub; /* "public" fields */ - jmp_buf setjmp_buffer; /* for return to caller */ + jmp_buf setjmp_buffer; /* for return to caller */ }; typedef struct my_error_mgr * my_error_ptr; @@ -53,15 +53,15 @@ typedef struct my_error_mgr * my_error_ptr; static void my_error_exit (j_common_ptr cinfo) { - /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ - my_error_ptr myerr = (my_error_ptr) cinfo->err; + /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ + my_error_ptr myerr = (my_error_ptr) cinfo->err; - /* Always display the message. */ - /* We could postpone this until after returning, if we chose. */ - (*cinfo->err->output_message) (cinfo); + /* Always display the message. */ + /* We could postpone this until after returning, if we chose. */ + (*cinfo->err->output_message) (cinfo); - /* Return control to the setjmp point */ - longjmp(myerr->setjmp_buffer, 1); + /* Return control to the setjmp point */ + longjmp(myerr->setjmp_buffer, 1); } @@ -69,8 +69,8 @@ static Bool canLoad(RContext *rc) { if (rc->depth != 16 || rc->vclass != TrueColor - || rc->red_offset!=11 || rc->green_offset!=5 || rc->blue_offset!=0) - return False; + || rc->red_offset!=11 || rc->green_offset!=5 || rc->blue_offset!=0) + return False; return True; } @@ -78,7 +78,7 @@ canLoad(RContext *rc) static void readData(RContext *rc, struct jpeg_decompress_struct *cinfo, - JSAMPROW *buffer, RXImage *ximg) + JSAMPROW *buffer, RXImage *ximg) { int i, j; unsigned long pixel; @@ -89,31 +89,31 @@ readData(RContext *rc, struct jpeg_decompress_struct *cinfo, jpeg_read_scanlines(cinfo, buffer, (JDIMENSION)1); - if (cinfo->out_color_space==JCS_RGB) { - for (i=0,j=0; iimage_width; i++) { - - printf("%i %i %i\n", - (((unsigned long)buffer[0][j])&0xf8)<<8, - (((unsigned long)buffer[0][j+1])&0xf4)<<3, - (((unsigned long)buffer[0][j+2]))>>3); - - pixel = (((unsigned long)buffer[0][j++])&0xf8)<<8 - |(((unsigned long)buffer[0][j++])&0xf4)<<3 - |(((unsigned long)buffer[0][j++]))>>3; - - XPutPixel(ximg->image, i, y, pixel); - } - } else { - for (i=0,j=0; iimage_width; i++, j++) { - - pixel = (unsigned long)buffer[0][j]<<8 - |(unsigned long)buffer[0][j]<<3 - |(unsigned long)buffer[0][j]>>3; - - XPutPixel(ximg->image, i, y, pixel); - } - } - y++; + if (cinfo->out_color_space==JCS_RGB) { + for (i=0,j=0; iimage_width; i++) { + + printf("%i %i %i\n", + (((unsigned long)buffer[0][j])&0xf8)<<8, + (((unsigned long)buffer[0][j+1])&0xf4)<<3, + (((unsigned long)buffer[0][j+2]))>>3); + + pixel = (((unsigned long)buffer[0][j++])&0xf8)<<8 + |(((unsigned long)buffer[0][j++])&0xf4)<<3 + |(((unsigned long)buffer[0][j++]))>>3; + + XPutPixel(ximg->image, i, y, pixel); + } + } else { + for (i=0,j=0; iimage_width; i++, j++) { + + pixel = (unsigned long)buffer[0][j]<<8 + |(unsigned long)buffer[0][j]<<3 + |(unsigned long)buffer[0][j]>>3; + + XPutPixel(ximg->image, i, y, pixel); + } + } + y++; } } @@ -131,19 +131,19 @@ LoadJPEG(RContext *rc, char *file_name, int *width, int *height) Pixmap p = None; if (!canLoad(rc)) - return None; + return None; file = fopen(file_name, "rb"); if (!file) { - return None; + return None; } if (fread(buf, 2, 1, file) != 1) { - fclose(file); - return None; + fclose(file); + return None; } if (buf[0] != 0xff || buf[1] != 0xd8) { - fclose(file); - return None; + fclose(file); + return None; } rewind(file); @@ -151,33 +151,33 @@ LoadJPEG(RContext *rc, char *file_name, int *width, int *height) jerr.pub.error_exit = my_error_exit; /* Establish the setjmp return context for my_error_exit to use. */ if (setjmp(jerr.setjmp_buffer)) { - /* If we get here, the JPEG code has signaled an error. - * We need to clean up the JPEG object, close the input file, and return. - */ - jpeg_destroy_decompress(&cinfo); - fclose(file); - - if (ximg) { - RDestroyXImage(rc, ximg); - } - - return None; + /* If we get here, the JPEG code has signaled an error. + * We need to clean up the JPEG object, close the input file, and return. + */ + jpeg_destroy_decompress(&cinfo); + fclose(file); + + if (ximg) { + RDestroyXImage(rc, ximg); + } + + return None; } jpeg_create_decompress(&cinfo); jpeg_stdio_src(&cinfo, file); - + jpeg_read_header(&cinfo, TRUE); buffer[0] = (JSAMPROW)malloc(cinfo.image_width*cinfo.num_components); if (!buffer[0]) { - RErrorCode = RERR_NOMEMORY; - goto bye; + RErrorCode = RERR_NOMEMORY; + goto bye; } if(cinfo.jpeg_color_space==JCS_GRAYSCALE) { - cinfo.out_color_space=JCS_GRAYSCALE; + cinfo.out_color_space=JCS_GRAYSCALE; } else cinfo.out_color_space = JCS_RGB; cinfo.quantize_colors = FALSE; @@ -187,7 +187,7 @@ LoadJPEG(RContext *rc, char *file_name, int *width, int *height) ximg = RCreateXImage(rc, rc->depth, cinfo.image_width, cinfo.image_height); if (!ximg) { - goto bye; + goto bye; } jpeg_start_decompress(&cinfo); @@ -195,26 +195,26 @@ LoadJPEG(RContext *rc, char *file_name, int *width, int *height) jpeg_finish_decompress(&cinfo); - p = XCreatePixmap(rc->dpy, rc->drawable, cinfo.image_width, - cinfo.image_height, rc->depth); + p = XCreatePixmap(rc->dpy, rc->drawable, cinfo.image_width, + cinfo.image_height, rc->depth); RPutXImage(rc, p, rc->copy_gc, ximg, 0, 0, 0, 0, cinfo.image_width, - cinfo.image_height); + cinfo.image_height); *width = cinfo.image_width; *height = cinfo.image_height; - - bye: + +bye: jpeg_destroy_decompress(&cinfo); fclose(file); if (buffer[0]) - free(buffer[0]); + free(buffer[0]); if (ximg) - RDestroyXImage(rc, ximg); - + RDestroyXImage(rc, ximg); + return p; } diff --git a/util/geticonset.c b/util/geticonset.c index a1387f58..bd0b3e97 100644 --- a/util/geticonset.c +++ b/util/geticonset.c @@ -1,9 +1,9 @@ /* geticonset.c - outputs icon configuration from WindowMaker to stdout * * Window Maker window manager - * + * * Copyright (c) 1997-2003 Alfredo K. Kojima - * + * * 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 @@ -16,7 +16,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. */ @@ -44,18 +44,18 @@ defaultsPathForDomain(char *domain) gspath = getenv("GNUSTEP_USER_ROOT"); if (gspath) { - strcpy(path, gspath); - strcat(path, "/"); + strcpy(path, gspath); + strcat(path, "/"); } else { - char *home; - - home = getenv("HOME"); - if (!home) { - printf("%s:could not get HOME environment variable!\n", ProgName); - exit(0); - } - strcpy(path, home); - strcat(path, "/GNUstep/"); + char *home; + + home = getenv("HOME"); + if (!home) { + printf("%s:could not get HOME environment variable!\n", ProgName); + exit(0); + } + strcpy(path, home); + strcat(path, "/GNUstep/"); } strcat(path, DEFAULTS_DIR); strcat(path, "/"); @@ -75,7 +75,7 @@ print_help() } -int +int main(int argc, char **argv) { WMPropList *window_name, *icon_key, *window_attrs, *icon_value; @@ -87,52 +87,52 @@ main(int argc, char **argv) ProgName = argv[0]; for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-h")==0 - || strcmp(argv[i], "--help")==0) { - print_help(); - exit(0); - } else if (strcmp(argv[i], "--version")==0) { - puts(PROG_VERSION); - exit(0); - } + if (strcmp(argv[i], "-h")==0 + || strcmp(argv[i], "--help")==0) { + print_help(); + exit(0); + } else if (strcmp(argv[i], "--version")==0) { + puts(PROG_VERSION); + exit(0); + } } - + path = defaultsPathForDomain("WMWindowAttributes"); - + all_windows = WMReadPropListFromFile(path); if (!all_windows) { - printf("%s:could not load WindowMaker configuration file \"%s\".\n", - ProgName, path); - exit(1); + printf("%s:could not load WindowMaker configuration file \"%s\".\n", + ProgName, path); + exit(1); } iconset = WMCreatePLDictionary(NULL, NULL); keylist = WMGetPLDictionaryKeys(all_windows); icon_key = WMCreatePLString("Icon"); - + for (i=0; ilen==0 || token->str[0]=='*') { - return -1; + return -1; } else { for (res=0, pos=0; poslen; pos++) { c = token->str[pos] - '0'; @@ -579,11 +579,11 @@ print_help() puts(" --ignore