1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-28 17:32:29 +01:00

default WMRootMenu is now a proplist menu instead of text

This commit is contained in:
kojima
2000-07-15 08:12:33 +00:00
parent bb6acdad3c
commit b3dee733bb
3 changed files with 116 additions and 18 deletions

View File

@@ -21,7 +21,7 @@
*/ */
#define PROG_VERSION "getstyle (Window Maker) 0.5" #define PROG_VERSION "getstyle (Window Maker) 0.6"
@@ -51,6 +51,9 @@ static char *options[] = {
"IconTitleFont", "IconTitleFont",
"DisplayFont", "DisplayFont",
"LargeDisplayFont", "LargeDisplayFont",
"WindowTitleExtendSpace",
"MenuTitleExtendSpace",
"MenuTextExtendSpace",
"HighlightColor", "HighlightColor",
"HighlightTextColor", "HighlightTextColor",
"ClipTitleColor", "ClipTitleColor",

View File

@@ -12,6 +12,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
/*
* TODO:
* - lens that shows where it's magnifying
*
*
*/
int refreshrate = 200; int refreshrate = 200;
@@ -23,15 +29,27 @@ typedef struct {
unsigned long lastpixel; unsigned long lastpixel;
unsigned long *buffer; unsigned long *buffer;
int width, height; int width, height;
int rwidth, rheight; /* size of window in real pixels */
int magfactor; int magfactor;
int refreshrate;
WMWindow *win; WMWindow *win;
WMLabel *label; WMLabel *label;
WMPixmap *pixmap; WMPixmap *pixmap;
WMWindow *dlg;
WMSlider *speed;
WMSlider *magnify;
WMButton *okB;
WMButton *cancelB;
WMButton *newB;
int x, y; int x, y;
Bool frozen; Bool frozen;
Bool firstDraw;
Bool markPointerHotspot;
WMHandlerID tid; WMHandlerID tid;
} BufferData; } BufferData;
@@ -46,6 +64,8 @@ int rectBufferSize = 32;
Display *dpy; Display *dpy;
WMScreen *scr; WMScreen *scr;
unsigned int black; unsigned int black;
WMColor *cursorColor1;
WMColor *cursorColor2;
#ifndef __GNUC__ #ifndef __GNUC__
#define inline #define inline
@@ -59,7 +79,14 @@ makeBufferData(WMWindow *win, WMLabel *label, int width, int height,
BufferData *data; BufferData *data;
data = wmalloc(sizeof(BufferData)); data = wmalloc(sizeof(BufferData));
data->rwidth = width;
data->rheight = height;
data->refreshrate = refreshrate;
data->firstDraw = True;
data->magfactor = magfactor; data->magfactor = magfactor;
data->rects = wmalloc(sizeof(XRectangle)*rectBufferSize); data->rects = wmalloc(sizeof(XRectangle)*rectBufferSize);
@@ -93,6 +120,9 @@ resizeBufferData(BufferData *data, int width, int height, int magfactor)
int w = width/magfactor; int w = width/magfactor;
int h = height/magfactor; int h = height/magfactor;
data->rwidth = width;
data->rheight = height;
data->firstDraw = True;
data->magfactor = magfactor; data->magfactor = magfactor;
data->buffer = wrealloc(data->buffer, sizeof(unsigned long)*w*h); data->buffer = wrealloc(data->buffer, sizeof(unsigned long)*w*h);
data->width = w; data->width = w;
@@ -114,17 +144,19 @@ static int
drawpoint(BufferData *data, unsigned long pixel, int x, int y) drawpoint(BufferData *data, unsigned long pixel, int x, int y)
{ {
static GC gc = NULL; static GC gc = NULL;
Bool flush = (x < 0);
if (data->buffer[x+data->width*y] == pixel) if (!flush) {
return 0; if (data->buffer[x+data->width*y] == pixel && !data->firstDraw)
return 0;
data->buffer[x+data->width*y] = pixel; data->buffer[x+data->width*y] = pixel;
}
if (gc == NULL) { if (gc == NULL) {
gc = XCreateGC(dpy, DefaultRootWindow(dpy), 0, NULL); gc = XCreateGC(dpy, DefaultRootWindow(dpy), 0, NULL);
} }
if (data->lastpixel == pixel && data->rectP < rectBufferSize) { if (!flush && data->lastpixel == pixel && data->rectP < rectBufferSize) {
data->rects[data->rectP].x = x*data->magfactor; data->rects[data->rectP].x = x*data->magfactor;
data->rects[data->rectP].y = y*data->magfactor; data->rects[data->rectP].y = y*data->magfactor;
data->rects[data->rectP].width = data->magfactor; data->rects[data->rectP].width = data->magfactor;
@@ -206,12 +238,44 @@ updateImage(BufferData *data, int rx, int ry)
changedPixels++; changedPixels++;
} }
} }
/* flush the point cache */
drawpoint(data, 0, -1, -1);
XDestroyImage(image); XDestroyImage(image);
if (data->markPointerHotspot && !data->frozen) {
XRectangle rects[4];
rects[0].x = (data->width/2 - 3)*data->magfactor;
rects[0].y = (data->height/2)*data->magfactor;
rects[0].width = 2*data->magfactor;
rects[0].height = data->magfactor;
rects[1].x = (data->width/2 + 2)*data->magfactor;
rects[1].y = (data->height/2)*data->magfactor;
rects[1].width = 2*data->magfactor;
rects[1].height = data->magfactor;
XFillRectangles(dpy, data->d, WMColorGC(cursorColor1), rects, 2);
rects[2].y = (data->height/2 - 3)*data->magfactor;
rects[2].x = (data->width/2)*data->magfactor;
rects[2].height = 2*data->magfactor;
rects[2].width = data->magfactor;
rects[3].y = (data->height/2 + 2)*data->magfactor;
rects[3].x = (data->width/2)*data->magfactor;
rects[3].height = 2*data->magfactor;
rects[3].width = data->magfactor;
XFillRectangles(dpy, data->d, WMColorGC(cursorColor2), rects + 2, 2);
}
if (changedPixels > 0) { if (changedPixels > 0) {
WMRedisplayWidget(data->label); WMRedisplayWidget(data->label);
} }
data->firstDraw = False;
} }
@@ -234,9 +298,10 @@ update(void *d)
} }
updateImage(data, rx, ry); updateImage(data, rx, ry);
data->tid = WMAddTimerHandler(refreshrate, update, data); data->tid = WMAddTimerHandler(data->refreshrate, update, data);
} }
void resizedWindow(void *d, WMNotification *notif) void resizedWindow(void *d, WMNotification *notif)
{ {
BufferData *data = (BufferData*)d; BufferData *data = (BufferData*)d;
@@ -268,6 +333,25 @@ void closeWindow(WMWidget *w, void *d)
} }
#if 0
static void
clickHandler(XEvent *event, void *d)
{
BufferData *data = (BufferData*)d;
data->win = WMCreateWindow(scr, "setup");
WMSetWindowTitle(data->win, "Magnify Options");
data->speed = WMCreateSlider(data->win);
data->magnify = WMCreateSlider(data->win);
}
#endif
static void static void
keyHandler(XEvent *event, void *d) keyHandler(XEvent *event, void *d)
{ {
@@ -284,6 +368,9 @@ keyHandler(XEvent *event, void *d)
case 'n': case 'n':
newWindow(data->magfactor); newWindow(data->magfactor);
break; break;
case 'm':
data->markPointerHotspot = !data->markPointerHotspot;
break;
case 'f': case 'f':
case ' ': case ' ':
data->frozen = !data->frozen; data->frozen = !data->frozen;
@@ -401,11 +488,19 @@ int main(int argc, char **argv)
} else if (strcmp(argv[i], "-h")==0 } else if (strcmp(argv[i], "-h")==0
|| strcmp(argv[i], "--help")==0) { || strcmp(argv[i], "--help")==0) {
help: help:
printf("Syntax: %s [-display <display>] [-m <number>] [-r <number>]\n",
printf("Syntax: %s [options]\n",
argv[0]); argv[0]);
puts("-display <display> display that should be used"); puts("Options:");
puts("-m <number> change magnification factor (default 2)"); puts(" -display <display> display that should be used");
puts("-r <number> change refresh delay, in milliseconds (default 200)"); puts(" -m <number> change magnification factor (default 2)");
puts(" -r <number> change refresh delay, in milliseconds (default 200)");
puts("Keys:");
puts(" 1,2,3,4,5,6,7,8,9 change the magnification factor");
puts(" <space>, f freeze the 'camera', making it magnify only the current\n"
" position");
puts(" n create a new window");
puts(" m show/hide the pointer hotspot mark");
exit(0); exit(0);
} }
} }
@@ -426,6 +521,9 @@ int main(int argc, char **argv)
scr = WMCreateScreen(dpy, 0); scr = WMCreateScreen(dpy, 0);
cursorColor1 = WMCreateNamedColor(scr, "#ff0000", False);
cursorColor2 = WMCreateNamedColor(scr, "#00ff00", False);
data = newWindow(magfactor); data = newWindow(magfactor);
WMScreenMainLoop(scr); WMScreenMainLoop(scr);

View File

@@ -54,10 +54,7 @@ copy() {
target=$2 target=$2
file=`basename $source` file=`basename $source`
rm -f $target rm -f $target
if [ "$file" = "WMRootMenu" ]; then if [ "$file" = "WindowMaker" ]; then
echo \"$GSDIR/Library/WindowMaker/menu\" > \
$target
elif [ "$file" = "WindowMaker" ]; then
sed -e "s|~/GNUstep|$GSDIR|g" $source > $target sed -e "s|~/GNUstep|$GSDIR|g" $source > $target
else else
if test "x$GNUSTEP_USER_ROOT" = "x"; then if test "x$GNUSTEP_USER_ROOT" = "x"; then
@@ -271,7 +268,7 @@ if test -z "#LITE#" ; then
echo "There are menus in 2 different file formats. The plain text format and" echo "There are menus in 2 different file formats. The plain text format and"
echo "the property list format. The plain text format is more flexible, but" echo "the property list format. The plain text format is more flexible, but"
echo "the menu in the property list format can be edited graphically. The" echo "the menu in the property list format can be edited graphically. The"
echo "menu that will be used by default is the plain text. Read" echo "menu that will be used by default is the property list one. Read"
echo "$GSDIR/Library/WindowMaker/README for information on how to change it." echo "$GSDIR/Library/WindowMaker/README for information on how to change it."
else else
echo "Your copy of Window Maker is configured especially for KDE." echo "Your copy of Window Maker is configured especially for KDE."