diff -NarU5 wmx-7/Channel.C SVN/wm2-2012-01-09/trunk/wmx/Channel.C --- wmx-7/Channel.C 2009-01-09 06:18:03.000000000 -0500 +++ SVN/wm2-2012-01-09/trunk/wmx/Channel.C 2012-01-09 11:05:39.676384280 -0500 @@ -16,96 +16,102 @@ { " ### ", "# #", "# #", " ### ", "# #", "# #", " ### " }, { " ### ", "# #", "# #", " ####", " #", " # ", " ## " } }; -void WindowManager::flipChannel(Boolean statusOnly, Boolean flipDown, - Boolean quickFlip, Client *push) +Window WindowManager::createNumberWindow(int screen, const char *colour) { - int x, y, i, sc; - if (!CONFIG_CHANNEL_SURF) return; - - for (sc = 0; sc < screensTotal(); sc++) - { - if (!m_channelWindow[sc]) { - - XColor nearest, ideal; - - if (!XAllocNamedColor(display(), DefaultColormap(display(), sc), - CONFIG_CHANNEL_NUMBER, &nearest, &ideal)) { + XColor nearest, ideal; + + if (!XAllocNamedColor(display(), DefaultColormap(display(), screen), + colour, &nearest, &ideal)) { - if (!XAllocNamedColor(display(), DefaultColormap(display(), sc), - "black", &nearest, &ideal)) { + if (!XAllocNamedColor(display(), DefaultColormap(display(), screen), + "black", &nearest, &ideal)) { - fatal("Couldn't allocate green or black"); - } - } - - XSetWindowAttributes wa; - wa.background_pixel = nearest.pixel; - wa.override_redirect = True; - - m_channelWindow[sc] = XCreateWindow - (display(), mroot(sc), - 0, 0, 1, 1, 0, CopyFromParent, CopyFromParent, - CopyFromParent, CWOverrideRedirect | CWBackPixel, &wa); - } + fatal("Couldn't allocate requested numeral colour or black"); + } } + + XSetWindowAttributes wa; + wa.background_pixel = nearest.pixel; + wa.override_redirect = True; + + Window w = XCreateWindow + (display(), mroot(screen), + 0, 0, 1, 1, 0, CopyFromParent, CopyFromParent, + CopyFromParent, CWOverrideRedirect | CWBackPixel, &wa); - int nextChannel; + return w; +} - if (statusOnly) nextChannel = m_currentChannel; - else { - if (!flipDown) { - nextChannel = m_currentChannel + 1; - if (nextChannel > m_channels) nextChannel = 1; - } else { - nextChannel = m_currentChannel - 1; - if (nextChannel < 1) nextChannel = m_channels; - } - } +int WindowManager::shapeNumberWindow(Window w, int n, int minDigits) +{ + int i, x, y; XRectangle r; Boolean first = True; char number[7]; - sprintf(number, "%d", nextChannel); + sprintf(number, "%0*d", minDigits, n); for (i = 0; i < (int)strlen(number); ++i) { for (y = 0; y < 7; ++y) { for (x = 0; x < 5; ++x) { if (numerals[number[i]-'0'][y][x] != ' ') { -/* - r.x = i * 110 + x * 20; r.y = y * 20; - r.width = r.height = 20; - */ + r.x = 10 + (i * 6 + x) * CONFIG_CHANNEL_NUMBER_SIZE; r.y = y * CONFIG_CHANNEL_NUMBER_SIZE; r.width = r.height = CONFIG_CHANNEL_NUMBER_SIZE; - for(sc = 0; sc < screensTotal(); sc++) - { + XShapeCombineRectangles - (display(), m_channelWindow[sc], ShapeBounding, + (display(), w, ShapeBounding, 0, 0, &r, 1, first ? ShapeSet : ShapeUnion, YXBanded); - } + first = False; } } } } - for(sc = 0; sc < screensTotal(); sc++) { -/* - XMoveResizeWindow(display(), m_channelWindow[sc], - DisplayWidth(display(), sc) - 30 - - 110 * strlen(number), 30, 500, 160); - */ + return (5 * CONFIG_CHANNEL_NUMBER_SIZE + 10) * strlen(number); +} + + +void WindowManager::flipChannel(Boolean statusOnly, Boolean flipDown, + Boolean quickFlip, Client *push) +{ + int wid, i, sc; + if (!CONFIG_CHANNEL_SURF) return; + + for (sc = 0; sc < screensTotal(); sc++) { + if (!m_channelWindow[sc]) { + m_channelWindow[sc] = createNumberWindow(sc, CONFIG_CHANNEL_NUMBER); + } + } + + int nextChannel; + + if (statusOnly) nextChannel = m_currentChannel; + else { + if (!flipDown) { + nextChannel = m_currentChannel + 1; + if (nextChannel > m_channels) nextChannel = 1; + } else { + nextChannel = m_currentChannel - 1; + if (nextChannel < 1) nextChannel = m_channels; + } + } + + for (sc = 0; sc < screensTotal(); sc++) { + + wid = shapeNumberWindow(m_channelWindow[sc], nextChannel, 1); XMoveResizeWindow(display(), m_channelWindow[sc], - DisplayWidth(display(), sc) - 30 - - (5 * CONFIG_CHANNEL_NUMBER_SIZE + 10) * - strlen(number), 30, 500, 160); + DisplayWidth(display(), sc) - 30 - wid, + 30, 500, 160); + XMapRaised(display(), m_channelWindow[sc]); } if (!statusOnly) { @@ -228,5 +234,38 @@ if (m_channels <= channel) { m_channels = channel + 1; netwmUpdateChannelList(); } } + +void +WindowManager::updateClock() +{ + time_t t; + struct tm *lt; + + fprintf(stderr, "updateClock\n"); + + time(&t); + lt = localtime(&t); + + if (!m_clockWindow[0]) { + m_clockWindow[0] = createNumberWindow(0, CONFIG_CLOCK_NUMBER); + m_clockWindow[1] = createNumberWindow(0, CONFIG_CLOCK_NUMBER); + } + + shapeNumberWindow(m_clockWindow[0], lt->tm_hour, 2); + shapeNumberWindow(m_clockWindow[1], lt->tm_min, 2); + + XMoveResizeWindow(display(), m_clockWindow[0], + 30, 30, 500, 160); + + XMoveResizeWindow(display(), m_clockWindow[1], + 30, 9 * CONFIG_CHANNEL_NUMBER_SIZE + 30, 500, 160); + + XMapWindow(display(), m_clockWindow[0]); + XLowerWindow(display(), m_clockWindow[0]); + + XMapWindow(display(), m_clockWindow[1]); + XLowerWindow(display(), m_clockWindow[1]); +} + diff -NarU5 wmx-7/Config.h SVN/wm2-2012-01-09/trunk/wmx/Config.h --- wmx-7/Config.h 2009-01-09 06:18:03.000000000 -0500 +++ SVN/wm2-2012-01-09/trunk/wmx/Config.h 2012-01-09 11:05:39.679384449 -0500 @@ -77,12 +77,11 @@ // Spawn a temporary new shell between the wm and each new process? #define CONFIG_EXEC_USING_SHELL False // What to run to get a new window (from the "New" menu option) #define CONFIG_NEW_WINDOW_LABEL "New" -#define CONFIG_NEW_WINDOW_COMMAND "xterm" -//#define CONFIG_NEW_WINDOW_COMMAND "/home/ccannam/.wmx/terminal" +#define CONFIG_NEW_WINDOW_COMMAND "x-terminal-emulator" #define CONFIG_NEW_WINDOW_COMMAND_OPTIONS 0 // or, for example, //#define CONFIG_NEW_WINDOW_COMMAND_OPTIONS "-ls","-sb","-sl","1024",0 // alternatively, #define CONFIG_DISABLE_NEW_WINDOW_COMMAND (DynamicConfig::config.disableNew()) @@ -146,10 +145,18 @@ // if False, behaviour will be as in wm2 (stretching the background // image only). #define CONFIG_RESIZE_UPDATE True +// If USE_COMPOSITE is true, wmx will enable composite redirects for +// all windows if the Composite extension is present. This should +// make no difference at all to the appearance or behaviour of wmx, +// but it may make it substantially faster with modern video cards +// that optimise rendering more than old-fashioned window operations. + +#define CONFIG_USE_COMPOSITE True + // If RAISELOWER_ON_CLICK is True, clicking on the title of the // topmost window will lower instead of raising it (patch due to // Kazushi (Jam) Marukawa) #define CONFIG_RAISELOWER_ON_CLICK False @@ -253,14 +260,12 @@ // at all, define it to CONFIG_NO_BUTTON. #define CONFIG_NO_BUTTON 999 #define CONFIG_CLIENTMENU_BUTTON Button1 #define CONFIG_COMMANDMENU_BUTTON Button2 #define CONFIG_CIRCULATE_BUTTON Button3 // switch window, when over frame -#define CONFIG_PREVCHANNEL_BUTTON CONFIG_NO_BUTTON // flip channel, when over frame -#define CONFIG_NEXTCHANNEL_BUTTON CONFIG_NO_BUTTON -//#define CONFIG_PREVCHANNEL_BUTTON CONFIG_NO_BUTTON -//#define CONFIG_NEXTCHANNEL_BUTTON CONFIG_NO_BUTTON +#define CONFIG_PREVCHANNEL_BUTTON Button5 // flip channel, when over frame +#define CONFIG_NEXTCHANNEL_BUTTON Button4 // flip channel, when over frame // ============================== // Section III. Colours and fonts // ============================== @@ -321,10 +326,11 @@ #define CONFIG_TAB_BACKGROUND (DynamicConfig::config.tabBackground()) #define CONFIG_FRAME_BACKGROUND (DynamicConfig::config.frameBackground()) #define CONFIG_BUTTON_BACKGROUND (DynamicConfig::config.frameBackground()) #define CONFIG_BORDERS "black" #define CONFIG_CHANNEL_NUMBER "green" +#define CONFIG_CLOCK_NUMBER "gray90" #define CONFIG_MENU_FOREGROUND (DynamicConfig::config.tabForeground()) #define CONFIG_MENU_BACKGROUND (DynamicConfig::config.tabBackground()) #define CONFIG_MENU_BORDERS "black" @@ -361,14 +367,14 @@ #define CONFIG_USE_CHANNEL_MENU False // FLIP_DELAY is the length of time the big green number stays in the // top-right when flipping channels, before the windows reappear. // QUICK_FLIP_DELAY is the equivalent figure used when flipping with -// the Alt-Fn keys. Milliseconds. +// the Alt-Fn keys or mouse wheel. Milliseconds. #define CONFIG_FLIP_DELAY 1000 -#define CONFIG_QUICK_FLIP_DELAY 200 +#define CONFIG_QUICK_FLIP_DELAY 500 // Set MAD_FEEDBACK for skeletal representations of windows when // flicking through the client menu and changing channels. The DELAY // is how long skeletal feedback has to persist before wmx decides to // post the entire window contents instead; if it's negative, the @@ -377,30 +383,36 @@ // delay of 0ms. #define CONFIG_MAD_FEEDBACK (DynamicConfig::config.useFeedback()) #define CONFIG_FEEDBACK_DELAY (DynamicConfig::config.feedbackDelay()) -// Groups are fun. you can bind a bunch of windows to a number key -// and when you press CONFIG_ALT_KEY_MASK and the number key -// all the windows of that group are raised. - // Position of the geometry window: // X < 0 left, X > 0 right, X = 0 center // Y < 0 top, Y > 0 bottom, Y = 0 center #define CONFIG_GEOMETRY_X_POS 0 #define CONFIG_GEOMETRY_Y_POS 0 +// Groups are fun. you can bind a bunch of windows to a number key +// and when you press CONFIG_ALT_KEY_MASK and the number key +// all the windows of that group are raised. + // You bind a window to a group by pressing the // CONFIG_ALT_KEY_MASK + CONFIG_GROUP_ADD + a number key // if you press CONFIG_ALT_KEY_MASK + CONFIG_GROUP_REMOVE_ALL // + a number key that group is cleared of all windows. #define CONFIG_GROUPS True #define CONFIG_GROUP_ADD ControlMask #define CONFIG_GROUP_REMOVE_ALL ShiftMask +// Set CLOCK if you want wmx to display a clock permanently in the +// background at top-left of screen 0. Use CONFIG_CLOCK_NUMBER +// to control the colour of the clock digits. + +#define CONFIG_CLOCK False + // This lets you choose whether to keep the regular wmx // mouse button behaviour, or go w/ the GNOME-described one. // If this is True, the left mouse button (button1) lets you // select 1 or more gmc 'icons' and drag them around etc, // the right mouse button (button3) pops up the GNOME diff -NarU5 wmx-7/configure SVN/wm2-2012-01-09/trunk/wmx/configure --- wmx-7/configure 2009-01-09 06:18:03.000000000 -0500 +++ SVN/wm2-2012-01-09/trunk/wmx/configure 2012-01-09 11:05:39.668383824 -0500 @@ -3018,10 +3018,87 @@ fi +{ echo "$as_me:$LINENO: checking for XCompositeQueryExtension in -lXcomposite" >&5 +echo $ECHO_N "checking for XCompositeQueryExtension in -lXcomposite... $ECHO_C" >&6; } +if test "${ac_cv_lib_Xcomposite_XCompositeQueryExtension+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lXcomposite $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char XCompositeQueryExtension (); +int +main () +{ +return XCompositeQueryExtension (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_Xcomposite_XCompositeQueryExtension=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_Xcomposite_XCompositeQueryExtension=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xcomposite_XCompositeQueryExtension" >&5 +echo "${ECHO_T}$ac_cv_lib_Xcomposite_XCompositeQueryExtension" >&6; } +if test $ac_cv_lib_Xcomposite_XCompositeQueryExtension = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBXCOMPOSITE 1 +_ACEOF + + LIBS="-lXcomposite $LIBS" + +else + + echo "Warning: Xcomposite library not found" + echo "Please either install the Xcomposite library and headers, or ensure you have CONFIG_USE_COMPOSITE set to False in Config.h" + +fi + + + { echo "$as_me:$LINENO: checking for SmcOpenConnection in -lSM" >&5 echo $ECHO_N "checking for SmcOpenConnection in -lSM... $ECHO_C" >&6; } if test "${ac_cv_lib_SM_SmcOpenConnection+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else diff -NarU5 wmx-7/configure.in SVN/wm2-2012-01-09/trunk/wmx/configure.in --- wmx-7/configure.in 2009-01-09 06:18:03.000000000 -0500 +++ SVN/wm2-2012-01-09/trunk/wmx/configure.in 2012-01-09 11:05:39.674384166 -0500 @@ -37,10 +37,16 @@ AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [], [ echo "Warning: Xpm library not found" echo "Please either install the Xpm library and headers, or ensure you have CONFIG_USE_PIXMAPS set to False in Config.h" ]) +dnl Composite is necessary if CONFIG_USE_COMPOSITE +AC_CHECK_LIB(Xcomposite, XCompositeQueryExtension, [], [ + echo "Warning: Xcomposite library not found" + echo "Please either install the Xcomposite library and headers, or ensure you have CONFIG_USE_COMPOSITE set to False in Config.h" + ]) + dnl SM and ICE are necessary if CONFIG_USE_SESSION_MANAGER AC_CHECK_LIB(SM, SmcOpenConnection) AC_CHECK_LIB(ICE, IceConnectionNumber) dnl Freetype: actually only needed if CONFIG_USE_XFT diff -NarU5 wmx-7/Events.C SVN/wm2-2012-01-09/trunk/wmx/Events.C --- wmx-7/Events.C 2009-01-09 06:18:03.000000000 -0500 +++ SVN/wm2-2012-01-09/trunk/wmx/Events.C 2012-01-09 11:05:39.672384052 -0500 @@ -142,15 +142,23 @@ if (!m_signalled) { waiting: - if (m_channelChangeTime > 0) { + if (m_channelChangeTime > 0 || CONFIG_CLOCK) { + Time t = timestamp(True); - if (t >= m_channelChangeTime) { + + if (m_channelChangeTime > 0 && t >= m_channelChangeTime) { instateChannel(); } + + if (CONFIG_CLOCK && (m_clockUpdateTime == CurrentTime || + t >= m_clockUpdateTime + 60000)) { + m_clockUpdateTime = t; + updateClock(); + } } if (QLength(m_display) > 0) { XNextEvent(m_display, e); return; diff -NarU5 wmx-7/Makefile.in SVN/wm2-2012-01-09/trunk/wmx/Makefile.in --- wmx-7/Makefile.in 2009-01-09 06:18:03.000000000 -0500 +++ SVN/wm2-2012-01-09/trunk/wmx/Makefile.in 2012-01-09 11:05:39.670383938 -0500 @@ -43,10 +43,15 @@ cp wmx @bindir@/wmx -chmod 0755 @bindir@/wmx -chown root:wheel @bindir@/wmx -rm -f @bindir@/wmx.old +install-rpm: + mkdir -p $(DESTDIR)/usr/bin/ + cp wmx $(DESTDIR)/usr/bin/wmx + + # DO NOT DELETE -- make depend depends on it Border.o: Border.C Border.h General.h Config.h Rotated.h Client.h \ Manager.h listmacro.h background.xpm Buttons.o: Buttons.C Manager.h General.h Config.h listmacro.h Client.h \ Border.h Rotated.h Menu.h diff -NarU5 wmx-7/Manager.C SVN/wm2-2012-01-09/trunk/wmx/Manager.C --- wmx-7/Manager.C 2009-01-09 06:18:03.000000000 -0500 +++ SVN/wm2-2012-01-09/trunk/wmx/Manager.C 2012-01-09 11:05:39.678384393 -0500 @@ -13,10 +13,14 @@ #include <sys/wait.h> #include "Cursors.h" #include <X11/cursorfont.h> +#ifdef CONFIG_USE_COMPOSITE +#include <X11/extensions/Xcomposite.h> +#endif + Atom Atoms::wm_state; Atom Atoms::wm_changeState; Atom Atoms::wm_protocols; Atom Atoms::wm_delete; Atom Atoms::wm_takeFocus; @@ -285,10 +289,12 @@ m_channels = 2; m_currentChannel = 1; m_channelChangeTime = 0; m_channelWindow = 0; + m_clockWindow = 0; + m_clockUpdateTime = CurrentTime; Atoms::wm_state = XInternAtom(m_display, "WM_STATE", False); Atoms::wm_changeState= XInternAtom(m_display, "WM_CHANGE_STATE", False); Atoms::wm_protocols = XInternAtom(m_display, "WM_PROTOCOLS", False); Atoms::wm_delete = XInternAtom(m_display, "WM_DELETE_WINDOW", False); @@ -338,11 +344,22 @@ initialiseScreen(); if (m_screensTotal > 1) { fprintf(stderr, "\n Detected %d screens.", m_screensTotal); } - + +#ifdef CONFIG_USE_COMPOSITE + int ev, er; + if (XCompositeQueryExtension(m_display, &ev, &er)) { + fprintf(stderr, "\n Enabling composite extension.\n"); + for (int i = 0; i < m_screensTotal; ++i) { + XCompositeRedirectSubwindows(m_display, RootWindow(m_display, i), + CompositeRedirectAutomatic); + } + } +#endif + XSetSelectionOwner(m_display, Atoms::wmx_running, None, timestamp(True)); // used to have m_menuWindow XSync(m_display, False); m_initialising = False; m_returnCode = 0; @@ -517,11 +534,12 @@ m_root = (Window *) malloc(m_screensTotal * sizeof(Window)); m_defaultColormap = (Colormap *) malloc(m_screensTotal * sizeof(Colormap)); // m_minimumColormaps = (int *) malloc(m_screensTotal * sizeof(int)); m_channelWindow = (Window *) malloc(m_screensTotal * sizeof(Window)); - + m_clockWindow = (Window *) malloc(2 * sizeof(Window)); + for (i = 0 ; i < m_screensTotal ; i++) { m_screenNumber = i; m_channelWindow[i] = 0; @@ -570,10 +588,14 @@ XChangeWindowAttributes(m_display, m_root[i], CWCursor | CWEventMask, &attr); XSync(m_display, False); } + for (i = 0; i < 2; ++i) { + m_clockWindow[i] = 0; + } + m_screenNumber = 0; } unsigned long WindowManager::allocateColour(int screen, const char *name, diff -NarU5 wmx-7/Manager.h SVN/wm2-2012-01-09/trunk/wmx/Manager.h --- wmx-7/Manager.h 2009-01-09 06:18:03.000000000 -0500 +++ SVN/wm2-2012-01-09/trunk/wmx/Manager.h 2012-01-09 11:05:39.682384620 -0500 @@ -150,16 +150,22 @@ int m_channels; int m_currentChannel; // from 1 to ... void flipChannel(Boolean statusOnly, Boolean flipDown, Boolean quickFlip, Client *push); // bleah! + Window createNumberWindow(int screen, const char *colour); + int shapeNumberWindow(Window w, int number, int minDigits); // returns width in pixels void instateChannel(); void createNewChannel(); void checkChannel(int); Time m_channelChangeTime; Window *m_channelWindow; + void updateClock(); + Window *m_clockWindow; + Time m_clockUpdateTime; + Boolean m_looping; int m_returnCode; static Boolean m_initialising; static int errorHandler(Display *, XErrorEvent *); diff -NarU5 wmx-7/Menu.C SVN/wm2-2012-01-09/trunk/wmx/Menu.C --- wmx-7/Menu.C 2009-01-09 06:18:03.000000000 -0500 +++ SVN/wm2-2012-01-09/trunk/wmx/Menu.C 2012-01-09 11:05:39.673384109 -0500 @@ -54,10 +54,14 @@ tokstr = 0; FcPattern *pattern = FcPatternCreate(); FcPatternAddString(pattern, FC_FAMILY, (FcChar8 *)fi); FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); + +#ifndef FC_WEIGHT_REGULAR +#define FC_WEIGHT_REGULAR FC_WEIGHT_MEDIUM +#endif FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_REGULAR); FcPatternAddInteger(pattern, FC_PIXEL_SIZE, CONFIG_MENU_FONT_SIZE); FcConfigSubstitute(FcConfigGetCurrent(), pattern, FcMatchPattern); FcResult result = FcResultMatch;