mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-11 13:50:48 -05:00
handle patchy EWMH support more gracefully
This commit is contained in:
parent
34a453e5a6
commit
5c5e0ebd12
1 changed files with 14 additions and 5 deletions
|
@ -44,6 +44,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <err.h>
|
||||||
#include <X11/extensions/Xinerama.h>
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
|
@ -708,7 +709,8 @@ void run_switcher(int mode, int fmode)
|
||||||
// if we happen to have a window destroyed while we're working...
|
// if we happen to have a window destroyed while we're working...
|
||||||
winlist *ids = winlist_new();
|
winlist *ids = winlist_new();
|
||||||
|
|
||||||
window_get_cardinal_prop(root, netatoms[_NET_CURRENT_DESKTOP], ¤t_desktop, 1);
|
if (!window_get_cardinal_prop(root, netatoms[_NET_CURRENT_DESKTOP], ¤t_desktop, 1))
|
||||||
|
current_desktop = 0;
|
||||||
|
|
||||||
// find window list
|
// find window list
|
||||||
Atom type; int nwins; unsigned long *wins = allocate_clear(sizeof(unsigned long) * 100);
|
Atom type; int nwins; unsigned long *wins = allocate_clear(sizeof(unsigned long) * 100);
|
||||||
|
@ -732,13 +734,16 @@ void run_switcher(int mode, int fmode)
|
||||||
}
|
}
|
||||||
classfield = MAX(classfield, strlen(c->class));
|
classfield = MAX(classfield, strlen(c->class));
|
||||||
winlist_append(ids, c->window, NULL);
|
winlist_append(ids, c->window, NULL);
|
||||||
|
warnx("%s", c->class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// build line sprintf pattern
|
// build line sprintf pattern
|
||||||
if (mode == ALLWINDOWS)
|
if (mode == ALLWINDOWS)
|
||||||
{
|
{
|
||||||
window_get_cardinal_prop(root, netatoms[_NET_NUMBER_OF_DESKTOPS], &desktops, 1);
|
if (!window_get_cardinal_prop(root, netatoms[_NET_NUMBER_OF_DESKTOPS], &desktops, 1))
|
||||||
|
desktops = 1;
|
||||||
|
|
||||||
plen += sprintf(pattern+plen, "%%-%ds ", desktops < 10 ? 1: 2);
|
plen += sprintf(pattern+plen, "%%-%ds ", desktops < 10 ? 1: 2);
|
||||||
}
|
}
|
||||||
plen += sprintf(pattern+plen, "%%-%ds %%s", MAX(5, classfield));
|
plen += sprintf(pattern+plen, "%%-%ds %%s", MAX(5, classfield));
|
||||||
|
@ -756,8 +761,12 @@ void run_switcher(int mode, int fmode)
|
||||||
{
|
{
|
||||||
// find client's desktop. this is zero-based, so we adjust by since most
|
// find client's desktop. this is zero-based, so we adjust by since most
|
||||||
// normal people don't think like this :-)
|
// normal people don't think like this :-)
|
||||||
window_get_cardinal_prop(c->window, netatoms[_NET_WM_DESKTOP], &wmdesktop, 1);
|
if (!window_get_cardinal_prop(c->window, netatoms[_NET_WM_DESKTOP], &wmdesktop, 1))
|
||||||
if (wmdesktop < 0xFFFFFFFF) sprintf(desktop, "%d", (int)wmdesktop+1);
|
wmdesktop = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
if (wmdesktop < 0xFFFFFFFF)
|
||||||
|
sprintf(desktop, "%d", (int)wmdesktop+1);
|
||||||
|
|
||||||
sprintf(line, pattern, desktop, c->class, c->title);
|
sprintf(line, pattern, desktop, c->class, c->title);
|
||||||
}
|
}
|
||||||
else sprintf(line, pattern, c->class, c->title);
|
else sprintf(line, pattern, c->class, c->title);
|
||||||
|
@ -778,7 +787,7 @@ void run_switcher(int mode, int fmode)
|
||||||
int n = menu(list, &input, "> ", 1, &time);
|
int n = menu(list, &input, "> ", 1, &time);
|
||||||
if (n >= 0 && list[n])
|
if (n >= 0 && list[n])
|
||||||
{
|
{
|
||||||
if (mode == ALLWINDOWS)
|
if (mode == ALLWINDOWS && isdigit(list[n][0]))
|
||||||
{
|
{
|
||||||
// TODO: get rid of strtol
|
// TODO: get rid of strtol
|
||||||
window_send_message(root, root, netatoms[_NET_CURRENT_DESKTOP], strtol(list[n], NULL, 10)-1,
|
window_send_message(root, root, netatoms[_NET_CURRENT_DESKTOP], strtol(list[n], NULL, 10)-1,
|
||||||
|
|
Loading…
Reference in a new issue