This code adds new features to the wmaker info panel.
This commit includes the original Kojima code removed in the commit
'f9792a042a5446197326b730f88e4b2de1eb8574' (16 Oct 2009).
---
src/dialog.c | 350 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/superfluous.c | 76 ++++++++++++
src/superfluous.h | 7 +-
src/wconfig.h.in | 2 +
4 files changed, 434 insertions(+), 1 deletion(-)
diff --git a/src/dialog.c b/src/dialog.c
index 43f12fc..8a472ba 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -60,6 +60,11 @@
#include "actions.h"
#include "xinerama.h"
+#ifdef SILLYNESS
+#include "superfluous.h"
+static void handleLogoPush(XEvent *event, void *data);
+static void logoPushCallback(void *data);
+#endif
static WMPoint getCenter(WScreen * scr, int width, int height)
{
@@ -1101,6 +1106,16 @@ typedef struct {
WMLabel *versionL;
WMLabel *infoL;
WMLabel *copyrL;
+#ifdef SILLYNESS
+ WMHandlerID timer;
+ int cycle;
+ RImage *icon;
+ RImage *pic;
+ WMPixmap *oldPix;
+ WMFont *oldFont;
+ char *str;
+ int x;
+#endif
} InfoPanel;
#define COPYRIGHT_TEXT \
@@ -1117,6 +1132,23 @@ static void destroyInfoPanel(WCoreWindow *foo, void
*data, XEvent *event)
(void) data;
(void) event;
+#ifdef SILLYNESS
+ if (thePanel->timer)
+ WMDeleteTimerHandler(thePanel->timer);
+
+ if (thePanel->oldPix)
+ WMReleasePixmap(thePanel->oldPix);
+
+ if (thePanel->oldFont)
+ WMReleaseFont(thePanel->oldFont);
+
+ if (thePanel->icon)
+ RReleaseImage(thePanel->icon);
+
+ if (thePanel->pic)
+ RReleaseImage(thePanel->pic);
+#endif /* SILLYNESS */
+
WMUnmapWidget(thePanel);
wUnmanageWindow(thePanel->wwin, False, False);
WMDestroyWidget(thePanel->win);
@@ -1173,6 +1205,9 @@ void wShowInfoPanel(WScreen *scr)
WMMoveWidget(panel->logoL, 30, 20);
WMSetLabelImagePosition(panel->logoL, WIPImageOnly);
WMSetLabelImage(panel->logoL, logo);
+#ifdef SILLYNESS
+ WMCreateEventHandler(WMWidgetView(panel->logoL),
ButtonPressMask, handleLogoPush, panel);
+#endif
WMReleasePixmap(logo);
}
@@ -1354,6 +1389,16 @@ void wShowInfoPanel(WScreen *scr)
panel->wwin = wwin;
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));
+ }
+#endif
}
/*
@@ -1654,3 +1699,308 @@ int wShowCrashingDialogPanel(int whatSig)
return action;
}
+
+#ifdef SILLYNESS
+
+static void logoPushCallback(void *data)
+{
+ InfoPanel *panel = (InfoPanel *) data;
+ char buffer[512];
+ int i;
+ static int oldi = 0;
+ int len;
+ static int jingobeu[] = {
+ 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
+ 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
+ 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
+ };
+ static int c = 0;
+
+ if (panel->x) {
+ XKeyboardControl kc;
+ XKeyboardState ksave;
+ unsigned long mask = KBBellPitch | KBBellDuration |
KBBellPercent;
+
+ XGetKeyboardControl(dpy, &ksave);
+
+ if (panel->x > 0) {
+ if (jingobeu[panel->x - 1] == 0) {
+ panel->x = -1;
+ } else if (jingobeu[panel->x - 1] < 0) {
+ panel->x++;
+ c = jingobeu[panel->x - 1] / 50;
+ panel->x++;
+ } else if (c == 0) {
+ kc.bell_percent = 50;
+ kc.bell_pitch = jingobeu[panel->x - 1];
+ panel->x++;
+ kc.bell_duration = jingobeu[panel->x - 1];
+ c = jingobeu[panel->x - 1] / 50;
+ panel->x++;
+ XChangeKeyboardControl(dpy, mask, &kc);
+ XBell(dpy, 50);
+ XFlush(dpy);
+ } else {
+ c--;
+ }
+ }
+ if (!(panel->cycle % 4)) {
+ WMPixmap *p;
+
+ p = DoXThing();
+ 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;
+ WMPixmap *pix;
+ RColor gray;
+
+ gray.red = 0xae;
+ gray.green = 0xaa;
+ 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);
+ }
+
+ /* slow down text a little */
+ i = (int)(panel->cycle * 50.0 / 85.0) % 200;
+
+ if (i != oldi) {
+ len = strlen(panel->str);
+
+ strncpy(buffer, panel->str, i < len ? i : len);
+ if (i >= len)
+ memset(&buffer[len], ' ', i - len);
+
+ strncpy(buffer, panel->str, i < len ? i : len);
+ if (i >= len)
+ memset(&buffer[len], ' ', i - len);
+ buffer[i] = 0;
+
+ WMSetLabelText(panel->versionL, buffer);
+
+ XFlush(WMScreenDisplay(WMWidgetScreen(panel->versionL)));
+
+ oldi = i;
+ }
+
+ panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
+ panel->cycle++;
+}
+
+static void handleLogoPush(XEvent *event, void *data)
+{
+ InfoPanel *panel = (InfoPanel *) data;
+ XEvent ev;
+ static int broken = 0;
+ static int clicks = 0;
+ static char *pic_data[] = {
+ "45 45 57 1",
+ " c None",
+ ". c #000000",
+ "X c #383C00",
+ "o c #515500",
+ "O c #616100",
+ "+ c #616900",
+ "@ c #696D00",
+ "# c #697100",
+ "$ c #495100",
+ "% c #202800",
+ "& c #969600",
+ "* c #CFCF00",
+ "= c #D7DB00",
+ "- c #D7D700",
+ "; c #C7CB00",
+ ": c #A6AA00",
+ "> c #494900",
+ ", c #8E8E00",
+ "< c #DFE700",
+ "1 c #F7FF00",
+ "2 c #FFFF00",
+ "3 c #E7EB00",
+ "4 c #B6B600",
+ "5 c #595900",
+ "6 c #717500",
+ "7 c #AEB200",
+ "8 c #CFD300",
+ "9 c #E7EF00",
+ "0 c #EFF300",
+ "q c #9EA200",
+ "w c #F7FB00",
+ "e c #F7F700",
+ "r c #BEBE00",
+ "t c #8E9200",
+ "y c #EFF700",
+ "u c #969A00",
+ "i c #414500",
+ "p c #595D00",
+ "a c #E7E700",
+ "s c #C7C700",
+ "d c #797D00",
+ "f c #BEC300",
+ "g c #DFE300",
+ "h c #868600",
+ "j c #EFEF00",
+ "k c #9E9E00",
+ "l c #616500",
+ "z c #DFDF00",
+ "x c #868A00",
+ "c c #969200",
+ "v c #B6BA00",
+ "b c #A6A600",
+ "n c #8E8A00",
+ "m c #717100",
+ "M c #AEAE00",
+ "N c #AEAA00",
+ "B c #868200",
+ " ............... ",
+ " ....XoO+@##+O$%.... ",
+ " ...%X&*========-;;:o... ",
+ " ...>.>,<122222222222134@... ",
+ " ..>5678912222222222222220q%.. ",
+ " ..$.&-w2222222222222222222er>.. ",
+ " ..O.t31222222222222222222222y4>.. ",
+ " ...O5u3222222222222222222222222yri... ",
+ " ..>p&a22222222222222222222222222wso.. ",
+ " ..ids91222222222222222222222222222wfi.. ",
+ " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
+ " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
+ " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
+ " ..o7y22222222v...r222222223hX.i82222221si.. ",
+ "..io*222222222&...u22222222yt..%*22222220:%. ",
+ "..>k02222222227...f222222222v..X=222222229t. ",
+ "..dz12222222220ui:y2222222223d%qw222222221g. ",
+ ".%vw222222222221y2222222222219*y2222222222wd.",
+ ".X;2222222222222222222222222222222222222222b.",
+ ".i*2222222222222222222222222222222222222222v.",
+ ".i*2222222222222222222222222222222222222222;.",
+ ".i*22222222222222222222222222222222222222228.",
+ ".>*2222222222222222222222222222222222222222=.",
+ ".i*22222222222222222222222222222222222222228.",
+ ".i*2222222222222222222222222222222222222222;.",
+ ".X*222222222222222222222222222222we12222222r.",
+ ".Xs12222222w3aw22222222222222222y8s0222222wk.",
+ ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
+ "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
+ "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
+ " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
+ " ..58222wagsh6ry222222222222221;>Of0w222y:...",
+ " ...:e2222218mdz22222222222222a&$vw222220@...",
+ " ...O-122222y:.u02222222222229q$uj222221r... ",
+ " ..%&a1222223&573w2222222219NOxz122221z>... ",
+ " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
+ " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
+ " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
+ " ..Xb9122222109g-****;<y22221zn%... ",
+ " ..X&801222222222222222222w-h.... ",
+ " ...o:=022222222222222221=lX... ",
+ " ..X@:;3w2222222222210fO... ",
+ " ...XX&v8<30000003-N@... ",
+ " .....XmnbN:q&Bo.... ",
+ " ............ "
+ };
+
+ static char *msgs[] = {
+ "Have a nice day!",
+ "Focus follow mouse users will burn in hell!!!",
+ "Mooo Canada!!!!",
+ "Hi! My name is bobby...",
+ "AHH! The neurotic monkeys are after me!",
+ "WE GET SIGNAL",
+ "HOW ARE YOU GENTLEMEN?",
+ "WHAT YOU SAY??",
+ "SOMEBODY SET UP US THE BOMB",
+ "ALL YOUR BASE ARE BELONG TO US!",
+ "Oh My God!!! Larry is back!",
+ "Alex Perez is aliveeeeeeee!!!"
+ };
+
+ /* Parameter not used, but tell the compiler it is ok */
+ (void) event;
+
+ clicks++;
+
+ if (!panel->timer && !broken && clicks > 0) {
+ WMFont *font;
+
+ panel->x = 0;
+ clicks = 0;
+ if (!panel->icon) {
+ panel->icon =
WMGetApplicationIconImage(panel->scr->wmscreen);
+ if (!panel->icon) {
+ broken = 1;
+ return;
+ } else {
+ RColor color;
+
+ color.red = 0xae;
+ color.green = 0xaa;
+ color.blue = 0xae;
+ color.alpha = 0;
+
+ panel->icon = RCloneImage(panel->icon);
+ 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;
+ 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 */
+ if ((panel->oldFont = WMGetLabelFont(panel->versionL)) != NULL)
+ WMRetainFont(panel->oldFont);
+
+ font = WMCreateFont(WMWidgetScreen(panel->versionL),
+ "Lucida Console,Courier
New,monospace:pixelsize=12");
+ if (font) {
+ WMSetLabelFont(panel->versionL, font);
+ WMReleaseFont(font);
+ }
+ WMSetLabelText(panel->versionL, "");
+ } else if (panel->timer) {
+ char version[20];
+
+ panel->x = 0;
+ clicks = 0;
+ WMSetLabelImage(panel->logoL, panel->oldPix);
+ WMReleasePixmap(panel->oldPix);
+ panel->oldPix = 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);
+ WMSetLabelText(panel->versionL, version);
+ XFlush(WMScreenDisplay(WMWidgetScreen(panel->versionL)));
+ }
+
+ while (XCheckTypedWindowEvent(dpy, WMWidgetXID(panel->versionL),
ButtonPress, &ev)) ;
+}
+#endif /* SILLYNESS */
diff --git a/src/superfluous.c b/src/superfluous.c
index 0883cc1..b6030a4 100644
--- a/src/superfluous.c
+++ b/src/superfluous.c
@@ -31,6 +31,10 @@
#include <wraster.h>
+#ifdef SILLYNESS
+#include <stdio.h>
+#endif
+
#include "WindowMaker.h"
#include "screen.h"
#include "superfluous.h"
@@ -381,3 +385,75 @@ void wAppBounceWhileUrgent(WApplication *wapp)
}
}
}
+
+#ifdef SILLYNESS
+static WMPixmap *data[12];
+
+static Bool loadData(WScreen *scr)
+{
+ FILE *f = NULL;
+ int i;
+ RImage *image;
+ Pixmap d[12];
+
+ f = fopen(PKGDATADIR "/xtree.dat", "rb");
+ if (!f)
+ return False;
+
+ image = RCreateImage(50, 50, False);
+ if (!image) {
+ fclose(f);
+ return False;
+ }
+
+ for (i = 0; i < 12; i++) {
+ if ((fread(image->data, 50 * 50 * 3, 1, f) != 1) ||
(!RConvertImage(scr->rcontext, image, &(d[i])))) {
+ RReleaseImage(image);
+ fclose(f);
+ while (--i > 0)
+ XFreePixmap(dpy, d[i]);
+
+ return False;
+ }
+ }
+
+ RReleaseImage(image);
+ fclose(f);
+
+ for (i = 0; i < 12; i++)
+ data[i] = WMCreatePixmapFromXPixmaps(scr->wmscreen, d[i], None,
50, 50, scr->w_depth);
+
+ return True;
+}
+
+WMPixmap *DoXThing(void)
+{
+ static int order = 0;
+
+ order++;
+ return data[order % 12];
+}
+
+Bool InitXThing(WScreen *scr)
+{
+ time_t t;
+ struct tm *l;
+ static int i = 0;
+
+ t = time(NULL);
+ l = localtime(&t);
+ if ((l->tm_mon != 11 || l->tm_mday < 24 || l->tm_mday > 26))
+ return False;
+
+ if (i)
+ return True;
+
+ if (!loadData(scr))
+ return False;
+
+ i = 1;
+
+ return True;
+}
+
+#endif /* SILLYNESS */
diff --git a/src/superfluous.h b/src/superfluous.h
index b3424cd..91ca3cd 100644
--- a/src/superfluous.h
+++ b/src/superfluous.h
@@ -26,4 +26,9 @@
void DoKaboom(WScreen *scr, Window win, int x, int y);
Pixmap MakeGhostIcon(WScreen *scr, Drawable drawable);
void DoWindowBirth(WWindow *wwin);
-#endif
+
+#ifdef SILLYNESS
+Bool InitXThing(WScreen *scr);
+WMPixmap *DoXThing(void);
+#endif /* SILLYNESS */
+#endif /* WMSUPERFLUOUS_H */
diff --git a/src/wconfig.h.in b/src/wconfig.h.in
index f444a19..9f9c426 100644
--- a/src/wconfig.h.in
+++ b/src/wconfig.h.in
@@ -97,6 +97,8 @@
*/
#undef IGNORE_PPOSITION
+#define SILLYNESS
+
/*
* The following options WILL NOT BE MADE RUN-TIME. Please do not request.
* They will only add unneeded bloat.
--
1.8.5.2
--
To unsubscribe, send mail to [email protected].