1
0
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:
dan
2002-01-02 17:45:40 +00:00
parent 7b00d9ec12
commit 365556b676
8 changed files with 113 additions and 77 deletions

View File

@@ -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: Changes since wmaker 0.70.0:
............................ ............................

View File

@@ -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) wfindfile(char *paths, char *file)
{ {
char *path; char *path;
char *tmp; char *tmp, *tmp2;
int done;
int len, flen; int len, flen;
char *fullpath; char *fullpath;
if (!file) if (!file)
return NULL; return NULL;
if (*file=='/' || *file=='~' || *file=='$' || !paths) { if (*file=='/' || *file=='~' || *file=='$' || !paths || *paths==0) {
if (access(file, F_OK)<0) { if (access(file, F_OK)<0) {
fullpath = wexpandpath(file); fullpath = wexpandpath(file);
if (!fullpath) if (!fullpath)
@@ -207,26 +227,29 @@ wfindfile(char *paths, char *file)
flen = strlen(file); flen = strlen(file);
tmp = paths; tmp = paths;
done = 0; while (*tmp) {
while (!done) { tmp = skipchar(tmp, ':');
len = strcspn(tmp, ":"); if (*tmp==0)
if (len==0) done=1; break;
path = wmalloc(len+flen+2); tmp2 = nextchar(tmp, ':');
path = memcpy(path, tmp, len); len = tmp2 - tmp;
path[len]=0; path = wmalloc(len+flen+2);
strcat(path, "/"); path = memcpy(path, tmp, len);
strcat(path, file); path[len]=0;
fullpath = wexpandpath(path); if (path[len-1] != '/')
wfree(path); strcat(path, "/");
if (fullpath) { strcat(path, file);
if (access(fullpath, F_OK)==0) { fullpath = wexpandpath(path);
return fullpath; wfree(path);
} if (fullpath) {
wfree(fullpath); if (access(fullpath, F_OK)==0) {
} return fullpath;
tmp=&(tmp[len+1]); }
if (*tmp==0) break; wfree(fullpath);
}
tmp = tmp2;
} }
return NULL; return NULL;
} }

View File

@@ -38,9 +38,14 @@ typedef struct SelectionCallback {
} SelectionCallback; } SelectionCallback;
WMArray *selCallbacks = NULL;
WMArray *selHandlers = NULL; static WMArray *selCallbacks = NULL;
static WMArray *selHandlers = NULL;
static Bool gotXError = False;
void void
@@ -54,6 +59,7 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp)
if (!selHandlers) if (!selHandlers)
return; return;
//printf("deleting selection handler for %d\n", win);
WM_ITERATE_ARRAY(selHandlers, handler, iter) { WM_ITERATE_ARRAY(selHandlers, handler, iter) {
if (handler->view == view if (handler->view == view
@@ -64,7 +70,8 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp)
handler->flags.delete_pending = 1; handler->flags.delete_pending = 1;
return; return;
} }
WMRemoveFromArray(selHandlers, handler); //puts("found & removed");
WMRemoveFromArray(selHandlers, handler);
break; break;
} }
} }
@@ -103,20 +110,20 @@ WMDeleteSelectionCallback(WMView *view, Atom selection, Time timestamp)
} }
static Bool gotError = 0;
/*
static int static int
errorHandler(XErrorEvent *error) handleXError(Display *dpy, XErrorEvent *ev)
{ {
return 0; gotXError = True;
return 1;
} }
*/
static Bool static Bool
writeSelection(Display *dpy, Window requestor, Atom property, Atom type, writeSelection(Display *dpy, Window requestor, Atom property, Atom type,
WMData *data) WMData *data)
{ {
static void *oldHandler;
int format, bpi; int format, bpi;
format = WMGetDataFormat(data); 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)); */ /* printf("write to %x: %s\n", requestor, XGetAtomName(dpy, property)); */
gotError = False; oldHandler = XSetErrorHandler(handleXError);
#ifndef __sgi gotXError = False;
if (!XChangeProperty(dpy, requestor, property, type, format,
PropModeReplace, WMDataBytes(data), XChangeProperty(dpy, requestor, property, type, format, PropModeReplace,
WMGetDataLength(data)/bpi)) 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
XFlush(dpy); XFlush(dpy);
return !gotError; XSetErrorHandler(oldHandler);
return !gotXError;
} }
@@ -341,6 +343,7 @@ handleNotifyEvent(XEvent *event)
void void
W_HandleSelectionEvent(XEvent *event) W_HandleSelectionEvent(XEvent *event)
{ {
//printf("%d received %d\n", event->xany.window, event->type);
if (event->type == SelectionNotify) { if (event->type == SelectionNotify) {
handleNotifyEvent(event); handleNotifyEvent(event);
} else { } else {
@@ -359,9 +362,11 @@ WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp,
Display *dpy = W_VIEW_SCREEN(view)->display; Display *dpy = W_VIEW_SCREEN(view)->display;
XSetSelectionOwner(dpy, selection, W_VIEW_DRAWABLE(view), timestamp); 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; return False;
}
//printf("created selection handler for %d\n", W_VIEW_DRAWABLE(view));
handler = malloc(sizeof(SelectionHandler)); handler = malloc(sizeof(SelectionHandler));
if (handler == NULL) if (handler == NULL)
return False; return False;

View File

@@ -285,6 +285,7 @@ lostHandler(WMView *view, Atom selection, void *cdata)
{ {
TextField *tPtr = (WMTextField*)view->self; TextField *tPtr = (WMTextField*)view->self;
//WMDeleteSelectionHandler(view, XA_PRIMARY, CurrentTime);
tPtr->flags.ownsSelection = 0; tPtr->flags.ownsSelection = 0;
tPtr->selection.count = 0; tPtr->selection.count = 0;
paintTextField(tPtr); paintTextField(tPtr);
@@ -1447,16 +1448,6 @@ handleTextFieldActionEvents(XEvent *event, void *data)
tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position; 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); paintCursor(tPtr);
paintTextField(tPtr); paintTextField(tPtr);
@@ -1482,7 +1473,8 @@ handleTextFieldActionEvents(XEvent *event, void *data)
textWidth = WMWidthOfString(tPtr->font, tPtr->text, tPtr->textLen); textWidth = WMWidthOfString(tPtr->font, tPtr->text, tPtr->textLen);
if (tPtr->flags.enabled && !tPtr->flags.focused) { if (tPtr->flags.enabled && !tPtr->flags.focused) {
WMSetFocusToWidget(tPtr); WMSetFocusToWidget(tPtr);
} else if (tPtr->flags.focused) { }
if (tPtr->flags.focused) {
tPtr->selection.position = tPtr->cursorPosition; tPtr->selection.position = tPtr->cursorPosition;
tPtr->selection.count = 0; tPtr->selection.count = 0;
} }
@@ -1499,11 +1491,8 @@ handleTextFieldActionEvents(XEvent *event, void *data)
case WALeft: case WALeft:
if (tPtr->flags.enabled && !tPtr->flags.focused) { if (tPtr->flags.enabled && !tPtr->flags.focused) {
WMSetFocusToWidget(tPtr); WMSetFocusToWidget(tPtr);
tPtr->cursorPosition = pointToCursorPosition(tPtr, }
event->xbutton.x); if (tPtr->flags.focused && event->xbutton.button == Button1) {
paintTextField(tPtr);
} else if (tPtr->flags.focused
&& event->xbutton.button == Button1) {
tPtr->cursorPosition = pointToCursorPosition(tPtr, tPtr->cursorPosition = pointToCursorPosition(tPtr,
event->xbutton.x); event->xbutton.x);
tPtr->selection.position = tPtr->cursorPosition; tPtr->selection.position = tPtr->cursorPosition;
@@ -1574,10 +1563,20 @@ handleTextFieldActionEvents(XEvent *event, void *data)
event->xbutton.time, event->xbutton.time,
&selectionHandler, NULL); &selectionHandler, NULL);
tPtr->flags.ownsSelection = 1; 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);
}
WMPostNotificationName("_lostOwnership", NULL, tPtr);
}
lastButtonReleasedEvent = event->xbutton.time; lastButtonReleasedEvent = event->xbutton.time;
break; break;
@@ -1602,3 +1601,5 @@ destroyTextField(TextField *tPtr)
wfree(tPtr); wfree(tPtr);
} }

View File

@@ -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 AM_PROG_LIBTOOL
@@ -244,7 +244,7 @@ dnl ==================
dnl List of supported locales dnl List of supported locales
dnl ------------------------- 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_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" supported_wings_locales="cs de sk"

View File

@@ -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 AM_PROG_LIBTOOL
@@ -244,7 +244,7 @@ dnl ==================
dnl List of supported locales dnl List of supported locales
dnl ------------------------- 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_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" supported_wings_locales="cs de sk"

View File

@@ -4,9 +4,10 @@ CATALOGS = @MOFILES@
CLEANFILES = $(CATALOGS) WindowMaker.pot 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 \ # keep this sorted
sv.po it.po no.po ru.po tr.po fi.po hr.po el.po pl.po ro.po zh_TW.Big5.po\ EXTRA_DIST = bg.po cs.po da.po de.po el.po es.po et.po fi.po fr.po gl.po \
zh_CN.po sk.po da.po bg.po hu.po ms.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 = \ POTFILES = \
$(top_builddir)/src/appicon.c \ $(top_builddir)/src/appicon.c \

View File

@@ -290,7 +290,7 @@ Bool copyAllFiles(char *gsdir)
FILE *f; FILE *f;
char path[2048]; char path[2048];
char file[256]; char file[256];
char target[256]; char target[2048];
/* copy misc data files */ /* copy misc data files */
@@ -298,7 +298,7 @@ Bool copyAllFiles(char *gsdir)
f = fopen(path, "r"); f = fopen(path, "r");
while (!feof(f)) { while (!feof(f)) {
if (!fgets(path, 255, f)) { if (!fgets(file, 255, f)) {
break; break;
} }
sprintf(path, "%s/%s", DATADIR, file); sprintf(path, "%s/%s", DATADIR, file);