mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-21 13:28:05 +01:00
misc selection and textfield fixes
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
Changes since wmaker 0.80.0:
|
||||
............................
|
||||
|
||||
- fixed a bug in wfindfile() (rewrote wfindfile() with better logic).
|
||||
|
||||
|
||||
Changes since wmaker 0.70.0:
|
||||
............................
|
||||
|
||||
|
||||
@@ -160,6 +160,27 @@ wexpandpath(char *path)
|
||||
}
|
||||
|
||||
|
||||
/* return address of next char != tok or end of string whichever comes first */
|
||||
static char*
|
||||
skipchar(char *string, char tok)
|
||||
{
|
||||
while(*string!=0 && *string==tok)
|
||||
string++;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/* return address of next char == tok or end of string whichever comes first */
|
||||
static char*
|
||||
nextchar(char *string, char tok)
|
||||
{
|
||||
while(*string!=0 && *string!=tok)
|
||||
string++;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
@@ -180,15 +201,14 @@ char*
|
||||
wfindfile(char *paths, char *file)
|
||||
{
|
||||
char *path;
|
||||
char *tmp;
|
||||
int done;
|
||||
char *tmp, *tmp2;
|
||||
int len, flen;
|
||||
char *fullpath;
|
||||
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
if (*file=='/' || *file=='~' || *file=='$' || !paths) {
|
||||
if (*file=='/' || *file=='~' || *file=='$' || !paths || *paths==0) {
|
||||
if (access(file, F_OK)<0) {
|
||||
fullpath = wexpandpath(file);
|
||||
if (!fullpath)
|
||||
@@ -207,13 +227,16 @@ wfindfile(char *paths, char *file)
|
||||
|
||||
flen = strlen(file);
|
||||
tmp = paths;
|
||||
done = 0;
|
||||
while (!done) {
|
||||
len = strcspn(tmp, ":");
|
||||
if (len==0) done=1;
|
||||
while (*tmp) {
|
||||
tmp = skipchar(tmp, ':');
|
||||
if (*tmp==0)
|
||||
break;
|
||||
tmp2 = nextchar(tmp, ':');
|
||||
len = tmp2 - tmp;
|
||||
path = wmalloc(len+flen+2);
|
||||
path = memcpy(path, tmp, len);
|
||||
path[len]=0;
|
||||
if (path[len-1] != '/')
|
||||
strcat(path, "/");
|
||||
strcat(path, file);
|
||||
fullpath = wexpandpath(path);
|
||||
@@ -224,9 +247,9 @@ wfindfile(char *paths, char *file)
|
||||
}
|
||||
wfree(fullpath);
|
||||
}
|
||||
tmp=&(tmp[len+1]);
|
||||
if (*tmp==0) break;
|
||||
tmp = tmp2;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,14 @@ typedef struct SelectionCallback {
|
||||
} SelectionCallback;
|
||||
|
||||
|
||||
WMArray *selCallbacks = NULL;
|
||||
|
||||
WMArray *selHandlers = NULL;
|
||||
static WMArray *selCallbacks = NULL;
|
||||
|
||||
static WMArray *selHandlers = NULL;
|
||||
|
||||
static Bool gotXError = False;
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
@@ -54,6 +59,7 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp)
|
||||
if (!selHandlers)
|
||||
return;
|
||||
|
||||
//printf("deleting selection handler for %d\n", win);
|
||||
|
||||
WM_ITERATE_ARRAY(selHandlers, handler, iter) {
|
||||
if (handler->view == view
|
||||
@@ -64,6 +70,7 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp)
|
||||
handler->flags.delete_pending = 1;
|
||||
return;
|
||||
}
|
||||
//puts("found & removed");
|
||||
WMRemoveFromArray(selHandlers, handler);
|
||||
break;
|
||||
}
|
||||
@@ -103,20 +110,20 @@ WMDeleteSelectionCallback(WMView *view, Atom selection, Time timestamp)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Bool gotError = 0;
|
||||
/*
|
||||
static int
|
||||
errorHandler(XErrorEvent *error)
|
||||
handleXError(Display *dpy, XErrorEvent *ev)
|
||||
{
|
||||
return 0;
|
||||
gotXError = True;
|
||||
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
static Bool
|
||||
writeSelection(Display *dpy, Window requestor, Atom property, Atom type,
|
||||
WMData *data)
|
||||
{
|
||||
static void *oldHandler;
|
||||
int format, bpi;
|
||||
|
||||
format = WMGetDataFormat(data);
|
||||
@@ -127,23 +134,18 @@ writeSelection(Display *dpy, Window requestor, Atom property, Atom type,
|
||||
|
||||
/* printf("write to %x: %s\n", requestor, XGetAtomName(dpy, property)); */
|
||||
|
||||
gotError = False;
|
||||
oldHandler = XSetErrorHandler(handleXError);
|
||||
|
||||
#ifndef __sgi
|
||||
if (!XChangeProperty(dpy, requestor, property, type, format,
|
||||
PropModeReplace, WMDataBytes(data),
|
||||
WMGetDataLength(data)/bpi))
|
||||
return False;
|
||||
#else
|
||||
/* in sgi seems this seems to return void */
|
||||
XChangeProperty(dpy, requestor, property, type, format,
|
||||
PropModeReplace, WMDataBytes(data),
|
||||
WMGetDataLength(data)/bpi);
|
||||
#endif
|
||||
gotXError = False;
|
||||
|
||||
XChangeProperty(dpy, requestor, property, type, format, PropModeReplace,
|
||||
WMDataBytes(data), WMGetDataLength(data)/bpi);
|
||||
|
||||
XFlush(dpy);
|
||||
|
||||
return !gotError;
|
||||
XSetErrorHandler(oldHandler);
|
||||
|
||||
return !gotXError;
|
||||
}
|
||||
|
||||
|
||||
@@ -341,6 +343,7 @@ handleNotifyEvent(XEvent *event)
|
||||
void
|
||||
W_HandleSelectionEvent(XEvent *event)
|
||||
{
|
||||
//printf("%d received %d\n", event->xany.window, event->type);
|
||||
if (event->type == SelectionNotify) {
|
||||
handleNotifyEvent(event);
|
||||
} else {
|
||||
@@ -359,9 +362,11 @@ WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp,
|
||||
Display *dpy = W_VIEW_SCREEN(view)->display;
|
||||
|
||||
XSetSelectionOwner(dpy, selection, W_VIEW_DRAWABLE(view), timestamp);
|
||||
if (XGetSelectionOwner(dpy, selection) != W_VIEW_DRAWABLE(view))
|
||||
if (XGetSelectionOwner(dpy, selection) != W_VIEW_DRAWABLE(view)) {
|
||||
return False;
|
||||
}
|
||||
|
||||
//printf("created selection handler for %d\n", W_VIEW_DRAWABLE(view));
|
||||
handler = malloc(sizeof(SelectionHandler));
|
||||
if (handler == NULL)
|
||||
return False;
|
||||
|
||||
@@ -285,6 +285,7 @@ lostHandler(WMView *view, Atom selection, void *cdata)
|
||||
{
|
||||
TextField *tPtr = (WMTextField*)view->self;
|
||||
|
||||
//WMDeleteSelectionHandler(view, XA_PRIMARY, CurrentTime);
|
||||
tPtr->flags.ownsSelection = 0;
|
||||
tPtr->selection.count = 0;
|
||||
paintTextField(tPtr);
|
||||
@@ -1447,16 +1448,6 @@ handleTextFieldActionEvents(XEvent *event, void *data)
|
||||
|
||||
tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position;
|
||||
|
||||
if (tPtr->selection.count != 0) {
|
||||
if (!tPtr->flags.ownsSelection) {
|
||||
WMCreateSelectionHandler(tPtr->view,
|
||||
XA_PRIMARY,
|
||||
event->xbutton.time,
|
||||
&selectionHandler, NULL);
|
||||
tPtr->flags.ownsSelection = 1;
|
||||
}
|
||||
}
|
||||
|
||||
paintCursor(tPtr);
|
||||
paintTextField(tPtr);
|
||||
|
||||
@@ -1482,7 +1473,8 @@ handleTextFieldActionEvents(XEvent *event, void *data)
|
||||
textWidth = WMWidthOfString(tPtr->font, tPtr->text, tPtr->textLen);
|
||||
if (tPtr->flags.enabled && !tPtr->flags.focused) {
|
||||
WMSetFocusToWidget(tPtr);
|
||||
} else if (tPtr->flags.focused) {
|
||||
}
|
||||
if (tPtr->flags.focused) {
|
||||
tPtr->selection.position = tPtr->cursorPosition;
|
||||
tPtr->selection.count = 0;
|
||||
}
|
||||
@@ -1499,11 +1491,8 @@ handleTextFieldActionEvents(XEvent *event, void *data)
|
||||
case WALeft:
|
||||
if (tPtr->flags.enabled && !tPtr->flags.focused) {
|
||||
WMSetFocusToWidget(tPtr);
|
||||
tPtr->cursorPosition = pointToCursorPosition(tPtr,
|
||||
event->xbutton.x);
|
||||
paintTextField(tPtr);
|
||||
} else if (tPtr->flags.focused
|
||||
&& event->xbutton.button == Button1) {
|
||||
}
|
||||
if (tPtr->flags.focused && event->xbutton.button == Button1) {
|
||||
tPtr->cursorPosition = pointToCursorPosition(tPtr,
|
||||
event->xbutton.x);
|
||||
tPtr->selection.position = tPtr->cursorPosition;
|
||||
@@ -1574,10 +1563,20 @@ handleTextFieldActionEvents(XEvent *event, void *data)
|
||||
event->xbutton.time,
|
||||
&selectionHandler, NULL);
|
||||
tPtr->flags.ownsSelection = 1;
|
||||
}
|
||||
|
||||
//puts("lost ownership");
|
||||
WMPostNotificationName("_lostOwnership", NULL, tPtr);
|
||||
}
|
||||
} else if (!tPtr->flags.secure && tPtr->selection.count!=0 &&
|
||||
!tPtr->flags.ownsSelection) {
|
||||
WMCreateSelectionHandler(tPtr->view,
|
||||
XA_PRIMARY,
|
||||
event->xbutton.time,
|
||||
&selectionHandler, NULL);
|
||||
tPtr->flags.ownsSelection = 1;
|
||||
//puts("lost ownership");
|
||||
WMPostNotificationName("_lostOwnership", NULL, tPtr);
|
||||
}
|
||||
|
||||
lastButtonReleasedEvent = event->xbutton.time;
|
||||
|
||||
break;
|
||||
@@ -1602,3 +1601,5 @@ destroyTextField(TextField *tPtr)
|
||||
|
||||
wfree(tPtr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ AC_INIT(src/WindowMaker.h)
|
||||
|
||||
|
||||
|
||||
AM_INIT_AUTOMAKE(WindowMaker, 0.80.0)
|
||||
AM_INIT_AUTOMAKE(WindowMaker, 0.80.1)
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
@@ -244,7 +244,7 @@ dnl ==================
|
||||
|
||||
dnl List of supported locales
|
||||
dnl -------------------------
|
||||
supported_locales="bg cs da de el es et fi fr gl hr hu it ja ko nl no pl pt ro ru sk sv tr zh_CN zh_TW.Big5"
|
||||
supported_locales="bg cs da de el es et fi fr gl hr hu it ja ko ms nl no pl pt ro ru sk sv tr zh_CN zh_TW.Big5"
|
||||
supported_wprefs_locales="bg cs de es et fi fr hr hu it ja ko pt ru sk zh_CN zh_TW.Big5"
|
||||
supported_wings_locales="cs de sk"
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ AC_INIT(src/WindowMaker.h)
|
||||
|
||||
|
||||
|
||||
AM_INIT_AUTOMAKE(WindowMaker, 0.80.0)
|
||||
AM_INIT_AUTOMAKE(WindowMaker, 0.80.1)
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
@@ -244,7 +244,7 @@ dnl ==================
|
||||
|
||||
dnl List of supported locales
|
||||
dnl -------------------------
|
||||
supported_locales="bg cs da de el es et fi fr gl hr hu it ja ko nl no pl pt ro ru sk sv tr zh_CN zh_TW.Big5"
|
||||
supported_locales="bg cs da de el es et fi fr gl hr hu it ja ko ms nl no pl pt ro ru sk sv tr zh_CN zh_TW.Big5"
|
||||
supported_wprefs_locales="bg cs de es et fi fr hr hu it ja ko pt ru sk zh_CN zh_TW.Big5"
|
||||
supported_wings_locales="cs de sk"
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@ CATALOGS = @MOFILES@
|
||||
|
||||
CLEANFILES = $(CATALOGS) WindowMaker.pot
|
||||
|
||||
EXTRA_DIST = cs.po de.po es.po et.po fr.po gl.po ja.po ko.po nl.po pt.po \
|
||||
sv.po it.po no.po ru.po tr.po fi.po hr.po el.po pl.po ro.po zh_TW.Big5.po\
|
||||
zh_CN.po sk.po da.po bg.po hu.po ms.po
|
||||
# keep this sorted
|
||||
EXTRA_DIST = bg.po cs.po da.po de.po el.po es.po et.po fi.po fr.po gl.po \
|
||||
hr.po hu.po it.po ja.po ko.po ms.po nl.po no.po pl.po pt.po ro.po \
|
||||
ru.po sk.po sv.po tr.po zh_CN.po zh_TW.Big5.po
|
||||
|
||||
POTFILES = \
|
||||
$(top_builddir)/src/appicon.c \
|
||||
|
||||
@@ -290,7 +290,7 @@ Bool copyAllFiles(char *gsdir)
|
||||
FILE *f;
|
||||
char path[2048];
|
||||
char file[256];
|
||||
char target[256];
|
||||
char target[2048];
|
||||
|
||||
/* copy misc data files */
|
||||
|
||||
@@ -298,7 +298,7 @@ Bool copyAllFiles(char *gsdir)
|
||||
|
||||
f = fopen(path, "r");
|
||||
while (!feof(f)) {
|
||||
if (!fgets(path, 255, f)) {
|
||||
if (!fgets(file, 255, f)) {
|
||||
break;
|
||||
}
|
||||
sprintf(path, "%s/%s", DATADIR, file);
|
||||
|
||||
Reference in New Issue
Block a user