1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-07 08:45:48 +01:00

Update for 0.51.0

This commit is contained in:
dan
1999-01-25 19:06:50 +00:00
parent 3aeb1eb052
commit 416e3a82be
238 changed files with 24235 additions and 11473 deletions

View File

@@ -1,3 +1,15 @@
changes since wmaker 0.50.2:
............................
- added wsetabort() - look WUtil.h
- fixed bug in WMList resize
- added notification sending when changing textfield programatically
- removed WMHideWindow()
- fixed bug in WMCloseWindow()
- added textfield selection patch
- added color panel code
changes since wmaker 0.20.3:
............................

View File

@@ -18,9 +18,7 @@ lib_LIBRARIES = libWINGs.a
include_HEADERS = WINGs.h WUtil.h WINGsP.h
bin_SCRIPTS = WINGs-flags
noinst_PROGRAMS = wtest wmquery wmfile fontl testmywidget
noinst_PROGRAMS = wtest wmquery wmfile fontl testmywidget testcolorpanel
testmywidget_SOURCES = testmywidget.c mywidget.c mywidget.h
@@ -39,6 +37,10 @@ wtest_DEPENDENCIES = libWINGs.a
wmfile_SOURCES = wmfile.c
wmfile_LDADD = libWINGs.a $(LIBLIST)
testcolorpanel_SOURCES = testcolorpanel.c
testcolorpanel_LDADD = libWINGs.a $(LIBLIST)
wmquery_SOURCES = wmquery.c
@@ -61,6 +63,7 @@ libWINGs_a_SOURCES = \
wbrowser.c \
wbutton.c \
wcolor.c \
wcolorpanel.c \
wcolorwell.c \
wevent.c \
wfilepanel.c \

View File

@@ -65,8 +65,6 @@ DFLAGS = @DFLAGS@
GFXFLAGS = @GFXFLAGS@
GFXLFLAGS = @GFXLFLAGS@
GFXLIBS = @GFXLIBS@
I18N = @I18N@
I18N_MB = @I18N_MB@
ICONEXT = @ICONEXT@
INTLIBS = @INTLIBS@
LD = @LD@
@@ -79,19 +77,13 @@ NLSDIR = @NLSDIR@
NM = @NM@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
REDUCE_APPICONS = @REDUCE_APPICONS@
SHAPE = @SHAPE@
SOUND = @SOUND@
VERSION = @VERSION@
WPMOFILES = @WPMOFILES@
XCFLAGS = @XCFLAGS@
XGETTEXT = @XGETTEXT@
XLFLAGS = @XLFLAGS@
XLIBS = @XLIBS@
XSHM = @XSHM@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_LOCALE = @X_LOCALE@
pixmapdir = @pixmapdir@
wprefsdir = @wprefsdir@
AUTOMAKE_OPTIONS = no-dependencies
@@ -110,9 +102,7 @@ lib_LIBRARIES = libWINGs.a
include_HEADERS = WINGs.h WUtil.h WINGsP.h
bin_SCRIPTS = WINGs-flags
noinst_PROGRAMS = wtest wmquery wmfile fontl testmywidget
noinst_PROGRAMS = wtest wmquery wmfile fontl testmywidget testcolorpanel
testmywidget_SOURCES = testmywidget.c mywidget.c mywidget.h
@@ -132,6 +122,10 @@ wmfile_SOURCES = wmfile.c
wmfile_LDADD = libWINGs.a $(LIBLIST)
testcolorpanel_SOURCES = testcolorpanel.c
testcolorpanel_LDADD = libWINGs.a $(LIBLIST)
wmquery_SOURCES = wmquery.c
wmquery_LDADD = libWINGs.a $(LIBLIST)
@@ -151,6 +145,7 @@ libWINGs_a_SOURCES = \
wbrowser.c \
wbutton.c \
wcolor.c \
wcolorpanel.c \
wcolorwell.c \
wevent.c \
wfilepanel.c \
@@ -196,10 +191,11 @@ X_PRE_LIBS = @X_PRE_LIBS@
libWINGs_a_LIBADD =
libWINGs_a_OBJECTS = configuration.o international.o notification.o \
selection.o userdefaults.o wapplication.o wbrowser.o wbutton.o wcolor.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
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)
@@ -222,8 +218,11 @@ testmywidget_DEPENDENCIES = libWINGs.a \
$(top_builddir)/wrlib/libwraster.la \
$(top_builddir)/libPropList/libPropList.la
testmywidget_LDFLAGS =
SCRIPTS = $(bin_SCRIPTS)
testcolorpanel_OBJECTS = testcolorpanel.o
testcolorpanel_DEPENDENCIES = libWINGs.a \
$(top_builddir)/wrlib/libwraster.la \
$(top_builddir)/libPropList/libPropList.la
testcolorpanel_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
@@ -237,8 +236,8 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP = --best
SOURCES = $(libWINGs_a_SOURCES) $(wtest_SOURCES) $(wmquery_SOURCES) $(wmfile_SOURCES) $(fontl_SOURCES) $(testmywidget_SOURCES)
OBJECTS = $(libWINGs_a_OBJECTS) $(wtest_OBJECTS) $(wmquery_OBJECTS) $(wmfile_OBJECTS) $(fontl_OBJECTS) $(testmywidget_OBJECTS)
SOURCES = $(libWINGs_a_SOURCES) $(wtest_SOURCES) $(wmquery_SOURCES) $(wmfile_SOURCES) $(fontl_SOURCES) $(testmywidget_SOURCES) $(testcolorpanel_SOURCES)
OBJECTS = $(libWINGs_a_OBJECTS) $(wtest_OBJECTS) $(wmquery_OBJECTS) $(wmfile_OBJECTS) $(fontl_OBJECTS) $(testmywidget_OBJECTS) $(testcolorpanel_OBJECTS)
all: all-recursive all-am
@@ -356,24 +355,9 @@ testmywidget: $(testmywidget_OBJECTS) $(testmywidget_DEPENDENCIES)
@rm -f testmywidget
$(LINK) $(testmywidget_LDFLAGS) $(testmywidget_OBJECTS) $(testmywidget_LDADD) $(LIBS)
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_SCRIPTS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
$(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
else if test -f $(srcdir)/$$p; then \
echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
$(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
else :; fi; fi; \
done
uninstall-binSCRIPTS:
@$(NORMAL_UNINSTALL)
list='$(bin_SCRIPTS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
done
testcolorpanel: $(testcolorpanel_OBJECTS) $(testcolorpanel_DEPENDENCIES)
@rm -f testcolorpanel
$(LINK) $(testcolorpanel_LDFLAGS) $(testcolorpanel_OBJECTS) $(testcolorpanel_LDADD) $(LIBS)
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
@@ -479,13 +463,13 @@ dvi: dvi-recursive
check: all-am
$(MAKE) check-recursive
installcheck: installcheck-recursive
all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(SCRIPTS) $(HEADERS)
all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS)
install-exec-am: install-libLIBRARIES install-binSCRIPTS
install-exec-am: install-libLIBRARIES
install-data-am: install-includeHEADERS
uninstall-am: uninstall-libLIBRARIES uninstall-binSCRIPTS uninstall-includeHEADERS
uninstall-am: uninstall-libLIBRARIES uninstall-includeHEADERS
install-exec: install-exec-recursive install-exec-am
@$(NORMAL_INSTALL)
@@ -501,8 +485,7 @@ uninstall: uninstall-recursive uninstall-am
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs-recursive
$(mkinstalldirs) $(DATADIR)$(libdir) $(DATADIR)$(bindir) \
$(DATADIR)$(includedir)
$(mkinstalldirs) $(DATADIR)$(libdir) $(DATADIR)$(includedir)
mostlyclean-generic:
@@ -555,12 +538,11 @@ clean-compile maintainer-clean-compile mostlyclean-libtool \
distclean-libtool clean-libtool maintainer-clean-libtool \
mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \
clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \
uninstall-binSCRIPTS install-binSCRIPTS uninstall-includeHEADERS \
install-includeHEADERS install-data-recursive uninstall-data-recursive \
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
uninstalldirs-recursive all-recursive check-recursive \
installcheck-recursive info-recursive dvi-recursive \
mostlyclean-recursive distclean-recursive clean-recursive \
uninstall-includeHEADERS install-includeHEADERS install-data-recursive \
uninstall-data-recursive install-exec-recursive \
uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
all-recursive check-recursive installcheck-recursive info-recursive \
dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info dvi \
installcheck all-am install-exec-am install-data-am uninstall-am \

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -65,8 +65,6 @@ DFLAGS = @DFLAGS@
GFXFLAGS = @GFXFLAGS@
GFXLFLAGS = @GFXLFLAGS@
GFXLIBS = @GFXLIBS@
I18N = @I18N@
I18N_MB = @I18N_MB@
ICONEXT = @ICONEXT@
INTLIBS = @INTLIBS@
LD = @LD@
@@ -79,19 +77,13 @@ NLSDIR = @NLSDIR@
NM = @NM@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
REDUCE_APPICONS = @REDUCE_APPICONS@
SHAPE = @SHAPE@
SOUND = @SOUND@
VERSION = @VERSION@
WPMOFILES = @WPMOFILES@
XCFLAGS = @XCFLAGS@
XGETTEXT = @XGETTEXT@
XLFLAGS = @XLFLAGS@
XLIBS = @XLIBS@
XSHM = @XSHM@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_LOCALE = @X_LOCALE@
pixmapdir = @pixmapdir@
wprefsdir = @wprefsdir@
resdatadir = $(datadir)/WINGs

View File

@@ -113,7 +113,7 @@ typedef enum {
WALeft,
WACenter,
WARight,
WMJustified /* not valid for textfields */
WAJustified /* not valid for textfields */
} WMAlignment;
@@ -175,6 +175,17 @@ enum {
WMDownTextMovement
};
typedef enum {
WMGrayModeColorPanel,
WMRGBModeColorPanel,
WMCMYKModeColorPanel,
WMHSBModeColorPanel,
WMCustomPaletteModeColorPanel,
WMColorListModeColorPanel,
WMWheelModeColorPanel
} WMColorPanelMode;
/* system images */
#define WSIReturnArrow 1
@@ -282,6 +293,8 @@ typedef WMFilePanel WMSavePanel;
typedef struct W_FontPanel WMFontPanel;
typedef struct W_ColorPanel WMColorPanel;
/* item for WMList */
typedef struct WMListItem {
@@ -370,8 +383,18 @@ typedef WMWidget *WMMatrixCreateCellProc(WMMatrix *mPtr);
typedef void WMBrowserFillColumnProc(WMBrowser *bPtr, int column);
typedef Bool WMConvertSelectionProc(WMWidget *w, Atom selection, Atom target,
Atom *type, void **value, unsigned *length,
int *format);
typedef void WMLoseSelectionProc(WMWidget *w, Atom selection);
typedef void WMSelectionDoneProc(WMWidget *w, Atom selection, Atom target);
/* ....................................................................... */
void WMInitializeApplication(char *applicationName, int *argc, char **argv);
void WMSetApplicationDataPath(char *path);
@@ -889,6 +912,20 @@ void WMSetPopUpButtonEnabled(WMPopUpButton *bPtr, Bool flag);
/* ....................................................................... */
WMColorPanel *WMGetColorPanel(WMScreen *scrPtr);
void WMFreeColorPanel(WMColorPanel *panel);
int WMRunColorPanel(WMColorPanel *panel, WMWindow *owner, RColor color);
void WMSetColorPanelColor(WMColorPanel *panel, RColor color);
RColor WMGetColorPanelColor(WMColorPanel *panel);
void WMSetPickerMode(WMColorPanel *panel, WMColorPanelMode mode);
/* ....................................................................... */
WMColorWell *WMCreateColorWell(WMWidget *parent);
void WMSetColorWellColor(WMColorWell *cPtr, WMColor *color);

View File

@@ -177,7 +177,26 @@ typedef struct W_Screen {
struct W_Pixmap *checkMark;
struct W_Pixmap *homeIcon;
struct W_Pixmap *homeAltIcon;
struct W_Pixmap *magnifyIcon;
struct W_Pixmap *wheelIcon;
struct W_Pixmap *grayIcon;
struct W_Pixmap *rgbIcon;
struct W_Pixmap *cmykIcon;
struct W_Pixmap *hsbIcon;
struct W_Pixmap *customPaletteIcon;
struct W_Pixmap *colorListIcon;
struct W_Pixmap *magnifyAltIcon;
struct W_Pixmap *wheelAltIcon;
struct W_Pixmap *grayAltIcon;
struct W_Pixmap *rgbAltIcon;
struct W_Pixmap *cmykAltIcon;
struct W_Pixmap *hsbAltIcon;
struct W_Pixmap *customPaletteAltIcon;
struct W_Pixmap *colorListAltIcon;
struct W_Pixmap *defaultObjectIcon;
Cursor defaultCursor;
@@ -395,3 +414,5 @@ void W_RedisplayView(WMView *view);
Bool W_ApplicationInitialized(void);
char *W_GetTextSelection(WMScreen *scr, Atom selection);
void W_HandleSelectionEvent(XEvent *event);

View File

@@ -39,7 +39,8 @@
#ifdef NDEBUG
#define wassertr(expr, val) ((void)0)
#define wassertr(expr) {}
#define wassertrv(expr, val) {}
#else /* !NDEBUG */
@@ -118,6 +119,10 @@ typedef void WMNotificationObserverAction(void *observerData,
/*......................................................................*/
typedef void (waborthandler)(int);
waborthandler *wsetabort(waborthandler*);
void wfatal(const char *msg, ...);
void wwarning(const char *msg, ...);

View File

@@ -29,6 +29,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <signal.h>
#ifndef False
# define False 0
@@ -37,7 +38,33 @@
# define True 1
#endif
extern void wAbort(int);
static void
defaultHandler(int bla)
{
if (bla)
raise(SIGABRT);
else
exit(1);
}
static waborthandler *aborthandler = (waborthandler*)defaultHandler;
#define wAbort(a) (*aborthandler)(a)
waborthandler*
wsetabort(waborthandler *handler)
{
waborthandler *old = aborthandler;
aborthandler = handler;
return old;
}
static int Aborting=0; /* if we're in the middle of an emergency exit */

View File

@@ -6,196 +6,260 @@
#include "WINGsP.h"
#if 0
#define MAX_PROPERTY_SIZE 8*1024
typedef struct W_SelectionHandler {
typedef struct SelectionHandler {
WMWidget *widget;
Atom selection;
void *clientData;
WMSelectionProc *proc;
WMHandlerID timerID;
W_SelectionHandler *next;
W_SelectionHandler *prev;
} W_SelectionHandler;
#endif
Time timestamp;
WMConvertSelectionProc *convProc;
WMLoseSelectionProc *loseProc;
WMSelectionDoneProc *doneProc;
#define SELECTION_TIMEOUT 2000
#define MAX_PROPERTY_SIZE 10*1024
#if 0
struct {
unsigned delete_pending:1;
unsigned done_pending:1;
} flags;
struct SelectionHandler *next;
} SelectionHandler;
static SelectionHandler *selHandlers = NULL;
void
WMWriteSelectionToClipboard(WMSelection *selection)
WMDeleteSelectionHandler(WMWidget *widget, Atom selection)
{
}
SelectionHandler *handler, *tmp;
Display *dpy = WMWidgetScreen(widget)->display;
Window win = WMWidgetXID(widget);
Time timestamp;
if (!selHandlers)
return;
WMSelection*
WMCreateSelectionWithData(WMData *data, Atom type)
{
}
#endif
tmp = selHandlers;
#if 0
if (tmp->widget == widget) {
#define MAX_PROPERTY_SIZE 100*1024
static void
handleSelectionEvent(XEvent *event, void *data)
{
W_SelectionHandler *handler = (W_SelectionHandler*)data;
char *data = NULL;
Atom type;
int format, result;
unsigned long numItems, bytesAfter;
WMScreen *scr = WMWidgetScreen(handler->widget);
WMDeleteTimerHandler(handler->timerID);
if (handler->next)
handler->next->prev = handler->prev;
if (handler->prev)
handler->prev->next = handler->next;
if (handler == WMWidgetScreen(handler->widget)->selectionHandlerList)
WMWidgetScreen(handler->widget)->selectionHandlerList = handler->next;
if (event->xselection.property == None) {
char *name = XGetAtomName(event->xselection.display,
handler->selection);
char *form = XGetAtomName(event->xselection.display, handler->type);
wwarning("error retrieving selection %s with form %s\n", name, form);
if (name)
XFree(name);
if (form)
XFree(form);
free(handler);
return;
}
if (XGetWindowProperty(event->xselection.display,
event->xselection.requestor, handler->property,
0, MAX_PROPERTY_SIZE, False, AnyPropertyType,
&type, &format, &numItems, &bytesAfter,
&data) != Success || type == None) {
if (data)
XFree(data);
free(handler);
return;
}
if (bytesAfter!=0) {
wwarning("data in selection is too large");
if (data)
XFree(data);
free(handler);
return;
}
if (type == XA_STRING || type == scr->compoundTextAtom) {
if (format!=8) {
wwarning("string in selection has format %i, which is invalid",
format);
if (data)
XFree(data);
free(handler);
if (tmp->flags.done_pending) {
tmp->flags.delete_pending = 1;
return;
}
(*handler->proc)();
selHandlers = tmp->next;
timestamp = tmp->timestamp;
free(tmp);
} else {
while (tmp->next) {
if (tmp->next->widget == widget) {
if (tmp->next->flags.done_pending) {
tmp->next->flags.delete_pending = 1;
return;
}
handler = tmp->next;
tmp->next = handler->next;
timestamp = handler->timestamp;
free(handler);
break;
}
tmp = tmp->next;
}
}
XGrabServer(dpy);
if (XGetSelectionOwner(dpy, selection) == win) {
XSetSelectionOwner(dpy, selection, None, timestamp);
}
XUngrabServer(dpy);
}
static int gotError = 0;
/*
static int
errorHandler(XErrorEvent *error)
{
return 0;
}
*/
static Bool
writeSelection(Display *dpy, Window requestor, Atom property, Atom type,
void *value, long length, int format)
{
/*
printf("write to %x: %s\n", requestor, XGetAtomName(dpy, property));
*/
gotError = 0;
if (!XChangeProperty(dpy, requestor, property, type, format,
PropModeReplace, value, length))
return 0;
XFlush(dpy);
return !gotError;
}
static void
timeoutHandler(void *data)
notifySelection(XEvent *event, Atom prop)
{
W_SelectionHandler *handler = (W_SelectionHandler*)data;
wwarning("selection timed out");
WMDeleteEventHandler(WMWidgetView(handler->widget), SelectionNotifyMask,
handleSelectionEvent, data);
if (handler->next)
handler->next->prev = handler->prev;
if (handler->prev)
handler->prev->next = handler->next;
if (handler == WMWidgetScreen(handler->widget)->selectionHandlerList)
WMWidgetScreen(handler->widget)->selectionHandlerList = handler->next;
XEvent ev;
/*
printf("envent to %x\n", event->xselectionrequest.requestor);
*/
ev.xselection.type = SelectionNotify;
ev.xselection.serial = 0;
ev.xselection.send_event = True;
ev.xselection.display = event->xselectionrequest.display;
ev.xselection.requestor = event->xselectionrequest.requestor;
ev.xselection.target = event->xselectionrequest.target;
ev.xselection.property = prop;
ev.xselection.time = event->xselectionrequest.time;
XSendEvent(event->xany.display, event->xselectionrequest.requestor,
False, 0, &ev);
XFlush(event->xany.display);
}
void
WMGetSelection(WMWidget *widget, Atom selection, Atom type, Atom property,
WMSelectionProc *proc, void *clientData, Time time)
W_HandleSelectionEvent(XEvent *event)
{
WMScreen *scr = WMWidgetScreen(widget);
void *data;
Atom rtype;
int bits;
unsigned long len, bytes;
unsigned char *data;
int buffer = -1;
SelectionHandler *handler;
switch (selection) {
case XA_CUT_BUFFER0:
buffer = 0;
break;
case XA_CUT_BUFFER1:
buffer = 1;
break;
case XA_CUT_BUFFER2:
buffer = 2;
break;
case XA_CUT_BUFFER3:
buffer = 3;
break;
case XA_CUT_BUFFER4:
buffer = 4;
break;
case XA_CUT_BUFFER5:
buffer = 5;
break;
case XA_CUT_BUFFER6:
buffer = 6;
break;
case XA_CUT_BUFFER7:
buffer = 7;
break;
}
if (buffer >= 0) {
char *data;
int size;
data = XFetchBuffer(scr->display, &size, buffer);
} else {
W_SelectionHandler *handler;
XDeleteProperty(scr->display, WMWidgetXID(widget), selection);
XConvertSelection(scr->display, selection, type, property,
WMWidgetXID(widget), time);
handler = selHandlers;
handler = wmalloc(sizeof(W_SelectionHandler));
handler->widget = widget;
handler->selection = selection;
handler->type = type;
handler->property = property;
handler->clientData = clientData;
handler->proc = proc;
handler->timerID = WMAddTimerHandler(SELECTION_TIMEOUT,
timeoutHandler, handler);
while (handler) {
if (WMWidgetXID(handler->widget)==event->xany.window
/* && handler->selection == event->selection*/) {
handler->next = scr->selectionHandlerList;
handler->prev = NULL;
if (scr->selectionHandlerList)
scr->selectionHandlerList->prev = handler;
scr->selectionHandlerList = handler;
switch (event->type) {
case SelectionClear:
if (handler->loseProc)
(*handler->loseProc)(handler->widget, handler->selection);
break;
WMCreateEventHandler(WMWidgetView(widget), SelectionNotifyMask,
handleSelectionEvent, handler);
case SelectionRequest:
if (handler->convProc) {
Atom atom;
void *data;
unsigned length;
int format;
Atom prop;
/* they're requesting for something old */
if (event->xselectionrequest.time < handler->timestamp
&& event->xselectionrequest.time != CurrentTime) {
notifySelection(event, None);
break;
}
handler->flags.done_pending = 1;
if (!(*handler->convProc)(handler->widget,
handler->selection,
event->xselectionrequest.target,
&atom, &data, &length, &format)) {
notifySelection(event, None);
break;
}
prop = event->xselectionrequest.property;
/* obsolete clients that don't set the property field */
if (prop == None)
prop = event->xselectionrequest.target;
if (!writeSelection(event->xselectionrequest.display,
event->xselectionrequest.requestor,
prop, atom, data, length, format)) {
free(data);
notifySelection(event, None);
break;
}
free(data);
notifySelection(event, prop);
if (handler->doneProc) {
(*handler->doneProc)(handler->widget,
handler->selection,
event->xselectionrequest.target);
}
handler->flags.done_pending = 0;
/* in case the handler was deleted from some
* callback */
if (handler->flags.delete_pending) {
WMDeleteSelectionHandler(handler->widget,
handler->selection);
}
}
break;
case SelectionNotify:
break;
}
}
handler = handler->next;
}
}
#endif
Bool
WMCreateSelectionHandler(WMWidget *w, Atom selection, Time timestamp,
WMConvertSelectionProc *convProc,
WMLoseSelectionProc *loseProc,
WMSelectionDoneProc *doneProc)
{
SelectionHandler *handler, *tmp;
Display *dpy = WMWidgetScreen(w)->display;
XSetSelectionOwner(dpy, selection, WMWidgetXID(w), timestamp);
if (XGetSelectionOwner(dpy, selection) != WMWidgetXID(w))
return False;
handler = malloc(sizeof(SelectionHandler));
if (!handler)
return False;
handler->widget = w;
handler->selection = selection;
handler->timestamp = timestamp;
handler->convProc = convProc;
handler->loseProc = loseProc;
handler->doneProc = doneProc;
memset(&handler->flags, 0, sizeof(handler->flags));
if (!selHandlers) {
/* first in the queue */
handler->next = selHandlers;
selHandlers = handler;
} else {
tmp = selHandlers;
while (tmp->next) {
tmp = tmp->next;
}
handler->next = tmp->next;
tmp->next = handler;
}
return True;
}
@@ -270,7 +334,8 @@ W_GetTextSelection(WMScreen *scr, Atom selection)
return NULL;
}
/* nobody owns the selection */
/* nobody owns the selection or the current owner has
* nothing to do with what we need */
if (ev.xselection.property == None) {
return NULL;
}

53
WINGs/testcolorpanel.c Normal file
View File

@@ -0,0 +1,53 @@
/*
* Author: Pascal Hofstee <daeron@shadowmere.student.utwente.nl>
*/
#include "WINGs.h"
#include <unistd.h>
#include <stdio.h>
#include "logo.xpm"
void
wAbort()
{
exit(1);
}
char *ProgName;
int main(int argc, char **argv)
{
Display *dpy = XOpenDisplay("");
WMScreen *scr;
WMPixmap *pixmap;
WMColorPanel *panel;
RColor startcolor;
WMInitializeApplication("WMColorPicker", &argc, argv);
ProgName = argv[0];
if (!dpy) {
puts("could not open display");
exit(1);
}
scr = WMCreateSimpleApplicationScreen(dpy);
pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
WMSetApplicationIconImage(scr, pixmap); WMReleasePixmap(pixmap);
panel = WMGetColorPanel(scr);
startcolor.red = 0;
startcolor.green = 0;
startcolor.blue = 255;
WMRunColorPanel(panel, NULL, startcolor);
return 0;
}

View File

@@ -4,6 +4,9 @@
#include <stdio.h>
#include <assert.h>
#include "../src/config.h"
#include "WUtil.h"
#include <proplist.h>
@@ -168,7 +171,7 @@ WMGetStandardUserDefaults(void)
/* set to save changes in defaults when program is exited */
#if !defined(HAVE_ATEXIT) && defined(HAVE_ON_EXIT)
#ifndef HAVE_ATEXIT
on_exit(saveDefaultsChanges,0);
#else
atexit(saveDefaultsChanges);

View File

@@ -159,7 +159,7 @@ WMPathForResourceOfType(char *resource, char *ext)
return path;
}
appdir = wmalloc(strlen(WMApplication.applicationName)+8);
appdir = wmalloc(strlen(WMApplication.applicationName)+10);
sprintf(appdir, "Apps/%s.app", WMApplication.applicationName);
if (getenv("GNUSTEP_USER_ROOT")) {

2792
WINGs/wcolorpanel.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -16,18 +16,18 @@
#endif
#include <X11/Xos.h>
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#ifdef HAVE_GETTIMEOFDAY
# include <sys/time.h>
# ifdef TIME_WITH_SYS_TIME
# include <time.h>
# endif
#else /* ! HAVE_GETTIMEOFDAY */
# include <time.h>
#endif /* ! HAVE_GETTIMEOFDAY */
#include <time.h>
#ifndef X_GETTIMEOFDAY
#define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
#endif
extern _WINGsConfiguration WINGsConfiguration;
@@ -119,15 +119,10 @@ static WMEventHook *extraEventHandler=NULL;
#define idlePending() (idleHandler)
#ifdef HAVE_GETTIMEOFDAY
static void
rightNow(struct timeval *tv) {
gettimeofday(tv, NULL);
X_GETTIMEOFDAY(tv);
}
#else /* !HAVE_GETTIMEOFDAY */
# define rightNow(tv) (tv)->tv_sec==time(NULL),(tv)->tv_usec=0
#endif /* !HAVE_GETTIMEOFDAY */
/* is t1 after t2 ? */
#define IS_AFTER(t1, t2) (((t1).tv_sec > (t2).tv_sec) || \
@@ -591,6 +586,12 @@ WMHandleEvent(XEvent *event)
toplevel = W_TopLevelOfView(view);
if (event->type == SelectionNotify || event->type == SelectionClear
|| event->type == SelectionRequest) {
/* handle selection related events */
W_HandleSelectionEvent(event);
}
/* if it's a key event, redispatch it to the focused control */
if (mask & (KeyPressMask|KeyReleaseMask)) {
W_View *focused = W_FocusedViewOfToplevel(toplevel);
@@ -619,8 +620,8 @@ WMHandleEvent(XEvent *event)
while (XCheckTypedWindowEvent(event->xexpose.display, view->window,
Expose, event));
}
if (view->screen->modal && toplevel!=view->screen->modalView
&& !toplevel->flags.worksWhenModal) {
if (event->type == KeyPress || event->type == KeyRelease

View File

@@ -194,6 +194,7 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title)
WMResizeWidget(fPtr->homeButton, 28, 28);
WMSetButtonImagePosition(fPtr->homeButton, WIPImageOnly);
WMSetButtonImage(fPtr->homeButton, scrPtr->homeIcon);
WMSetButtonAltImage(fPtr->homeButton, scrPtr->homeAltIcon);
WMSetButtonAction(fPtr->homeButton, goHome, fPtr);
WMRealizeWidget(fPtr->win);
@@ -281,6 +282,9 @@ WMRunModalSavePanelForDirectory(WMFilePanel *panel, WMWindow *owner,
WMHandleEvent(&event);
}
/* Must withdraw window because the next time we map
* it, it might have a different transient owner.
*/
WMCloseWindow(panel->win);
return (panel->flags.canceled ? False : True);

View File

@@ -455,7 +455,158 @@ loadPixmaps(WMScreen *scr)
scr->depth);
}
RDestroyImage(tmp);
RDestroyImage(image);
/* Magnifying Glass Icon for ColorPanel */
tmp = RGetSubImage(image, 24, 0, 40, 32);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->magnifyIcon = NULL;
} else {
scr->magnifyIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 32, scr->depth);
}
RDestroyImage(tmp);
/* ColorWheel Icon for ColorPanel */
tmp = RGetSubImage(image, 0, 25, 24, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->wheelIcon = NULL;
} else {
scr->wheelIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 24, 24, scr->depth);
}
RDestroyImage(tmp);
/* GrayScale Icon for ColorPanel */
tmp = RGetSubImage(image, 65, 0, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->grayIcon = NULL;
} else {
scr->grayIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* RGB Icon for ColorPanel */
tmp = RGetSubImage(image, 25, 33, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->rgbIcon = NULL;
} else {
scr->rgbIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* CMYK Icon for ColorPanel */
tmp = RGetSubImage(image, 65, 25, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->cmykIcon = NULL;
} else {
scr->cmykIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* HSB Icon for ColorPanel */
tmp = RGetSubImage(image, 0, 57, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->hsbIcon = NULL;
} else {
scr->hsbIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* CustomColorPalette Icon for ColorPanel */
tmp = RGetSubImage(image, 81, 57, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->customPaletteIcon = NULL;
} else {
scr->customPaletteIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* ColorList Icon for ColorPanel */
tmp = RGetSubImage(image, 41, 57, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->colorListIcon = NULL;
} else {
scr->colorListIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
RDestroyImage(image);
image = RLoadImage(scr->rcontext, WINGS_IMAGES_FILE, 0);
if (!image) {
wwarning("WINGs: could not load widget images file: %s",
RMessageForError(RErrorCode));
return False;
}
/* make it have a white background */
gray.red = 0xff;
gray.green = 0xff;
gray.blue = 0xff;
RCombineImageWithColor(image, &gray);
tmp = RGetSubImage(image, 0, 0, 24, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->homeAltIcon = NULL;
} else {
scr->homeAltIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 24, 24,
scr->depth);
}
RDestroyImage(tmp);
/* Magnifying Glass Icon for ColorPanel */
tmp = RGetSubImage(image, 25, 0, 40, 32);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->magnifyAltIcon = NULL;
} else {
scr->magnifyAltIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 32, scr->depth);
}
RDestroyImage(tmp);
/* ColorWheel Icon for ColorPanel */
tmp = RGetSubImage(image, 0, 25, 24, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->wheelAltIcon = NULL;
} else {
scr->wheelAltIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 24, 24, scr->depth);
}
RDestroyImage(tmp);
/* GrayScale Icon for ColorPanel */
tmp = RGetSubImage(image, 65, 0, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->grayAltIcon = NULL;
} else {
scr->grayAltIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* RGB Icon for ColorPanel */
tmp = RGetSubImage(image, 25, 33, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->rgbAltIcon = NULL;
} else {
scr->rgbAltIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* CMYK Icon for ColorPanel */
tmp = RGetSubImage(image, 65, 25, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->cmykAltIcon = NULL;
} else {
scr->cmykAltIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* HSB Icon for ColorPanel */
tmp = RGetSubImage(image, 0, 57, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->hsbAltIcon = NULL;
} else {
scr->hsbAltIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* CustomColorPalette Icon for ColorPanel */
tmp = RGetSubImage(image, 81, 57, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->customPaletteAltIcon = NULL;
} else {
scr->customPaletteAltIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
/* ColorList Icon for ColorPanel */
tmp = RGetSubImage(image, 41, 57, 40, 24);
if (!RConvertImage(scr->rcontext, tmp, &pixmap)) {
scr->colorListAltIcon = NULL;
} else {
scr->colorListAltIcon = WMCreatePixmapFromXPixmaps(scr, pixmap, None, 40, 24, scr->depth);
}
RDestroyImage(tmp);
RDestroyImage(image);
#if 0
scr->defaultObjectIcon =

View File

@@ -752,15 +752,15 @@ handleActionEvents(XEvent *event, void *data)
if (event->xbutton.x > WMWidgetWidth(lPtr->vScroller)) {
tmp = getItemIndexAt(lPtr, event->xbutton.y);
if (tmp>=0) {
WMSelectListItem(lPtr, tmp);
lPtr->selectedItem = tmp;
}
lPtr->flags.buttonPressed = 1;
if (WMIsDoubleClick(event)) {
if (lPtr->doubleAction)
(*lPtr->doubleAction)(lPtr, lPtr->doubleClientData);
if (tmp >= 0) {
WMSelectListItem(lPtr, tmp);
if (tmp == lPtr->selectedItem && WMIsDoubleClick(event)) {
if (lPtr->doubleAction)
(*lPtr->doubleAction)(lPtr, lPtr->doubleClientData);
}
lPtr->selectedItem = tmp;
}
}
break;
@@ -793,6 +793,14 @@ resizeList(WMList *lPtr, unsigned int width, unsigned int height)
} else {
lPtr->flags.dontFitAll = 0;
}
if (lPtr->itemCount - lPtr->topItem <= lPtr->fullFitLines) {
lPtr->topItem = lPtr->itemCount - lPtr->fullFitLines;
if (lPtr->topItem < 0)
lPtr->topItem = 0;
}
updateScroller(lPtr);
}

View File

@@ -190,8 +190,8 @@ WMInsertPopUpButtonItem(WMPopUpButton *bPtr, int index, char *title)
while (--i > 0) {
tmp = tmp->nextPtr;
}
bPtr->items->nextPtr = tmp->nextPtr;
tmp->nextPtr = bPtr->items;
itemPtr->nextPtr = tmp->nextPtr;
tmp->nextPtr = itemPtr;
}
bPtr->itemCount++;

View File

@@ -37,6 +37,7 @@ typedef struct W_TextField {
short offsetWidth; /* offset of text from border */
WMRange selection;
WMRange prevselection;
#if 0
WMHandlerID timerID; /* for cursor blinking */
@@ -131,6 +132,7 @@ incrToFit(TextField *tPtr)
return vp!=tPtr->viewPosition;
}
static int
incrToFit2(TextField *tPtr)
{
@@ -248,6 +250,8 @@ WMInsertTextFieldText(WMTextField *tPtr, char *text, int position)
}
paintTextField(tPtr);
WMPostNotificationName(WMTextDidChangeNotification, tPtr, NULL);
}
@@ -281,6 +285,8 @@ WMDeleteTextFieldRange(WMTextField *tPtr, WMRange range)
}
paintTextField(tPtr);
WMPostNotificationName(WMTextDidChangeNotification, tPtr, NULL);
}
@@ -318,6 +324,8 @@ WMSetTextFieldText(WMTextField *tPtr, char *text)
if (tPtr->view->flags.realized)
paintTextField(tPtr);
WMPostNotificationName(WMTextDidChangeNotification, tPtr, NULL);
}
@@ -405,6 +413,8 @@ paintCursor(TextField *tPtr)
case WALeft:
cx += tPtr->offsetWidth;
break;
case WAJustified:
/* not supported */
case WACenter:
textWidth = WMWidthOfString(screen->normalFont, tPtr->text,
tPtr->textLen);
@@ -463,6 +473,7 @@ paintTextField(TextField *tPtr)
W_Screen *screen = tPtr->view->screen;
W_View *view = tPtr->view;
int tx, ty, tw, th;
int rx;
int bd;
int totalWidth;
@@ -519,7 +530,30 @@ paintTextField(TextField *tPtr)
screen->normalFont, tx, ty,
&(tPtr->text[tPtr->viewPosition]),
tPtr->textLen - tPtr->viewPosition);
if (tPtr->selection.count) {
int count;
count = tPtr->selection.count < 0
? tPtr->selection.position + tPtr->selection.count
: tPtr->selection.position;
rx = tx + WMWidthOfString(screen->normalFont,
&(tPtr->text[tPtr->viewPosition]),
count);
XSetBackground(screen->display, screen->textFieldGC,
screen->gray->color.pixel);
WMDrawImageString(screen, view->window, screen->textFieldGC,
screen->normalFont, rx, ty,
&(tPtr->text[count]),
abs(tPtr->selection.count));
XSetBackground(screen->display, screen->textFieldGC,
screen->white->color.pixel);
}
if (!tPtr->flags.enabled)
WMSetColorInGC(screen->black, screen->textFieldGC);
}
@@ -559,6 +593,7 @@ blinkCursor(void *data)
}
#endif
static void
handleEvents(XEvent *event, void *data)
{
@@ -599,7 +634,7 @@ handleEvents(XEvent *event, void *data)
(void*)WMIllegalTextMovement);
}
break;
case Expose:
if (event->xexpose.count!=0)
break;
@@ -632,6 +667,14 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
count = XLookupString(&event->xkey, buffer, 63, &ksym, NULL);
buffer[count] = '\0';
if (!event->xkey.state & ShiftMask) {
if (tPtr->selection.count)
refresh = 1;
tPtr->prevselection = tPtr->selection;
tPtr->selection.position = tPtr->cursorPosition;
tPtr->selection.count = 0;
}
switch (ksym) {
case XK_Tab:
if (event->xkey.state & ShiftMask) {
@@ -666,7 +709,16 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
case XK_Left:
if (tPtr->cursorPosition > 0) {
paintCursor(tPtr);
tPtr->cursorPosition--;
if (event->xkey.state & ControlMask) {
int i;
for (i = tPtr->cursorPosition - 1; i >= 0; i--)
if (tPtr->text[i] == ' ' || i == 0) {
tPtr->cursorPosition = i;
break;
}
} else {
tPtr->cursorPosition--;
}
if (tPtr->cursorPosition < tPtr->viewPosition) {
tPtr->viewPosition = tPtr->cursorPosition;
refresh = 1;
@@ -684,7 +736,16 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
case XK_Right:
if (tPtr->cursorPosition < tPtr->textLen) {
paintCursor(tPtr);
tPtr->cursorPosition++;
if (event->xkey.state & ControlMask) {
int i;
for (i = tPtr->cursorPosition + 1; i <= tPtr->textLen; i++)
if (tPtr->text[i] == ' ' || i == tPtr->textLen) {
tPtr->cursorPosition = i;
break;
}
} else {
tPtr->cursorPosition++;
}
while (WMWidthOfString(scr->normalFont,
&(tPtr->text[tPtr->viewPosition]),
tPtr->cursorPosition-tPtr->viewPosition)
@@ -728,7 +789,7 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
while (WMWidthOfString(scr->normalFont,
&(tPtr->text[tPtr->viewPosition]),
tPtr->textLen-tPtr->viewPosition)
>= tPtr->usableWidth) {
> tPtr->usableWidth) {
tPtr->viewPosition++;
refresh = 1;
}
@@ -743,10 +804,18 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
}
case XK_BackSpace:
if (tPtr->cursorPosition > 0) {
WMRange range;
changed = 1;
range.position = tPtr->cursorPosition-1;
range.count = 1;
WMRange range;
changed = 1;
if (tPtr->prevselection.count) {
range.position = tPtr->prevselection.count < 0
? tPtr->prevselection.position + tPtr->prevselection.count
: tPtr->prevselection.position;
range.count = abs(tPtr->prevselection.count);
} else {
range.position = tPtr->cursorPosition - 1;
range.count = 1;
}
WMDeleteTextFieldRange(tPtr, range);
}
break;
@@ -757,11 +826,19 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
}
case XK_KP_Delete:
case XK_Delete:
if (tPtr->cursorPosition < tPtr->textLen) {
WMRange range;
changed = 1;
range.position = tPtr->cursorPosition;
range.count = 1;
if (tPtr->cursorPosition < tPtr->textLen || tPtr->prevselection.count) {
WMRange range;
changed = 1;
if (tPtr->prevselection.count) {
range.position = tPtr->prevselection.count < 0
? tPtr->prevselection.position + tPtr->prevselection.count
: tPtr->prevselection.position;
range.count = abs(tPtr->prevselection.count);
} else {
range.position = tPtr->cursorPosition;
range.count = 1;
}
WMDeleteTextFieldRange(tPtr, range);
}
break;
@@ -769,10 +846,33 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
normal_key:
default:
if (count > 0 && !iscntrl(buffer[0])) {
WMRange range;
changed = 1;
if (tPtr->prevselection.count) {
range.position = tPtr->prevselection.count < 0
? tPtr->prevselection.position + tPtr->prevselection.count
: tPtr->prevselection.position;
range.count = abs(tPtr->prevselection.count);
} else {
range.position = tPtr->cursorPosition;
range.count = 1;
}
if (tPtr->prevselection.count)
WMDeleteTextFieldRange(tPtr, range);
WMInsertTextFieldText(tPtr, buffer, tPtr->cursorPosition);
} else {
return;
}
break;
}
if (event->xkey.state & ShiftMask) {
if (tPtr->selection.count == 0)
tPtr->selection.position = tPtr->cursorPosition;
tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position;
refresh = 1;
}
tPtr->prevselection.count = 0;
if (refresh) {
paintTextField(tPtr);
}
@@ -826,15 +926,24 @@ handleTextFieldActionEvents(XEvent *event, void *data)
if (tPtr->flags.enabled)
handleTextFieldKeyPress(tPtr, event);
break;
case MotionNotify:
if (tPtr->flags.enabled && (event->xmotion.state & Button1Mask)) {
if (!tPtr->selection.count) {
tPtr->selection.position = tPtr->cursorPosition;
}
tPtr->cursorPosition = pointToCursorPosition(tPtr,
event->xmotion.x);
tPtr->selection.count = tPtr->cursorPosition
- tPtr->selection.position;
paintTextField(tPtr);
}
break;
case ButtonPress:
if (tPtr->flags.enabled && !tPtr->flags.focused) {
WMSetFocusToWidget(tPtr);
@@ -844,12 +953,14 @@ handleTextFieldActionEvents(XEvent *event, void *data)
} else if (tPtr->flags.focused) {
tPtr->cursorPosition = pointToCursorPosition(tPtr,
event->xbutton.x);
tPtr->selection.count = 0;
paintTextField(tPtr);
}
if (event->xbutton.button == Button2 && tPtr->flags.enabled) {
char *text;
text = W_GetTextSelection(tPtr->view->screen, XA_PRIMARY);
text = W_GetTextSelection(tPtr->view->screen,
tPtr->view->screen->clipboardAtom);
if (!text) {
text = W_GetTextSelection(tPtr->view->screen, XA_CUT_BUFFER0);
}
@@ -861,9 +972,9 @@ handleTextFieldActionEvents(XEvent *event, void *data)
}
}
break;
case ButtonRelease:
break;
}
}

View File

@@ -431,15 +431,6 @@ realizeWindow(WMWindow *win)
}
void
WMHideWindow(WMWindow *win)
{
WMUnmapWidget(win);
XWithdrawWindow(win->view->screen->display, win->view->window,
win->view->screen->screen);
}
void
WMSetWindowMinSize(WMWindow *win, unsigned width, unsigned height)
{
@@ -564,6 +555,7 @@ WMSetWindowMiniwindowTitle(WMWindow *win, char *title)
void
WMCloseWindow(WMWindow *win)
{
WMUnmapWidget(win);
/* withdraw the window */
if (win->view->flags.realized)
XWithdrawWindow(win->view->screen->display, win->view->window,
@@ -588,6 +580,9 @@ handleEvents(XEvent *event, void *clientData)
}
}
break;
case UnmapNotify:
WMUnmapWidget(win);
break;
case DestroyNotify:
destroyWindow(win);
break;