mirror of
https://github.com/0intro/wmii
synced 2024-12-26 21:29:45 +03:00
merge
This commit is contained in:
commit
f398f6970a
@ -9,8 +9,8 @@ LDFLAGS += -L../../liblitz -llitz -L../../libixp -lixp -L../../libcext -lcext -
|
||||
# Solaris
|
||||
# LDFLAGS += -lsocket
|
||||
|
||||
SRC = area.c bar.c client.c column.c event.c frame.c fs.c key.c mouse.c \
|
||||
rule.c view.c wm.c
|
||||
SRC = area.c bar.c client.c column.c event.c frame.c fs.c geom.c \
|
||||
key.c mouse.c rule.c view.c wm.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: wmiiwm
|
||||
|
@ -29,7 +29,7 @@ update_client_name(Client *c)
|
||||
if(name.encoding == XA_STRING)
|
||||
cext_strlcpy(c->name, (char *)name.value, sizeof(c->name));
|
||||
else {
|
||||
if(Xi18nTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
||||
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
||||
&& n > 0 && *list)
|
||||
{
|
||||
cext_strlcpy(c->name, *list, sizeof(c->name));
|
||||
|
@ -330,10 +330,10 @@ frame_of_point(XPoint *pt)
|
||||
if(!v)
|
||||
return nil;
|
||||
|
||||
for(a=v->area->next; a && !blitz_ispointinrect(pt->x, pt->y, &a->rect);
|
||||
for(a=v->area->next; a && !ispointinrect(pt->x, pt->y, &a->rect);
|
||||
a=a->next);
|
||||
if(a)
|
||||
for(f=a->frame; f && !blitz_ispointinrect(pt->x, pt->y, &f->rect);
|
||||
for(f=a->frame; f && !ispointinrect(pt->x, pt->y, &f->rect);
|
||||
f=f->anext);
|
||||
return f;
|
||||
}
|
||||
@ -348,7 +348,7 @@ drop_move(Frame *f, XRectangle *new, XPoint *pt)
|
||||
if(!pt)
|
||||
return;
|
||||
|
||||
for(tgt=v->area->next; tgt && !blitz_ispointinrect(pt->x, pt->y, &tgt->rect);
|
||||
for(tgt=v->area->next; tgt && !ispointinrect(pt->x, pt->y, &tgt->rect);
|
||||
tgt=tgt->next);
|
||||
if(tgt) {
|
||||
if(pt->x < 16) {
|
||||
|
@ -72,7 +72,7 @@ handle_buttonrelease(XEvent *e)
|
||||
static char buf[32];
|
||||
if(ev->window == barwin) {
|
||||
for(b=bar; b; b=b->next)
|
||||
if(blitz_ispointinrect(ev->x, ev->y, &b->rect)) {
|
||||
if(ispointinrect(ev->x, ev->y, &b->rect)) {
|
||||
snprintf(buf, sizeof(buf), "BarClick %s %d\n",
|
||||
b->name, ev->button);
|
||||
write_event(buf);
|
||||
@ -101,7 +101,7 @@ handle_buttonpress(XEvent *e)
|
||||
do_mouse_resize(c, CENTER);
|
||||
break;
|
||||
case Button3:
|
||||
do_mouse_resize(c, blitz_quadofcoord(&c->rect, ev->x, ev->y));
|
||||
do_mouse_resize(c, quadofcoord(&c->rect, ev->x, ev->y));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1437,7 +1437,7 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
XRectangle new;
|
||||
f = FRAME(i3);
|
||||
new = f->rect;
|
||||
blitz_strtorect(&new, buf);
|
||||
strtorect(&new, buf);
|
||||
if(new.width == 0)
|
||||
new.width = rect.width;
|
||||
if(new.height == 0)
|
||||
|
@ -4,14 +4,11 @@
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cext.h>
|
||||
|
||||
#include "blitz.h"
|
||||
#include "wm.h"
|
||||
|
||||
BlitzAlign
|
||||
blitz_quadofcoord(XRectangle *rect, int x, int y)
|
||||
quadofcoord(XRectangle *rect, int x, int y)
|
||||
{
|
||||
BlitzAlign ret = 0;
|
||||
x -= rect->x;
|
||||
@ -29,15 +26,16 @@ blitz_quadofcoord(XRectangle *rect, int x, int y)
|
||||
return ret;
|
||||
}
|
||||
|
||||
Bool blitz_ispointinrect(int x, int y, XRectangle * r)
|
||||
Bool
|
||||
ispointinrect(int x, int y, XRectangle * r)
|
||||
{
|
||||
return (x >= r->x) && (x <= r->x + r->width)
|
||||
&& (y >= r->y) && (y <= r->y + r->height);
|
||||
}
|
||||
|
||||
|
||||
/* Syntax: <x> <y> <width> <height> */
|
||||
int blitz_strtorect(XRectangle *r, const char *val)
|
||||
int
|
||||
strtorect(XRectangle *r, const char *val)
|
||||
{
|
||||
XRectangle new;
|
||||
if (!val)
|
@ -322,6 +322,11 @@ unsigned long long pack_qpath(unsigned char type, unsigned short i1,
|
||||
void write_event(char *event);
|
||||
void new_ixp_conn(IXPConn *c);
|
||||
|
||||
/* geom.c */
|
||||
BlitzAlign quadofcoord(XRectangle *rect, int x, int y);
|
||||
Bool ispointinrect(int x, int y, XRectangle * r);
|
||||
int strtorect(XRectangle *r, const char *val);
|
||||
|
||||
/* key.c */
|
||||
void handle_key(Window w, unsigned long mod, KeyCode keycode);
|
||||
void update_keys();
|
||||
|
@ -6,7 +6,7 @@ include ../config.mk
|
||||
CFLAGS += -I../libixp -I../libcext
|
||||
LDFLAGS += -L../libixp -lixp -L../libcext -lcext
|
||||
|
||||
SRC = color.c font.c draw.c geometry.c
|
||||
SRC = blitz.c color.c font.c draw.c window.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: liblitz.a
|
||||
|
20
liblitz/blitz.c
Normal file
20
liblitz/blitz.c
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include "blitz.h"
|
||||
|
||||
/* blitz.c */
|
||||
void
|
||||
blitz_init(Blitz *blitz, Display *dpy)
|
||||
{
|
||||
blitz->display = dpy;
|
||||
blitz->screen = DefaultScreen(dpy);
|
||||
blitz->root = DefaultRootWindow(dpy);
|
||||
}
|
||||
|
||||
void
|
||||
blitz_deinit(Blitz *blitz)
|
||||
{
|
||||
}
|
@ -9,20 +9,8 @@
|
||||
#define BLITZ_FONT "fixed"
|
||||
#define BLITZ_SELCOLORS "#ffffff #335577 #447799"
|
||||
#define BLITZ_NORMCOLORS "#222222 #eeeeee #666666"
|
||||
|
||||
/*
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
#define Xi18nTextPropertyToTextList Xutf8TextPropertyToTextList
|
||||
#define Xi18nDrawString Xutf8DrawString
|
||||
#define Xi18nTextExtents Xutf8TextExtents
|
||||
#else
|
||||
*/
|
||||
#define Xi18nTextPropertyToTextList XmbTextPropertyToTextList
|
||||
#define Xi18nDrawString XmbDrawString
|
||||
#define Xi18nTextExtents XmbTextExtents
|
||||
/*
|
||||
#endif
|
||||
*/
|
||||
#define BLITZ_FRAME_MASK SubstructureRedirectMask | SubstructureNotifyMask \
|
||||
| ExposureMask | ButtonPressMask | ButtonReleaseMask;
|
||||
|
||||
typedef enum {
|
||||
NORTH = 0x01,
|
||||
@ -71,7 +59,27 @@ int blitz_loadcolor(Display *dpy, BlitzColor *c, int mon, char *colstr);
|
||||
void blitz_drawlabel(Display *dpy, BlitzDraw *d);
|
||||
void blitz_drawborder(Display *dpy, BlitzDraw *d);
|
||||
|
||||
/* geometry.c */
|
||||
int blitz_strtorect(XRectangle *r, const char *val);
|
||||
BlitzAlign blitz_quadofcoord(XRectangle *rect, int x, int y);
|
||||
Bool blitz_ispointinrect(int x, int y, XRectangle *r);
|
||||
/* new stuff */
|
||||
|
||||
typedef struct {
|
||||
Display *display;
|
||||
int screen;
|
||||
Window root;
|
||||
} Blitz;
|
||||
|
||||
typedef struct {
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
XRectangle rect;
|
||||
} BlitzWindow;
|
||||
|
||||
/* blitz.c */
|
||||
void blitz_init(Blitz *blitz, Display *dpy);
|
||||
void blitz_deinit(Blitz *blitz);
|
||||
|
||||
/* window.c */
|
||||
void blitz_create_win(Blitz *blitz, BlitzWindow *win, unsigned long mask,
|
||||
int x, int y, int w, int h);
|
||||
void blitz_resize_win(Blitz *blitz, BlitzWindow *win,
|
||||
int x, int y, int w, int h);
|
||||
void blitz_destroy_win(Blitz *blitz, BlitzWindow *win);
|
||||
|
@ -110,7 +110,7 @@ xdrawtext(Display *dpy, BlitzDraw *d)
|
||||
break;
|
||||
}
|
||||
if(d->font.set)
|
||||
Xi18nDrawString(dpy, d->drawable, d->font.set, d->gc, x, y, text, len);
|
||||
XmbDrawString(dpy, d->drawable, d->font.set, d->gc, x, y, text, len);
|
||||
else
|
||||
XDrawString(dpy, d->drawable, d->gc, x, y, text, len);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ blitz_textwidth(Display *dpy, BlitzFont *font, char *text)
|
||||
{
|
||||
if(font->set) {
|
||||
XRectangle r;
|
||||
Xi18nTextExtents(font->set, text, strlen(text), nil, &r);
|
||||
XmbTextExtents(font->set, text, strlen(text), nil, &r);
|
||||
return r.width;
|
||||
}
|
||||
return XTextWidth(font->xfont, text, strlen(text));
|
||||
|
43
liblitz/window.c
Normal file
43
liblitz/window.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cext.h>
|
||||
|
||||
#include "blitz.h"
|
||||
|
||||
void
|
||||
blitz_create_win(Blitz *blitz, BlitzWindow *win, unsigned long mask,
|
||||
int x, int y, int w, int h)
|
||||
{
|
||||
XSetWindowAttributes wa;
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = mask;
|
||||
|
||||
win->drawable = XCreateWindow(blitz->display, blitz->root,
|
||||
x, y, w, h, 0, DefaultDepth(blitz->display, blitz->screen),
|
||||
CopyFromParent, DefaultVisual(blitz->display, blitz->screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
win->gc = XCreateGC(blitz->display, win->drawable, 0, 0);
|
||||
win->rect.x = x;
|
||||
win->rect.y = y;
|
||||
win->rect.width = w;
|
||||
win->rect.height = h;
|
||||
}
|
||||
|
||||
void
|
||||
blitz_resize_win(Blitz *blitz, BlitzWindow *win, int x, int y, int w, int h)
|
||||
{
|
||||
XMoveResizeWindow(blitz->display, win->drawable, x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
blitz_destroy_win(Blitz *blitz, BlitzWindow *win)
|
||||
{
|
||||
XFreeGC(blitz->display, win->gc);
|
||||
XDestroyWindow(blitz->display, win->drawable);
|
||||
free(win);
|
||||
}
|
Loading…
Reference in New Issue
Block a user