[dev] [dwm] [PATCH] iscentered: Center client on monitor

2014-01-23 Thread Chris Down
This is a tiny patch to add client centering support, which I am using
to hack up scratchpad functionality elsewhere.

Obviously this is only really useful if c->isfloating is also True.

I hacked this patch into my current configuration, so it is not tested
verbatim, but it should work when applied to vanilla dwm.
diff --git a/config.def.h b/config.def.h
index 875885b..2e3a9fb 100644
--- a/config.def.h
+++ b/config.def.h
@@ -21,9 +21,9 @@ static const Rule rules[] = {
 *  WM_CLASS(STRING) = instance, class
 *  WM_NAME(STRING) = title
 */
-   /* class  instancetitle   tags mask isfloating   
monitor */
-   { "Gimp", NULL,   NULL,   0,True,-1 },
-   { "Firefox",  NULL,   NULL,   1 << 8,   False,   -1 },
+   /* class  instancetitle   tags mask iscentered 
isfloating   monitor */
+   { "Gimp", NULL,   NULL,   0,False, 
True,-1 },
+   { "Firefox",  NULL,   NULL,   1 << 8,   False, 
False,   -1 },
 };
 
 /* layout(s) */
diff --git a/dwm.c b/dwm.c
index 1bbb4b3..a8a3356 100644
--- a/dwm.c
+++ b/dwm.c
@@ -91,7 +91,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
-   Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+   Bool isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate, 
isfullscreen;
Client *next;
Client *snext;
Monitor *mon;
@@ -136,6 +136,7 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
+   Bool iscentered;
Bool isfloating;
int monitor;
 } Rule;
@@ -294,6 +295,7 @@ applyrules(Client *c) {
&& (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance)))
{
+   c->iscentered = r->iscentered;
c->isfloating = r->isfloating;
c->tags |= r->tags;
for(m = mons; m && m->num != r->monitor; m = m->next);
@@ -1038,6 +1040,11 @@ manage(Window w, XWindowAttributes *wa) {
   && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : 
c->mon->my);
c->bw = borderpx;
 
+   if(c->iscentered) {
+   c->x = (c->mon->mw - WIDTH(c)) / 2;
+   c->y = (c->mon->mh - HEIGHT(c)) / 2;
+   }
+
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->rgb);


pgp0kw4p37buX.pgp
Description: PGP signature


Re: [dev] [PATCH] update years in copyright notices

2014-01-23 Thread Martti Kühne
Hmm. How about reading the last commit year from the master branch
over network...?
You could add a git hook for these things as well.

cheers!
mar77i



[dev] swc: A small Wayland compositor

2014-01-23 Thread Michael Forney
Hi suckless,

As discussed in the previous thread (swc library to implement dwm under
Wayland), I've been working on a Wayland compositor library, and after
several redesigns, I'm pretty happy with where it is now.

You can find the source here: https://github.com/michaelforney/swc

There is still some more work to be done, in particular moving/resizing
windows with the mouse, and more careful handling of special window
states (for example transient and fullscreen). However, for basic usage
it should work fine.

Here is the current output of sloccount:

SLOCDirectory   SLOC-by-Language (Sorted)
5801libswc  ansic=5801
533 launch  ansic=533
409 cursor  ansic=409

launch/ contains code for swc-launch, a privileged launcher that handles
VTs, managing DRM master, and opening/revoking input devices. cursor/
contains a program taken from wayland to extract cursors from the X
server cursor font.

As far as dependencies go, currently you need wayland, libdrm, libevdev,
libxkbcommon, pixman, and wld[0]. wld contains the buffer management and
rendering code used by swc and Wayland versions of st and dmenu.

Optionally, you can use libudev for input hotplugging. This is the only
way I know to accomplish this, and I am open to suggestions for
alternatives (I'd still like to remain compatible with systems running
udevd though).

I'd also like suggestions for how to deal with configuration for things
like what settings to use for XKB (keyboard layout, etc). This is a
per-user setting, so I don't think setting it in a config.h would be
appropriate.

I have not begun any process of porting/rewriting dwm to use swc. I
figured I'd see where people want to go from here. One potential
obstacle that might show up is the status bar. Since with swc the window
manager is in the same process as the compositor, currently the status
bar would have to go in to a separate process. I accomplished this in
the video below by adding a protocol extension which can notify clients
when certain things happen in the window manager (like workspace or
focus change). I'm not sure if this is the best approach though.

I made a demo video showing some of swc's features (as well as Wayland
st and dmenu) here: http://www.youtube.com/watch?v=5thcLnLHkjs&hd=1

The window manager used in the video is one that I started quite a while
ago, which I hacked up to use swc instead. It suits my needs for
developing swc, but I'd like to see what others can come up with! The
public API is available in swc.h[1].

Comments, questions, and criticism are welcome! You can find me on
freenode or OFTC under the nick tridactyla.

[0]: https://github.com/michaelforney/wld
[1]: https://github.com/michaelforney/swc/blob/master/libswc/swc.h

-- 
Michael Forney 



Re: [dev] swc: A small Wayland compositor

2014-01-23 Thread Bobby Powers
Hi,

Michael Forney wrote:
> As discussed in the previous thread (swc library to implement dwm under
> Wayland), I've been working on a Wayland compositor library, and after
> several redesigns, I'm pretty happy with where it is now.

This is very exciting.  I hope to play with this in the next few days.

yours,
Bobby