2 * Window Maker window manager
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include <X11/Xutil.h>
24 #include <X11/Xatom.h>
38 #include <X11/XKBlib.h>
40 #include <WINGs/WUtil.h>
45 #include "WindowMaker.h"
53 #include "xmodifier.h"
59 #define ICON_SIZE wPreferences.icon_size
61 /**** Local prototypes *****/
62 static void UnescapeWM_CLASS(const char *str
, char **name
, char **class);
64 /* XFetchName Wrapper */
65 Bool
wFetchName(Display
*dpy
, Window win
, char **winname
)
67 XTextProperty text_prop
;
71 if (XGetWMName(dpy
, win
, &text_prop
)) {
72 if (text_prop
.value
&& text_prop
.nitems
> 0) {
73 if (text_prop
.encoding
== XA_STRING
) {
74 *winname
= wstrdup((char *)text_prop
.value
);
75 XFree(text_prop
.value
);
77 text_prop
.nitems
= strlen((char *)text_prop
.value
);
78 if (XmbTextPropertyToTextList(dpy
, &text_prop
, &list
, &num
) >=
79 Success
&& num
> 0 && *list
) {
80 XFree(text_prop
.value
);
81 *winname
= wstrdup(*list
);
82 XFreeStringList(list
);
84 *winname
= wstrdup((char *)text_prop
.value
);
85 XFree(text_prop
.value
);
89 /* the title is set, but it was set to none */
90 *winname
= wstrdup("");
94 /* the hint is probably not set */
101 /* XGetIconName Wrapper */
102 Bool
wGetIconName(Display
*dpy
, Window win
, char **iconname
)
104 XTextProperty text_prop
;
108 if (XGetWMIconName(dpy
, win
, &text_prop
) != 0 && text_prop
.value
&& text_prop
.nitems
> 0) {
109 if (text_prop
.encoding
== XA_STRING
)
110 *iconname
= (char *)text_prop
.value
;
112 text_prop
.nitems
= strlen((char *)text_prop
.value
);
113 if (XmbTextPropertyToTextList(dpy
, &text_prop
, &list
, &num
) >= Success
&& num
> 0 && *list
) {
114 XFree(text_prop
.value
);
115 *iconname
= wstrdup(*list
);
116 XFreeStringList(list
);
118 *iconname
= (char *)text_prop
.value
;
126 static void eatExpose(void)
130 /* compress all expose events into a single one */
132 if (XCheckMaskEvent(dpy
, ExposureMask
, &event
)) {
133 /* ignore other exposure events for this window */
134 while (XCheckWindowEvent(dpy
, event
.xexpose
.window
, ExposureMask
, &foo
)) ;
135 /* eat exposes for other windows */
138 event
.xexpose
.count
= 0;
139 XPutBackEvent(dpy
, &event
);
143 void move_window(Window win
, int from_x
, int from_y
, int to_x
, int to_y
)
145 #ifdef USE_ANIMATIONS
146 if (wPreferences
.no_animations
)
147 XMoveWindow(dpy
, win
, to_x
, to_y
);
149 slide_window(win
, from_x
, from_y
, to_x
, to_y
);
151 XMoveWindow(dpy
, win
, to_x
, to_y
);
153 /* Tell the compiler it is normal that those parameters are not used in this case */
159 /* wins is an array of Window, sorted from left to right, the first is
160 * going to be moved from (from_x,from_y) to (to_x,to_y) and the
161 * following windows are going to be offset by (ICON_SIZE*i,0) */
162 void slide_windows(Window wins
[], int n
, int from_x
, int from_y
, int to_x
, int to_y
)
164 time_t time0
= time(NULL
);
165 float dx
, dy
, x
= from_x
, y
= from_y
, px
, py
;
166 Bool is_dx_nul
, is_dy_nul
;
167 int dx_is_bigger
= 0, dx_int
, dy_int
;
168 int slide_delay
, slide_steps
, slide_slowdown
;
171 /* animation parameters */
172 static const struct {
177 {ICON_SLIDE_DELAY_UF
, ICON_SLIDE_STEPS_UF
, ICON_SLIDE_SLOWDOWN_UF
},
178 {ICON_SLIDE_DELAY_F
, ICON_SLIDE_STEPS_F
, ICON_SLIDE_SLOWDOWN_F
},
179 {ICON_SLIDE_DELAY_M
, ICON_SLIDE_STEPS_M
, ICON_SLIDE_SLOWDOWN_M
},
180 {ICON_SLIDE_DELAY_S
, ICON_SLIDE_STEPS_S
, ICON_SLIDE_SLOWDOWN_S
},
181 {ICON_SLIDE_DELAY_US
, ICON_SLIDE_STEPS_US
, ICON_SLIDE_SLOWDOWN_US
}
184 slide_slowdown
= apars
[(int)wPreferences
.icon_slide_speed
].slowdown
;
185 slide_steps
= apars
[(int)wPreferences
.icon_slide_speed
].steps
;
186 slide_delay
= apars
[(int)wPreferences
.icon_slide_speed
].delay
;
188 dx_int
= to_x
- from_x
;
189 dy_int
= to_y
- from_y
;
190 is_dx_nul
= (dx_int
== 0);
191 is_dy_nul
= (dy_int
== 0);
195 if (abs(dx_int
) > abs(dy_int
)) {
200 px
= dx
/ slide_slowdown
;
201 if (px
< slide_steps
&& px
> 0)
203 else if (px
> -slide_steps
&& px
< 0)
205 py
= (is_dx_nul
? 0.0F
: px
* dy
/ dx
);
207 py
= dy
/ slide_slowdown
;
208 if (py
< slide_steps
&& py
> 0)
210 else if (py
> -slide_steps
&& py
< 0)
212 px
= (is_dy_nul
? 0.0F
: py
* dx
/ dy
);
215 while (((int)x
) != to_x
||
219 if ((px
< 0 && (int)x
< to_x
) || (px
> 0 && (int)x
> to_x
))
221 if ((py
< 0 && (int)y
< to_y
) || (py
> 0 && (int)y
> to_y
))
225 px
= px
* (1.0F
- 1 / (float)slide_slowdown
);
226 if (px
< slide_steps
&& px
> 0)
228 else if (px
> -slide_steps
&& px
< 0)
230 py
= (is_dx_nul
? 0.0F
: px
* dy
/ dx
);
232 py
= py
* (1.0F
- 1 / (float)slide_slowdown
);
233 if (py
< slide_steps
&& py
> 0)
235 else if (py
> -slide_steps
&& py
< 0)
237 px
= (is_dy_nul
? 0.0F
: py
* dx
/ dy
);
240 for (i
= 0; i
< n
; i
++) {
241 XMoveWindow(dpy
, wins
[i
], (int)x
+ i
* ICON_SIZE
, (int)y
);
244 if (slide_delay
> 0) {
245 wusleep(slide_delay
* 1000L);
249 if (time(NULL
) - time0
> MAX_ANIMATION_TIME
)
252 for (i
= 0; i
< n
; i
++) {
253 XMoveWindow(dpy
, wins
[i
], to_x
+ i
* ICON_SIZE
, to_y
);
257 /* compress expose events */
261 char *ShrinkString(WMFont
*font
, const char *string
, int width
)
270 w
= WMWidthOfString(font
, string
, p
);
271 text
= wmalloc(strlen(string
) + 8);
272 strcpy(text
, string
);
276 pos
= strchr(text
, ' ');
278 pos
= strchr(text
, ':');
283 w1
= WMWidthOfString(font
, text
, p
);
299 width
-= WMWidthOfString(font
, "...", 3);
304 while (p2
> p1
&& p1
!= t
) {
305 w
= WMWidthOfString(font
, &string
[p
- t
], t
);
308 t
= p1
+ (p2
- p1
) / 2;
309 } else if (w
< width
) {
311 t
= p1
+ (p2
- p1
) / 2;
315 strcat(text
, &string
[p
- p1
]);
320 char *FindImage(const char *paths
, const char *file
)
322 char *tmp
, *path
= NULL
;
324 tmp
= strrchr(file
, ':');
327 path
= wfindfile(paths
, file
);
331 path
= wfindfile(paths
, file
);
336 static void timeoutHandler(void *data
)
341 static char *getTextSelection(WScreen
* screen
, Atom selection
)
375 data
= XFetchBuffer(dpy
, &size
, buffer
);
382 unsigned long len
, bytes
;
386 static Atom clipboard
= 0;
389 clipboard
= XInternAtom(dpy
, "CLIPBOARD", False
);
391 XDeleteProperty(dpy
, screen
->info_window
, clipboard
);
393 XConvertSelection(dpy
, selection
, XA_STRING
, clipboard
, screen
->info_window
, CurrentTime
);
395 timer
= WMAddTimerHandler(1000, timeoutHandler
, &timeout
);
397 while (!XCheckTypedWindowEvent(dpy
, screen
->info_window
, SelectionNotify
, &ev
) && !timeout
) ;
400 WMDeleteTimerHandler(timer
);
402 wwarning("selection retrieval timed out");
406 /* nobody owns the selection or the current owner has
407 * nothing to do with what we need */
408 if (ev
.xselection
.property
== None
) {
412 if (XGetWindowProperty(dpy
, screen
->info_window
,
414 False
, XA_STRING
, &rtype
, &bits
, &len
,
415 &bytes
, (unsigned char **)&data
) != Success
) {
418 if (rtype
!= XA_STRING
|| bits
!= 8) {
419 wwarning("invalid data in text selection");
428 static char *getselection(WScreen
* scr
)
432 tmp
= getTextSelection(scr
, XA_PRIMARY
);
434 tmp
= getTextSelection(scr
, XA_CUT_BUFFER0
);
439 parseuserinputpart(const char *line
, int *ptr
, const char *endchars
)
441 int depth
= 0, begin
;
445 while(line
[*ptr
] != '\0') {
446 if(line
[*ptr
] == '(') {
448 } else if(depth
> 0 && line
[*ptr
] == ')') {
450 } else if(depth
== 0 && strchr(endchars
, line
[*ptr
]) != NULL
) {
451 value
= wmalloc(*ptr
- begin
+ 1);
452 strncpy(value
, line
+ begin
, *ptr
- begin
);
453 value
[*ptr
- begin
] = '\0';
463 getuserinput(WScreen
*scr
, const char *line
, int *ptr
, Bool advanced
)
465 char *ret
= NULL
, *title
= NULL
, *prompt
= NULL
, *name
= NULL
;
468 if(line
[*ptr
] == '(')
469 title
= parseuserinputpart(line
, ptr
, ",)");
470 if(title
!= NULL
&& line
[*ptr
] == ',')
471 prompt
= parseuserinputpart(line
, ptr
, ",)");
472 if(prompt
!= NULL
&& line
[*ptr
] == ',')
473 name
= parseuserinputpart(line
, ptr
, ")");
476 rv
= wAdvancedInputDialog(scr
,
477 title
? _(title
):_("Program Arguments"),
478 prompt
? _(prompt
):_("Enter command arguments:"),
481 rv
= wInputDialog(scr
,
482 title
? _(title
):_("Program Arguments"),
483 prompt
? _(prompt
):_("Enter command arguments:"),
486 if(title
) wfree(title
);
487 if(prompt
) wfree(prompt
);
488 if(name
) wfree(name
);
490 return rv
? ret
: NULL
;
498 * state input new-state output
499 * NORMAL % OPTION <nil>
500 * NORMAL \ ESCAPE <nil>
501 * NORMAL etc. NORMAL <input>
502 * ESCAPE any NORMAL <input>
503 * OPTION s NORMAL <selection buffer>
504 * OPTION w NORMAL <selected window id>
505 * OPTION a NORMAL <input text>
506 * OPTION d NORMAL <OffiX DND selection object>
507 * OPTION W NORMAL <current workspace>
508 * OPTION etc. NORMAL %<input>
510 #define TMPBUFSIZE 64
511 char *ExpandOptions(WScreen
*scr
, const char *cmdline
)
513 int ptr
, optr
, state
, len
, olen
;
515 char *selection
= NULL
;
516 char *user_input
= NULL
;
517 char tmpbuf
[TMPBUFSIZE
];
520 len
= strlen(cmdline
);
524 wwarning(_("out of memory during expansion of \"%s\""), cmdline
);
528 ptr
= 0; /* input line pointer */
529 optr
= 0; /* output line pointer */
534 switch (cmdline
[ptr
]) {
543 out
[optr
++] = cmdline
[ptr
];
548 switch (cmdline
[ptr
]) {
562 out
[optr
++] = cmdline
[ptr
];
568 switch (cmdline
[ptr
]) {
570 if (scr
->focused_window
&& scr
->focused_window
->flags
.focused
) {
571 snprintf(tmpbuf
, sizeof(tmpbuf
), "0x%x",
572 (unsigned int)scr
->focused_window
->client_win
);
573 slen
= strlen(tmpbuf
);
575 nout
= realloc(out
, olen
);
577 wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%w", cmdline
);
589 snprintf(tmpbuf
, sizeof(tmpbuf
), "0x%x", (unsigned int)scr
->current_workspace
+ 1);
590 slen
= strlen(tmpbuf
);
592 nout
= realloc(out
, olen
);
594 wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%W", cmdline
);
605 user_input
= getuserinput(scr
, cmdline
, &ptr
, cmdline
[ptr
-1] == 'A');
607 slen
= strlen(user_input
);
609 nout
= realloc(out
, olen
);
611 wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%a", cmdline
);
615 strcat(out
, user_input
);
618 /* Not an error, but user has Canceled the dialog box.
619 * This will make the command to not be performed. */
626 if (!scr
->xdestring
) {
627 scr
->flags
.dnd_data_convertion_status
= 1;
630 slen
= strlen(scr
->xdestring
);
632 nout
= realloc(out
, olen
);
634 wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%d", cmdline
);
638 strcat(out
, scr
->xdestring
);
641 #endif /* USE_DOCK_XDND */
645 selection
= getselection(scr
);
648 wwarning(_("selection not available"));
651 slen
= strlen(selection
);
653 nout
= realloc(out
, olen
);
655 wwarning(_("out of memory during expansion of '%s' for command \"%s\""), "%s", cmdline
);
659 strcat(out
, selection
);
665 out
[optr
++] = cmdline
[ptr
];
683 void ExecuteExitCommand(WScreen
*scr
, long quickmode
)
685 static int inside
= 0;
688 /* prevent reentrant calls */
698 if (quickmode
== M_QUICK
) {
701 int r
, oldSaveSessionFlag
;
703 oldSaveSessionFlag
= wPreferences
.save_session_on_exit
;
704 r
= wExitDialog(scr
, _("Exit"),
705 _("Are you sure you want to quit Window Maker?"), _("Exit"), _("Cancel"), NULL
);
707 if (r
== WAPRDefault
) {
709 } else if (r
== WAPRAlternate
) {
710 /* Don't modify the "save session on exit" flag if the
711 * user canceled the operation. */
712 wPreferences
.save_session_on_exit
= oldSaveSessionFlag
;
715 if (result
== R_EXIT
)
716 Shutdown(WSExitMode
);
723 void ExecuteInputCommand(WScreen
*scr
, const char *cmdline
)
727 cmd
= ExpandOptions(scr
, cmdline
);
729 XGrabPointer(dpy
, scr
->root_win
, True
, 0,
730 GrabModeAsync
, GrabModeAsync
, None
, wPreferences
.cursor
[WCUR_WAIT
], CurrentTime
);
733 ExecuteShellCommand(scr
, cmd
);
736 XUngrabPointer(dpy
, CurrentTime
);
741 void ParseWindowName(WMPropList
*value
, char **winstance
, char **wclass
, const char *where
)
745 *winstance
= *wclass
= NULL
;
747 if (!WMIsPLString(value
)) {
748 wwarning(_("bad window name value in %s state info"), where
);
752 name
= WMGetFromPLString(value
);
753 if (!name
|| strlen(name
) == 0) {
754 wwarning(_("bad window name value in %s state info"), where
);
758 UnescapeWM_CLASS(name
, winstance
, wclass
);
762 static char *keysymToString(KeySym keysym
, unsigned int state
)
765 char *buf
= wmalloc(20);
770 kev
.send_event
= False
;
771 kev
.window
= DefaultRootWindow(dpy
);
772 kev
.root
= DefaultRootWindow(dpy
);
773 kev
.same_screen
= True
;
774 kev
.subwindow
= kev
.root
;
775 kev
.serial
= 0x12344321;
776 kev
.time
= CurrentTime
;
778 kev
.keycode
= XKeysymToKeycode(dpy
, keysym
);
779 count
= XLookupString(&kev
, buf
, 19, NULL
, NULL
);
786 char *GetShortcutString(const char *shortcut
)
789 char *k
, *tmp
, *text
;
791 tmp
= text
= wstrdup(shortcut
);
794 while ((k
= strchr(text
, '+')) != NULL
) {
799 mod
= wXModifierFromKey(text
);
801 return wstrdup("bug");
803 lbl
= wXModifierToShortcutLabel(mod
);
805 buffer
= wstrappend(buffer
, lbl
);
807 buffer
= wstrappend(buffer
, text
);
811 buffer
= wstrappend(buffer
, text
);
817 char *GetShortcutKey(WShortKey key
)
819 const char *key_name
;
823 void append_string(const char *text
)
825 const char *string
= text
;
828 if (wr
>= buffer
+ sizeof(buffer
) - 1)
834 void append_modifier(int modifier_index
, const char *fallback_name
)
836 if (wPreferences
.modifier_labels
[modifier_index
]) {
837 append_string(wPreferences
.modifier_labels
[modifier_index
]);
839 append_string(fallback_name
);
843 key_name
= XKeysymToString(XkbKeycodeToKeysym(dpy
, key
.keycode
, 0, 0));
848 if (key
.modifier
& ControlMask
) append_modifier(1, "Control+");
849 if (key
.modifier
& ShiftMask
) append_modifier(0, "Shift+");
850 if (key
.modifier
& Mod1Mask
) append_modifier(2, "Mod1+");
851 if (key
.modifier
& Mod2Mask
) append_modifier(3, "Mod2+");
852 if (key
.modifier
& Mod3Mask
) append_modifier(4, "Mod3+");
853 if (key
.modifier
& Mod4Mask
) append_modifier(5, "Mod4+");
854 if (key
.modifier
& Mod5Mask
) append_modifier(6, "Mod5+");
855 append_string(key_name
);
858 return GetShortcutString(buffer
);
861 char *EscapeWM_CLASS(const char *name
, const char *class)
864 char *ename
= NULL
, *eclass
= NULL
;
872 ename
= wmalloc(l
* 2 + 1);
874 for (i
= 0; i
< l
; i
++) {
875 if (name
[i
] == '\\') {
877 } else if (name
[i
] == '.') {
880 ename
[j
++] = name
[i
];
886 eclass
= wmalloc(l
* 2 + 1);
888 for (i
= 0; i
< l
; i
++) {
889 if (class[i
] == '\\') {
891 } else if (class[i
] == '.') {
894 eclass
[j
++] = class[i
];
899 if (ename
&& eclass
) {
900 int len
= strlen(ename
) + strlen(eclass
) + 4;
902 snprintf(ret
, len
, "%s.%s", ename
, eclass
);
906 ret
= wstrdup(ename
);
909 ret
= wstrdup(eclass
);
916 static void UnescapeWM_CLASS(const char *str
, char **name
, char **class)
923 /* separate string in 2 parts */
926 for (i
= 0; i
< j
; i
++, length_of_name
++) {
927 if (str
[i
] == '\\') {
930 } else if (str
[i
] == '.') {
936 /* unescape the name */
937 if (length_of_name
> 0) {
938 *name
= wmalloc(length_of_name
+ 1);
939 for (i
= 0, k
= 0; i
< dot
; i
++) {
941 (*name
)[k
++] = str
[i
];
948 /* unescape the class */
950 *class = wmalloc(j
- (dot
+ 1) + 1);
951 for (i
= dot
+ 1, k
= 0; i
< j
; i
++) {
953 (*class)[k
++] = str
[i
];
961 static void track_bg_helper_death(pid_t pid
, unsigned int status
, void *client_data
)
963 WScreen
*scr
= (WScreen
*) client_data
;
965 /* Parameter not used, but tell the compiler that it is ok */
969 close(scr
->helper_fd
);
972 scr
->flags
.backimage_helper_launched
= 0;
975 Bool
start_bg_helper(WScreen
*scr
)
980 if (pipe(filedes
) < 0) {
981 werror(_("%s failed, can't set workspace specific background image (%s)"),
982 "pipe()", strerror(errno
));
988 werror(_("%s failed, can't set workspace specific background image (%s)"),
989 "fork()", strerror(errno
));
994 } else if (pid
== 0) {
997 /* We don't need this side of the pipe in the child process */
1000 SetupEnvironment(scr
);
1002 close(STDIN_FILENO
);
1003 if (dup2(filedes
[0], STDIN_FILENO
) < 0) {
1004 werror(_("%s failed, can't set workspace specific background image (%s)"),
1005 "dup2()", strerror(errno
));
1010 dither
= wPreferences
.no_dithering
? "-m" : "-d";
1011 if (wPreferences
.smooth_workspace_back
)
1012 execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither
, NULL
);
1014 execlp("wmsetbg", "wmsetbg", "-helper", dither
, NULL
);
1016 werror(_("could not execute \"%s\": %s"), "wmsetbg", strerror(errno
));
1020 /* We don't need this side of the pipe in the parent process */
1023 if (fcntl(filedes
[1], F_SETFD
, FD_CLOEXEC
) < 0)
1024 wwarning(_("could not set close-on-exec flag for bg_helper's communication file handle (%s)"),
1027 scr
->helper_fd
= filedes
[1];
1028 scr
->helper_pid
= pid
;
1029 scr
->flags
.backimage_helper_launched
= 1;
1031 wAddDeathHandler(pid
, track_bg_helper_death
, scr
);
1037 void SendHelperMessage(WScreen
*scr
, char type
, int workspace
, const char *msg
)
1044 if (!scr
->flags
.backimage_helper_launched
) {
1048 len
= (msg
? strlen(msg
) : 0) + (workspace
>= 0 ? 4 : 0) + 1;
1049 buffer
= wmalloc(len
+ 5);
1050 snprintf(buf
, sizeof(buf
), "%4i", len
);
1051 memcpy(buffer
, buf
, 4);
1054 if (workspace
>= 0) {
1055 snprintf(buf
, sizeof(buf
), "%4i", workspace
);
1056 memcpy(&buffer
[i
], buf
, 4);
1061 strcpy(&buffer
[i
], msg
);
1063 if (write(scr
->helper_fd
, buffer
, len
+ 4) < 0) {
1064 werror(_("could not send message to background image helper"));
1069 Bool
UpdateDomainFile(WDDomain
* domain
)
1072 char path
[PATH_MAX
];
1073 WMPropList
*shared_dict
, *dict
;
1074 Bool result
, freeDict
= False
;
1076 dict
= domain
->dictionary
;
1077 if (WMIsPLDictionary(domain
->dictionary
)) {
1078 /* retrieve global system dictionary */
1079 snprintf(path
, sizeof(path
), "%s/%s", PKGCONFDIR
, domain
->domain_name
);
1080 if (stat(path
, &stbuf
) >= 0) {
1081 shared_dict
= WMReadPropListFromFile(path
);
1083 if (WMIsPLDictionary(shared_dict
)) {
1085 dict
= WMDeepCopyPropList(domain
->dictionary
);
1086 WMSubtractPLDictionaries(dict
, shared_dict
, True
);
1088 WMReleasePropList(shared_dict
);
1093 result
= WMWritePropListToFile(dict
, domain
->path
);
1096 WMReleasePropList(dict
);
1102 char *StrConcatDot(const char *a
, const char *b
)
1112 len
= strlen(a
) + strlen(b
) + 4;
1115 snprintf(str
, len
, "%s.%s", a
, b
);
1120 static char *getCommandForWindow(Window win
, int elements
)
1122 char **argv
, *command
= NULL
;
1125 if (XGetCommand(dpy
, win
, &argv
, &argc
)) {
1126 if (argc
> 0 && argv
!= NULL
) {
1129 command
= wtokenjoin(argv
, WMIN(argc
, elements
));
1130 if (command
[0] == 0) {
1136 XFreeStringList(argv
);
1143 /* Free result when done */
1144 char *GetCommandForWindow(Window win
)
1146 return getCommandForWindow(win
, 0);