1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-06 16:25:50 +01:00

- made deiconification not automatically focus window in sloppy focus

- fixed crash with DisableMiniwindows and icon pixmap changes
- fixed crash when changing icon of window without WM_CLASS
- added IAmAnnoyingAndDontWantWorkspaceNameDisplay
- added hysteresys for offscreen menu scrollback
- fixed bug with IgnoreFocusClick
- fixed crash with windows with width == 1 (Alban Hertroys
					<dalroi@wit401310.student.utwente.nl>)
- added SHEXEC command
- fixed resizebarback for SHADOW_RESIZEBAR ( jim knoble jmknoble@pobox.com)
This commit is contained in:
kojima
1999-04-24 20:08:20 +00:00
parent 446c02aa5c
commit 7f01849758
41 changed files with 851 additions and 150 deletions

View File

@@ -1,3 +1,9 @@
changes since wmaker 0.53.0:
............................
- added balloon help
changes since wmaker 0.52.0:
............................

View File

@@ -67,6 +67,7 @@ libWINGs_a_SOURCES = \
selection.c \
userdefaults.c \
wapplication.c \
wballoon.c \
wbrowser.c \
wbutton.c \
wcolor.c \

View File

@@ -139,7 +139,7 @@ wmquery_LDADD = libWINGs.a $(LIBLIST)
EXTRA_DIST = logo.xpm
# wbutton.c
libWINGs_a_SOURCES = WINGs.h WINGsP.h configuration.c llist.h llist.c international.c notification.c selection.c userdefaults.c wapplication.c wbrowser.c wbutton.c wcolor.c wcolorpanel.c wcolorwell.c wevent.c wfilepanel.c wframe.c wfont.c wfontpanel.c widgets.c wlabel.c wlist.c wmisc.c wpanel.c wpixmap.c wpopupbutton.c wscroller.c wscrollview.c wslider.c wsplitview.c wtextfield.c wwindow.c wview.c error.c findfile.c hashtable.c memory.c usleep.c
libWINGs_a_SOURCES = WINGs.h WINGsP.h configuration.c llist.h llist.c international.c notification.c selection.c userdefaults.c wapplication.c wballoon.c wbrowser.c wbutton.c wcolor.c wcolorpanel.c wcolorwell.c wevent.c wfilepanel.c wframe.c wfont.c wfontpanel.c widgets.c wlabel.c wlist.c wmisc.c wpanel.c wpixmap.c wpopupbutton.c wscroller.c wscrollview.c wslider.c wsplitview.c wtextfield.c wwindow.c wview.c error.c findfile.c hashtable.c memory.c usleep.c
INCLUDES = -I$(top_srcdir)/wrlib -I$(top_srcdir)/src -DRESOURCE_PATH=\"$(datadir)/WINGs\" @HEADER_SEARCH_PATH@ -DDEBUG
@@ -159,12 +159,12 @@ X_LIBS = @X_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libWINGs_a_LIBADD =
libWINGs_a_OBJECTS = configuration.o llist.o international.o \
notification.o selection.o userdefaults.o wapplication.o wbrowser.o \
wbutton.o wcolor.o wcolorpanel.o wcolorwell.o wevent.o wfilepanel.o \
wframe.o wfont.o wfontpanel.o widgets.o wlabel.o wlist.o wmisc.o \
wpanel.o wpixmap.o wpopupbutton.o wscroller.o wscrollview.o wslider.o \
wsplitview.o wtextfield.o wwindow.o wview.o error.o findfile.o \
hashtable.o memory.o usleep.o
notification.o selection.o userdefaults.o wapplication.o wballoon.o \
wbrowser.o wbutton.o wcolor.o wcolorpanel.o wcolorwell.o wevent.o \
wfilepanel.o wframe.o wfont.o wfontpanel.o widgets.o wlabel.o wlist.o \
wmisc.o wpanel.o wpixmap.o wpopupbutton.o wscroller.o wscrollview.o \
wslider.o wsplitview.o wtextfield.o wwindow.o wview.o error.o \
findfile.o hashtable.o memory.o usleep.o
AR = ar
PROGRAMS = $(noinst_PROGRAMS)

View File

@@ -108,9 +108,9 @@ GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps WINGs/Resources/Makefile
cd $(top_srcdir) && $(AUTOMAKE) --gnu WINGs/Resources/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
@@ -142,6 +142,11 @@ distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = WINGs/Resources
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu WINGs/Resources/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \

View File

@@ -639,6 +639,22 @@ extern char *WMViewSizeDidChangeNotification;
extern char *WMViewRealizedNotification;
/* ....................................................................... */
void WMSetBalloonTextForView(char *text, WMView *view);
void WMSetBalloonTextAlignment(WMScreen *scr, WMAlignment alignment);
void WMSetBalloonFont(WMScreen *scr, WMFont *font);
void WMSetBalloonTextColor(WMScreen *scr, WMColor *color);
void WMSetBalloonDelay(WMScreen *scr, int delay);
void WMSetBalloonEnabled(WMScreen *scr, Bool flag);
/* ....................................................................... */
WMWindow *WMCreateWindow(WMScreen *screen, char *name);

View File

@@ -134,7 +134,9 @@ typedef struct W_Screen {
struct W_FontPanel *sharedFontPanel;
struct W_ColorPanel *sharedColorPanel;
Pixmap stipple;
/* colors */
W_Color *white;
W_Color *black;
@@ -432,3 +434,8 @@ void W_FlushASAPNotificationQueue();
void W_FlushIdleNotificationQueue();
struct W_Balloon *W_CreateBalloon(WMScreen *scr);
void W_BalloonHandleEnterView(WMView *view);
void W_BalloonHandleLeaveView(WMView *view);

473
WINGs/wballoon.c Normal file
View File

@@ -0,0 +1,473 @@
#include "WINGsP.h"
#include <X11/extensions/shape.h>
typedef struct W_Balloon {
W_View *view;
WMHashTable *table; /* Table from view ptr to text */
WMColor *backColor;
WMColor *textColor;
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 */
struct {
WMAlignment alignment:2;
unsigned enabled:1;
unsigned noDelay:1;
} flags;
} Balloon;
#define DEFAULT_WIDTH 60
#define DEFAULT_HEIGHT 14
#define DEFAULT_ALIGNMENT WALeft
#define DEFAULT_DELAY 500
#define NO_DELAY_DELAY 150
static void destroyBalloon(Balloon *bPtr);
static void handleEvents(XEvent *event, void *data);
static void showText(Balloon *bPtr, int x, int y, int w, int h, char *text);
struct W_Balloon*
W_CreateBalloon(WMScreen *scr)
{
Balloon *bPtr;
bPtr = wmalloc(sizeof(Balloon));
memset(bPtr, 0, sizeof(Balloon));
bPtr->view = W_CreateTopView(scr);
if (!bPtr->view) {
free(bPtr);
return NULL;
}
bPtr->view->self = bPtr;
bPtr->view->attribFlags |= CWOverrideRedirect;
bPtr->view->attribs.override_redirect = True;
bPtr->textColor = WMRetainColor(bPtr->view->screen->black);
WMCreateEventHandler(bPtr->view, StructureNotifyMask, handleEvents, bPtr);
W_ResizeView(bPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
bPtr->flags.alignment = DEFAULT_ALIGNMENT;
bPtr->table = WMCreateHashTable(WMIntHashCallbacks);
bPtr->delay = DEFAULT_DELAY;
bPtr->flags.enabled = 1;
return bPtr;
}
void
WMSetBalloonTextAlignment(WMScreen *scr, WMAlignment alignment)
{
scr->balloon->flags.alignment = alignment;
}
void
WMSetBalloonTextForView(char *text, WMView *view)
{
char *oldText = NULL;
WMScreen *scr = view->screen;
if (text) {
oldText = WMHashInsert(scr->balloon->table, view, wstrdup(text));
} else {
oldText = WMHashGet(scr->balloon->table, view);
WMHashRemove(scr->balloon->table, view);
}
if (oldText) {
free(oldText);
}
}
void
WMSetBalloonFont(WMScreen *scr, WMFont *font)
{
Balloon *bPtr = scr->balloon;
if (bPtr->font!=NULL)
WMReleaseFont(bPtr->font);
if (font)
bPtr->font = WMRetainFont(font);
else
bPtr->font = NULL;
}
void
WMSetBalloonTextColor(WMScreen *scr, WMColor *color)
{
Balloon *bPtr = scr->balloon;
if (bPtr->textColor)
WMReleaseColor(bPtr->textColor);
bPtr->textColor = WMRetainColor(color);
}
void
WMSetBalloonDelay(WMScreen *scr, int delay)
{
scr->balloon->delay = delay;
}
void
WMSetBalloonEnabled(WMScreen *scr, Bool flag)
{
scr->balloon->flags.enabled = flag;
W_UnmapView(scr->balloon->view);
}
static void
clearNoDelay(void *data)
{
Balloon *bPtr = (Balloon*)data;
bPtr->flags.noDelay = 0;
bPtr->noDelayTimer = NULL;
}
void
W_BalloonHandleLeaveView(WMView *view)
{
Balloon *bPtr = view->screen->balloon;
if (bPtr->view->flags.mapped && bPtr->forWindow == view->window) {
W_UnmapView(bPtr->view);
if (bPtr->timer)
WMDeleteTimerHandler(bPtr->timer);
bPtr->timer = NULL;
bPtr->noDelayTimer = WMAddTimerHandler(NO_DELAY_DELAY, clearNoDelay,
bPtr);
}
bPtr->forWindow = None;
}
static void
showBalloon(void *data)
{
char *text;
WMView *view = (WMView*)data;
Balloon *bPtr = view->screen->balloon;
int x, y;
Window foo;
bPtr->timer = NULL;
text = WMHashGet(bPtr->table, view);
if (!text)
return;
XTranslateCoordinates(view->screen->display, view->window,
view->screen->rootWin, 0, 0, &x, &y, &foo);
if (!bPtr->view->flags.realized)
W_RealizeView(bPtr->view);
showText(bPtr, x, y, view->size.width, view->size.height, text);
bPtr->forWindow = view->window;
bPtr->flags.noDelay = 1;
}
void
W_BalloonHandleEnterView(WMView *view)
{
Balloon *bPtr = view->screen->balloon;
char *text;
if (!bPtr->flags.enabled)
return;
text = WMHashGet(bPtr->table, view);
if (!text) {
bPtr->forWindow = None;
if (bPtr->view->flags.realized)
W_UnmapView(bPtr->view);
return;
}
if (bPtr->timer)
WMDeleteTimerHandler(bPtr->timer);
if (bPtr->noDelayTimer)
WMDeleteTimerHandler(bPtr->noDelayTimer);
bPtr->noDelayTimer = NULL;
if (bPtr->flags.noDelay) {
bPtr->timer = NULL;
showBalloon(view);
} else {
bPtr->timer = WMAddTimerHandler(bPtr->delay, showBalloon, view);
}
}
#define TOP 0
#define BOTTOM 1
#define LEFT 0
#define RIGHT 2
#define TLEFT (TOP|LEFT)
#define TRIGHT (TOP|RIGHT)
#define BLEFT (BOTTOM|LEFT)
#define BRIGHT (BOTTOM|RIGHT)
#define SPACE 12
static void
drawBalloon(Display *dpy, Pixmap pix, GC gc, int x, int y, int w, int h,
int side)
{
int rad = h*3/10;
XPoint pt[3];
XFillArc(dpy, pix, gc, x, y, rad, rad, 90*64, 90*64);
XFillArc(dpy, pix, gc, x, y+h-1-rad, rad, rad, 180*64, 90*64);
XFillArc(dpy, pix, gc, x+w-1-rad, y, rad, rad, 0*64, 90*64);
XFillArc(dpy, pix, gc, x+w-1-rad, y+h-1-rad, rad, rad, 270*64, 90*64);
XFillRectangle(dpy, pix, gc, x, y+rad/2, w, h-rad);
XFillRectangle(dpy, pix, gc, x+rad/2, y, w-rad, h);
if (side & BOTTOM) {
pt[0].y = y+h-1;
pt[1].y = y+h-1+SPACE;
pt[2].y = y+h-1;
} else {
pt[0].y = y;
pt[1].y = y-SPACE;
pt[2].y = y;
}
if (side & RIGHT) {
pt[0].x = x+w-h+2*h/16;
pt[1].x = x+w-h+11*h/16;
pt[2].x = x+w-h+7*h/16;
} else {
pt[0].x = x+h-2*h/16;
pt[1].x = x+h-11*h/16;
pt[2].x = x+h-7*h/16;
}
XFillPolygon(dpy, pix, gc, pt, 3, Convex, CoordModeOrigin);
}
static Pixmap
makePixmap(WMScreen *scr, int width, int height, int side, Pixmap *mask)
{
Display *dpy = WMScreenDisplay(scr);
Pixmap bitmap;
Pixmap pixmap;
int x, y;
WMColor *black = WMBlackColor(scr);
WMColor *white = WMWhiteColor(scr);
bitmap = XCreatePixmap(dpy, scr->rootWin, width+SPACE, height+SPACE, 1);
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,
scr->depth);
XFillRectangle(dpy, pixmap, WMColorGC(black), 0, 0,
width+SPACE, height+SPACE);
if (side & BOTTOM) {
y = 0;
} else {
y = SPACE;
}
x = 0;
XSetForeground(dpy, scr->monoGC, 1);
drawBalloon(dpy, bitmap, scr->monoGC, x, y, width, height, side);
drawBalloon(dpy, pixmap, WMColorGC(white), x+1, y+1, width-2, height-2,
side);
*mask = bitmap;
WMReleaseColor(black);
WMReleaseColor(white);
return pixmap;
}
static void
showText(Balloon *bPtr, int x, int y, int h, int w, char *text)
{
WMScreen *scr = bPtr->view->screen;
Display *dpy = WMScreenDisplay(scr);
int width;
int height;
Pixmap pixmap;
Pixmap mask;
WMFont *font = bPtr->font ? bPtr->font : scr->normalFont;
int textHeight;
int side = 0;
int ty;
int bx, by;
{
int w;
char *ptr, *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;
if (width < height)
width = height;
if (x + width > scr->rootView->size.width) {
side = RIGHT;
bx = x - width + w/2;
if (bx < 0)
bx = 0;
} else {
side = LEFT;
bx = x + w/2;
}
if (bx + width > scr->rootView->size.width)
bx = scr->rootView->size.width - width;
if (y - (height + SPACE) < 0) {
side |= TOP;
by = y+h-1;
ty = SPACE;
} else {
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,
WMColorGC(bPtr->textColor ? bPtr->textColor : scr->black),
False, text, strlen(text));
XSetWindowBackgroundPixmap(dpy, bPtr->view->window, pixmap);
W_ResizeView(bPtr->view, width, height+SPACE);
XFreePixmap(dpy, pixmap);
XShapeCombineMask(dpy, bPtr->view->window, ShapeBounding, 0, 0, mask,
ShapeSet);
XFreePixmap(dpy, mask);
W_MoveView(bPtr->view, bx, by);
W_MapView(bPtr->view);
}
static void
handleEvents(XEvent *event, void *data)
{
Balloon *bPtr = (Balloon*)data;
switch (event->type) {
case DestroyNotify:
destroyBalloon(bPtr);
break;
}
}
static void
destroyBalloon(Balloon *bPtr)
{
WMHashEnumerator e;
char *str;
e = WMEnumerateHashTable(bPtr->table);
while ((str = WMNextHashEnumeratorItem(&e))) {
free(str);
}
WMFreeHashTable(bPtr->table);
if (bPtr->textColor)
WMReleaseColor(bPtr->textColor);
if (bPtr->font)
WMReleaseFont(bPtr->font);
free(bPtr);
}

View File

@@ -13,10 +13,12 @@ typedef struct W_Button {
char *altCaption;
WMFont *font;
W_Pixmap *image;
W_Pixmap *altImage;
W_Pixmap *dimage;
void *clientData;
WMAction *action;
@@ -231,14 +233,62 @@ WMCreateButton(WMWidget *parent, WMButtonType type)
}
static void
updateDisabledMask(WMButton *bPtr)
{
WMScreen *scr = WMWidgetScreen(bPtr);
Display *dpy = scr->display;
if (bPtr->image) {
XGCValues gcv;
bPtr->dimage->mask = XCreatePixmap(dpy, scr->stipple,
bPtr->dimage->width,
bPtr->dimage->height, 1);
XSetForeground(dpy, scr->monoGC, 0);
XFillRectangle(dpy, bPtr->dimage->mask, scr->monoGC, 0, 0,
bPtr->dimage->width, bPtr->dimage->height);
gcv.foreground = 1;
gcv.background = 0;
gcv.stipple = scr->stipple;
gcv.fill_style = FillStippled;
gcv.clip_mask = bPtr->image->mask;
gcv.clip_x_origin = 0;
gcv.clip_y_origin = 0;
XChangeGC(dpy, scr->monoGC, GCForeground|GCBackground|GCStipple
|GCFillStyle|GCClipMask|GCClipXOrigin|GCClipYOrigin, &gcv);
XFillRectangle(dpy, bPtr->dimage->mask, scr->monoGC, 0, 0,
bPtr->dimage->width, bPtr->dimage->height);
gcv.fill_style = FillSolid;
gcv.clip_mask = None;
XChangeGC(dpy, scr->monoGC, GCFillStyle|GCClipMask, &gcv);
}
}
void
WMSetButtonImage(WMButton *bPtr, WMPixmap *image)
{
if (bPtr->image!=NULL)
WMReleasePixmap(bPtr->image);
bPtr->image = WMRetainPixmap(image);
if (bPtr->dimage) {
bPtr->dimage->pixmap = None;
WMReleasePixmap(bPtr->dimage);
}
bPtr->dimage = WMCreatePixmapFromXPixmaps(WMWidgetScreen(bPtr),
image->pixmap, None,
image->width, image->height,
image->depth);
updateDisabledMask(bPtr);
if (bPtr->view->flags.realized) {
paintButton(bPtr);
}
@@ -502,7 +552,10 @@ paintButton(Button *bPtr)
gc = NULL;
caption = bPtr->caption;
image = bPtr->image;
if (bPtr->flags.enabled)
image = bPtr->image;
else
image = bPtr->dimage;
offset = 0;
if (bPtr->flags.bordered)
relief = WRRaised;
@@ -689,7 +742,7 @@ destroyButton(Button *bPtr)
if (bPtr->flags.addedObserver) {
WMRemoveNotificationObserver(bPtr);
}
if (bPtr->timer)
WMDeleteTimerHandler(bPtr->timer);
@@ -704,7 +757,13 @@ destroyButton(Button *bPtr)
if (bPtr->image)
WMReleasePixmap(bPtr->image);
if (bPtr->dimage) {
/* yuck.. kluge */
bPtr->dimage->pixmap = None;
WMReleasePixmap(bPtr->dimage);
}
if (bPtr->altImage)
WMReleasePixmap(bPtr->altImage);

View File

@@ -586,7 +586,7 @@ WMHandleEvent(XEvent *event)
return False;
}
view->screen->lastEventTime = getEventTime(view->screen, event);
toplevel = W_TopLevelOfView(view);
@@ -637,6 +637,12 @@ WMHandleEvent(XEvent *event)
}
}
/* do balloon stuffs */
if (event->type == EnterNotify)
W_BalloonHandleEnterView(view);
else if (event->type == LeaveNotify)
W_BalloonHandleLeaveView(view);
/* This is a hack. It will make the panel be secure while
* the event handlers are handled, as some event handler
* might destroy the widget. */

View File

@@ -297,10 +297,9 @@ static char *CHECK_MARK[] = {
"#%======="};
#define STIPPLE_WIDTH 8
#define STIPPLE_HEIGHT 8
static unsigned char STIPPLE_BITS[] = {
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa};
#define STIPPLE_WIDTH 2
#define STIPPLE_HEIGHT 2
static unsigned char STIPPLE_BITS[] = {0x01, 0x02};
extern void W_ReadConfigurations(void);
@@ -632,9 +631,8 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
/* we need a 1bpp drawable for the monoGC, so borrow this one */
scrPtr->monoGC = XCreateGC(display, stipple, 0, NULL);
XFreePixmap(display, stipple);
scrPtr->stipple = stipple;
scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 12);
scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 12);
@@ -741,6 +739,10 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
scrPtr->rootView = W_CreateRootView(scrPtr);
scrPtr->balloon = W_CreateBalloon(scrPtr);
W_InitApplication(scrPtr);
return scrPtr;

View File

@@ -172,7 +172,7 @@ W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
void
W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
WMReliefType relief, char *text,
WMAlignment alignment, W_Pixmap *image,
WMAlignment alignment, W_Pixmap *image,
WMImagePosition position, GC backGC, int ofs)
{
W_Screen *screen = view->screen;
@@ -264,7 +264,7 @@ W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
ix += ofs;
iy += ofs;
XSetClipOrigin(screen->display, screen->clipGC, ix, iy);
XSetClipMask(screen->display, screen->clipGC, image->mask);

View File

@@ -22,7 +22,8 @@ WMReleasePixmap(WMPixmap *pixmap)
pixmap->refCount--;
if (pixmap->refCount<1) {
XFreePixmap(pixmap->screen->display, pixmap->pixmap);
if (pixmap->pixmap)
XFreePixmap(pixmap->screen->display, pixmap->pixmap);
if (pixmap->mask)
XFreePixmap(pixmap->screen->display, pixmap->mask);
free(pixmap);

View File

@@ -143,6 +143,8 @@ testGradientButtons(WMScreen *scr)
WMSetButtonAltImage(btn, pix2);
WMSetButtonText(btn, "Cool");
WMSetBalloonTextForView("This is a button", WMWidgetView(btn));
btn = WMCreateButton(win, WBTMomentaryChange);
WMResizeWidget(btn, 60, 24);
WMMoveWidget(btn, 90, 100);
@@ -152,6 +154,8 @@ testGradientButtons(WMScreen *scr)
WMSetButtonAltImage(btn, pix2);
WMSetButtonText(btn, "Button");
WMSetBalloonTextForView("This is another button", WMWidgetView(btn));
btn = WMCreateButton(win, WBTMomentaryChange);
WMResizeWidget(btn, 60, 24);
WMMoveWidget(btn, 160, 100);
@@ -160,7 +164,10 @@ testGradientButtons(WMScreen *scr)
WMSetButtonImage(btn, pix1);
WMSetButtonAltImage(btn, pix2);
WMSetButtonText(btn, "Test");
WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
WMWidgetView(btn));
WMRealizeWidget(win);
WMMapSubwidgets(win);
WMMapWidget(win);
@@ -409,15 +416,17 @@ int main(int argc, char **argv)
*
* Put the testSomething() function you want to test here.
*/
testGradientButtons(scr);
#if 0
testOpenFilePanel(scr);
testFontPanel(scr);
testList(scr);
testGradientButtons(scr);
testScrollView(scr);
#endif
testColorWell(scr);
#if 1
testSlider(scr);
testTextField(scr);
testPullDown(scr);

View File

@@ -102,43 +102,6 @@ adoptChildView(W_View *view, W_View *child)
}
static void
handleEvents(XEvent *event, void *data)
{
W_View *view = (W_View*)data;
if (event->type == 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);
}
}
}
}
static W_View*
createView(W_Screen *screen, W_View *parent)
{
@@ -213,9 +176,6 @@ W_CreateTopView(W_Screen *screen)
view->flags.topLevel = 1;
view->attribs.event_mask |= StructureNotifyMask;
/* catch changes in the toplevel window (resize from user etc.) */
WMCreateEventHandler(view, StructureNotifyMask, handleEvents, view);
return view;
}

View File

@@ -172,8 +172,8 @@ 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);
@@ -616,6 +616,7 @@ static void
handleEvents(XEvent *event, void *clientData)
{
_Window *win = (_Window*)clientData;
W_View *view = win->view;
switch (event->type) {
@@ -629,12 +630,43 @@ handleEvents(XEvent *event, void *clientData)
}
}
break;
case UnmapNotify:
WMUnmapWidget(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;
}
}