mirror of
https://github.com/0intro/wmii
synced 2024-12-24 04:16:50 +03:00
removed spawn.c, removed wmiiwarp.c (instead use warp action on /ctl), spawning is not necessary, remove exec on page heuristic (too crappy, instead I'll use class hints again, they are at least more reliable)
This commit is contained in:
parent
67b6b3433e
commit
88ae3e3606
3
Makefile
3
Makefile
@ -5,8 +5,7 @@ include config.mk
|
||||
|
||||
SUBDIRS = libcext liblitz libixp cmd
|
||||
|
||||
BIN = cmd/wm/wmii cmd/wm/wmiiwm cmd/wmiimenu \
|
||||
cmd/wmiipsel cmd/wmiir cmd/wmiiwarp
|
||||
BIN = cmd/wm/wmii cmd/wm/wmiiwm cmd/wmiimenu cmd/wmiipsel cmd/wmiir
|
||||
|
||||
MAN1 = cmd/wm/wmii.1 cmd/wm/wmiiwm.1 \
|
||||
cmd/wmiimenu.1 cmd/wmiir.1
|
||||
|
@ -15,10 +15,7 @@ OBJ_r = ${SRC_r:.c=.o}
|
||||
SRC_psel = wmiipsel.c
|
||||
OBJ_psel = ${SRC_psel:.c=.o}
|
||||
|
||||
SRC_warp = wmiiwarp.c
|
||||
OBJ_warp = ${SRC_warp:.c=.o}
|
||||
|
||||
all: wmiimenu wmiir wmiipsel wmiiwarp
|
||||
all: wmiimenu wmiir wmiipsel
|
||||
@echo built wmii commands
|
||||
|
||||
.c.o:
|
||||
|
@ -9,8 +9,7 @@ LDFLAGS += -L../../liblitz -llitz -L../../libixp -lixp -L../../libcext -lcext
|
||||
# Solaris
|
||||
# LDFLAGS += -lsocket
|
||||
|
||||
SRC = area.c bar.c fs.c wm.c kb.c client.c event.c mouse.c page.c\
|
||||
column.c spawn.c
|
||||
SRC = area.c bar.c fs.c wm.c kb.c client.c event.c mouse.c page.c column.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: wmiiwm
|
||||
|
@ -369,6 +369,7 @@ void
|
||||
attach_client(Client *c)
|
||||
{
|
||||
Page *p;
|
||||
char buf[32];
|
||||
if(!page)
|
||||
p = alloc_page();
|
||||
else
|
||||
@ -389,6 +390,9 @@ attach_client(Client *c)
|
||||
map_client(c);
|
||||
XMapWindow(dpy, c->frame.win);
|
||||
focus_client(c);
|
||||
snprintf(buf, sizeof(buf), "CA %d %d %d %d\n", c->frame.rect.x, c->frame.rect.y,
|
||||
c->frame.rect.width, c->frame.rect.height);
|
||||
broadcast_event(buf);
|
||||
}
|
||||
|
||||
void
|
||||
@ -574,7 +578,6 @@ client_to_index(Client *c)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
select_client(Client *c, char *arg)
|
||||
{
|
||||
|
@ -242,12 +242,6 @@ handle_maprequest(XEvent *e)
|
||||
return;
|
||||
}
|
||||
|
||||
/* attach heuristic support */
|
||||
if(aqsz && aq[0]) {
|
||||
focus_page(0);
|
||||
cext_array_detach((void **)aq, aq[0], &aqsz);
|
||||
}
|
||||
|
||||
/* there're client which send map requests twice */
|
||||
c = win_to_client(ev->window);
|
||||
if(!c)
|
||||
|
@ -1064,14 +1064,15 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
attach_detached_client();
|
||||
else if(!strncmp(buf, "select", 6))
|
||||
select_page(&buf[7]);
|
||||
else if(!strncmp(buf, "warp ", 5)) {
|
||||
char *err;
|
||||
if((err = warp_mouse(&buf[5])))
|
||||
return err;
|
||||
}
|
||||
else
|
||||
return Enocommand;
|
||||
break;
|
||||
case Dpage:
|
||||
if(!strncmp(buf, "exec ", 5)) {
|
||||
aq = (Page **)cext_array_attach((void **)aq, page[i1], sizeof(Page *), &aqsz);
|
||||
spawn(&buf[5]);
|
||||
}
|
||||
break;
|
||||
case Darea:
|
||||
if(!strncmp(buf, "select ", 7)) {
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "wm.h"
|
||||
@ -625,3 +626,25 @@ ungrab_mouse(Window w, unsigned long mod, unsigned int button)
|
||||
XUngrabButton(dpy, button, mod | num_lock_mask | LockMask, w);
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
warp_mouse(char *arg)
|
||||
{
|
||||
const char *errstr;
|
||||
char *sx = arg, *sy;
|
||||
unsigned int x, y;
|
||||
sy = strchr(sx, ' ');
|
||||
if(!sy)
|
||||
return "invalid argument";
|
||||
*sy = 0;
|
||||
sy++;
|
||||
x = cext_strtonum(sx, 0, rect.width, &errstr);
|
||||
if(errstr)
|
||||
return "invalid x argument";
|
||||
y = cext_strtonum(sy, 0, rect.height, &errstr);
|
||||
if(errstr)
|
||||
return "invalid y argument";
|
||||
XWarpPointer(dpy, None, root, 0, 0, 0, 0, x, y);
|
||||
XSync(dpy, False);
|
||||
return nil;
|
||||
}
|
||||
|
@ -10,20 +10,6 @@
|
||||
|
||||
#include "wm.h"
|
||||
|
||||
/*
|
||||
static void select_client(void *obj, char *arg);
|
||||
static void xexec(void *obj, char *arg);
|
||||
*/
|
||||
|
||||
/* action table for /?/ namespace */
|
||||
/*
|
||||
Action page_acttbl[] = {
|
||||
{"swap", swap_client},
|
||||
{"select", select_client},
|
||||
{0, 0}
|
||||
};
|
||||
*/
|
||||
|
||||
Page *
|
||||
alloc_page()
|
||||
{
|
||||
@ -44,14 +30,6 @@ void
|
||||
destroy_page(Page *p)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t naqueue = 0;
|
||||
|
||||
for(i = 0; (i < aqsz) && aq[i]; i++)
|
||||
if(aq[i] == p)
|
||||
naqueue++;
|
||||
for(i = 0; i < naqueue; i++)
|
||||
cext_array_detach((void **)aq, p, &aqsz);
|
||||
|
||||
for(i = 0; i < p->narea; i++)
|
||||
destroy_area(p->area[i]);
|
||||
free(p->area);
|
||||
@ -61,12 +39,15 @@ destroy_page(Page *p)
|
||||
|
||||
cext_array_detach((void **)page, p, &pagesz);
|
||||
npage--;
|
||||
|
||||
for(i = 0; i < npage; i++) {
|
||||
if(page[i]->revert == p)
|
||||
page[i]->revert = nil;
|
||||
XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
|
||||
32, PropModeReplace, (unsigned char *) &i, 1);
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
for(i = 0; i < npage; i++);
|
||||
XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
|
||||
32, PropModeReplace, (unsigned char *) &i, 1);
|
||||
|
||||
if(npage)
|
||||
focus_page(page[sel]);
|
||||
else
|
||||
@ -96,6 +77,9 @@ focus_page(Page *p)
|
||||
|
||||
return;
|
||||
}
|
||||
if(sel == i)
|
||||
return;
|
||||
page[i]->revert = page[sel];
|
||||
sel = i;
|
||||
for(i = 0; i < nclient; i++) {
|
||||
c = client[i];
|
||||
@ -179,4 +163,3 @@ select_page(char *arg)
|
||||
}
|
||||
focus_page(page[new]);
|
||||
}
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "wm.h"
|
||||
|
||||
void
|
||||
spawn(char *cmd)
|
||||
{
|
||||
if(fork() == 0) {
|
||||
if(fork() == 0) {
|
||||
setsid();
|
||||
close(ConnectionNumber(dpy));
|
||||
execlp("rc", "rc", "-c", cmd, (char *) 0);
|
||||
perror("failed");
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
wait(0);
|
||||
}
|
@ -629,10 +629,9 @@ main(int argc, char *argv[])
|
||||
ixp_server_open_conn(&srv, ConnectionNumber(dpy), check_x_event, nil);
|
||||
init_x_event_handler();
|
||||
|
||||
ndet = npage = nclient = aqsz = detsz = pagesz = clientsz = sel = 0;
|
||||
ndet = npage = nclient = detsz = pagesz = clientsz = sel = 0;
|
||||
page = nil;
|
||||
client = det = nil;
|
||||
aq = nil;
|
||||
|
||||
key = nil;
|
||||
keysz = nkey = 0;
|
||||
|
@ -75,6 +75,7 @@ struct Page {
|
||||
size_t areasz;
|
||||
size_t narea;
|
||||
size_t sel;
|
||||
Page *revert;
|
||||
};
|
||||
|
||||
struct Client {
|
||||
@ -137,8 +138,6 @@ Page **page;
|
||||
size_t npage;
|
||||
size_t pagesz;
|
||||
size_t sel;
|
||||
Page **aq;
|
||||
size_t aqsz;
|
||||
Client **det;
|
||||
size_t ndet;
|
||||
size_t detsz;
|
||||
@ -258,6 +257,7 @@ Align xy_to_align(XRectangle * rect, int x, int y);
|
||||
void drop_move(Client *c, XRectangle *new, XPoint *pt);
|
||||
void grab_mouse(Window w, unsigned long mod, unsigned int button);
|
||||
void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
|
||||
char *warp_mouse(char *arg);
|
||||
|
||||
/* page.c */
|
||||
Page *alloc_page();
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include "cext.h"
|
||||
|
||||
static char version[] = "wmiiwarp - " VERSION ", (C)opyright MMIV-MMVI Anselm R. Garbe\n";
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "%s", "usage: wmiiwarp <x> <y> [-v]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Display *dpy;
|
||||
int x, y;
|
||||
const char *errstr;
|
||||
|
||||
/* command line args */
|
||||
if(argc < 2)
|
||||
usage();
|
||||
if(!strncmp(argv[1], "-v", 2)) {
|
||||
fprintf(stdout, "%s", version);
|
||||
exit(0);
|
||||
}
|
||||
dpy = XOpenDisplay(0);
|
||||
if(!dpy) {
|
||||
fprintf(stderr, "%s", "wmiiwarp: cannot open display\n");
|
||||
exit(1);
|
||||
}
|
||||
if((argc == 2) && !strncmp(argv[1], "center", 7)) {
|
||||
x = DisplayWidth(dpy, DefaultScreen(dpy)) / 2;
|
||||
y = DisplayHeight(dpy, DefaultScreen(dpy)) / 2;
|
||||
} else if(argc == 3) {
|
||||
x = cext_strtonum(argv[1], 0, DisplayWidth(dpy, DefaultScreen(dpy)), &errstr);
|
||||
if(errstr) {
|
||||
fprintf(stderr, "wmiiwarp: invalid x value: '%s'\n", errstr);
|
||||
usage();
|
||||
}
|
||||
y = cext_strtonum(argv[2], 0, DisplayHeight(dpy, DefaultScreen(dpy)), &errstr);
|
||||
if(errstr) {
|
||||
fprintf(stderr, "wmiiwarp: invalid y value: '%s'\n", errstr);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
XWarpPointer(dpy, None, RootWindow(dpy, DefaultScreen(dpy)),
|
||||
0, 0, 0, 0, x, y);
|
||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XCloseDisplay(dpy);
|
||||
return 0;
|
||||
}
|
@ -112,6 +112,8 @@ while(event=`{read}) {
|
||||
text=`{echo $"event | sed 's/^CN //g'}
|
||||
xwrite /bar/2/data $"text
|
||||
}
|
||||
if(~ $event(1) CA)
|
||||
xwrite /ctl 'warp '^`{echo $event(2) + 10 | bc}^' '^`{echo $event(3) + 10 | bc}
|
||||
if(~ $event(1) LB) { # label button press
|
||||
switch($event(3)) { # button
|
||||
case 1
|
||||
|
Loading…
Reference in New Issue
Block a user