You are not logged in.

#51 2009-10-15 17:42:49

meth0dz
Member
Registered: 2009-10-15
Posts: 8

Re: Bare Window Manager (ex-MMWM)

Sure, and yeah I generally just lurk but your project looked pretty cool and you seemed generally excited about it, thought I'd give some input. As for the max_title thing, you may want to change the variable name as that is somewhat misleading.  And if you are only using it for the purpose that you said above, there is no reason to check if the current title is longer than the max_title.  Just do..

max_title = strlen(title);

Really your C just needs touching up, perhaps read a good book.

[e] As far as declaring _most_ functions as int goes, that's alright for debugging.  But in releases you should change functions that don't return things to void.

Last edited by meth0dz (2009-10-15 17:44:11)

Offline

#52 2009-10-15 17:56:24

Lich
Member
Registered: 2009-09-13
Posts: 437

Re: Bare Window Manager (ex-MMWM)

Ok thanks for your interrest, I guess I should pick up K&R from where I left of (already knew that my skills are average, but your post kinda placed me a few rows more towards the bottom). I'm so glad that I never get pissed off when someone proves I suck at something big_smile
BTW switching to c99 doesn't compile, I got a ton of errors, probably because of functions not being c99 compliant. Should I go back, or can you give me some pointers on how to fix this? (some errors are related to your get_window too)

ターミナル (bare-rewrite-03) $ make
cc -Os -Wall -std=c99 -I/usr/include -L/usr/lib -lX11 -o barewm barewm.c
barewm.c:53: error: expected ')' before 'nex_prev'
barewm.c: In function 'sighandler':
barewm.c:90: error: 'WAIT_ANY' undeclared (first use in this function)
barewm.c:90: error: (Each undeclared identifier is reported only once
barewm.c:90: error: for each function it appears in.)
barewm.c: At top level:
barewm.c:150: error: expected ')' before 'nex_prev'
barewm.c: In function 'echo_output':
barewm.c:202: warning: implicit declaration of function 'popen'
barewm.c:202: warning: initialization makes pointer from integer without a cast
barewm.c:211: warning: implicit declaration of function 'pclose'
barewm.c: In function 'main':
barewm.c:570: error: storage size of 'act' isn't known
barewm.c:613: warning: implicit declaration of function 'sigemptyset'
barewm.c:614: error: 'SA_NOCLDSTOP' undeclared (first use in this function)
barewm.c:614: error: 'SA_RESTART' undeclared (first use in this function)
barewm.c:615: warning: implicit declaration of function 'sigaction'
barewm.c:570: warning: unused variable 'act'
make: *** [all] Error 1
ターミナル (bare-rewrite-03) $

Last edited by Lich (2009-10-15 18:09:19)


Archlinux | ratpoison + evilwm | urxvtc | tmux

Offline

#53 2009-10-15 18:42:47

Lich
Member
Registered: 2009-09-13
Posts: 437

Re: Bare Window Manager (ex-MMWM)

Ok, fixed the popen/pclose problems by including

extern FILE *popen (__const char *__command, __const char *__modes) __wur;
extern int pclose (FILE *__stream);

Temporary removed the sighandler part, so now all there's left are the errors about your get_window function. I guess I'll get into it tomorrow morning.
[edit] ok added stdbool.h and it's all fine smile

Last edited by Lich (2009-10-15 18:54:11)


Archlinux | ratpoison + evilwm | urxvtc | tmux

Offline

#54 2009-10-15 20:17:26

meth0dz
Member
Registered: 2009-10-15
Posts: 8

Re: Bare Window Manager (ex-MMWM)

Sorry I missed a semi-colon, this should work (coded it in the reply box).

// true = next, false = previous
int get_window(bool nex_prev)
{
        int x = get_position(selected);
        nex_prev ? x++ :  x--;
        while ( x >= 0 && x < max_windows) {
                if(windows_container[x] != None)
                {
                        LOG_DEBUG("Found next window at: %d\n", x);
                        return x;
                }
                nex_prev ? x++ :  x--;
         }
         return -1;
}

Make sure you are including signal.h, that should eliminate the errors with your sighandler.

Including stdio.h should eliminate your problems with pclose and popen.

Try that stuff and post if you are still having problems.

[e] K&R is a good choice.

Last edited by meth0dz (2009-10-15 20:51:37)

Offline

#55 2009-10-16 10:07:35

Lich
Member
Registered: 2009-09-13
Posts: 437

Re: Bare Window Manager (ex-MMWM)

I am including signal.h and stdio.h, and I still got the errors, that's why I added that stuff, but the sighandler part is simply impossible. I'll look and see where the missing definitions are stored, and just embed those.
Right now working on making the get_window loop if it reaches the end, this will also fix an intentional "bug" that I have when destroying clients, it selects root instead of the next window it finds...
[edit] fixed the destroying part, uploading to git now. Won't fiddle with the get_window() function for now.

Last edited by Lich (2009-10-16 10:35:53)


Archlinux | ratpoison + evilwm | urxvtc | tmux

Offline

#56 2009-10-16 19:35:18

meth0dz
Member
Registered: 2009-10-15
Posts: 8

Re: Bare Window Manager (ex-MMWM)

Those header files should work, check them out.
http://opengroup.org/onlinepubs/0079087 … dio.h.html
http://www.opengroup.org/onlinepubs/009 … nal.h.html

As for the next_window issue, I would suggest that if it fails to finding any windows it should just return the current window.  I'll take another glance through the source in a little bit as well.

[e] I guess since they are non-standard functions (popen & pclose) you aren't really guarenteed to have them in stdio.h.  You may need to grep your headers and see how your header is set up.

Last edited by meth0dz (2009-10-16 19:50:50)

Offline

#57 2009-10-16 20:42:44

meth0dz
Member
Registered: 2009-10-15
Posts: 8

Re: Bare Window Manager (ex-MMWM)

On my next glance through I noticed two new things in addition to things that I mentioned earlier that you haven't dealt with.

1) There is no need for both the LOG (line 74) and LOG_DEBUG (line 82) functions, these can easily be condensed to one function

2) In the function TextWidth (line 101), if you are going to insist on using strlen(), there is no reason to actually do strlen() >= 1.  Just do strlen() as it will return something >= 0.

I'll work on your sighandler.

Offline

Board footer

Powered by FluxBB