mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
- Added WMSetWindowUserPosition()
- Replaced FlattenStringList() and TokenizeString() with wtokenjoin() respective wtokensplit() from WINGs
This commit is contained in:
@@ -10,13 +10,14 @@ changes since wmaker 0.62.1:
|
|||||||
- added WMReparentWidget()
|
- added WMReparentWidget()
|
||||||
- added WMCreateTabViewItem()
|
- added WMCreateTabViewItem()
|
||||||
- added W_CreateUnmanagedTopView()
|
- added W_CreateUnmanagedTopView()
|
||||||
- added wtokenize()
|
- added wtokenjoin(), wtokensplit(), wtokenfree(), wtrimspace()
|
||||||
- added WMWidgetIsMapped()
|
- added WMWidgetIsMapped()
|
||||||
- added WMSetApplicationIconWindow()
|
- added WMSetApplicationIconWindow()
|
||||||
- restructured the directory tree. Added Documentation, Examples and Tests
|
- restructured the directory tree. Added Documentation, Examples and Tests
|
||||||
subdirectories
|
subdirectories
|
||||||
- removed WMArrayBag and reorganized WMTreeBag to be WMBag.
|
- removed WMArrayBag and reorganized WMTreeBag to be WMBag.
|
||||||
- added WMArray class.
|
- added WMArray class.
|
||||||
|
- added WMSetWindowUserPosition()
|
||||||
|
|
||||||
|
|
||||||
changes since wmaker 0.62.0:
|
changes since wmaker 0.62.0:
|
||||||
|
|||||||
@@ -880,6 +880,8 @@ void WMSetWindowCloseAction(WMWindow *win, WMAction *action, void *clientData);
|
|||||||
|
|
||||||
void WMSetWindowInitialPosition(WMWindow *win, int x, int y);
|
void WMSetWindowInitialPosition(WMWindow *win, int x, int y);
|
||||||
|
|
||||||
|
void WMSetWindowUserPosition(WMWindow *win, int x, int y);
|
||||||
|
|
||||||
void WMSetWindowAspectRatio(WMWindow *win, int minX, int minY,
|
void WMSetWindowAspectRatio(WMWindow *win, int minX, int minY,
|
||||||
int maxX, int maxY);
|
int maxX, int maxY);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ typedef struct W_Window {
|
|||||||
WMPoint maxAspect;
|
WMPoint maxAspect;
|
||||||
|
|
||||||
WMPoint upos;
|
WMPoint upos;
|
||||||
|
WMPoint ppos;
|
||||||
|
|
||||||
WMAction *closeAction;
|
WMAction *closeAction;
|
||||||
void *closeData;
|
void *closeData;
|
||||||
@@ -40,7 +41,8 @@ typedef struct W_Window {
|
|||||||
unsigned configured:1;
|
unsigned configured:1;
|
||||||
unsigned documentEdited:1;
|
unsigned documentEdited:1;
|
||||||
|
|
||||||
unsigned setPPos:1;
|
unsigned setUPos:1;
|
||||||
|
unsigned setPPos:1;
|
||||||
unsigned setAspect:1;
|
unsigned setAspect:1;
|
||||||
} flags;
|
} flags;
|
||||||
} _Window;
|
} _Window;
|
||||||
@@ -314,6 +316,11 @@ setSizeHints(WMWindow *win)
|
|||||||
|
|
||||||
if (win->flags.setPPos) {
|
if (win->flags.setPPos) {
|
||||||
hints->flags |= PPosition;
|
hints->flags |= PPosition;
|
||||||
|
hints->x = win->ppos.x;
|
||||||
|
hints->y = win->ppos.y;
|
||||||
|
}
|
||||||
|
if (win->flags.setUPos) {
|
||||||
|
hints->flags |= USPosition;
|
||||||
hints->x = win->upos.x;
|
hints->x = win->upos.x;
|
||||||
hints->y = win->upos.y;
|
hints->y = win->upos.y;
|
||||||
}
|
}
|
||||||
@@ -470,6 +477,19 @@ void
|
|||||||
WMSetWindowInitialPosition(WMWindow *win, int x, int y)
|
WMSetWindowInitialPosition(WMWindow *win, int x, int y)
|
||||||
{
|
{
|
||||||
win->flags.setPPos = 1;
|
win->flags.setPPos = 1;
|
||||||
|
win->ppos.x = x;
|
||||||
|
win->ppos.y = y;
|
||||||
|
if (win->view->flags.realized)
|
||||||
|
setSizeHints(win);
|
||||||
|
WMMoveWidget(win, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMSetWindowUserPosition(WMWindow *win, int x, int y)
|
||||||
|
{
|
||||||
|
win->flags.setUPos = 1;
|
||||||
win->upos.x = x;
|
win->upos.x = x;
|
||||||
win->upos.y = y;
|
win->upos.y = y;
|
||||||
if (win->view->flags.realized)
|
if (win->view->flags.realized)
|
||||||
|
|||||||
@@ -789,6 +789,7 @@ WEditMenuShowAt(WEditMenu *menu, int x, int y)
|
|||||||
W_VIEW_DRAWABLE(menu->view),
|
W_VIEW_DRAWABLE(menu->view),
|
||||||
hints);
|
hints);
|
||||||
XFree(hints);
|
XFree(hints);
|
||||||
|
|
||||||
WMMapWidget(menu);
|
WMMapWidget(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2108,7 +2108,7 @@ wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y)
|
|||||||
icon->editing = 0;
|
icon->editing = 0;
|
||||||
if (XGetCommand(dpy, wwin->client_win, &argv, &argc) && argc>0) {
|
if (XGetCommand(dpy, wwin->client_win, &argv, &argc) && argc>0) {
|
||||||
|
|
||||||
icon->command = FlattenStringList(argv, argc);
|
icon->command = wtokenjoin(argv, argc);
|
||||||
XFreeStringList(argv);
|
XFreeStringList(argv);
|
||||||
} else {
|
} else {
|
||||||
char *command=NULL;
|
char *command=NULL;
|
||||||
@@ -2243,7 +2243,7 @@ moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, int y)
|
|||||||
if ((dest->type==WM_DOCK /*|| dest->keep_attracted*/) && icon->command==NULL) {
|
if ((dest->type==WM_DOCK /*|| dest->keep_attracted*/) && icon->command==NULL) {
|
||||||
if (XGetCommand(dpy, wwin->client_win, &argv, &argc) && argc>0) {
|
if (XGetCommand(dpy, wwin->client_win, &argv, &argc) && argc>0) {
|
||||||
|
|
||||||
icon->command = FlattenStringList(argv, argc);
|
icon->command = wtokenjoin(argv, argc);
|
||||||
XFreeStringList(argv);
|
XFreeStringList(argv);
|
||||||
} else {
|
} else {
|
||||||
char *command=NULL;
|
char *command=NULL;
|
||||||
@@ -2940,7 +2940,7 @@ execCommand(WAppIcon *btn, char *command, WSavedState *state)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenizeString(cmdline, &argv, &argc);
|
wtokensplit(cmdline, &argv, &argc);
|
||||||
|
|
||||||
if (argv==NULL) {
|
if (argv==NULL) {
|
||||||
if (cmdline)
|
if (cmdline)
|
||||||
@@ -3131,7 +3131,7 @@ wDockTrackWindowLaunch(WDock *dock, Window window)
|
|||||||
|
|
||||||
if (XGetCommand(dpy, window, &argv, &argc)) {
|
if (XGetCommand(dpy, window, &argv, &argc)) {
|
||||||
if (argc > 0 && argv != NULL)
|
if (argc > 0 && argv != NULL)
|
||||||
command = FlattenStringList(argv,argc);
|
command = wtokenjoin(argv,argc);
|
||||||
if (argv) {
|
if (argv) {
|
||||||
XFreeStringList(argv);
|
XFreeStringList(argv);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,8 +126,6 @@ BOOL StringCompareHook(proplist_t pl1, proplist_t pl2);
|
|||||||
|
|
||||||
int IsEof(FILE * stream); /* feof that stats pipes */
|
int IsEof(FILE * stream); /* feof that stats pipes */
|
||||||
|
|
||||||
char *FlattenStringList(char **list, int count);
|
|
||||||
|
|
||||||
void ParseWindowName(proplist_t value, char **winstance, char **wclass,
|
void ParseWindowName(proplist_t value, char **winstance, char **wclass,
|
||||||
char *where);
|
char *where);
|
||||||
|
|
||||||
@@ -151,8 +149,6 @@ void wHackedGrabButton(unsigned int button, unsigned int modifiers,
|
|||||||
int keyboard_mode, Window confine_to, Cursor cursor);
|
int keyboard_mode, Window confine_to, Cursor cursor);
|
||||||
|
|
||||||
|
|
||||||
void TokenizeString(char *command, char ***argv, int *argc);
|
|
||||||
|
|
||||||
void ExecExitScript();
|
void ExecExitScript();
|
||||||
|
|
||||||
/****** I18N Wrapper for XFetchName,XGetIconName ******/
|
/****** I18N Wrapper for XFetchName,XGetIconName ******/
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ static WRootMenuData *dir_openMenuFile(char *paths, time_t *timestamp)
|
|||||||
|
|
||||||
/* timestamp for directory is a "checksum" of the directory times */
|
/* timestamp for directory is a "checksum" of the directory times */
|
||||||
|
|
||||||
TokenizeString(paths, &dirs, &dirN);
|
wtokensplit(paths, &dirs, &dirN);
|
||||||
|
|
||||||
if (dirN == 0) {
|
if (dirN == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
155
src/misc.c
155
src/misc.c
@@ -237,7 +237,8 @@ isBelow(WWindow *win1, WWindow *win2)
|
|||||||
* XFetchName Wrapper
|
* XFetchName Wrapper
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Bool wFetchName(dpy, win, winname)
|
Bool
|
||||||
|
wFetchName(dpy, win, winname)
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
Window win;
|
Window win;
|
||||||
char **winname;
|
char **winname;
|
||||||
@@ -281,7 +282,8 @@ char **winname;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Bool wGetIconName(dpy, win, iconname)
|
Bool
|
||||||
|
wGetIconName(dpy, win, iconname)
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
Window win;
|
Window win;
|
||||||
char **iconname;
|
char **iconname;
|
||||||
@@ -502,153 +504,6 @@ FindImage(char *paths, char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char*
|
|
||||||
FlattenStringList(char **list, int count)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
char *flat_string, *wspace;
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
for (i=0; i<count; i++) {
|
|
||||||
if (list[i]!=NULL && list[i][0]!=0) {
|
|
||||||
j += strlen(list[i]);
|
|
||||||
if (strpbrk(list[i], " \t"))
|
|
||||||
j += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flat_string = malloc(j+count+1);
|
|
||||||
if (!flat_string) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*flat_string = 0;
|
|
||||||
for (i=0; i<count; i++) {
|
|
||||||
if (list[i]!=NULL && list[i][0]!=0) {
|
|
||||||
if (i>0)
|
|
||||||
strcat(flat_string, " ");
|
|
||||||
wspace = strpbrk(list[i], " \t");
|
|
||||||
if (wspace)
|
|
||||||
strcat(flat_string, "\"");
|
|
||||||
strcat(flat_string, list[i]);
|
|
||||||
if (wspace)
|
|
||||||
strcat(flat_string, "\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return flat_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*----------------------------------------------------------------------
|
|
||||||
* ParseCommand --
|
|
||||||
* Divides a command line into a argv/argc pair.
|
|
||||||
*----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#define PRC_ALPHA 0
|
|
||||||
#define PRC_BLANK 1
|
|
||||||
#define PRC_ESCAPE 2
|
|
||||||
#define PRC_DQUOTE 3
|
|
||||||
#define PRC_EOS 4
|
|
||||||
#define PRC_SQUOTE 5
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
short nstate;
|
|
||||||
short output;
|
|
||||||
} DFA;
|
|
||||||
|
|
||||||
|
|
||||||
static DFA mtable[9][6] = {
|
|
||||||
{{3,1},{0,0},{4,0},{1,0},{8,0},{6,0}},
|
|
||||||
{{1,1},{1,1},{2,0},{3,0},{5,0},{1,1}},
|
|
||||||
{{1,1},{1,1},{1,1},{1,1},{5,0},{1,1}},
|
|
||||||
{{3,1},{5,0},{4,0},{1,0},{5,0},{6,0}},
|
|
||||||
{{3,1},{3,1},{3,1},{3,1},{5,0},{3,1}},
|
|
||||||
{{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
|
|
||||||
{{6,1},{6,1},{7,0},{6,1},{5,0},{3,0}},
|
|
||||||
{{6,1},{6,1},{6,1},{6,1},{5,0},{6,1}},
|
|
||||||
{{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
|
|
||||||
};
|
|
||||||
|
|
||||||
char*
|
|
||||||
next_token(char *word, char **next)
|
|
||||||
{
|
|
||||||
char *ptr;
|
|
||||||
char *ret, *t;
|
|
||||||
int state, ctype;
|
|
||||||
|
|
||||||
t = ret = wmalloc(strlen(word)+1);
|
|
||||||
ptr = word;
|
|
||||||
|
|
||||||
state = 0;
|
|
||||||
*t = 0;
|
|
||||||
while (1) {
|
|
||||||
if (*ptr==0)
|
|
||||||
ctype = PRC_EOS;
|
|
||||||
else if (*ptr=='\\')
|
|
||||||
ctype = PRC_ESCAPE;
|
|
||||||
else if (*ptr=='"')
|
|
||||||
ctype = PRC_DQUOTE;
|
|
||||||
else if (*ptr=='\'')
|
|
||||||
ctype = PRC_SQUOTE;
|
|
||||||
else if (*ptr==' ' || *ptr=='\t')
|
|
||||||
ctype = PRC_BLANK;
|
|
||||||
else
|
|
||||||
ctype = PRC_ALPHA;
|
|
||||||
|
|
||||||
if (mtable[state][ctype].output) {
|
|
||||||
*t = *ptr; t++;
|
|
||||||
*t = 0;
|
|
||||||
}
|
|
||||||
state = mtable[state][ctype].nstate;
|
|
||||||
ptr++;
|
|
||||||
if (mtable[state][0].output<0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*ret==0)
|
|
||||||
t = NULL;
|
|
||||||
else
|
|
||||||
t = wstrdup(ret);
|
|
||||||
|
|
||||||
free(ret);
|
|
||||||
|
|
||||||
if (ctype==PRC_EOS)
|
|
||||||
*next = NULL;
|
|
||||||
else
|
|
||||||
*next = ptr;
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* separate a string in tokens, taking " and ' into account */
|
|
||||||
void
|
|
||||||
TokenizeString(char *command, char ***argv, int *argc)
|
|
||||||
{
|
|
||||||
char *token, *line;
|
|
||||||
int count;
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
line = command;
|
|
||||||
do {
|
|
||||||
token = next_token(line, &line);
|
|
||||||
if (token) {
|
|
||||||
if (count == 0)
|
|
||||||
*argv = wmalloc(sizeof(char**));
|
|
||||||
else
|
|
||||||
*argv = wrealloc(*argv, (count+1)*sizeof(char**));
|
|
||||||
(*argv)[count++] = token;
|
|
||||||
}
|
|
||||||
} while (token!=NULL && line!=NULL);
|
|
||||||
|
|
||||||
*argc = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
timeoutHandler(void *data)
|
timeoutHandler(void *data)
|
||||||
{
|
{
|
||||||
@@ -875,7 +730,7 @@ get_dnd_selection(WScreen *scr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
flat_string = FlattenStringList(list, count);
|
flat_string = wtokenjoin(list, count);
|
||||||
if (!flat_string) {
|
if (!flat_string) {
|
||||||
wwarning(_("out of memory while getting data from DND drop"));
|
wwarning(_("out of memory while getting data from DND drop"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ makeWindowState(WWindow *wwin, WApplication *wapp)
|
|||||||
win = wwin->client_win;
|
win = wwin->client_win;
|
||||||
|
|
||||||
if (XGetCommand(dpy, win, &argv, &argc) && argc>0) {
|
if (XGetCommand(dpy, win, &argv, &argc) && argc>0) {
|
||||||
command = FlattenStringList(argv, argc);
|
command = wtokenjoin(argv, argc);
|
||||||
XFreeStringList(argv);
|
XFreeStringList(argv);
|
||||||
}
|
}
|
||||||
if (!command)
|
if (!command)
|
||||||
@@ -381,7 +381,7 @@ execCommand(WScreen *scr, char *command, char *host)
|
|||||||
char **argv;
|
char **argv;
|
||||||
int argc;
|
int argc;
|
||||||
|
|
||||||
TokenizeString(command, &argv, &argc);
|
wtokensplit(command, &argv, &argc);
|
||||||
|
|
||||||
if (argv==NULL) {
|
if (argv==NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -2632,7 +2632,7 @@ wWindowGetSavedState(Window win)
|
|||||||
|
|
||||||
if (XGetCommand(dpy, win, &argv, &argc)) {
|
if (XGetCommand(dpy, win, &argv, &argc)) {
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
command = FlattenStringList(argv, argc);
|
command = wtokenjoin(argv, argc);
|
||||||
XFreeStringList(argv);
|
XFreeStringList(argv);
|
||||||
}
|
}
|
||||||
if (!command)
|
if (!command)
|
||||||
|
|||||||
Reference in New Issue
Block a user