304 Commits

Author SHA1 Message Date
Raphael Khaiat
0e8634fbe4 Fix bug #104 found by pistache 2011-03-24 13:34:47 +01:00
Raphael Khaiat
df4e32f4f9 Fix feature expose when there is no client on the screen.
Bug found by pistache
2011-03-24 13:05:37 +01:00
Viet Nguyen Quoc
6372f3974c Fix "flick" when new client is not in current tag 2011-03-23 14:15:19 +01:00
Raphael Khaiat
703974cb00 Add the keybind client_set_master in the default wmfsrc 2011-03-23 13:55:54 +01:00
Viet Nguyen Quoc
4064cbdfd9 Add client_set_master command
The function swaps selected client with the first one (master).
2011-03-23 13:49:23 +01:00
Raphael Khaiat
a7f9bf65ff Fix "expose" feature by adding "request_update" to all tags of the
screen
2011-03-23 13:42:53 +01:00
Raphael Khaiat
79928efd35 Delete useless function 2011-03-22 14:08:59 +01:00
Raphael Khaiat
b1a52a3a6b Fix "expose feature" 2011-03-22 14:07:53 +01:00
Raphael Khaiat
41c4570dcf Add "expose" feature ala mac OS X to display all client of a screen
Feature #100 requested by shibo
2011-03-21 13:28:15 +01:00
Paride Legovini
5ece3a6e55 focus_follow_movement caused flickering, fixed.
When using focus_follow_movement, client_focus() should be called only
if the target client is unfocused. Calling client_focus() on every motion
event causes an ugly flickering of the window.

Signed-off-by: Raphael Khaiat <raphael@khaiat.org>
2011-03-11 17:18:00 +01:00
Raphael Khaiat
4d39413f56 Merge branch 'master' into bacardi55 2011-03-11 17:17:19 +01:00
Martin Duquesnoy
8bc30628c3 Client: Fix client closing from additional tag 2011-03-06 02:20:49 +01:00
Martin Duquesnoy
041e9ec20d Event/conf: Add focus_follow_movement [misc] option requested by pl_ 2011-02-25 19:22:29 +01:00
Martin Duquesnoy
1e35777c18 Client: Add client_screen_set uicb function requested by 0x1 2011-02-25 11:11:33 +01:00
Raphael Khaiat
3ca201c42a Delete deprecated option raiseswitch 2011-02-23 23:22:11 +01:00
Raphael Khaiat
34f2cb5b03 Merge branch 'master' of github.com:xorg62/wmfs into bacardi55 2011-02-23 23:19:40 +01:00
Raphael Khaiat
946e4c1606 Remove double follow_client entry in the rule section of the wmfsrc 2011-02-23 23:19:06 +01:00
Clément Bœsch
6291639b24 Remove a lot of static declarations
A lot of functions are also moved in the process.
2011-02-23 22:37:42 +01:00
Clément Bœsch
6a0eedb63c Make a bunch of stuff static 2011-02-23 22:37:13 +01:00
Clément Bœsch
22c9eee9af Remove unused functions 2011-02-23 22:37:13 +01:00
Clément Bœsch
7d66c50676 Cosmetic 2011-02-23 22:37:13 +01:00
Clément Bœsch
9766392332 Avoid overflow on ret 2011-02-23 21:53:40 +01:00
Clément Bœsch
d79404f5ee Avoid last ret char not being zero after strncpy 2011-02-23 21:53:40 +01:00
Clément Bœsch
f5134bd6b3 Option -W is deprecated; -Wextra is its replacement 2011-02-23 21:53:40 +01:00
Martin Duquesnoy
d213d13784 Barwin/Frame: Optimization of saikobee feature 2011-02-23 15:15:31 +01:00
Martin Duquesnoy
57019236aa Merge https://github.com/saikobee/wmfs 2011-02-23 14:15:56 +01:00
Brian Mock
ac00fefaa9 Fixed tag bar border drawing 2011-02-23 00:51:50 -08:00
Brian Mock
ddcdf6ce83 Tag background wasn't shaded properly 2011-02-22 23:25:39 -08:00
Brian Mock
9235775dd2 Final touches, including wmfsrc default options 2011-02-22 19:37:06 -08:00
Brian Mock
971fb3240a Should work... but no compile 2011-02-22 15:37:50 -08:00
Brian Mock
bd1575e1b2 Fixed some bad whitespace in config.c 2011-02-22 14:05:46 -08:00
Brian Mock
83d2da9da6 Added comments to all my color.c functions 2011-02-22 13:02:40 -08:00
Brian Mock
3be59059f4 Shading seems to work, still need to add config 2011-02-22 12:35:42 -08:00
Raphael Khaiat
891ba6d866 Fix client_tile_raise feature 2011-02-22 14:47:32 +01:00
Brian Mock
5729fe95fb Fixed style on "if" 2011-02-21 16:30:23 -08:00
Brian Mock
43686dc82c Fixed licensing info to use my name 2011-02-21 16:28:38 -08:00
Brian Mock
d1f400e940 Forgot license info 2011-02-21 16:23:56 -08:00
Brian Mock
16120744a8 Added color functions 2011-02-21 16:20:02 -08:00
Martin Duquesnoy
e2942ec597 Client: Fix raise of client when maximize 2011-02-21 12:54:42 +01:00
Martin Duquesnoy
bf26e8c22e Client: Add new_client_get_mouse feature requested by thechitowncubs 2011-02-21 03:20:58 +01:00
Raphael Khaiat
4898e07e5e Fix typo in wmfsrc about the status_path 2011-02-19 02:13:11 +01:00
Raphael Khaiat
ff7853738f Merge branch 'master' into bacardi55 2011-02-19 02:09:58 +01:00
Raphael Khaiat
7180d733bd Correct previous feature for raising tiled client 2011-02-16 19:20:58 +01:00
Raphael Khaiat
325f115c09 Add feature for raising tile client over free client when selected.
Feature requested by bacardi55 :)
2011-02-15 19:10:10 +01:00
Martin Duquesnoy
f48b9651c9 Fix mod of configure 2011-02-15 18:12:22 +01:00
Martin Duquesnoy
dcf3979c00 Add removed things from bacadi55 commits 2011-02-15 17:59:25 +01:00
Martin Duquesnoy
db98e3978b Client: Swap tag in client_swap if c1->tag != c2->tag 2011-02-15 17:57:24 +01:00
Raphael Khaiat
3cc68b6872 Delete unused param 2011-02-14 18:42:23 +01:00
Raphael Khaiat
45e796406b Add unused function and comments in the wmfsrc 2011-02-14 18:39:50 +01:00
Raphael Khaiat
f91699d6bc Add function about changing screen in the default wmfsrc 2011-02-02 18:43:04 +01:00
Raphael Khaiat
7d391f47f5 Merge branch 'master' into bacardi55 2011-02-01 20:54:56 +01:00
David Delassus
aa3f2b7fd0 Fix _WMFS_FONT, bug #83
Signed-off-by: Raphael Khaiat <raphael@khaiat.org>
2011-01-31 13:58:34 +01:00
Raphael Khaiat
2e4c8bd202 Merge branch 'bacardi55' of github.com:xorg62/wmfs into bacardi55 2011-01-26 13:37:21 +01:00
Raphael Khaiat
741002b724 remove bug if there is only one screen and screen_next is called
(used to unselect all client of the screen)
2011-01-26 13:35:54 +01:00
Raphael Khaiat
c8e5ac4619 Feature #79 : add a keybind to toggle the display of the infobar.
Feature requested by litemotiv
2011-01-24 23:50:52 +01:00
Raphael Khaiat
07ad0c6263 Merge branch 'bacardi55' of github.com:xorg62/wmfs into bacardi55 2011-01-24 08:51:46 +01:00
Raphael Khaiat
41cc6944ae Merge branch 'bacardi55' of github.com:xorg62/wmfs into bacardi55 2011-01-23 23:59:30 +01:00
Raphael Khaiat
48e226f5ae Merge branch 'master' into bacardi55 2011-01-23 23:58:39 +01:00
Raphael Khaiat
3652a4060c Add feature for following a client that is open in a different tag.
Feature requested by anonymous_user on the wmfs thread in the
archlinux.org forum
2011-01-23 23:56:21 +01:00
Raphael Khaiat
b4e33395b3 Merge branch 'master' into bacardi55 2011-01-21 16:10:28 +01:00
Philippe Pepiot
d0bb69150a Clean thread/spawn/signal usage in wmfs
- Don't create 2 thread
- Don't create status thread when conf.status_timing == 0
- Don't launch status script if still running
- Remove double fork() hack in spawn()
- Wait childs properly
- mutex on conf.status_pid and sig_chld variable, thread-safe and
  signal-safe
- Set exiting variable volatile, signal-safe
- Use sigaction instead of signal

TODO: set mutex for exiting variable because this is not thread-safe
2011-01-20 11:32:29 +01:00
Martin Duquesnoy
7e0436ffdc Systray: Replace zcalloc with xcalloc (potential bug) 2011-01-17 20:19:25 +01:00
Martin Duquesnoy
c8c210bcac Wmfs: Fix typo 2011-01-15 20:59:19 +01:00
Martin Duquesnoy
993b408262 Apply Almito's patchs for xcompmgr opacity support (#70), skype focus bug (#66) and fix for #68 & #69 2011-01-15 20:55:13 +01:00
Raphael Khaiat
f51d943bd9 Merge branch 'master' into bacardi55 2011-01-14 13:35:11 +01:00
Clément Bœsch
56b6b467ee Avoid fd leak in parse_keywords. 2011-01-12 20:17:57 +01:00
Clément Bœsch
7ac4bf32c2 One memset instead of two.
This also fix the strange sizeof.
2011-01-12 20:17:57 +01:00
Clément Bœsch
b5f24e042f Remove a few check before calling free in parser. 2011-01-12 20:17:57 +01:00
Clément Bœsch
a5432919ca Remove pointless if before calling free.
The free() function frees the memory space pointed to by ptr, which must
have been returned by a previous call to malloc(), calloc() or
realloc().  Otherwise, or if free(ptr) has already been called before,
undefined behavior occurs.  If ptr is NULL, no operation is performed.
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

                                          -- man malloc(3)
2011-01-12 20:17:57 +01:00
Clément Bœsch
c174e69b64 Fix potential crash when using mouse_button_list. 2011-01-12 20:17:56 +01:00
Clément Bœsch
209f9a09a4 Make a bunch of functions static. 2011-01-12 20:17:56 +01:00
Raphael Khaiat
c5dfeb9878 Merge branch 'master' into bacardi55 2011-01-12 15:45:37 +01:00
Raphael Khaiat
3abfe9d7bb Report the correction of the reload event that had been made for the
uicb_reload function
2011-01-12 15:43:01 +01:00
Martin Duquesnoy
27c4c260c6 Client: Revert libvte patch by roidelapluie 2011-01-12 11:26:41 +01:00
Raphael Khaiat
8ea76e1167 Fix reload function (problem due to a bad merge), thanks to Erus 2011-01-10 21:45:11 +01:00
Raphael Khaiat
6ec79f626e Merge branch 'master' into bacardi55 2011-01-10 20:42:15 +01:00
Raphael Khaiat
2320e8586c Implement fixture #63 : auto center option for free client 2011-01-10 20:40:55 +01:00
Raphael Khaiat
c317afc79d Re-arrange code for fix #67 (avoid code duplication) 2011-01-10 20:39:14 +01:00
Martin Duquesnoy
056cb5daf6 Util: Fix spawn 2011-01-10 19:31:42 +01:00
Raphael Khaiat
7bb0fdcbad Fix bug #67 2011-01-08 18:23:11 +01:00
Raphael Khaiat
2273ccc5d5 Let wmfs reload now with the same argument that it was launched with 2011-01-08 18:20:27 +01:00
Martin Duquesnoy
18e97d3e1e Wmfs: Use pthread instead of setitimer 2011-01-08 15:47:19 +01:00
Martin Duquesnoy
9de133dac7 Merge branch 'master' of git.wmfs.info:wmfs 2011-01-08 15:21:59 +01:00
Raphael Khaiat
b1d4e2a403 Merge branch 'bacardi55' of github.com:xorg62/wmfs into bacardi55 2011-01-05 19:57:22 +01:00
Raphael Khaiat
8e6cea6d05 Makes code pretyer :) 2011-01-05 19:55:16 +01:00
bacardi55@gmail.com
03c41f9b3b Add option (tag_auto_prev) in wmfsrc to disable the auto tag prev
when going twice on the same tag.
2011-01-05 19:51:48 +01:00
Raphael Khaiat
42a0612664 Merge branch 'bacardi55' of github.com:xorg62/wmfs into bacardi55 2011-01-05 01:28:50 +01:00
Raphael Khaiat
fb1627e8cc Fix Feature #22 : set a default tag and/or screen where to send client
that have no tag/screen specific rule. Feature requested by philpep
2011-01-05 01:25:12 +01:00
bacardi55@gmail.com
c8eb002768 Fix tag_prev_sel 2011-01-04 22:53:24 +01:00
bacardi55@gmail.com
0d0c3af47b Merge branch 'master' of github.com:xorg62/wmfs into bacardi55 2011-01-04 22:51:42 +01:00
bacardi55@gmail.com
5b5dd104d9 Merge branch 'bacardi55' of github.com:xorg62/wmfs into bacardi55 2011-01-04 21:13:14 +01:00
Philippe Pepiot
0a2c1f9d13 Use sigaction instead of signal.
SIGCHLD and SIGALRM are now exclusives (one mask other)
2011-01-04 03:02:29 +01:00
Philippe Pepiot
c817b7277b Disable status script timer on reload (instead of ignoring signal) 2011-01-04 01:24:51 +01:00
Philippe Pepiot
99e85cbfc2 Use setitimer instead of alarm 2011-01-04 01:10:27 +01:00
Julien Pivotto
a1ad5685f9 Fix libvte bug when resizing them
Signed-off-by: Raphael Khaiat <raphael@khaiat.org>
2011-01-03 22:27:41 +01:00
Julien Pivotto
abf71d99b9 [PATCH] Add a ignoretags rule 2011-01-03 21:49:25 +01:00
Raphael Khaiat
1460229397 Merge branch 'master' into bacardi55 2011-01-03 21:40:27 +01:00
Martin Duquesnoy
47a68568fe Tag: Fix last feature with tag_round 2011-01-03 21:33:43 +01:00
Martin Duquesnoy
a0fd6a77cc Layout: Fix nmaster ksh bug with tile_right/left 2011-01-03 20:01:04 +01:00
bacardi55@gmail.com
ef6b057234 Merge branch 'master' into bacardi55 2011-01-03 19:42:54 +01:00
Martin Duquesnoy
e32726f008 Tag: Fix infobar position when tag switch with last feature 2011-01-03 19:40:42 +01:00
bacardi55@gmail.com
74bbf0bd04 Merge remote branch 'github/master' into bacardi55 2011-01-02 19:51:36 +01:00
Martin Duquesnoy
b85b6bd687 Tag: Add toggle to prev selected tag if tag is selected two times (requested by addikt1ve) 2011-01-02 19:36:33 +01:00
Julien Pivotto
bf16b4a2e7 Add a 'ignoretags' rule
Signed-off-by: bacardi55@gmail.com <bacardi55@daimadoshi.bacardi55.org>
2010-12-31 15:12:53 +01:00
Philippe Pepiot
f2bd808b86 Fix segfault in parser if options == PARSE_MAX_LIST-1
Reported by Armael
Increase PARSE_MAX_LIST from 10 to 32
2010-12-25 16:25:42 +01:00
bacardi55@gmail.com
f2734a5f2b Correct typo thanks to ubitux 2010-12-19 13:42:39 +01:00
bacardi55@gmail.com
b4fb75806a Merge branch 'master' into bacardi55 2010-12-19 13:14:30 +01:00
Philippe Pepiot
dbe7588c0a Ignore SIGALRM before restart
If new wmfs process receive SIGALRM before set the handler, wmfs quits
Bug found by Erus
2010-12-18 14:58:29 +01:00
Engil Hramn
dae3019185 Fix some error in the manpage and in the information printed by the binary 2010-12-09 17:09:47 +01:00
Raphael Khaiat
3f461810d2 Add engil's patch 2010-12-09 16:01:19 +01:00
Raphael Khaiat
0a708c8dda Merge branch 'master' into bacardi55
Conflicts:
	src/config.c
2010-12-07 19:16:32 +01:00
Philippe Pepiot
6072c2d811 Set default tag params. (patch by bacardi55) fixes #51 2010-12-07 01:38:21 +01:00
Philippe Pepiot
ce3813608c Status script not spawned if still running 2010-12-07 01:34:22 +01:00
Philippe Pepiot
6c332c9ea5 Oops. Fix signal not handled at all 2010-12-07 01:19:28 +01:00
Philippe Pepiot
d606f999f9 Add distclean target (clean && remove Makefile) 2010-12-07 00:30:36 +01:00
Philippe Pepiot
87575a019d Use SIGALRM instead of pthread for status script 2010-12-07 00:28:12 +01:00
Philippe Pepiot
6882cfb986 Only one handler for signals 2010-12-07 00:12:54 +01:00
Philippe Pepiot
9e457b3832 Remove glibc stuffs, wmfs is not ansi C that's a fact 2010-12-06 23:49:42 +01:00
Philippe Pepiot
c8a74878a1 Remove double fork for spawn and kill status with SIGTERM 2010-12-03 16:59:07 +01:00
Philippe Pepiot
d0058146dd Remove non used function get_mouse_pos 2010-12-03 12:36:51 +01:00
Philippe Pepiot
77e458048d Fix tag_new() tag name
possible overflow + random memory access
2010-12-03 11:06:33 +01:00
Raphael Khaiat
f6206d65b1 Merge branch 'master' into bacardi55
Conflicts:
	src/wmfs.c
2010-11-30 00:38:27 +01:00
Philippe Pepiot
c90a5743b3 Parser: Use read() instead of mmap() 2010-11-29 22:08:01 +01:00
Philippe Pepiot
3459ed0b20 Define optarg and optind (was breaking compilation on NetBSD) 2010-11-29 21:17:04 +01:00
Martin Duquesnoy
3cf93a0961 Launcher: Add width_limit option in multi set_launcher section to limit size of launcher window (Requested by s__C) 2010-11-28 13:06:24 +01:00
Martin Duquesnoy
719654fcbc Ewmh: Add _WMFS_FONT property for external information about font 2010-11-26 21:32:28 +01:00
Raphael Khaiat
e053d41a3d Change the default name at empty as it should be 2010-11-21 22:06:55 +01:00
Raphael Khaiat
1170a6afbc Put back the good default value, thanks xorg62 2010-11-21 22:01:43 +01:00
Raphael Khaiat
a42237aab7 Correction of the #51 bug for default_tag value in tag defined in the
wmfsrc without all options.
2010-11-21 21:55:57 +01:00
Raphael Khaiat
f5f2d8c7de Correction for the new function stay_last_tag 2010-11-21 19:58:01 +01:00
Raphael Khaiat
bc31510d64 Merge branch master in bacardi55 2010-11-19 23:41:56 +01:00
Raphael Khaiat
f928497e70 Add "stay_last_tag" fonction/keybind 2010-11-19 20:17:17 +01:00
Philippe Pepiot
daeffb324e Fix possibles segfaults, dead assignment and other division by zero.
Thanks to clang build report
2010-11-19 19:55:57 +01:00
Philippe Pepiot
d75746bcf4 s/strcpy/strncpy and fix somes unused variables 2010-11-19 17:36:37 +01:00
Philippe Pepiot
82b17ea02f Improve allocating system and integrate parser
emalloc remplaced with xcalloc/xmalloc/xrealloc
and easy wrappers for strings zmalloc/zcalloc/zrealloc
 - exit on fail
 - prevent size_t overflow

Integrate parser in src/
2010-11-19 16:42:14 +01:00
Philippe Pepiot
19ecd89d89 End func_list[] with { NULL, NULL } 2010-11-19 14:44:34 +01:00
Philippe Pepiot
c7b2d98303 BuildSystem: fix XDG_CONFIG_DIR issue 2010-11-19 14:35:35 +01:00
Raphael Khaiat
546366b282 Merge master in bacardi55 branch 2010-11-18 19:48:18 +01:00
Raphael Khaiat
20c99826ce Merge branch 'master' into bacardi55
Conflicts:
	src/wmfs.c
2010-11-18 19:47:36 +01:00
Martin Duquesnoy
eda1bfdfec Merge branch 'master' of git.wmfs.info:wmfs 2010-11-18 19:12:35 +01:00
Martin Duquesnoy
22295948ec Ewmh: Remove _NET_WORKAREA support, Fix bug #58 signaled by Kernald. 2010-11-18 19:12:10 +01:00
Philippe Pepiot
c2664e8e85 wmfs compile with -W -Wall -Wextra (TODO: fix types !!) 2010-11-17 02:27:15 +01:00
Raphael Khaiat
e5b2a9e058 Add a uicb function to go to the last tag directly (will probably be
used only by myself ^^)
2010-11-17 01:52:24 +01:00
Philippe Pepiot
b6c557a8ee Declare _POSIX_SOURCE for glib to define kill() 2010-11-17 01:30:35 +01:00
Philippe Pepiot
14f12edf25 Remove non ansi comments 2010-11-17 01:30:12 +01:00
Philippe Pepiot
3d6f8da805 Declare func_list const 2010-11-17 01:24:57 +01:00
Philippe Pepiot
40b4662ff8 Merge branch 'bacardi55' 2010-11-17 00:53:56 +01:00
Raphael Khaiat
8d71b8c2a8 Reload wmfs with exact same argument as it has been launched instead of
just reloading the good wmfsrc (idea from ksh.)
2010-11-16 23:18:18 +01:00
Raphael Khaiat
31899139e4 Revert "Reload wmfs with exact same argument as it has been launched instead of"
This reverts commit 61a1e18a59.
2010-11-16 23:13:47 +01:00
Raphael Khaiat
61a1e18a59 Reload wmfs with exact same argument as it has been launched instead of
just reloading the good wmfsrc (idea from ksh.)
2010-11-16 23:01:18 +01:00
Philippe Pepiot
3d3dbf589f BuildSystem: s/IMLIB2/IMLIB :> (thx to Erus) 2010-11-16 21:28:51 +01:00
Philippe Pepiot
6912599c72 BuildSystem: fix configure erase {C|LD}FLAGS 2010-11-16 19:15:39 +01:00
Philippe Pepiot
1294d7e35c BuildSystem: remove Makefile 2010-11-16 13:15:06 +01:00
Philippe Pepiot
6bd0175db0 BuildSystem: complete rewrite
Should compile properly on Linux, FreeBSD, OpenBSD and NetBSD
2010-11-16 13:09:40 +01:00
Raphael Khaiat
2d9baf78c5 Starting wmfs with an alternate wmfs was possible with wmfs -C
otherWmfsrc but only $HOME/.config/wmfsrc was read when reloading wmfs.
Now, if you start wmfs with -C and a different file, this file will be
reloaded.
2010-11-16 01:09:35 +01:00
Raphael Khaiat
b7ded56ef9 Merge branch 'master' into bacardi55 2010-11-15 20:54:17 +01:00
Raphael Khaiat
7f96a338c6 Merge branch 'master' of git://github.com/xorg62/wmfs 2010-11-15 20:53:59 +01:00
Philippe Pepiot
bfc56f8c37 BuildSystem: default {C|LD}FLAGS for OpenBSD 2010-11-14 19:32:12 +01:00
Philippe Pepiot
d8e2d54d8e BuildSystem: fix install target on OpenBSD 2010-11-14 19:23:41 +01:00
Philippe Pepiot
7096101651 Update README 2010-11-14 15:29:08 +01:00
Philippe Pepiot
103c86db03 BuildSystem: small stuffs
move VERSION to common.mk
Remove obscure {C|LD}_FLAGS
OPTIONS with optional libs and LIBS = ${REQUIRED} ${OPTIONS}
2010-11-14 15:19:36 +01:00
Philippe Pepiot
01bd4cc265 BuildSystem: set HAVE_IMLIB instead of HAVE_IMLIB 2010-11-12 18:14:31 +01:00
Philippe Pepiot
f6ad74273c BuildSystem: fix empty LD_FLAGS cause empty real arg 2010-11-11 22:36:42 +01:00
Philippe Pepiot
c3cf9d64b3 BuildSystem: CFLAGS and LDFLAGS can be customised through command line 2010-11-11 19:27:09 +01:00
Philippe Pepiot
26dde34d5c BuildSystem: create xsession directory 2010-11-11 18:51:25 +01:00
Philippe Pepiot
9ff9c81441 BuildSystem: change default MANPREFIX 2010-11-11 18:42:32 +01:00
Philippe Pepiot
66d1b9b2fb BuildSystem: install wmfsrc in XDG_CONFIG_DIR 2010-11-11 17:19:28 +01:00
Philippe Pepiot
6ac65840c0 BuildSystem: pkg-config optional 2010-11-11 17:13:34 +01:00
Philippe Pepiot
7c9e560236 BuildSystem: Improve detection of optionals libs 2010-11-11 16:33:24 +01:00
Philippe Pepiot
5a05594092 BuildSystem: add BSDMakefile 2010-11-11 16:14:26 +01:00
Philippe Pepiot
eb567d9936 BuildSystem: fix stuff on install 2010-11-09 20:07:29 +01:00
David Delassus
b055908080 Add out-of-tree building (make O=/path -C /path/to/wmfs) 2010-11-09 20:04:19 +01:00
Philippe Pepiot
2614c61657 build: all .o and wmfs depend on config.mk 2010-11-09 19:24:22 +01:00
Philippe Pepiot
52e53c7415 Remove another CMakelist.txt 2010-11-09 18:28:39 +01:00
Philippe Pepiot
e01bb5c3b0 Re use doxygen file (in fact still used /o\) 2010-11-09 18:22:02 +01:00
Philippe Pepiot
a1de32cac7 wmfsrc: Made change announced in f3c0f5492a 2010-11-09 12:36:13 +01:00
Philippe Pepiot
57f8768228 Merge branch 'master' of git.philpep.org:wmfs into nocmake 2010-11-09 12:33:45 +01:00
Philippe Pepiot
f3c0f5492a Parser: fix unused variable 2010-11-09 12:32:48 +01:00
Philippe Pepiot
7db51713e5 Build System: remove cmake
Cmake is bloat and wmfs doesn't need a complex build system
So now wmfs compile with a Makefile using gmake and pkg-config
compilation options can be customised through confix.mk (dwm like)

Remove doxygen config files (wmfs code doesn't use it, and nobody use
doxygen with wmfs)
Replace wmfsrc.in by wmfsrc (change @WMFS_TERM@ and use shell choice
urxvt || xterm || ...)
Remove generation of Changelog file (we can git log > Changelog before
creating a dist package)
Remove README from install process (this file don't need to be included in dist
package)

What's next before merging into master ?
- provide a BSD Makefile
- discuss if we use or not pkg-config (we can document common places
  to include directory and libs in config.mk)
- compile out of tree
2010-11-09 12:15:11 +01:00
Raphael Khaiat
20756b30cd Merge remote branch 'origin/master' into bacardi55 2010-11-01 18:43:10 +01:00
Raphael Khaiat
d242ab880a Merge branch 'bacardi55' 2010-11-01 18:42:40 +01:00
Philippe Pepiot
658e26bd49 parse: detect empty file + fix memleak 2010-10-30 23:16:44 +02:00
Philippe Pepiot
464f06c5c1 parse: typo 2010-10-30 23:11:10 +02:00
Martin Duquesnoy
a0e5ddc45a Ewmh: Apply lukasg's patch for fullscreen flag (Bug #48 fixed, thanks to lukasg) 2010-10-25 13:06:48 +02:00
Martin Duquesnoy
2a9d024784 Config/Infobar: Add occupied_fg option (Requested by s__C) 2010-10-23 16:36:07 +02:00
Martin Duquesnoy
6b788edc38 Tag: Disable prevseltag saving when switching tag to the current tag (bug #57 by Erus) 2010-10-11 20:56:42 +02:00
Raphael Khaiat
8f8d47dc23 Merge branches 'master' and 'bacardi55' into bacardi55 2010-09-19 12:29:03 +02:00
Philippe Pepiot
3a021bf026 Parse: fix segfault 2010-09-05 22:08:38 +02:00
Raphael Khaiat
1ec6d90c1e Merge branch 'master' into bacardi55 2010-09-05 15:13:49 +02:00
Philippe Pepiot
b91db6b431 Parser: free keywords list and free files 2010-08-31 01:55:42 +02:00
Philippe Pepiot
c6469260de Cmake: put default config in XDGCONFDIR 2010-08-31 00:59:35 +02:00
Philippe Pepiot
5aeeae4198 Parse: when syntax error, fallback to default config, fixes #45 2010-08-31 00:55:51 +02:00
Philippe Pepiot
3841e55f82 Parser: Use defined Bool or create one 2010-08-30 19:50:38 +02:00
Philippe Pepiot
4a3952f54f Parser: errors on calloc fail or buffer overflow 2010-08-30 19:37:04 +02:00
Philippe Pepiot
8816bd6753 Spawn: check write() 2010-08-28 23:47:47 +02:00
Philippe Pepiot
3366ec835f Parser and launcher: check asprintf return 2010-08-28 23:44:49 +02:00
Radek Tříška
839ebeaf2b Launcher: autocompletion alphabetical sort from PeVe 2010-08-28 23:26:35 +02:00
Philippe Pepiot
36aa4ce43a Parser: when @include path can be prefixed by "~" or be relative to
parent file directory. refs #21
2010-08-28 21:26:42 +02:00
Philippe Pepiot
4f1742eef9 Parser: recode / independant from wmfs code / @include works, closes #21 2010-08-28 20:40:54 +02:00
Philippe Pepiot
fd9cedd695 Parser: simplification, don't abuse of macros (work in progress) 2010-08-27 03:06:30 +02:00
Tomáš Chvátal
3644bc736b Fix typo in wmfsrc pathspec. 2010-08-23 07:04:51 +02:00
Tomáš Chvátal
1eeb5e167e Fixup one more source/binary dir missmatch 2010-08-23 07:04:46 +02:00
Tomáš Chvátal
a1d134a1b7 Drop duped file. 2010-08-21 20:40:42 +02:00
Tomáš Chvátal
52bfa713df Fix username settings in conf.h 2010-08-21 20:40:23 +02:00
Martin Duquesnoy
3b60e23f9f Remove warning 2010-08-21 20:30:03 +02:00
Tomáš Chvátal
59d9dcdc93 Fixup xinerama define. 2010-08-21 20:29:37 +02:00
Tomáš Chvátal
9055a55d58 Use cmake properly, basically complete cmake build system rewrite.
Signed-off-by: Tomáš Chvátal <scarabeus@gentoo.org>
2010-08-21 15:32:26 +02:00
Martin Duquesnoy
e254f76211 Revert "CMake: Add scarabeus patch (rewrite of CMakeLists.h), fix warning"
This reverts commit e6db51d8fd.
2010-08-21 13:42:30 +02:00
Martin Duquesnoy
e6db51d8fd CMake: Add scarabeus patch (rewrite of CMakeLists.h), fix warning 2010-08-21 13:38:25 +02:00
Martin Duquesnoy
ce4575ee04 Event: Focus client before click on titlebar buttons 2010-08-20 06:19:19 +02:00
Martin Duquesnoy
e9b409b564 Config: Put example in default conf 2010-08-18 23:45:12 +02:00
Martin Duquesnoy
578b62ec09 Update version 2010-08-18 23:43:20 +02:00
Martin Duquesnoy
4f42436098 Config: Apply second patch of mseed/PeVe about conf split: Can comment @include line in conf. 2010-08-18 23:42:31 +02:00
Martin Duquesnoy
dce3b8eb3c Client: Fix screen setting in client_set_attributes 2010-08-18 21:32:39 +02:00
Martin Duquesnoy
ce8238fb20 Client: Fix mistake in function name 2010-08-18 21:29:48 +02:00
Martin Duquesnoy
e9ffab7d62 Client: Fix client_get_prev/next not working when screen switching with mouse 2010-08-18 19:41:47 +02:00
Martin Duquesnoy
cf565c9b57 Config: Apply mseed/PeVe great patch: Add conf split with @include "file". Thanks to Czech WMFS dev team :) 2010-08-18 13:36:55 +02:00
Martin Duquesnoy
179c94f26f Menu: Apply PeVe/mseed path: Menu optimisation/improvment and some fixation 2010-08-13 03:11:44 +02:00
Martin Duquesnoy
5017c4ced5 Config: Apply PeVe/mseed patch: layout_button_width option in [layouts] section. Thanks to them. 2010-08-12 21:58:28 +02:00
Martin Duquesnoy
7b0113ab6e Config: Fix mistaken option 2010-08-12 20:23:09 +02:00
Martin Duquesnoy
dc2e571e5e Config: Fix UGLY mistake (lenght -> length, thanks chacha) 2010-08-12 19:57:00 +02:00
Martin Duquesnoy
5d9ad3e1db Client: Fix mistake 2010-08-10 14:22:03 +02:00
Martin Duquesnoy
695cf69790 Client: Fixed wm_window_role condition in rules function 2010-08-10 14:21:17 +02:00
Martin Duquesnoy
86b20ba799 Client: Fix role usage in rule section 2010-08-10 10:45:01 +02:00
Martin Duquesnoy
ec2c2f6337 Client: Fixes details in client_set_rule 2010-08-10 03:38:53 +02:00
Martin Duquesnoy
5d7f4a2382 Config: Add WM_WINDOW_ROLE match in rule section 2010-08-10 03:22:22 +02:00
Martin Duquesnoy
d8d09f9e1a Struct: Fix mistake in Alias struct 2010-08-10 02:47:14 +02:00
Martin Duquesnoy
a496d77f9e Conf: Add [rules] section. (Feature #34 requested by markand CHACHA) clients option, autofree and automax option are DEPRECATED but works for some revision. 2010-08-10 02:40:06 +02:00
Martin Duquesnoy
7a1bfb48f5 Menu: Set clientlist menu alignement to left for better visibility 2010-08-10 01:37:37 +02:00
Martin Duquesnoy
3e71c420d6 Client: Add "all" cmd option to clientlist uicb function to display all client in menu instead only in current tag 2010-08-10 01:31:23 +02:00
Raphael Khaiat
0eab6d1a92 Merge branch 'master' into bacardi55 2010-08-07 14:44:44 +02:00
Martin Duquesnoy
c63a9af492 Layout: Remove layer layout (was for testing) 2010-08-05 16:06:39 +02:00
Martin Duquesnoy
0c38afdb35 Frame: Fix buttons flags with max and layout max 2010-08-05 14:45:21 +02:00
Martin Duquesnoy
19f9a35685 Menu: Improve submenu behaviour (Thanks to peve and mseed) 2010-08-03 20:33:40 +02:00
Raphael Khaiat
ed390279f5 Merge branch 'master' into bacardi55 2010-08-03 08:20:13 +02:00
Martin Duquesnoy
6d99de883c Layout: Fix toggle maximization in free layout 2010-08-03 02:03:01 +02:00
Raphael Khaiat
7abc282d21 Merge branch 'master' into bacardi55 2010-08-03 00:08:52 +02:00
Martin Duquesnoy
ed254ea417 Event: Fix configure event in tiling mode. 2010-08-02 22:10:02 +02:00
Martin Duquesnoy
f2e9c1fd02 Util: Remove debug printf 2010-08-02 19:20:53 +02:00
Martin Duquesnoy
36ca03f8f3 Util: Add patht function to transform path: '~/' is now allowed 2010-08-02 19:20:06 +02:00
Martin Duquesnoy
00638264d3 Frame: Fix buttons flags with free and layout free 2010-08-02 18:56:49 +02:00
Martin Duquesnoy
6a420e2934 Systray: Reparent systray window to infobar 2010-08-02 17:32:16 +02:00
Martin Duquesnoy
132f7d1da4 Client: Add focusontag option in Client structure to save focused client on every tag 2010-08-02 17:26:43 +02:00
Martin Duquesnoy
4a1ab8ef79 Client/Tag: Fix focus problems with tag_transfert 2010-08-02 16:27:30 +02:00
Martin Duquesnoy
61015e2567 Client: Fix possible flash-fullscreen problem 2010-08-02 16:12:33 +02:00
Martin Duquesnoy
5742ed4fca Client: Fix client swapping with additional tag 2010-08-02 15:45:31 +02:00
Martin Duquesnoy
872d9cb348 Event: Remove test in propertynotify handle 2010-07-31 14:30:45 +02:00
Martin Duquesnoy
2292ab97d1 Systray: Fix systray at reloading or for manage already running tray icon 2010-07-31 14:28:04 +02:00
Martin Duquesnoy
3b81cacaac Client: Fix arranging bug when closing client in additional tag condition 2010-07-26 19:38:23 +02:00
Martin Duquesnoy
0270a28181 Ewmh: Improve ewmh_send_message 2010-07-26 11:38:25 +02:00
Martin Duquesnoy
e6fc0a4976 Event: Remove send_client_message function 2010-07-26 11:32:26 +02:00
Martin Duquesnoy
374abb0e26 Update improvement 2010-07-26 11:20:20 +02:00
Martin Duquesnoy
1d5792b278 Conf: Move [systray] section in [bar] section 2010-07-23 14:49:57 +02:00
Martin Duquesnoy
461b45545a Conf/Systray: add [systray] section 2010-07-23 14:36:05 +02:00
Martin Duquesnoy
4cf2b8bf8f Status: Fix text drawing with systray shift 2010-07-23 12:31:08 +02:00
Martin Duquesnoy
cc10d56359 Systray/status: Adapt statuspos (with image/rectangle) with systray width 2010-07-23 04:15:33 +02:00
Martin Duquesnoy
1094861b49 Ewmh: Fix panels crash and type_dock management 2010-07-22 23:57:31 +02:00
Martin Duquesnoy
fdb1d2c748 Systray: Fix BadWindow (because of unmap event) and segfault at pressing button 2010-07-22 22:07:26 +02:00
Martin Duquesnoy
908978cca1 !! Implementation of System tray !! 2010-07-22 20:12:27 +02:00
Raphael Khaiat
b3325867ed Merge remote branch 'origin/master' into bacardi55 2010-07-21 23:04:49 +02:00
Martin Duquesnoy
d32ee3295e Systray: Prepare file 2010-07-21 22:52:18 +02:00
Martin Duquesnoy
910421c41c Layout: Fix screen test in arrange (reported by mseed) 2010-07-21 13:20:09 +02:00
Martin Duquesnoy
46d212297a Ewmh: Add _NET_WM_STATE_STICKY management 2010-07-17 03:32:47 +02:00
Martin Duquesnoy
bf9e9ca578 Improve _NET_WM_STATE part in ewmh_manage_window_type 2010-07-17 03:21:08 +02:00
Martin Duquesnoy
ce652d29e4 Fix _NET_WM_STATE_FULLSCREEN for flash apps or stuff like this 2010-07-17 03:09:55 +02:00
Raphael Khaiat
00e4e9975e Fix a bug that printed the tag previous count instead of the new one when using the tag_add with the name_count = true 2010-07-06 23:03:40 +02:00
Raphael Khaiat
aa04eab011 Delete struct default_tag by using tag structure for default_layout feature 2010-07-05 00:43:33 +02:00
Raphael Khaiat
afdda3b95a Add an option (selected_layout_symbol) in the wmfsrc -> [layouts] to change the star (*) that is used as default symbol for the selected symbol in the layout list in the infobar 2010-07-04 19:42:05 +02:00
Raphael Khaiat
2522b21ab3 Add default_tag section in the tags section of the wmfsrc. It allows
user to set all options of a new tag when they will use add a tag
dynamically. Feature #73 requested by bacardi55
2010-07-04 17:46:01 +02:00
Martin Duquesnoy
8aeded6cd6 Fix mistake in ewmh manage window type function 2010-06-30 13:23:20 +02:00
Raphael Khaiat
9a3b06c645 Wmfs coding norms :) 2010-06-30 13:13:08 +02:00
Raphael Khaiat
89b115e850 Fix bug #54 reported by bacardi55 2010-06-30 00:57:55 +02:00
Raphael Khaiat
e71f85ff26 Fix segfault when using client_ignore_tag. bug #72 reported by myself 2010-06-27 00:47:36 +02:00
Raphael Khaiat
253d50762b Add an option to choose the default layout that will be used when adding
a new tag dynamically. Feature #71 requested by myself ^^
2010-06-26 00:26:16 +02:00
Raphael Khaiat
e17f36f24f Change declaration place for uniformity 2010-06-25 14:02:14 +02:00
Raphael Khaiat
6d720d9848 Remove useless lines, thanks to xorg62 :-) 2010-06-25 13:55:08 +02:00
Raphael Khaiat
414273fff9 Prevent user the resize client while using tile_grid vertically or
horizontally.
2010-06-25 13:52:04 +02:00
Raphael Khaiat
cee16d6f7f Add a tile_grid_vertical layout that split vertically unlike the tile_grid
layout that split horizontally. Add tile_grid_horizontal too that is the
same as tile_grid. You should use the tile_grid_horizontal, tile_grid is
kept for backward compatibility
2010-06-25 01:40:53 +02:00
Raphael Khaiat
fb0ddc6b73 When name_count is true, put the count in the tag name
after using wmfs -c tag_new
2010-06-22 01:11:11 +02:00
Raphael Khaiat
8062f4a42a Correcting bug reported by xorg62 while using the command line
wmfs -c tag_new
2010-06-22 00:59:06 +02:00
Raphael Khaiat
c6f0204901 Add a default name option (default_name) to change "new tag" when you
add a tag by a keybind.
Add an option (name_count) to put the number of the tag as a
default name.
2010-06-21 23:58:08 +02:00
Martin Duquesnoy
a90f4ee7ce Client: Fix bug #70 (reported by bacardi55) 2010-06-21 16:06:14 +02:00
Martin Duquesnoy
fb97d95787 Event: Improve grabkeys() 2010-06-10 16:39:48 +02:00
Martin Duquesnoy
6e05fd498d Conf/Layout/Client: Add option keep_layout_geo (requested by Armael) 2010-06-10 15:41:53 +02:00
Martin Duquesnoy
f683022678 Client: Code typo.. 2010-06-09 19:26:19 +02:00
Martin Duquesnoy
32b3120fbd Client/conf: Add automax option (same that autofree but for maximization) (Feature #62 requested by bacardi55) 2010-06-09 19:24:48 +02:00
Martin Duquesnoy
470606af1b Client: Fix possible segfault when there is no autofree option (shame on me :o) 2010-06-06 23:40:55 +02:00
Martin Duquesnoy
12fc01b824 Client: add autofree option in client section (Feature #9 requested by lidstah (and tamtam)) See default wmfsrc 2010-06-06 23:34:11 +02:00
Martin Duquesnoy
9067f3cb66 Client: Add focus traveling with uicb function: client_focus_{right, left, top, bottom} (Feature #45 requested by biiter) [NEED TEST] 2010-06-06 22:48:25 +02:00
Martin Duquesnoy
2040385af6 Tag: Add tag_rename uicb function (Feature #55 requested by bacardi55) 2010-06-05 23:36:49 +02:00
Martin Duquesnoy
510cb29e9f Launcher: Fix launchers position when layout placement is left (Bug #53 signaled by Armael) 2010-06-05 23:26:33 +02:00
Martin Duquesnoy
32686569c4 Merge version (201005 will never exist, mouahahahaha!!) 2010-06-05 23:01:29 +02:00
Martin Duquesnoy
faab6d946e Client: Remove urgent when unmanaging a client without focus it 2010-06-05 22:59:43 +02:00
Martin Duquesnoy
d49ebaa57e Ewmh: Fix closing of splash windows (Bug #60 signaled by nythain) 2010-06-05 22:39:39 +02:00
Philippe Pepiot
5d1aaa1363 Merge branch 'master' of git.philpep.org:wmfs into philpep 2010-05-09 03:03:51 +02:00
Philippe Pepiot
5dd811b91e Parse: fix possible segfaults. Add syntax() for syntax errors 2010-05-09 03:03:03 +02:00
Martin Duquesnoy
a0a53f3af2 Infobar: Improve selbar check if there is no sel (in current screen) 2010-05-08 21:41:53 +02:00
Martin Duquesnoy
6ecc58bdb1 Client: Remove free in client_get_name 2010-05-08 19:26:55 +02:00
Martin Duquesnoy
c524326714 Client: Remove comment lines in client_moveresize 2010-05-07 18:54:48 +02:00
Martin Duquesnoy
c886edb19d Client: Map client after almost all in client_manage 2010-05-07 18:53:43 +02:00
Martin Duquesnoy
995c4e94e7 Client: Add padding option in client to set space between tiled client (Feature #52 requested by Armael) 2010-04-25 17:20:24 +02:00
Martin Duquesnoy
d3207be191 Finally fix wmfs.desktop 2010-04-24 14:06:34 +02:00
Martin Duquesnoy
1cc8506610 wmfs.desktop: Remove TryExec line 2010-04-24 13:54:44 +02:00
Martin Duquesnoy
4b692b7a0f wmfs.desktop: Fix bug with Gdm? (Bug #48 signaled by add1ktive, fixed by arpinux) 2010-04-24 13:49:59 +02:00
39 changed files with 4068 additions and 2368 deletions

16
.gitignore vendored
View File

@@ -1,17 +1,9 @@
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
cmake_uninstall.cmake
Makefile
*.o
.*.sw?
wmfs
src/config.h
changelog
config.h
#*
\#*
build/
doc/
wmfs.doxygen
wmfsrc
Makefile
wmfs.1.gz
tags
*.patch

View File

@@ -1,272 +0,0 @@
# -*- mode: cmake -*-
#Cmakelists.txt
# Minimum version of CMake
cmake_minimum_required(VERSION 2.6)
if(COMMAND cmake_policy)
cmake_policy(VERSION 2.6)
endif()
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
# Source and build dirs
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
# Project name - wmfs
set(PROJECT_NAME wmfs)
project(${PROJECT_NAME} C)
# Definition of the wmfs source
set(wmfs_src
src/parse/parse.c
src/barwin.c
src/client.c
src/config.c
src/
src/draw.c
src/event.c
src/ewmh.c
src/frame.c
src/getinfo.c
src/infobar.c
src/init.c
src/launcher.c
src/layout.c
src/menu.c
src/mouse.c
src/screen.c
src/status.c
src/tag.c
src/util.c
src/viwmfs.c
src/wmfs.c)
# Set the executable from the wmfs_src
add_executable(wmfs ${wmfs_src})
# Set the version
set(VERSION "WMFS-201004")
# FLAGS
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -ansi")
# Linker FLAGS
set(DEFAULT_LDFLAGS "-L /usr/local/lib -lpthread")
if(CMAKE_SYSTEM_NAME MATCHES NetBSD)
message("-- NetBSD system found - Using /usr/pkg/lib for linker")
set(LDFLAGS "${DEFAULT_LDFLAGS} -L /usr/pkg/lib")
else(CMAKE_SYSTEM_NAME MATCHES NetBSD)
set(LDFLAGS ${DEFAULT_LDFLAGS})
endif(CMAKE_SYSTEM_NAME MATCHES NetBSD)
set_target_properties(wmfs PROPERTIES LINK_FLAGS ${LDFLAGS})
# Includes dir for libs in build_dir
include_directories(
${BUILD_DIR}/src
)
# Package find
find_package(Freetype)
if(FREETYPE_FOUND)
include_directories(${FREETYPE_INCLUDE_DIRS})
else (FREETYPE_FOUND)
message(FATAL_ERROR "Could not find Freetype")
endif (FREETYPE_FOUND)
find_package(X11)
if(X11_FOUND)
include_directories(${X11_INCLUDE_DIR})
else (X11_FOUND)
message(FATAL_ERROR "Could not find X11")
endif (X11_FOUND)
# Link Libraries
set(LIBRARIES_TO_LINK
${FREETYPE_LIBRARIES}
${X11_LIBRARIES}
Xft)
# Includes
include(FindDoxygen)
include(FindPkgConfig)
# Use pkgconfig to get required libraries
pkg_check_modules(WMFS_REQUIRED REQUIRED
x11
freetype2
xft)
# Optional dependencies check
# Check for xinerama
pkg_check_modules(HAVE_XINERAMA xinerama)
if(HAVE_XINERAMA_FOUND)
set(WMFS_HAVE_XINERAMA "#define HAVE_XINERAMA")
set(LIBRARIES_TO_LINK ${LIBRARIES_TO_LINK} Xinerama)
else()
set(WMFS_HAVE_XINERAMA "")
endif()
# Check for xrandr
pkg_check_modules(HAVE_XRANDR xrandr)
if(HAVE_XRANDR_FOUND)
set(WMFS_HAVE_XRANDR "#define HAVE_XRANDR")
set(LIBRARIES_TO_LINK ${LIBRARIES_TO_LINK} Xrandr)
else()
set(WMFS_HAVE_XRANDR "")
endif()
# Check for Imlib
pkg_check_modules(HAVE_IMLIB imlib2)
if(HAVE_IMLIB_FOUND)
set(WMFS_HAVE_IMLIB "#define HAVE_IMLIB")
set(LIBRARIES_TO_LINK ${LIBRARIES_TO_LINK} Imlib2)
else()
set(WMFS_HAVE_IMLIB "")
endif()
target_link_libraries(wmfs ${LIBRARIES_TO_LINK})
# Messages
message("Project version: ${VERSION}")
message("Using these CFLAGS: ${CMAKE_C_FLAGS}")
message("Using these LDFLAGS: ${LDFLAGS}")
message("Linking with theses libraries : ${LIBRARIES_TO_LINK}")
# Generating man page
find_program(GZIP_EXECUTABLE gzip)
if(NOT GZIP_EXECUTABLE)
message(STATUS "Looking for gzip -- not found")
message(STATUS "Could not generating man page")
else()
message(STATUS "Looking for gzip -- ${GZIP_EXECUTABLE}")
message(STATUS "Generating man page")
set(WMFS_MAN1_FILES ${BUILD_DIR}/wmfs.1.gz)
execute_process(
COMMAND ${GZIP_EXECUTABLE} -c wmfs.1
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_FILE ${WMFS_MAN1_FILES})
endif()
# Generating CHANGELOG
find_program(GIT_EXECUTABLE git)
if(EXISTS ${SOURCE_DIR}/.git/HEAD AND GIT_EXECUTABLE)
message(STATUS "Looking for git -- ${GIT_EXECUTABLE}")
message(STATUS "Git dir -- Generating changelog...")
set(PROJECT_CHANGELOG ${SOURCE_DIR}/changelog)
execute_process(
COMMAND ${GIT_EXECUTABLE} log
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_FILE ${PROJECT_CHANGELOG})
else()
message(STATUS "Looking for git -- not found")
message(STATUS "Could not generating changelog")
endif()
# sets
# {{{ Install path and configuration variables
if(DEFINED PREFIX)
set(PREFIX ${PREFIX} CACHE PATH "install prefix")
set(CMAKE_INSTALL_PREFIX ${PREFIX})
else()
set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "install prefix")
endif()
#If a sysconfdir is specified, use it instead
#of the default configuration dir.
if(DEFINED SYSCONFDIR)
set(SYSCONFDIR ${SYSCONFDIR} CACHE PATH "config directory")
else()
set(SYSCONFDIR /etc CACHE PATH "config directory")
endif()
#If an XDG Config Dir is specificed, use it instead
#of the default XDG configuration dir.
if(DEFINED XDG_CONFIG_DIR)
set(XDG_CONFIG_DIR ${XDG_CONFIG_SYS} CACHE PATH "xdg config directory")
else()
set(XDG_CONFIG_DIR ${SYSCONFDIR}/xdg CACHE PATH "xdg config directory")
endif()
# setting WMFS_XSESSION_PATH
if(DEFINED WMFS_XSESSION_PATH)
set(WMFS_XSESSION_PATH ${WMFS_XSESSION_PATH} CACHE PATH "wmfs xsessions directory")
else()
set(WMFS_XSESSION_PATH ${PREFIX}/share/xsessions CACHE PATH "wmfs xsessions directory")
endif()
if(DEFINED WMFS_MAN_PATH)
set(WMFS_MAN_PATH ${WMFS_MAN_PATH} CACHE PATH "wmfs manpage directory")
else()
set(WMFS_MAN_PATH ${PREFIX}/share/man CACHE PATH "wmfs manpage directory")
endif()
if(DOXYGEN_EXECUTABLE)
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${SOURCE_DIR}/wmfs.doxygen
WORKING_DIRECTORY ${BUILD_DIR})
endif()
find_program(URXVT_EXECUTABLE urxvt)
if(URXVT_EXECUTABLE)
set(WMFS_TERM urxvt)
else()
set(WMFS_TERM xterm)
endif()
# Remplace strings in configs
set(WMFS_VERSION ${VERSION})
set(WMFS_COMPILE_MACHINE ${CMAKE_SYSTEM_PROCESSOR})
set(WMFS_COMPILE_BY $ENV{USER})
set(WMFS_COMPILE_FLAGS ${CMAKE_C_FLAGS})
set(WMFS_LINKED_LIBS ${LIBRARIES_TO_LINK})
set(WMFS_SYSCONFDIR ${XDG_CONFIG_DIR}/${PROJECT_NAME})
set(WMFS_SOURCE_DIR ${SOURCE_DIR})
# Configure files
set(wmfs_configure_files
src/config.h.in
wmfs.doxygen.in
wmfsrc.in)
macro(a_configure_file file)
string(REGEX REPLACE ".in\$" "" outfile ${file})
message(STATUS "Configuring ${outfile}")
configure_file(${SOURCE_DIR}/${file}
${SOURCE_DIR}/${outfile}
ESCAPE_QUOTE
@ONLY)
endmacro()
foreach(file ${wmfs_configure_files})
a_configure_file(${file})
endforeach()
set(PROJECT_DATA_PATH share/${PROJECT_NAME})
set(PROJECT_TODO ${SOURCE_DIR}/TODO)
set(PROJECT_README ${SOURCE_DIR}/README)
set(PROJECT_DEFAULT_CONF ${SOURCE_DIR}/wmfsrc)
# installs
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
if(WMFS_MAN1_FILES)
install(FILES ${WMFS_MAN1_FILES} DESTINATION ${WMFS_MAN_PATH}/man1)
endif()
if(PROJECT_CHANGELOG)
install(FILES ${PROJECT_CHANGELOG} DESTINATION ${PROJECT_DATA_PATH})
endif()
install(FILES ${PROJECT_TODO} ${PROJECT_README}
${PROJECT_DEFAULT_CONF} DESTINATION ${PROJECT_DATA_PATH})
install(FILES ${PROJECT_DEFAULT_CONF} DESTINATION ${WMFS_SYSCONFDIR})
install(FILES "wmfs.desktop" DESTINATION ${WMFS_XSESSION_PATH})

86
Makefile.in Normal file
View File

@@ -0,0 +1,86 @@
PROG=wmfs
MAN=wmfs.1
# wmfs version
VERSION= 201011
SRCS= \
src/barwin.c \
src/client.c \
src/config.c \
src/draw.c \
src/event.c \
src/ewmh.c \
src/frame.c \
src/getinfo.c \
src/infobar.c \
src/init.c \
src/launcher.c \
src/layout.c \
src/menu.c \
src/mouse.c \
src/parse_api.c \
src/parse.c \
src/screen.c \
src/status.c \
src/systray.c \
src/tag.c \
src/util.c \
src/viwmfs.c \
src/color.c \
src/wmfs.c
# flags
CFLAGS+= -DXDG_CONFIG_DIR=\"${XDG_CONFIG_DIR}\"
CFLAGS+= -DWMFS_VERSION=\"${VERSION}\"
CFLAGS+= -Wall -Wextra
OBJS= ${SRCS:.c=.o}
all: ${PROG} ${MAN}.gz
${PROG}: ${OBJS} src/structs.h src/wmfs.h src/parse.h
${CC} -o $@ ${OBJS} ${LDFLAGS}
${MAN}.gz: ${MAN}
gzip -cn -9 ${MAN} > $@
.c.o:
${CC} -c ${CFLAGS} $< -o $@
clean:
rm -f ${OBJS} wmfs ${MAN}.gz
distclean: clean
rm -f Makefile
install: all
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
mkdir -p ${DESTDIR}${PREFIX}/bin
install ${PROG} ${DESTDIR}${PREFIX}/bin
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
mkdir -p ${DESTDIR}${MANPREFIX}/man1
install -m 644 ${MAN}.gz ${DESTDIR}${MANPREFIX}/man1/
@echo installing xsession file to ${DESTDIR}${PREFIX}/share/xsessions
mkdir -p ${DESTDIR}${PREFIX}/share/xsessions
install -m 644 wmfs.desktop ${DESTDIR}${PREFIX}/share/xsessions/
@echo installing default config file to ${DESTDIR}${XDG_CONFIG_DIR}/wmfs/
mkdir -p ${DESTDIR}${XDG_CONFIG_DIR}/wmfs/
install -m 444 wmfsrc ${DESTDIR}${XDG_CONFIG_DIR}/wmfs/
uninstall:
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
rm -f ${DESTDIR}${PREFIX}/bin/wmfs
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
rm -f ${DESTDIR}${MANPREFIX}/man1/wmfs.1.gz
@echo removing xsession file from ${DESTDIR}${PREFIX}/share/xsessions
rm -f ${DESTDIR}${PREFIX}/share/xsessions/wmfs.desktop
@echo removing config file from ${DESTDIR}${XDG_CONFIG_DIR}/wmfs/
rm -f ${DESTDIR}${XDG_CONFIG_DIR}/wmfs/wmfsrc
rmdir ${DESTDIR}${XDG_CONFIG_DIR}/wmfs/
.PHONY: all clean distclean install uninstall

29
README
View File

@@ -4,33 +4,34 @@ WMFS Window Manager.
A highly configurable and manageable tiling Window Manager created from scratch
AUTHORS :
Martin Duquesnoy <xorg62@gmail.com>
AUTHORS : (in order of commits and > 5 commits)
- Martin Duquesnoy <xorg62@gmail.com>
- Philippe Pepiot <phil@philpep.org>
- Marc Lagrange <markocpc@gmail.com>
- OldMan <tele-post@mail.ru>
- Raphael Khaiat <raphael@khaiat.org>
- Tomáš Chvátal <scarabeus@gentoo.org>
- David Delassus <linkdd@ydb.me>
LICENSE : BSD
REQUIREMENT :
- freetype2
- libxft
- libx11
- libxinerama (optional)
- libxrandr (optional)
- imlib2 (optional)
- libxft
- libx11
- CMake >= 2.6
OS :
- GNU/Linux : Supported.
- FreeBSD : Supported.
- FreeBSD/OpenBSD/NetBSD : Supported.
INSTALL :
- mkdir build
- cd build
- cmake ..
- make
- sudo make install
- sudo make uninstall # if you would to remove it.
If you have doxygen installed you can generate doxygen documentation via custom target 'make doc' in the build dir.
./configure [--without-imlib2|--without-xrandr|--without-xinerama] (./configure -h)
make
sudo make install
DISTROS :
- wmfs port for FreeBSD at x11-wm/wmfs

View File

@@ -1,21 +0,0 @@
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
IF(EXISTS "$ENV{DESTDIR}${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF(NOT "${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF(NOT "${rm_retval}" STREQUAL 0)
ELSE(EXISTS "$ENV{DESTDIR}${file}")
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
ENDFOREACH(file)

105
configure vendored Executable file
View File

@@ -0,0 +1,105 @@
#!/bin/sh
LIBS="x11 xft freetype2"
USE_XINERAMA="xinerama"
USE_XRANDR="xrandr"
USE_IMLIB2="imlib2"
OS=`uname -s`
PREFIX=/usr/local
MANPREFIX="$PREFIX/man"
XDG_CONFIG_DIR="$PREFIX/etc/xdg"
while true; do
case "$1" in
--without-xinerama)
USE_XINERAMA=""; shift;;
--without-xrandr)
USE_XRANDR=""; shift;;
--without-imlib2)
USE_IMLIB2=""; shift;;
--prefix)
[ -z "$2" ] && echo "Missing argument" && exit 1
PREFIX=$2; shift 2;;
--xdg-config-dir)
[ -z "$2" ] && echo "Missing argument" && exit 1
XDG_CONFIG_DIR=$2; shift 2;;
--man-prefix)
[ -z "$2" ] && echo "Missing argument" && exit 1
MANPREFIX=$2; shift 2;;
--help|-h)
echo "Usage: ./configure [options]
--without-imlib2 : compile without imlib2 support
--without-xrandr : compile without xrandr support
--without-xinerama : compile without xinerama support
--prefix DIRECTORY : install binary with specified prefix (default $PREFIX)
--xdg-config-dir DIRECTORY : install configuration to specified directory (default $XDG_CONFIG_DIR)
--man-prefix DIRECTORY : install man page to specified prefix (default $MANPREFIX)"
exit 0;;
*) break;;
esac
done
LIBS="$LIBS $USE_XINERAMA $USE_XRANDR $USE_IMLIB2"
which pkg-config >/dev/null 2>&1
if [ $? -eq 0 ];
then
CFLAGS=`pkg-config --cflags-only-I $LIBS`
LDFLAGS=`pkg-config --libs $LIBS`
else
# Try to use some known paths
case $OS in
FreeBSD)
CFLAGS="-I/usr/local/include -I/usr/local/include/freetype2"
LDFLAGS="-L/usr/local/lib";;
OpenBSD)
CFLAGS="-I/usr/X11R6/include -I/usr/X11R6/include/freetype2 -I/usr/local/include"
LDFLAGS="-L/usr/X11R6/lib -L/usr/local/lib";;
NetBSD)
CFLAGS="-I/usr/X11R7/include -I/usr/X11R7/include/freetype2 -I/usr/local/include"
LDFLAGS="-L/usr/X11R7/lib -L/usr/local/lib";;
Linux)
CFLAGS="-I/usr/include/freetype2"
LDFLAGS=""
;;
*)
echo "No default CFLAGS and LDFLAGS found for your OS, feel free to contribute or install pkg-config :)"
exit 1;;
esac
LDFLAGS="$LDFLAGS -lX11 -lXft -lfreetype"
[ -n "$USE_XINERAMA" ] && LDFLAGS="$LDFLAGS -lXinerama"
[ -n "$USE_XRANDR" ] && LDFLAGS="$LDFLAGS -lXrandr"
[ -n "$USE_IMLIB2" ] && LDFLAGS="$LDFLAGS -lImlib2"
fi
[ -n "$USE_XINERAMA" ] && CFLAGS="$CFLAGS -DHAVE_XINERAMA"
[ -n "$USE_XRANDR" ] && CFLAGS="$CFLAGS -DHAVE_XRANDR"
[ -n "$USE_IMLIB2" ] && CFLAGS="$CFLAGS -DHAVE_IMLIB"
LDFLAGS="$LDFLAGS -lpthread"
cat > Makefile << EOF
PREFIX=$PREFIX
XDG_CONFIG_DIR=$XDG_CONFIG_DIR
MANPREFIX=$MANPREFIX
CFLAGS+=$CFLAGS
LDFLAGS+=$LDFLAGS
EOF
cat Makefile.in >> Makefile
echo "Compilation resume:
OS=$OS
CFLAGS=$CFLAGS
LDFLAGS=$LDFLAGS
PREFIX=$PREFIX
MANPREFIX=$MANPREFIX
XDG_CONFIG_DIR=$XDG_CONFIG_DIR
You can run 'make' now :-)
"

View File

@@ -58,7 +58,7 @@ barwin_create(Window parent,
BarWindow *bw;
/* Allocate memory */
bw = emalloc(1, sizeof(BarWindow));
bw = zcalloc(sizeof(*bw));
/* Barwin attributes */
at.override_redirect = True;
@@ -81,11 +81,13 @@ barwin_create(Window parent,
if(border)
{
bw->bord = True;
bw->border.light = color_shade(bg, conf.colors.bar_light_shade);
bw->border.dark = color_shade(bg, conf.colors.bar_dark_shade);
CWIN(bw->border.left, bw->win, 0, 0, SHADH, h, 0, CWBackPixel, color_enlight(bg), &at);
CWIN(bw->border.top, bw->win, 0, 0, w, SHADH, 0, CWBackPixel, color_enlight(bg), &at);
CWIN(bw->border.bottom, bw->win, 0, h - SHADH, w, SHADH, 0, CWBackPixel, SHADC, &at);
CWIN(bw->border.right, bw->win, w - SHADH, 0, SHADH, h, 0, CWBackPixel, SHADC, &at);
CWIN(bw->border.left, bw->win, 0, 0, SHADH, h, 0, CWBackPixel, bg, &at);
CWIN(bw->border.top, bw->win, 0, 0, w, SHADH, 0, CWBackPixel, bg, &at);
CWIN(bw->border.bottom, bw->win, 0, h - SHADH, w, SHADH, 0, CWBackPixel, bg, &at);
CWIN(bw->border.right, bw->win, w - SHADH, 0, SHADH, h, 0, CWBackPixel, bg, &at);
}
/* Property */
@@ -95,8 +97,6 @@ barwin_create(Window parent,
bw->geo.height = h;
bw->bg = bg;
bw->fg = fg;
bw->border.light = color_enlight(bg);
bw->border.dark = SHADC;
bw->stipple = stipple;
bw->stipple_color = -1;
@@ -116,13 +116,50 @@ barwin_draw_text(BarWindow *bw, int x, int y, char *text)
draw_rectangle(bw->dr, x - 4, 0, textw(text) + 8, bw->geo.height, bw->bg);
/* Draw text */
draw_text(bw->dr, x, y, bw->fg, 0, text);
draw_text(bw->dr, x, y, bw->fg, text);
barwin_refresh(bw);
return;
}
/** Draw text in a Barwindow
*/
void
barwin_draw_image_ofset_text(BarWindow *bw, int x, int y, char *text, int x_image_ofset, int y_image_ofset)
{
if(!text)
return;
/* Background color of the text if there is stipple */
if(bw->stipple)
draw_rectangle(bw->dr, x - 4, 0, textw(text) + 8, bw->geo.height, bw->bg);
/* Draw text */
draw_image_ofset_text(bw->dr, x, y, bw->fg, text, x_image_ofset, y_image_ofset);
barwin_refresh(bw);
return;
}
void
barwin_color_set(BarWindow *bw, uint bg, char *fg)
{
CHECK(bw);
bw->bg = bg;
bw->fg = fg;
if(bw->bord)
{
bw->border.light = color_shade(bg, conf.colors.bar_light_shade);
bw->border.dark = color_shade(bg, conf.colors.bar_dark_shade);
}
return;
}
/** Delete a BarWindow
* \param bw BarWindow pointer
*/
@@ -273,7 +310,7 @@ barwin_refresh_color(BarWindow *bw)
if(bw->stipple)
{
XSetForeground(dpy, gc_stipple, ((bw->stipple_color != -1) ? bw->stipple_color : getcolor(bw->fg)));
XSetForeground(dpy, gc_stipple, ((bw->stipple_color != (uint)-1) ? (long)bw->stipple_color : getcolor(bw->fg)));
XFillRectangle(dpy, bw->dr, gc_stipple, 3, 2, bw->geo.width - 6, bw->geo.height - 4);
}

View File

@@ -88,11 +88,13 @@ client_detach(Client *c)
/** Get the next client
*\return The next client or NULL
*/
Client*
static Client*
client_get_next(void)
{
Client *c = NULL;
screen_get_sel();
if(!sel || ishide(sel, selscreen))
return NULL;
@@ -107,11 +109,13 @@ client_get_next(void)
/** Get the previous client
*\return The previous client or NULL
*/
Client*
static Client*
client_get_prev(void)
{
Client *c = NULL, *d;
screen_get_sel();
if(!sel || ishide(sel, selscreen))
return NULL;
@@ -127,6 +131,49 @@ client_get_prev(void)
return c;
}
/** Get client left/right/top/bottom of selected client
*\param pos Position (Left/Right/Top/Bottom
*\return Client found
*/
static Client*
client_get_next_with_direction(Position pos)
{
Client *c = NULL;
Client *ret = NULL;
if(!sel || ishide(sel, selscreen))
return NULL;
for(c = clients; c; c = c->next)
if(c != sel && !ishide(c, sel->screen))
switch(pos)
{
default:
case Right:
if(c->geo.x > sel->geo.x
&& (!ret || (ret && ret->geo.x > sel->geo.x && c->geo.x < ret->geo.x)))
ret = c;
break;
case Left:
if(c->geo.x < sel->geo.x
&& (!ret || (ret && ret->geo.x < sel->geo.x && c->geo.x > ret->geo.x)))
ret = c;
break;
case Top:
if(c->geo.y < sel->geo.y
&& (!ret || (ret && ret->geo.y < sel->geo.y && c->geo.y > ret->geo.y)))
ret = c;
break;
case Bottom:
if(c->geo.y > sel->geo.y
&& (!ret || (ret && ret->geo.y > sel->geo.y && c->geo.y < ret->geo.y)))
ret = c;
break;
}
return ret;
}
/** Switch to the previous client
* \param cmd uicb_t type unused
*/
@@ -134,6 +181,7 @@ void
uicb_client_prev(uicb_t cmd)
{
Client *c;
(void)cmd;
if((c = client_get_prev()))
{
@@ -151,6 +199,7 @@ void
uicb_client_next(uicb_t cmd)
{
Client *c;
(void)cmd;
if((c = client_get_next()))
{
@@ -168,6 +217,7 @@ void
uicb_client_swap_next(uicb_t cmd)
{
Client *c;
(void)cmd;
if((c = client_get_next()))
{
@@ -185,6 +235,7 @@ void
uicb_client_swap_prev(uicb_t cmd)
{
Client *c;
(void)cmd;
if((c = client_get_prev()))
{
@@ -195,13 +246,88 @@ uicb_client_swap_prev(uicb_t cmd)
return;
}
/** Select next client positioned to the right
*\param cmd uicb_t type unused
*/
void
uicb_client_focus_right(uicb_t cmd)
{
Client *c;
(void)cmd;
if((c = client_get_next_with_direction(Right)))
{
client_focus(c);
client_raise(c);
}
return;
}
/** Select next client positioned to the left
*\param cmd uicb_t type unused
*/
void
uicb_client_focus_left(uicb_t cmd)
{
Client *c;
(void)cmd;
if((c = client_get_next_with_direction(Left)))
{
client_focus(c);
client_raise(c);
}
return;
}
/** Select next client positioned to the top
*\param cmd uicb_t type unused
*/
void
uicb_client_focus_top(uicb_t cmd)
{
Client *c;
(void)cmd;
if((c = client_get_next_with_direction(Top)))
{
client_focus(c);
client_raise(c);
}
return;
}
/** Select next client positioned to the bottom
*\param cmd uicb_t type unused
*/
void
uicb_client_focus_bottom(uicb_t cmd)
{
Client *c;
(void)cmd;
if((c = client_get_next_with_direction(Bottom)))
{
client_focus(c);
client_raise(c);
}
return;
}
/** Set the client c above
*\param c Client pointer
*/
void
static void
client_above(Client *c)
{
XRectangle geo = { 0 };
XRectangle geo;
memset(&geo, 0, sizeof(geo));
if(c->flags & AboveFlag)
return;
@@ -228,32 +354,36 @@ client_above(Client *c)
void
client_focus(Client *c)
{
Client *cc;
Window w;
int d;
if(sel && sel != c)
{
sel->colors.frame = conf.client.bordernormal;
sel->colors.fg = conf.titlebar.fg_normal;
sel->colors.resizecorner = conf.client.resizecorner_normal;
if(TBARH - BORDH && sel->titlebar->stipple)
sel->titlebar->stipple_color = conf.titlebar.stipple.colors.normal;
if(sel->flags & AboveFlag)
sel->flags &= ~AboveFlag;
XChangeProperty(dpy, sel->frame, net_atom[net_wm_window_opacity], XA_CARDINAL,
32, PropModeReplace, (uchar *)&conf.opacity, 1);
frame_update_color(sel, True);
frame_update(sel);
mouse_grabbuttons(sel, !conf.focus_pclick);
}
if((sel = c))
{
c->colors.frame = conf.client.borderfocus;
c->colors.fg = conf.titlebar.fg_focus;
c->colors.resizecorner = conf.client.resizecorner_focus;
if(TBARH - BORDH && c->titlebar->stipple)
c->titlebar->stipple_color = conf.titlebar.stipple.colors.focus;
/* Set focusontag option */
for(cc = clients; cc; cc = cc->next)
if(cc->focusontag == (int)c->tag)
cc->focusontag = -1;
c->focusontag = seltag[selscreen];
XDeleteProperty(dpy, c->frame, net_atom[net_wm_window_opacity]);
frame_update_color(c, False);
frame_update(c);
mouse_grabbuttons(c, True);
@@ -271,11 +401,7 @@ client_focus(Client *c)
client_above(sel);
if(c->flags & UrgentFlag)
{
c->flags &= ~UrgentFlag;
tags[c->screen][c->tag].urgent = False;
infobar_draw_taglist(c->screen);
}
client_urgent(c, False);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
@@ -292,6 +418,22 @@ client_focus(Client *c)
return;
}
/** Set urgency flag of the client
* \param c Client pointer
* \param u Bool
*/
void
client_urgent(Client *c, Bool u)
{
if(u)
c->flags |= UrgentFlag;
else
c->flags &= ~UrgentFlag;
tags[c->screen][c->tag].urgent = u;
infobar_draw_taglist(c->screen);
}
/* The following functions have the same point :
* find a client member with a Window {{{
*/
@@ -388,8 +530,6 @@ client_get_name(Client *c)
int rf;
ulong ir, il;
IFREE(c->title);
/* This one instead XFetchName for utf8 name support */
if(XGetWindowProperty(dpy, c->win, net_atom[net_wm_name], 0, 4096,
False, net_atom[utf8_string], &rt, &rf, &ir, &il, (uchar**)&c->title) != Success)
@@ -402,7 +542,7 @@ client_get_name(Client *c)
XFetchName(dpy, c->win, &(c->title));
if(!c->title)
c->title = _strdup("WMFS");
c->title = xstrdup("WMFS");
}
frame_update(c);
@@ -435,7 +575,7 @@ client_hide(Client *c)
Bool
ishide(Client *c, int screen)
{
if(((c->tag == seltag[screen] || c->tag == MAXTAG + 1) && c->screen == screen)
if(((c->tag == (uint)seltag[screen] || c->tag == MAXTAG + 1) && c->screen == screen)
|| tags[screen][seltag[screen]].tagad & TagFlag(c->tag))
return False;
@@ -490,6 +630,7 @@ client_kill(Client *c)
void
uicb_client_kill(uicb_t cmd)
{
(void)cmd;
CHECK(sel);
client_kill(sel);
@@ -505,7 +646,7 @@ client_map(Client *c)
{
CHECK(c);
if(c->flags & FSSFlag)
if(c->flags & FSSFlag || c->flags & DockFlag)
XMapWindow(dpy, c->win);
else
{
@@ -523,6 +664,143 @@ client_map(Client *c)
return;
}
/** Set the wanted tag or autofree/max of a client
*\param c Client pointer
*/
static void
client_set_rules(Client *c)
{
XClassHint xch;
int i, j, k, f;
Atom rf;
ulong n, il;
uchar *data = NULL;
char wwrole[256] = { 0 };
Bool applied_tag_rule = False;
Bool applied_screen_rule = False;
memset(&xch, 0, sizeof(xch));
if(conf.ignore_next_client_rules)
{
conf.ignore_next_client_rules = False;
return;
}
/* Get WM_CLASS */
XGetClassHint(dpy, c->win, &xch);
/* Get WM_WINDOW_ROLE */
if(XGetWindowProperty(dpy, c->win, ATOM("WM_WINDOW_ROLE"), 0L, 0x7FFFFFFFL, False,
XA_STRING, &rf, &f, &n, &il, &data) == Success && data)
{
strncpy(wwrole, (char*)data, sizeof(wwrole));
XFree(data);
}
/* Following features is *DEPRECATED*, will be removed in some revision. {{{ */
/* Auto free */
if(conf.client.autofree && ((xch.res_name && strstr(conf.client.autofree, xch.res_name))
|| (xch.res_class && strstr(conf.client.autofree, xch.res_class))))
c->flags |= FreeFlag;
/* Auto maximize */
if(conf.client.automax && ((xch.res_name && strstr(conf.client.automax, xch.res_name))
|| (xch.res_class && strstr(conf.client.automax, xch.res_class))))
{
client_maximize(c);
c->flags |= MaxFlag;
}
/* Wanted tag */
for(i = 0; i < screen_count(); ++i)
for(j = 1; j < conf.ntag[i] + 1; ++j)
if(tags[i][j].clients)
for(k = 0; k < tags[i][j].nclients; ++k)
if((xch.res_name && strstr(xch.res_name, tags[i][j].clients[k]))
|| (xch.res_class && strstr(xch.res_class, tags[i][j].clients[k])))
{
c->screen = i;
c->tag = j;
if(c->tag != (uint)seltag[selscreen])
tags[c->screen][c->tag].request_update = True;
else
tags[c->screen][c->tag].layout.func(c->screen);
/* Deprecated but still in use */
applied_tag_rule = True;
applied_screen_rule = True;
}
/* }}} */
/* Apply Rule if class || instance || role match */
for(i = 0; i < conf.nrule; ++i)
{
if((xch.res_class && conf.rule[i].class && !strcmp(xch.res_class, conf.rule[i].class))
|| (xch.res_name && conf.rule[i].instance && !strcmp(xch.res_name, conf.rule[i].instance)))
{
if((strlen(wwrole) && conf.rule[i].role && !strcmp(wwrole, conf.rule[i].role)) || (!strlen(wwrole) || !conf.rule[i].role))
{
if(conf.rule[i].screen != -1)
c->screen = conf.rule[i].screen;
if(conf.rule[i].tag != -1)
{
c->tag = conf.rule[i].tag;
applied_tag_rule = True;
}
if(conf.rule[i].free)
c->flags |= FreeFlag;
if(conf.rule[i].ignoretags)
c->tag = MAXTAG + 1;
if(conf.rule[i].max)
{
client_maximize(c);
c->flags |= MaxFlag;
}
if(c->tag != (uint)seltag[selscreen])
{
tags[c->screen][c->tag].request_update = True;
client_focus(NULL);
}
if(!conf.rule[i].ignoretags)
tags[c->screen][c->tag].layout.func(c->screen);
if(conf.rule[i].follow_client)
seltag[c->screen] = c->tag;
}
}
}
if(!applied_tag_rule && conf.client.default_open_tag > 0
&& conf.client.default_open_tag < (uint)conf.ntag[selscreen])
{
c->tag = conf.client.default_open_tag;
client_focus_next(c);
tags[c->screen][c->tag].request_update = True;
}
if(!applied_screen_rule && conf.client.default_open_screen > -1
&& conf.client.default_open_screen < screen_count())
{
c->screen = conf.client.default_open_screen;
client_focus_next(c);
tags[c->screen][c->tag].request_update = True;
}
return;
}
/** Manage a client with a window and his attributes
* \param w Cient's futur Window
* \param wa XWindowAttributes pointer, Window w attributes
@@ -536,17 +814,16 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
Window trans, dw;
Status rettrans;
XSetWindowAttributes at;
int mx, my, dint;
int mx, my, dint, x, y, d;
uint duint;
screen_get_sel();
c = emalloc(1, sizeof(Client));
c = zmalloc(sizeof(Client));
c->win = w;
c->screen = selscreen;
c->flags = 0;
XQueryPointer(dpy, ROOT, &dw, &dw, &mx, &my, &dint, &dint, &duint);
if(conf.client.place_at_mouse)
@@ -572,17 +849,26 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
mx += spgeo[selscreen].x;
my += spgeo[selscreen].y;
}
if(conf.client_auto_center)
{
XRectangle tmp;
tmp = screen_get_geo(selscreen);
mx = (tmp.width + mx - wa->width) / 2;
my = (tmp.height + my - wa->height) / 2;
}
}
c->ogeo.x = c->geo.x = mx;
c->ogeo.y = c->geo.y = my;
c->ogeo.width = c->geo.width = wa->width;
c->ogeo.height = c->geo.height = wa->height;
c->free_geo = c->geo;
c->tag = seltag[c->screen];
c->focusontag = -1;
c->layer = (sel && sel->layer > 0) ? sel->layer : 1;
at.event_mask = PropertyChangeMask;
frame_create(c);
@@ -610,15 +896,21 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
free(t);
client_attach(c);
client_set_rules(c);
client_get_name(c);
client_map(c);
client_raise(c);
client_focus(c);
setwinstate(c->win, NormalState);
if(c->tag == (uint)seltag[selscreen])
{
client_raise(c);
setwinstate(c->win, NormalState);
}
else
client_hide(c);
ewmh_get_client_list();
ewmh_manage_window_type(c);
client_set_wanted_tag(c);
client_update_attributes(c);
if(c->tag == (uint)seltag[selscreen])
client_map(c);
ewmh_manage_window_type(c);
if(ar)
arrange(c->screen, True);
@@ -626,6 +918,19 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
if(!conf.client.set_new_win_master)
layout_set_client_master(c);
if(c->tag == (uint)seltag[selscreen])
client_focus(c);
if(conf.client.new_client_get_mouse)
{
/* Move pointer on client */
XQueryPointer(dpy, ROOT, &dw, &dw, &x, &y, &d, &d, (uint *)&d);
XWarpPointer(dpy, ROOT, ROOT, x, y, d, d,
c->geo.x + c->geo.width / 2,
c->geo.y + c->geo.height / 2);
}
return c;
}
@@ -698,10 +1003,21 @@ client_moveresize(Client *c, XRectangle geo, Bool r)
client_geo_hints(&geo, c);
c->flags &= ~MaxFlag;
c->geo = c->ogeo = geo;
if(c->flags & FreeFlag || tags[c->screen][c->tag].layout.func == freelayout)
c->free_geo = geo;
if(conf.client.padding && c->flags & TileFlag && c->flags & FLayFlag)
{
geo.x += conf.client.padding;
geo.y += conf.client.padding;
geo.width -= conf.client.padding * 2;
geo.height -= conf.client.padding * 2;
c->flags &= ~FLayFlag;
}
c->geo = geo;
if(c->flags & FreeFlag || !(c->flags & (TileFlag | LMaxFlag)) || conf.keep_layout_geo)
c->free_geo = c->geo;
if((c->screen = screen_get_with_geo(c->geo.x, c->geo.y)) != os
&& c->tag != MAXTAG + 1)
@@ -711,8 +1027,8 @@ client_moveresize(Client *c, XRectangle geo, Bool r)
XMoveResizeWindow(dpy, c->win, BORDH, TBARH, c->geo.width, c->geo.height);
client_configure(c);
client_update_attributes(c);
client_configure(c);
return;
}
@@ -723,19 +1039,20 @@ client_moveresize(Client *c, XRectangle geo, Bool r)
void
client_maximize(Client *c)
{
XRectangle geo;
if(!c || c->flags & FSSFlag)
return;
c->screen = screen_get_with_geo(c->geo.x, c->geo.y);
geo.x = sgeo[c->screen].x;
geo.y = sgeo[c->screen].y;
geo.width = sgeo[c->screen].width - BORDH * 2;
geo.height = sgeo[c->screen].height - BORDH;
c->geo.x = sgeo[c->screen].x;
c->geo.y = sgeo[c->screen].y;
c->geo.width = sgeo[c->screen].width - BORDH * 2;
c->geo.height = sgeo[c->screen].height - BORDH;
client_moveresize(c, geo, False);
client_moveresize(c, c->geo, False);
/* Raise for maximized clients, client_raise has too much condition */
XRaiseWindow(dpy, c->frame);
return;
}
@@ -823,13 +1140,22 @@ client_size_hints(Client *c)
void
client_swap(Client *c1, Client *c2)
{
int tmp;
/* Check if no one of these clients are free */
CHECK(!(c1->flags & FreeFlag));
CHECK(!(c2->flags & FreeFlag));
if(c1 == c2 || (c1->screen == c2->screen && c1->tag != c2->tag))
if(c1 == c2)
return;
if(c1->tag != c2->tag)
{
tmp = c1->tag;
c1->tag = c2->tag;
c2->tag = tmp;
}
/* Swap only the windows */
swap_ptr((void**)&c1->win, (void**)&c2->win);
@@ -852,45 +1178,6 @@ client_swap(Client *c1, Client *c2)
return;
}
/** Set the wanted tag of a client
*\param c Client pointer
*/
void
client_set_wanted_tag(Client *c)
{
XClassHint xch = { 0 };
int i, j, k;
if(conf.ignore_next_client_rules)
{
conf.ignore_next_client_rules = False;
return;
}
XGetClassHint(dpy, c->win, &xch);
for(i = 0; i < screen_count(); ++i)
for(j = 1; j < conf.ntag[i] + 1; ++j)
if(tags[i][j].clients)
for(k = 0; k < tags[i][j].nclients; ++k)
if((xch.res_name && strstr(xch.res_name, tags[i][j].clients[k]))
|| (xch.res_class && strstr(xch.res_class, tags[i][j].clients[k])))
{
c->screen = i;
c->tag = j;
if(c->tag != seltag[selscreen])
{
tags[c->screen][c->tag].request_update = True;
client_focus(NULL);
}
tags[c->screen][c->tag].layout.func(c->screen);
}
return;
}
/** Update client attributes (_WMFS_TAG _WMFS_SCREEN)
*\param c Client pointer
*/
@@ -920,7 +1207,8 @@ client_update_attributes(Client *c)
void
client_raise(Client *c)
{
if(!c || ((c->flags & TileFlag) && !(c->flags & AboveFlag)))
if((!c || ((c->flags & TileFlag) && !(c->flags & AboveFlag)))
&& !conf.client_tile_raise)
return;
XRaiseWindow(dpy, c->frame);
@@ -934,6 +1222,7 @@ client_raise(Client *c)
void
uicb_client_raise(uicb_t cmd)
{
(void)cmd;
CHECK(sel);
client_raise(sel);
@@ -956,13 +1245,33 @@ client_unhide(Client *c)
return;
}
/** Select next or previous client to don't lose focus
* \param c Client pointer
*/
void
client_focus_next(Client *c)
{
Client *c_next = NULL;
for(c_next = clients;
c_next && c_next != c->prev
&& c_next->tag != c->tag
&& c_next->screen != c->screen;
c_next = c_next->next);
if(c_next && c_next->tag == (uint)seltag[selscreen]
&& c_next->screen == selscreen)
client_focus(c_next);
return;
}
/** Unmanage a client
* \param c Client pointer
*/
void
client_unmanage(Client *c)
{
Client *c_next = NULL;
Bool b = False;
int i;
@@ -973,6 +1282,9 @@ client_unmanage(Client *c)
if(sel == c)
client_focus(NULL);
if(c->flags & UrgentFlag)
client_urgent(c, False);
client_detach(c);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
setwinstate(c->win, WithdrawnState);
@@ -981,31 +1293,42 @@ client_unmanage(Client *c)
XUngrabServer(dpy);
ewmh_get_client_list();
/* Arrange */
for(i = 0; i < screen_count() && !b; ++i)
if(c->tag == seltag[i])
b = True;
if(b)
tags[c->screen][c->tag].layout.func(c->screen);
if(c->tag == MAXTAG + 1)
{
for(i = 0; i < conf.ntag[c->screen]; i++)
tags[c->screen][i].request_update = True;
tags[c->screen][seltag[c->screen]].layout.func(c->screen);
}
else
{
tags[c->screen][c->tag].request_update = True;
infobar_draw(c->screen);
/* Arrange */
for(i = 0; i < screen_count() && !b; ++i)
if(c->tag == (uint)seltag[i])
{
b = True;
break;
}
else if(tags[i][seltag[i]].tagad & TagFlag(c->tag))
{
tags[i][seltag[i]].layout.func(c->screen);
break;
}
if(b)
tags[c->screen][c->tag].layout.func(c->screen);
else
{
tags[c->screen][c->tag].request_update = True;
infobar_draw(c->screen);
}
}
XFree(c->title);
/* To focus the previous client */
for(c_next = clients;
c_next && c_next != c->prev
&& c_next->tag != c->tag
&& c_next->screen != c->screen;
c_next = c_next->next);
if(c_next && c_next->tag == seltag[selscreen]
&& c_next->screen == selscreen)
client_focus(c_next);
/*XFree(c->title);*/
client_focus_next(c);
free(c);
@@ -1042,7 +1365,7 @@ client_unmap(Client *c)
*\param c Client pointer
*\param s Screen id
*/
void
static void
client_set_screen(Client *c, int s)
{
int os;
@@ -1087,6 +1410,7 @@ client_set_screen(Client *c, int s)
void
uicb_client_screen_next(uicb_t cmd)
{
(void)cmd;
CHECK(sel);
client_set_screen(sel, (sel->screen + 1 > screen_count() - 1) ? 0 : sel->screen + 1);
@@ -1100,6 +1424,7 @@ uicb_client_screen_next(uicb_t cmd)
void
uicb_client_screen_prev(uicb_t cmd)
{
(void)cmd;
CHECK(sel);
client_set_screen(sel, (sel->screen - 1 < 0) ? screen_count() - 1 : sel->screen - 1);
@@ -1107,6 +1432,19 @@ uicb_client_screen_prev(uicb_t cmd)
return;
}
/** Change client of screen to n
* \param cmd uicb_t type screen
*/
void
uicb_client_screen_set(uicb_t cmd)
{
(void)cmd;
CHECK(sel);
client_set_screen(sel, atoi(cmd));
return;
}
/** Move a client
*\param cmd uicb_t type
@@ -1172,11 +1510,45 @@ uicb_client_resize(uicb_t cmd)
void
uicb_ignore_next_client_rules(uicb_t cmd)
{
(void)cmd;
conf.ignore_next_client_rules = !conf.ignore_next_client_rules;
return;
}
/** Select client
*\param cmd uicb_t type clientlist index
*/
static void
uicb_client_select(uicb_t cmd)
{
int i;
Window w;
int d, x, y;
for(i = 0; i < MAXCLIST && clist_index[i].client; ++i)
if(!strcmp(cmd, clist_index[i].key))
{
if(clist_index[i].client->screen != selscreen)
screen_set_sel(clist_index[i].client->screen);
if(clist_index[i].client->tag != (uint)seltag[clist_index[i].client->screen])
tag_set(clist_index[i].client->tag);
client_focus(clist_index[i].client);
client_raise(clist_index[i].client);
/* Move pointer on client */
XQueryPointer(dpy, ROOT, &w, &w, &x, &y, &d, &d, (uint *)&d);
XWarpPointer(dpy, ROOT, ROOT, x, y, d, d,
clist_index[i].client->geo.x + clist_index[i].client->geo.width / 2,
clist_index[i].client->geo.y + clist_index[i].client->geo.height / 2);
}
return;
}
/** Show clientlist menu
*\param cmd uicb_t type
*/
@@ -1185,13 +1557,17 @@ uicb_clientlist(uicb_t cmd)
{
int i, d, u, x, y;
int n = 0;
Bool all = False;
Window w;
Client *c = NULL;
screen_get_sel();
if(cmd && !strcmp(cmd, "all"))
all = True;
for(c = clients; c; c = c->next)
if(!ishide(c, selscreen))
if(!ishide(c, selscreen) || all)
++n;
if(n > 0)
@@ -1206,8 +1582,10 @@ uicb_clientlist(uicb_t cmd)
conf.colors.bar,
conf.colors.text);
clientlist.align = MA_Left;
for(i = 0, c = clients; c; c = c->next)
if(!ishide(c, selscreen))
if(!ishide(c, selscreen) || all)
{
sprintf(clist_index[i].key, "%d", i);
clist_index[i].client = c;
@@ -1230,39 +1608,13 @@ uicb_clientlist(uicb_t cmd)
return;
}
/** Select client
*\param cmd uicb_t type clientlist index
*/
void
uicb_client_select(uicb_t cmd)
{
int i;
Window w;
int d, x, y;
for(i = 0; i < MAXCLIST && clist_index[i].client; ++i)
if(!strcmp(cmd, clist_index[i].key))
{
client_focus(clist_index[i].client);
client_raise(clist_index[i].client);
/* Move pointer on client */
XQueryPointer(dpy, ROOT, &w, &w, &x, &y, &d, &d, (uint *)&d);
XWarpPointer(dpy, ROOT, ROOT, x, y, d, d,
clist_index[i].client->geo.x + clist_index[i].client->geo.width / 2,
clist_index[i].client->geo.y + clist_index[i].client->geo.height / 2);
}
return;
}
/** Check clientlist menu fake function
* \param cmd uicb_t type unused
*/
Bool
uicb_checkclist(uicb_t cmd)
{
(void)cmd;
return True;
}
@@ -1272,6 +1624,7 @@ uicb_checkclist(uicb_t cmd)
void
uicb_client_ignore_tag(uicb_t cmd)
{
(void)cmd;
CHECK(sel);
screen_get_sel();
@@ -1283,3 +1636,26 @@ uicb_client_ignore_tag(uicb_t cmd)
return;
}
/** Set current client as master
*\para cmd uicb_t type unused
*/
void
uicb_client_set_master(uicb_t cmd)
{
Client *c;
(void)cmd;
/* get the first client */
screen_get_sel();
if(!sel || ishide(sel, selscreen))
return;
for(c = clients; c && ishide(c, selscreen); c = c->next);
if (c && c != sel)
{
client_swap(c, sel);
client_focus(c);
}
return;
}

223
src/color.c Normal file
View File

@@ -0,0 +1,223 @@
/*
* color.c
* Copyright © 2011 Brian Mock <mock.brian@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "wmfs.h"
/** Clamp a number x within the range [a, b].
* \param x the number which to clamp
* \param a the lowest possible value
* \param b the highest possible value
* \return the clamped number
*/
static double
color_clamp(double x, double a, double b)
{
if(x < a)
return a;
else if(x > b)
return b;
else
return x;
}
/** Pack a triplet of RGB values into a single uint
* \param r the red value
* \param g the green value
* \param b the blue value
* \return the packed RGB value
*/
static uint
color_pack_rgb(uint r, uint g, uint b)
{
return (r << 16) | (g << 8) | b;
}
/** Unpack an RGB uint into three separate values
* \param rgb the packed color
* \param r a pointer to a uint where the red value will be stored
* \param g a pointer to a uint where the green value will be stored
* \param b a pointer to a uint where the blue value will be stored
*/
static void
color_unpack_rgb(uint rgb, uint *r, uint *g, uint *b)
{
*r = (rgb >> 16) & 0xFF;
*g = (rgb >> 8) & 0xFF;
*b = rgb & 0xFF;
}
/** Convert unpacked RGB values into HSL, storing in the doubles referenced
* by the pointers h, s, l
*/
static void
color_rgb_to_hsl(uint xr, uint xg, uint xb, double *h, double *s, double *l)
{
double r = xr/255.0;
double g = xg/255.0;
double b = xb/255.0;
double v;
double m;
double vm;
double r2, g2, b2;
*h = 0;
*s = 0;
*l = 0;
/* v is max(r, g, b)
* m is min(r, g, b)
*/
v = r > g ? r : g;
v = v > b ? v : b;
m = r < g ? r : g;
m = m < b ? m : b;
*l = (m + v)/2.0;
if(*l <= 0.0)
return;
vm = v - m;
*s = vm;
if(*s > 0.0)
*s /= (*l <= 0.5) ? (v + m) : (2.0 - v - m);
else
return;
r2 = (v - r)/vm;
g2 = (v - g)/vm;
b2 = (v - b)/vm;
if(r == v)
*h = (g == m ? 5.0 + b2 : 1.0 - g2);
else if(g == v)
*h = (b == m ? 1.0 + r2 : 3.0 - b2);
else
*h = (r == m ? 3.0 + g2 : 5.0 - r2);
*h /= 6.0;
}
/** Convert h, s, l values to RGB and store them in the three uint
* referenced by the last three parameters.
*/
static void
color_hsl_to_rgb(double h, double sl, double l, uint *rx, uint *gx, uint *bx)
{
double v;
double r,g,b;
r = l;
g = l;
b = l;
v = (l <= 0.5) ? (l * (1.0 + sl)) : (l + sl - l * sl);
if(v > 0)
{
double m;
double sv;
int sextant;
double fract, vsf, mid1, mid2;
m = l + l - v;
sv = (v - m ) / v;
h *= 6.0;
sextant = (int) h;
fract = h - sextant;
vsf = v * sv * fract;
mid1 = m + vsf;
mid2 = v - vsf;
switch(sextant)
{
case 0:
r = v;
g = mid1;
b = m;
break;
case 1:
r = mid2;
g = v;
b = m;
break;
case 2:
r = m;
g = v;
b = mid1;
break;
case 3:
r = m;
g = mid2;
b = v;
break;
case 4:
r = mid1;
g = m;
b = v;
break;
case 5:
r = v;
g = m;
b = mid2;
break;
}
}
*rx = r * 255.0;
*gx = g * 255.0;
*bx = b * 255.0;
}
/** Shades a color by the amount. This works by converting a packed RGB
* color to HSL, adding the amount to the lightness,
* and then converting back to RGB. 1.0 is max lightness, 0.0 is min lightness.
* \param shadeVal the amount to shade the lightness by.
* \return the shaded color
*/
uint
color_shade(uint rgb, double shadeVal)
{
uint r, g, b;
double h, s, l;
color_unpack_rgb(rgb, &r, &g, &b);
color_rgb_to_hsl(r, g, b, &h, &s, &l);
l += shadeVal;
l = color_clamp(l, 0, 1);
color_hsl_to_rgb(h, s, l, &r, &g, &b);
rgb = color_pack_rgb(r, g, b);
return rgb;
}

View File

@@ -32,7 +32,7 @@
#include "wmfs.h"
func_name_list_t tmp_func_list[] =
const func_name_list_t func_list[] =
{
{"spawn", uicb_spawn },
{"client_kill", uicb_client_kill },
@@ -42,9 +42,15 @@ func_name_list_t tmp_func_list[] =
{"client_swap_prev", uicb_client_swap_prev },
{"client_screen_next", uicb_client_screen_next },
{"client_screen_prev", uicb_client_screen_prev },
{"client_screen_set", uicb_client_screen_set },
{"client_focus_right", uicb_client_focus_right },
{"client_focus_left" , uicb_client_focus_left },
{"client_focus_top", uicb_client_focus_top },
{"client_focus_bottom", uicb_client_focus_bottom },
{"client_move", uicb_client_move },
{"client_resize", uicb_client_resize },
{"client_ignore_tag", uicb_client_ignore_tag },
{"client_set_master", uicb_client_set_master },
{"toggle_max", uicb_togglemax },
{"layout_next", uicb_layout_next },
{"layout_prev", uicb_layout_prev },
@@ -64,10 +70,14 @@ func_name_list_t tmp_func_list[] =
{"tag_swap_prev", uicb_tag_swap_previous },
{"tag_new", uicb_tag_new },
{"tag_del", uicb_tag_del },
{"tag_rename", uicb_tag_rename },
{"tag_last", uicb_tag_last },
{"tag_stay_last", uicb_tag_stay_last },
{"set_mwfact", uicb_set_mwfact },
{"set_nmaster", uicb_set_nmaster },
{"quit", uicb_quit },
{"toggle_infobar_position", uicb_infobar_togglepos },
{"toggle_infobar_display", uicb_infobar_toggledisplay },
{"toggle_resizehint", uicb_toggle_resizehint },
{"mouse_move", uicb_mouse_move },
{"mouse_resize", uicb_mouse_resize },
@@ -82,18 +92,18 @@ func_name_list_t tmp_func_list[] =
{"launcher", uicb_launcher },
{"set_layout", uicb_set_layout },
{"menu", uicb_menu },
{"set_client_layer", uicb_set_client_layer },
{"set_layer", uicb_set_layer },
{"ignore_next_client_rules", uicb_ignore_next_client_rules },
{"check_max", uicb_checkmax },
{"check_free", uicb_checkfree },
{"check_layout", uicb_checklayout },
{"clientlist", uicb_clientlist },
{"check_clist", uicb_checkclist },
{"toggle_tagautohide", uicb_toggle_tagautohide }
{"toggle_tagautohide", uicb_toggle_tagautohide },
{"toggle_tag_expose", uicb_tag_toggle_expose},
{NULL, NULL}
};
key_name_list_t key_list[] =
static key_name_list_t key_list[] =
{
{"Control", ControlMask },
{"Shift", ShiftMask },
@@ -108,7 +118,7 @@ key_name_list_t key_list[] =
{NULL, NoSymbol }
};
name_to_uint_t mouse_button_list[] =
static name_to_uint_t mouse_button_list[] =
{
{"Button1", Button1 },
{"Button2", Button2 },
@@ -120,9 +130,10 @@ name_to_uint_t mouse_button_list[] =
{"3", Button3 },
{"4", Button4 },
{"5", Button5 },
{NULL, NoSymbol}
};
void
static void
mouse_section(MouseBinding mb[], struct conf_sec **sec)
{
int n;
@@ -137,24 +148,31 @@ mouse_section(MouseBinding mb[], struct conf_sec **sec)
}
}
void
static void
conf_misc_section(void)
{
int pad = 12;
uint opacity = 255;
struct conf_sec *sec;
sec = fetch_section_first(NULL, "misc");
conf.font = fetch_opt_first(sec, "sans-9", "font").str;
conf.raisefocus = fetch_opt_first(sec, "false", "raisefocus").bool;
conf.raiseswitch = fetch_opt_first(sec, "false", "raiseswitch").bool;
conf.focus_fmouse = fetch_opt_first(sec, "true", "focus_follow_mouse").bool;
conf.focus_fmov = fetch_opt_first(sec, "false", "focus_follow_movement").bool;
conf.focus_pclick = fetch_opt_first(sec, "true", "focus_pointer_click").bool;
conf.status_timing = fetch_opt_first(sec, "1", "status_timing").num;
conf.status_path = fetch_opt_first(sec, "", "status_path").str;
conf.autostart_path = fetch_opt_first(sec, "", "autostart_path").str;
conf.autostart_command = fetch_opt_first(sec, "", "autostart_command").str;
pad = fetch_opt_first(sec, "12", "pad").num;
opacity = fetch_opt_first(sec, "255", "opacity").num;
if(opacity > 255)
opacity = 255;
conf.opacity = opacity << 24;
if(pad > 24 || pad < 1)
{
@@ -174,11 +192,12 @@ conf_misc_section(void)
return;
}
void
static void
conf_bar_section(void)
{
struct conf_sec *bar, **mouse, *selbar;
struct conf_sec *bar, **mouse, *selbar, *systray;
char *barbg;
int sc = screen_count();
bar = fetch_section_first(NULL, "bar");
@@ -187,38 +206,54 @@ conf_bar_section(void)
conf.colors.bar = getcolor((barbg = fetch_opt_first(bar, "#000000", "bg").str));
conf.colors.text = fetch_opt_first(bar, "#ffffff", "fg").str;
conf.colors.bar_light_shade = fetch_opt_first(bar, "0.25", "light_shade").fnum;
conf.colors.bar_dark_shade = fetch_opt_first(bar, "-0.25", "dark_shade").fnum;
mouse = fetch_section(bar, "mouse");
if ((conf.bars.nmouse = fetch_section_count(mouse)) > 0)
{
conf.bars.mouse = emalloc(conf.bars.nmouse, sizeof(MouseBinding));
conf.bars.mouse = xcalloc(conf.bars.nmouse, sizeof(MouseBinding));
mouse_section(conf.bars.mouse, mouse);
}
free(mouse);
if((systray = fetch_section_first(bar, "systray")))
{
conf.systray.active = fetch_opt_first(systray, "true", "active").bool;
if((conf.systray.screen = fetch_opt_first(systray, "0", "screen").num) < 0
|| conf.systray.screen >= sc)
conf.systray.screen = 0;
if((conf.systray.spacing = fetch_opt_first(systray, "3", "spacing").num) < 0)
conf.systray.spacing = 0;
}
else
conf.systray.active = False;
selbar = fetch_section_first(bar, "selbar");
conf.bars.selbar = selbar ? True : False;
conf.selbar.bg = getcolor(fetch_opt_first(selbar, barbg, "bg").str);
conf.selbar.fg = fetch_opt_first(selbar, conf.colors.text, "fg").str;
conf.selbar.maxlenght = fetch_opt_first(selbar, "-1", "max_lenght").num;
conf.selbar.maxlength = fetch_opt_first(selbar, "-1", "max_length").num;
mouse = fetch_section(selbar, "mouse");
if ((conf.selbar.nmouse = fetch_section_count(mouse)))
{
conf.selbar.mouse = emalloc(conf.selbar.nmouse, sizeof(MouseBinding));
conf.selbar.mouse = xcalloc(conf.selbar.nmouse, sizeof(MouseBinding));
mouse_section(conf.selbar.mouse, mouse);
}
free(mouse);
free(barbg);
return;
}
void
static void
conf_root_section(void)
{
struct conf_sec *root, **mouse;
@@ -231,7 +266,7 @@ conf_root_section(void)
if ((conf.root.nmouse = fetch_section_count(mouse)) > 0)
{
conf.root.mouse = emalloc(conf.root.nmouse, sizeof(MouseBinding));
conf.root.mouse = xcalloc(conf.root.nmouse, sizeof(MouseBinding));
mouse_section(conf.root.mouse, mouse);
}
@@ -240,7 +275,7 @@ conf_root_section(void)
return;
}
void
static void
conf_client_section(void)
{
int i, j;
@@ -251,24 +286,35 @@ conf_client_section(void)
sec = fetch_section_first(NULL, "client");
conf.client_round = fetch_opt_first(sec, "true", "client_round").bool;
conf.client_auto_center = fetch_opt_first(sec, "false", "client_auto_center").bool;
conf.client_tile_raise = fetch_opt_first(sec, "false", "client_tile_raise").bool;
if ((conf.client.borderheight = fetch_opt_first(sec, "1", "border_height").num) < 1)
conf.client.borderheight = 1;
conf.client.border_shadow = fetch_opt_first(sec, "false", "border_shadow").bool;
conf.client.place_at_mouse = fetch_opt_first(sec, "false", "place_at_mouse").bool;
conf.client.bordernormal = getcolor(fetch_opt_first(sec, "#000000", "border_normal").str);
conf.client.borderfocus = getcolor(fetch_opt_first(sec, "#ffffff", "border_focus").str);
conf.client.resizecorner_normal = getcolor(fetch_opt_first(sec, "#222222", "resize_corner_normal").str);
conf.client.resizecorner_focus = getcolor(fetch_opt_first(sec, "#DDDDDD", "resize_corner_focus").str);
conf.client.mod |= char_to_modkey(fetch_opt_first(sec, "Alt", "modifier").str, key_list);
conf.client.set_new_win_master = fetch_opt_first(sec, "true", "set_new_win_master").bool;
conf.client.border_shadow = fetch_opt_first(sec, "false", "border_shadow").bool;
conf.client.place_at_mouse = fetch_opt_first(sec, "false", "place_at_mouse").bool;
conf.client.bordernormal = getcolor(fetch_opt_first(sec, "#000000", "border_normal").str);
conf.client.borderfocus = getcolor(fetch_opt_first(sec, "#ffffff", "border_focus").str);
conf.client.resizecorner_normal = getcolor(fetch_opt_first(sec, "#222222", "resize_corner_normal").str);
conf.client.resizecorner_focus = getcolor(fetch_opt_first(sec, "#DDDDDD", "resize_corner_focus").str);
conf.client.mod |= char_to_modkey(fetch_opt_first(sec, "Alt", "modifier").str, key_list);
conf.client.set_new_win_master = fetch_opt_first(sec, "true", "set_new_win_master").bool;
conf.client.padding = fetch_opt_first(sec, "0", "padding").num;
conf.client.autofree = fetch_opt_first(sec, "", "autofree").str;
conf.client.automax = fetch_opt_first(sec, "", "automax").str;
conf.client.default_open_tag = fetch_opt_first(sec, "0", "default_open_tag").num;
conf.client.default_open_screen = fetch_opt_first(sec, "-1", "default_open_screen").num;
conf.client.new_client_get_mouse = fetch_opt_first(sec, "false", "new_client_get_mouse").bool;
conf.colors.client_light_shade = fetch_opt_first(sec, "0.25", "light_shade").fnum;
conf.colors.client_dark_shade = fetch_opt_first(sec, "-0.25", "dark_shade").fnum;
mouse = fetch_section(sec, "mouse");
if((conf.client.nmouse = fetch_section_count(mouse)) > 0)
{
conf.client.mouse = emalloc(conf.client.nmouse, sizeof(MouseBinding));
conf.client.mouse = xcalloc(conf.client.nmouse, sizeof(MouseBinding));
mouse_section(conf.client.mouse, mouse);
}
@@ -296,7 +342,7 @@ conf_client_section(void)
if((conf.titlebar.nmouse = fetch_section_count(mouse)) > 0)
{
conf.titlebar.mouse = emalloc(conf.titlebar.nmouse, sizeof(MouseBinding));
conf.titlebar.mouse = xcalloc(conf.titlebar.nmouse, sizeof(MouseBinding));
mouse_section(conf.titlebar.mouse, mouse);
}
@@ -307,7 +353,7 @@ conf_client_section(void)
if((conf.titlebar.nbutton = fetch_section_count(button)) > 0)
{
conf.titlebar.button = emalloc(conf.titlebar.nbutton, sizeof(Button));
conf.titlebar.button = xcalloc(conf.titlebar.nbutton, sizeof(Button));
for(i = 0; i < conf.titlebar.nbutton; ++i)
{
flags = fetch_opt_first(button[i], "none", "flags").str;
@@ -325,7 +371,7 @@ conf_client_section(void)
if((conf.titlebar.button[i].nmouse = fetch_section_count(mouse)) > 0)
{
conf.titlebar.button[i].mouse = emalloc(conf.titlebar.button[i].nmouse, sizeof(MouseBinding));
conf.titlebar.button[i].mouse = xcalloc(conf.titlebar.button[i].nmouse, sizeof(MouseBinding));
mouse_section(conf.titlebar.button[i].mouse, mouse);
}
@@ -336,7 +382,7 @@ conf_client_section(void)
if((conf.titlebar.button[i].nlines = fetch_section_count(line)) > 0)
{
conf.titlebar.button[i].linecoord = emalloc(conf.titlebar.button[i].nlines, sizeof(XSegment));
conf.titlebar.button[i].linecoord = xcalloc(conf.titlebar.button[i].nlines, sizeof(XSegment));
for(j = 0; j < conf.titlebar.button[i].nlines; ++j)
{
@@ -357,7 +403,7 @@ conf_client_section(void)
return;
}
void
static void
conf_layout_section(void)
{
int i;
@@ -373,10 +419,12 @@ conf_layout_section(void)
layouts = fetch_section_first(NULL, "layouts");
conf.border.layout = fetch_opt_first(layouts, "false", "border").bool;
conf.colors.layout_fg = fetch_opt_first(layouts, "#ffffff", "fg").str;
conf.colors.layout_bg = getcolor((fetch_opt_first(layouts, "#000000", "bg").str));
conf.layout_button_width = fetch_opt_first(layouts, "O", "layout_button_width").num;
conf.border.layout = fetch_opt_first(layouts, "false", "border").bool;
conf.colors.layout_fg = fetch_opt_first(layouts, "#ffffff", "fg").str;
conf.colors.layout_bg = getcolor((fetch_opt_first(layouts, "#000000", "bg").str));
conf.keep_layout_geo = fetch_opt_first(layouts, "false", "keep_layout_geo").bool;
conf.selected_layout_symbol = fetch_opt_first(layouts, "*", "selected_layout_symbol").str;
if((tmp = fetch_opt_first(layouts, "menu", "system").str) && !strcmp(tmp, "menu"))
conf.layout_system = True;
@@ -391,7 +439,7 @@ conf_layout_section(void)
{
warnx("configuration : Too many or no layouts (%d).", conf.nlayout);
conf.nlayout = 1;
conf.layout[0].symbol = _strdup("TILE");
conf.layout[0].symbol = xstrdup("TILE");
conf.layout[0].func = tile;
}
@@ -433,32 +481,56 @@ conf_layout_section(void)
return;
}
void
static void
conf_tag_section(void)
{
int i, j, k, l = 0, m, n, sc, count;
int i, j, k, l = 0, m, n, sc, count, bar_pos;
char *tmp;
struct conf_sec *sec, **tag, **mouse;
char *position;
struct conf_sec *sec, *def_tag, **tag, **mouse;
struct opt_type *opt;
/* If there is no tag in the conf or more than
* MAXTAG (32) print an error and create only one.
*/
Tag default_tag = { "WMFS", NULL, 0, 1,
0.50, 1, False, False, False, False, IB_Top,
layout_name_to_struct(conf.layout, "tile_right", conf.nlayout, layout_list),
0, NULL, 0 };
sec = fetch_section_first(NULL, "tags");
conf.tag_round = fetch_opt_first(sec, "false", "tag_round").bool;
conf.tag_auto_prev = fetch_opt_first(sec, "true", "tag_auto_prev").bool;
conf.colors.tagselfg = fetch_opt_first(sec, "#ffffff", "sel_fg").str;
conf.colors.tagselbg = getcolor(fetch_opt_first(sec, "#000000", "sel_bg").str);
conf.colors.tagurfg = fetch_opt_first(sec, "#000000", "urgent_fg").str;
conf.colors.tagurbg = getcolor(fetch_opt_first(sec, "#DD1111", "urgent_bg").str);
conf.colors.tag_occupied_bg = getcolor(fetch_opt_first(sec, "#222222", "occupied_bg").str);
conf.colors.tag_occupied_fg = fetch_opt_first(sec, conf.colors.text, "occupied_fg").str;
conf.border.tag = fetch_opt_first(sec, "false", "border").bool;
conf.tagautohide = fetch_opt_first(sec, "false", "autohide").bool;
conf.tagnamecount = fetch_opt_first(sec, "false", "name_count").bool;
conf.tag_expose_name = fetch_opt_first(sec, "EXPOSE", "expose_name").str;
conf.expose_layout = fetch_opt_first(sec, "tile_grid_vertical", "expose_layout").str;
def_tag = fetch_section_first(sec, "default_tag");
position = fetch_opt_first(def_tag, "top", "infobar_position").str;
if(!strcmp(position, "none")
|| !strcmp(position, "hide")
|| !strcmp(position, "hidden"))
bar_pos = IB_Hide;
else if(!strcmp(position, "bottom")
|| !strcmp(position, "down"))
bar_pos = IB_Bottom;
else
bar_pos = IB_Top;
/* If there is no tag in the conf or more than
* MAXTAG (36) print an error and create only one.
*/
Tag default_tag = { fetch_opt_first(def_tag, "new tag", "name").str, NULL, 0, 1,
fetch_opt_first(def_tag, "0.6", "mwfact").fnum,
fetch_opt_first(def_tag, "1", "nmaster").num,
False, fetch_opt_first(def_tag, "False", "resizehint").bool,
False, False, bar_pos, bar_pos,
layout_name_to_struct(conf.layout, fetch_opt_first(def_tag, "title_right", "layout").str, conf.nlayout, layout_list),
0, NULL, 0, False };
conf.default_tag = default_tag;
/* Mouse button action on tag */
conf.mouse_tag_action[TagSel] =
@@ -475,10 +547,10 @@ conf_tag_section(void)
sc = screen_count();
/* Alloc all */
conf.ntag = emalloc(sc, sizeof(int));
tags = emalloc(sc, sizeof(Tag*));
seltag = emalloc(sc, sizeof(int));
prevseltag = emalloc(sc, sizeof(int));
conf.ntag = xcalloc(sc, sizeof(*conf.ntag));
tags = xcalloc(sc, sizeof(*tags));
seltag = xcalloc(sc, sizeof(*seltag));
prevseltag = xcalloc(sc, sizeof(*prevseltag));
for(i = 0; i < sc; ++i)
seltag[i] = 1;
@@ -488,7 +560,7 @@ conf_tag_section(void)
n = fetch_section_count(tag);
for(i = 0; i < sc; ++i)
tags[i] = emalloc(n + 2, sizeof(Tag));
tags[i] = xcalloc(n + 2, sizeof(Tag));
for(i = 0; i < n; i++)
{
@@ -502,14 +574,14 @@ conf_tag_section(void)
((j == -1) ? ++k : --l))
{
++conf.ntag[k];
tags[k][conf.ntag[k]].name = fetch_opt_first(tag[i], "", "name").str;
tags[k][conf.ntag[k]].mwfact = fetch_opt_first(tag[i], "0.65", "mwfact").fnum;
tags[k][conf.ntag[k]].nmaster = fetch_opt_first(tag[i], "1", "nmaster").num;
tags[k][conf.ntag[k]].resizehint = fetch_opt_first(tag[i], "false", "resizehint").bool;
tags[k][conf.ntag[k]].name = fetch_opt_first(tag[i], fetch_opt_first(def_tag, "", "name").str, "name").str;
tags[k][conf.ntag[k]].mwfact = fetch_opt_first(tag[i], fetch_opt_first(def_tag, "0.65", "mwfact").str, "mwfact").fnum;
tags[k][conf.ntag[k]].nmaster = fetch_opt_first(tag[i], fetch_opt_first(def_tag, "1", "nmaster").str, "nmaster").num;
tags[k][conf.ntag[k]].resizehint = fetch_opt_first(tag[i], fetch_opt_first(def_tag, "false", "resizehint").str, "resizehint").bool;
tags[k][conf.ntag[k]].abovefc = fetch_opt_first(tag[i], "false", "abovefc").bool;
tags[k][conf.ntag[k]].layers = 1;
tmp = fetch_opt_first(tag[i], "top", "infobar_position").str;
tmp = fetch_opt_first(tag[i], fetch_opt_first(def_tag, "top", "infobar_position").str, "infobar_position").str;
if(!strcmp(tmp ,"none") || !strcmp(tmp, "hide") || !strcmp(tmp, "hidden"))
tags[k][conf.ntag[k]].barpos = IB_Hide;
@@ -519,7 +591,7 @@ conf_tag_section(void)
tags[k][conf.ntag[k]].barpos = IB_Top;
tags[k][conf.ntag[k]].layout = layout_name_to_struct(conf.layout,
fetch_opt_first(tag[i], "tile_right", "layout").str,
fetch_opt_first(tag[i], fetch_opt_first(def_tag, "title_right", "layout").str, "layout").str,
conf.nlayout,
layout_list);
@@ -529,7 +601,7 @@ conf_tag_section(void)
if ((count = fetch_opt_count(opt)))
{
tags[k][conf.ntag[k]].nclients = count;
tags[k][conf.ntag[k]].clients = emalloc(count, sizeof(char *));
tags[k][conf.ntag[k]].clients = xcalloc(count, sizeof(char *));
for(m = 0; m < count; ++m)
tags[k][conf.ntag[k]].clients[m] = opt[m].str;
}
@@ -541,7 +613,7 @@ conf_tag_section(void)
if((tags[k][conf.ntag[k]].nmouse = fetch_section_count(mouse)))
{
tags[k][conf.ntag[k]].mouse = emalloc(tags[k][conf.ntag[k]].nmouse, sizeof(MouseBinding));
tags[k][conf.ntag[k]].mouse = xcalloc(tags[k][conf.ntag[k]].nmouse, sizeof(MouseBinding));
mouse_section(tags[k][conf.ntag[k]].mouse, mouse);
}
@@ -563,7 +635,39 @@ conf_tag_section(void)
return;
}
void
static void
conf_rule_section(void)
{
int i;
struct conf_sec *rules, **rule;
rules = fetch_section_first(NULL, "rules");
rule = fetch_section(rules, "rule");
CHECK((conf.nrule = fetch_section_count(rule)));
conf.rule = xcalloc(conf.nrule, sizeof(Rule));
for(i = 0; i < conf.nrule; ++i)
{
conf.rule[i].class = fetch_opt_first(rule[i], "", "class").str;
conf.rule[i].instance = fetch_opt_first(rule[i], "", "instance").str;
conf.rule[i].role = fetch_opt_first(rule[i], "", "role").str;
conf.rule[i].screen = fetch_opt_first(rule[i], "-1", "screen").num;
conf.rule[i].tag = fetch_opt_first(rule[i], "-1", "tag").num;
conf.rule[i].free = fetch_opt_first(rule[i], "false", "free").bool;
conf.rule[i].max = fetch_opt_first(rule[i], "false", "max").bool;
conf.rule[i].ignoretags = fetch_opt_first(rule[i], "false", "ignoretags").bool;
conf.rule[i].follow_client = fetch_opt_first(rule[i], "false", "follow_client").bool;
}
free(rule);
return;
}
static void
conf_menu_section(void)
{
char *tmp2;
@@ -576,7 +680,7 @@ conf_menu_section(void)
CHECK((conf.nmenu = fetch_section_count(set_menu)));
conf.menu = calloc(conf.nmenu, sizeof(Menu));
conf.menu = xcalloc(conf.nmenu, sizeof(Menu));
for(i = 0; i < conf.nmenu; ++i)
{
@@ -607,7 +711,7 @@ conf_menu_section(void)
if((conf.menu[i].nitem = fetch_section_count(item)))
{
conf.menu[i].item = emalloc(conf.menu[i].nitem, sizeof(MenuItem));
conf.menu[i].item = xcalloc(conf.menu[i].nitem, sizeof(MenuItem));
for(j = 0; j < conf.menu[i].nitem; ++j)
{
conf.menu[i].item[j].name = fetch_opt_first(item[j], "item_wname", "name").str;
@@ -624,7 +728,7 @@ conf_menu_section(void)
return;
}
void
static void
conf_launcher_section(void)
{
int i;
@@ -635,13 +739,14 @@ conf_launcher_section(void)
CHECK((conf.nlauncher = fetch_section_count(set_launcher)));
conf.launcher = emalloc(conf.nlauncher, sizeof(Launcher));
conf.launcher = xcalloc(conf.nlauncher, sizeof(Launcher));
for(i = 0; i < conf.nlauncher; ++i)
{
conf.launcher[i].name = fetch_opt_first(set_launcher[i], "launcher", "name").str;
conf.launcher[i].prompt = fetch_opt_first(set_launcher[i], "Exec:", "prompt").str;
conf.launcher[i].command = fetch_opt_first(set_launcher[i], "exec", "command").str;
conf.launcher[i].width = fetch_opt_first(set_launcher[i], "0", "width_limit").num;
conf.launcher[i].nhisto = 1;
}
free(set_launcher);
@@ -649,10 +754,11 @@ conf_launcher_section(void)
return;
}
void
static void
conf_keybind_section(void)
{
int i, j;
int i;
size_t j;
struct conf_sec *sec, **ks;
struct opt_type *opt;
@@ -660,7 +766,7 @@ conf_keybind_section(void)
ks = fetch_section(sec, "key");
conf.nkeybind = fetch_section_count(ks);
keys = emalloc(conf.nkeybind, sizeof(Key));
keys = xcalloc(conf.nkeybind, sizeof(Key));
for(i = 0; i < conf.nkeybind; ++i)
{
@@ -694,26 +800,23 @@ conf_keybind_section(void)
void
init_conf(void)
{
if (get_conf(conf.confpath) == -1)
if(get_conf(conf.confpath) == -1)
{
warnx("parsing configuration file (%s) failed.", conf.confpath);
sprintf(conf.confpath, "%s/wmfs/wmfsrc", XDG_CONFIG_DIR);
warnx("Use the default configuration (%s).", conf.confpath);
if (get_conf(conf.confpath) == -1)
if(get_conf(conf.confpath) == -1)
errx(1, "parsing configuration file (%s) failed.", conf.confpath);
}
/* Set func_list */
func_list = emalloc(LEN(tmp_func_list), sizeof(func_name_list_t));
memcpy(func_list, tmp_func_list, LEN(tmp_func_list) * sizeof(func_name_list_t));
conf_misc_section();
conf_bar_section();
conf_root_section();
conf_client_section();
conf_layout_section();
conf_tag_section();
conf_rule_section();
conf_menu_section();
conf_launcher_section();
conf_keybind_section();

View File

@@ -1,50 +0,0 @@
/*
* config.h
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CONFIG_H
#define CONFIG_H
#include "wmfs.h"
#define WMFS_VERSION "@WMFS_VERSION@"
#define WMFS_COMPILE_MACHINE "@WMFS_COMPILE_MACHINE@"
#define WMFS_COMPILE_BY "@WMFS_COMPILE_BY@"
#define WMFS_COMPILE_FLAGS "@WMFS_COMPILE_FLAGS@"
#define WMFS_LINKED_LIBS "@WMFS_LINKED_LIBS@"
#define XDG_CONFIG_DIR "@XDG_CONFIG_DIR@"
/* Optional dependencies */
@WMFS_HAVE_XINERAMA@
@WMFS_HAVE_XRANDR@
@WMFS_HAVE_IMLIB@
#endif /* CONFIG_H */

View File

@@ -32,6 +32,53 @@
#include "wmfs.h"
#ifdef HAVE_IMLIB
/** Draw an image in a drawable
* \param dr Drawable
* \param x X position
* \param y Y position
* \param name Path of the image
*/
static void draw_image(Drawable dr, int x, int y, int w, int h, char *name)
{
Imlib_Image image;
if(!name)
return;
imlib_set_cache_size(2048 * 1024);
imlib_context_set_display(dpy);
imlib_context_set_visual(DefaultVisual(dpy, DefaultScreen(dpy)));
imlib_context_set_colormap(DefaultColormap(dpy, DefaultScreen(dpy)));
imlib_context_set_drawable(dr);
image = imlib_load_image(patht(name));
imlib_context_set_image(image);
if(w <= 0)
w = imlib_image_get_width();
if(h <= 0)
h = imlib_image_get_height();
if(image)
{
imlib_render_image_on_drawable_at_size(x, y, w, h);
imlib_free_image();
}
else
warnx("Can't draw image: '%s'", name);
return;
}
#endif /* HAVE_IMLIB */
void
draw_text(Drawable d, int x, int y, char* fg, char *str)
{
draw_image_ofset_text(d, x, y, fg, str, 0, 0);
}
/** Draw a string in a Drawable
* \param d Drawable
* \param x X position
@@ -41,28 +88,38 @@
* \param str String that will be draw
*/
void
draw_text(Drawable d, int x, int y, char* fg, int pad, char *str)
draw_image_ofset_text(Drawable d, int x, int y, char* fg, char *str, int x_image_ofset, int y_image_ofset)
{
XftColor xftcolor;
XftDraw *xftd;
#ifdef HAVE_IMLIB
char *ostr = NULL;
int i, ni, sw = 0;
ImageAttr im[128];
size_t textlen;
#else
(void)x_image_ofset;
(void)y_image_ofset;
#endif /* HAVE_IMLIB */
if(!str)
return;
/* To draw image everywhere we can draw text */
#ifdef HAVE_IMLIB
char *ostr = NULL;
int i, ni;
ImageAttr im[128];
ostr = _strdup(str);
ostr = xstrdup(str);
textlen = strlen(ostr);
if(strstr(str, "i["))
{
ni = parse_image_block(im, str);
if(infobar[conf.systray.screen].bar && d == infobar[conf.systray.screen].bar->dr)
sw = systray_get_width();
for(i = 0; i < ni; ++i)
draw_image(d, im[i].x, im[i].y, im[i].w, im[i].h, im[i].name);
draw_image(d, x_image_ofset + im[i].x - sw, y_image_ofset + im[i].y, im[i].w, im[i].h, im[i].name);
}
#endif /* HAVE_IMLIB */
@@ -82,9 +139,9 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str)
#ifdef HAVE_IMLIB
if(strstr(ostr, "i["))
strcpy(str, ostr);
strncpy(str, ostr, textlen);
IFREE(ostr);
free(ostr);
#endif /* HAVE_IMLIB */
return;
@@ -121,7 +178,7 @@ draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color)
void
draw_graph(Drawable dr, int x, int y, uint w, uint h, uint color, char *data)
{
int i;
uint i;
XSetForeground(dpy, gc, color);
@@ -135,48 +192,6 @@ draw_graph(Drawable dr, int x, int y, uint w, uint h, uint color, char *data)
return;
}
#ifdef HAVE_IMLIB
/** Draw an image in a drawable
* \param dr Drawable
* \param x X position
* \param y Y position
* \param name Path of the image
*/
void
draw_image(Drawable dr, int x, int y, int w, int h, char *name)
{
Imlib_Image image;
if(!name)
return;
imlib_set_cache_size(2048 * 1024);
imlib_context_set_display(dpy);
imlib_context_set_visual(DefaultVisual(dpy, DefaultScreen(dpy)));
imlib_context_set_colormap(DefaultColormap(dpy, DefaultScreen(dpy)));
imlib_context_set_drawable(dr);
image = imlib_load_image(name);
imlib_context_set_image(image);
if(w <= 0)
w = imlib_image_get_width();
if(h <= 0)
h = imlib_image_get_height();
if(image)
{
imlib_render_image_on_drawable_at_size(x, y, w, h);
imlib_free_image();
}
else
warnx("Can't draw image: '%s'", name);
return;
}
#endif /* HAVE_IMLIB */
/** Calculates the text's size relatively to the font
* \param text Text string
* \return final text width
@@ -185,16 +200,20 @@ ushort
textw(char *text)
{
XGlyphInfo gl;
#ifdef HAVE_IMLIB
char *ostr = NULL;
ImageAttr im[128];
size_t textlen;
#endif /* HAVE_IMLIB */
if(!text)
return 0;
#ifdef HAVE_IMLIB
char *ostr = NULL;
ImageAttr im[128];
ostr = _strdup(text);
ostr = xstrdup(text);
textlen = strlen(ostr);
if(strstr(text, "i["))
parse_image_block(im, text);
@@ -204,12 +223,10 @@ textw(char *text)
#ifdef HAVE_IMLIB
if(strstr(ostr, "i["))
strcpy(text, ostr);
strncpy(text, ostr, textlen);
IFREE(ostr);
free(ostr);
#endif /* HAVE_IMLIB */
return gl.width + font->descent;
}

View File

@@ -35,7 +35,7 @@
/** ButtonPress handle event
* \param ev XButtonEvent pointer
*/
void
static void
buttonpress(XButtonEvent *ev)
{
Client *c;
@@ -65,7 +65,10 @@ buttonpress(XButtonEvent *ev)
for(i = 0; i < conf.titlebar.button[n].nmouse; ++i)
if(ev->button == conf.titlebar.button[n].mouse[i].button)
if(conf.titlebar.button[n].mouse[i].func)
{
client_focus(c);
conf.titlebar.button[n].mouse[i].func(conf.titlebar.button[n].mouse[i].cmd);
}
/* Frame Resize Area */
if((c = client_gb_resize(ev->window)))
@@ -77,6 +80,7 @@ buttonpress(XButtonEvent *ev)
if(ev->button == conf.client.mouse[i].button)
if(conf.client.mouse[i].func)
conf.client.mouse[i].func(conf.client.mouse[i].cmd);
/* Root */
if(ev->window == ROOT)
for(i = 0; i < conf.root.nmouse; ++i)
@@ -158,10 +162,11 @@ buttonpress(XButtonEvent *ev)
/* ClientMessage handle event
*\param ev XClientMessageEvent pointer
*/
void
static void
clientmessageevent(XClientMessageEvent *ev)
{
Client *c;
Systray *sy;
int s, i, mess_t = 0;
Atom rt;
int rf;
@@ -195,8 +200,28 @@ clientmessageevent(XClientMessageEvent *ev)
/* Manage _NET_ACTIVE_WINDOW */
else if(mess_t == net_active_window)
{
if((c = client_gb_win(ev->window)))
client_focus(c);
else if((sy = systray_find(ev->data.l[0])))
XSetInputFocus(dpy, sy->win, RevertToNone, CurrentTime);
}
}
else if(ev->window == traywin)
{
/* Manage _NET_WM_SYSTEM_TRAY_OPCODE */
if(mess_t == net_wm_system_tray_opcode)
{
if(ev->data.l[1] == XEMBED_EMBEDDED_NOTIFY)
{
systray_add(ev->data.l[2]);
systray_update();
}
else if(ev->data.l[1] == XEMBED_REQUEST_FOCUS)
if((sy = systray_find(ev->data.l[2])))
ewmh_send_message(sy->win, sy->win, "_XEMBED",
XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT, 0, 0, 0);
}
}
/* Manage _NET_WM_STATE */
@@ -211,7 +236,7 @@ clientmessageevent(XClientMessageEvent *ev)
/* Manage _NET_WM_DESKTOP */
if(mess_t == net_wm_desktop)
if((c = client_gb_win(ev->window)))
if((c = client_gb_win(ev->window)) && ev->data.l[0] != (long)0xFFFFFFFF)
tag_transfert(c, ev->data.l[0]);
/* Manage _WMFS_STATUSTEXT_x */
@@ -250,7 +275,6 @@ clientmessageevent(XClientMessageEvent *ev)
ewmh_get_client_list();
ewmh_get_desktop_names();
ewmh_set_desktop_geometry();
ewmh_set_workarea();
screen_count();
screen_get_sel();
}
@@ -262,10 +286,10 @@ clientmessageevent(XClientMessageEvent *ev)
return;
}
/** ConfigureRequest & ConfigureNotify handle events
* \param ev XEvent pointer
/** ConfigureRequesthandle events
* \param ev XConfigureRequestEvent pointer
*/
void
static void
configureevent(XConfigureRequestEvent *ev)
{
XWindowChanges wc;
@@ -275,7 +299,6 @@ configureevent(XConfigureRequestEvent *ev)
if((c = client_gb_win(ev->window))
|| (c = client_gb_win(ev->window)))
{
CHECK(!(c->flags & TileFlag));
CHECK(!(c->flags & LMaxFlag));
CHECK(!(c->flags & MaxFlag));
CHECK(!(c->flags & FSSFlag));
@@ -292,8 +315,13 @@ configureevent(XConfigureRequestEvent *ev)
if(ev->value_mask & CWHeight)
c->geo.height = ev->height;
if(c->flags & FreeFlag)
if(c->flags & FreeFlag || !(c->flags & (TileFlag | LMaxFlag)))
client_moveresize(c, c->geo, False);
else
{
client_configure(c);
arrange(c->screen, True);
}
}
else
{
@@ -314,16 +342,23 @@ configureevent(XConfigureRequestEvent *ev)
/** DestroyNotify handle event
* \param ev XDestroyWindowEvent pointer
*/
void
static void
destroynotify(XDestroyWindowEvent *ev)
{
Client *c;
Systray *s;
if((c = client_gb_win(ev->window)))
{
client_unmanage(c);
XSetErrorHandler(errorhandler);
}
else if((s = systray_find(ev->window)))
{
setwinstate(s->win, WithdrawnState);
systray_del(s);
systray_update();
}
return;
}
@@ -331,7 +366,7 @@ destroynotify(XDestroyWindowEvent *ev)
/** EnterNotify handle event
* \param ev XCrossingEvent pointer
*/
void
static void
enternotify(XCrossingEvent *ev)
{
Client *c;
@@ -342,6 +377,10 @@ enternotify(XCrossingEvent *ev)
&& ev->window != ROOT)
return;
/* Don't handle EnterNotify event if it's about systray */
if(systray_find(ev->window) || ev->window == traywin)
return;
if(conf.focus_fmouse)
{
if((c = client_gb_win(ev->window))
@@ -360,7 +399,7 @@ enternotify(XCrossingEvent *ev)
/** ExposeEvent handle event
* \param ev XExposeEvent pointer
*/
void
static void
expose(XExposeEvent *ev)
{
Client *c;
@@ -391,7 +430,7 @@ expose(XExposeEvent *ev)
* \param ev XFocusChangeEvent pointer
* \return
*/
void
static void
focusin(XFocusChangeEvent *ev)
{
if(sel && ev->window != sel->win)
@@ -400,34 +439,13 @@ focusin(XFocusChangeEvent *ev)
return;
}
/** Key grabbing function
*/
void
grabkeys(void)
{
uint i;
KeyCode code;
XUngrabKey(dpy, AnyKey, AnyModifier, ROOT);
for(i = 0; i < conf.nkeybind; ++i)
{
code = XKeysymToKeycode(dpy, keys[i].keysym);
XGrabKey(dpy, code, keys[i].mod, ROOT, True, GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, code, keys[i].mod | LockMask, ROOT, True, GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, code, keys[i].mod | numlockmask, ROOT, True, GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, code, keys[i].mod | LockMask | numlockmask, ROOT, True, GrabModeAsync, GrabModeAsync);
}
return;
}
/** KeyPress handle event
* \param ev XKeyPressedEvent pointer
*/
void
static void
keypress(XKeyPressedEvent *ev)
{
uint i;
int i;
KeySym keysym;
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
@@ -441,10 +459,10 @@ keypress(XKeyPressedEvent *ev)
return;
}
/** MapNotify handle event
/** MappingNotify handle event
* \param ev XMappingEvent pointer
*/
void
static void
mappingnotify(XMappingEvent *ev)
{
XRefreshKeyboardMapping(ev);
@@ -455,19 +473,47 @@ mappingnotify(XMappingEvent *ev)
return;
}
/** MapNotify handle event
* \param ev XMapEvent pointer
*/
static void
mapnotify(XMapEvent *ev)
{
Client *c;
Systray *s;
if(ev->window != ev->event && !ev->send_event)
return;
if((c = client_gb_win(ev->window)))
setwinstate(c->win, NormalState);
else if((s = systray_find(ev->window)))
{
setwinstate(s->win, NormalState);
ewmh_send_message(s->win, s->win, "_XEMBED", CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, 0, 0);
}
return;
}
/** MapRequest handle event
* \param ev XMapRequestEvent pointer
*/
void
static void
maprequest(XMapRequestEvent *ev)
{
XWindowAttributes at;
Client *c;
Systray *s;
CHECK(XGetWindowAttributes(dpy, ev->window, &at));
CHECK(!at.override_redirect);
if(!(c = client_gb_win(ev->window)))
if((s = systray_find(ev->window)))
{
ewmh_send_message(s->win, s->win, "_XEMBED", CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, 0, 0);
systray_update();
}
else if(!client_gb_win(ev->window))
client_manage(ev->window, &at, True);
return;
@@ -476,16 +522,23 @@ maprequest(XMapRequestEvent *ev)
/** PropertyNotify handle event
* \param ev XPropertyEvent pointer
*/
void
static void
propertynotify(XPropertyEvent *ev)
{
Client *c;
Systray *s;
Window trans;
XWMHints *h;
if(ev->state == PropertyDelete)
return;
if((s = systray_find(ev->window)))
{
systray_state(s);
systray_update();
}
if((c = client_gb_win(ev->window)))
{
switch(ev->atom)
@@ -494,7 +547,7 @@ propertynotify(XPropertyEvent *ev)
XGetTransientForHint(dpy, c->win, &trans);
if((c->flags & TileFlag || c->flags & MaxFlag))
if(((c->flags & HintFlag && (client_gb_win(trans) != NULL)))
|| (!(c->flags & HintFlag && (client_gb_win(trans) != NULL))))
|| (!(c->flags & HintFlag && (client_gb_win(trans) != NULL))))
arrange(c->screen, True);
break;
case XA_WM_NORMAL_HINTS:
@@ -503,11 +556,7 @@ propertynotify(XPropertyEvent *ev)
case XA_WM_HINTS:
if((h = XGetWMHints(dpy, c->win)) && (h->flags & XUrgencyHint) && c != sel)
{
c->flags |= UrgentFlag;
tags[c->screen][c->tag].urgent = True;
infobar_draw_taglist(c->screen);
client_urgent(c, True);
XFree(h);
}
break;
@@ -524,13 +573,40 @@ propertynotify(XPropertyEvent *ev)
return;
}
/** XReparentEvent handle event
* \param ev XReparentEvent pointer
*/
static void
reparentnotify(XReparentEvent *ev)
{
(void)ev;
return;
}
/** SelectionClearEvent handle event
* \param ev XSelectionClearEvent pointer
*/
static void
selectionclearevent(XSelectionClearEvent *ev)
{
/* Getting selection if lost it */
if(ev->window == traywin)
systray_acquire();
systray_update();
return;
}
/** UnmapNotify handle event
* \param ev XUnmapEvent pointer
*/
void
static void
unmapnotify(XUnmapEvent *ev)
{
Client *c;
Systray *s;
if((c = client_gb_win(ev->window))
&& ev->send_event
@@ -540,31 +616,50 @@ unmapnotify(XUnmapEvent *ev)
XSetErrorHandler(errorhandler);
}
if((s = systray_find(ev->window)))
{
systray_del(s);
systray_update();
}
return;
}
/** Send a client event
*\param data Event data
*\param atom_name Event atom name
/** XMotionNotify handle event
* \param ev XMotionEvent pointer
*/
void
send_client_event(long data[5], char *atom_name)
static void
motionnotify(XMotionEvent *ev)
{
Client *c;
if(!conf.focus_fmouse || !conf.focus_fmov)
return;
if((c = client_gb_win(ev->subwindow)))
if (c != sel)
client_focus(c);
return;
}
/** Key grabbing function
*/
void
grabkeys(void)
{
XEvent ev;
int i;
KeyCode code;
ev.xclient.type = ClientMessage;
ev.xclient.serial = 0;
ev.xclient.send_event = True;
ev.xclient.message_type = ATOM(atom_name);
ev.xclient.window = ROOT;
ev.xclient.format = 32;
for(i = 0; i < 5; ++i, ev.xclient.data.l[i] = data[i]);
XSendEvent(dpy, ROOT, False, SubstructureRedirectMask | SubstructureNotifyMask, &ev);
XSync(dpy, False);
XUngrabKey(dpy, AnyKey, AnyModifier, ROOT);
for(i = 0; i < conf.nkeybind; ++i)
if((code = XKeysymToKeycode(dpy, keys[i].keysym)))
{
XGrabKey(dpy, code, keys[i].mod, ROOT, True, GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, code, keys[i].mod | LockMask, ROOT, True, GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, code, keys[i].mod | numlockmask, ROOT, True, GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, code, keys[i].mod | LockMask | numlockmask, ROOT, True, GrabModeAsync, GrabModeAsync);
}
return;
}
@@ -579,18 +674,22 @@ getevent(XEvent ev)
switch(ev.type)
{
case ButtonPress: buttonpress(&ev.xbutton); break;
case ClientMessage: clientmessageevent(&ev.xclient); break;
case ConfigureRequest: configureevent(&ev.xconfigurerequest); break;
case DestroyNotify: destroynotify(&ev.xdestroywindow); break;
case EnterNotify: enternotify(&ev.xcrossing); break;
case Expose: expose(&ev.xexpose); break;
case FocusIn: focusin(&ev.xfocus); break;
case KeyPress: keypress(&ev.xkey); break;
case MapRequest: maprequest(&ev.xmaprequest); break;
case MappingNotify: mappingnotify(&ev.xmapping); break;
case PropertyNotify: propertynotify(&ev.xproperty); break;
case UnmapNotify: unmapnotify(&ev.xunmap); break;
case ButtonPress: buttonpress(&ev.xbutton); break;
case ClientMessage: clientmessageevent(&ev.xclient); break;
case ConfigureRequest: configureevent(&ev.xconfigurerequest); break;
case DestroyNotify: destroynotify(&ev.xdestroywindow); break;
case EnterNotify: enternotify(&ev.xcrossing); break;
case Expose: expose(&ev.xexpose); break;
case FocusIn: focusin(&ev.xfocus); break;
case KeyPress: keypress(&ev.xkey); break;
case MapNotify: mapnotify(&ev.xmap); break;
case MapRequest: maprequest(&ev.xmaprequest); break;
case MappingNotify: mappingnotify(&ev.xmapping); break;
case MotionNotify: motionnotify(&ev.xmotion); break;
case PropertyNotify: propertynotify(&ev.xproperty); break;
case ReparentNotify: reparentnotify(&ev.xreparent); break;
case SelectionClear: selectionclearevent(&ev.xselectionclear); break;
case UnmapNotify: unmapnotify(&ev.xunmap); break;
default:
#ifdef HAVE_XRANDR
@@ -603,13 +702,11 @@ getevent(XEvent ev)
/* Reload WMFS to update the screen(s) geometry changement */
quit();
for(; argv_global[0] && argv_global[0] == ' '; ++argv_global);
execlp(argv_global, argv_global, NULL);
execvp(argv_global, all_argv);
}
#endif /* HAVE_XRANDR */
break;
}
wait((int[]){0});
return;
}

View File

@@ -46,9 +46,11 @@ ewmh_init_hints(void)
char root_name[] = WMFS_VERSION;
char class[] = "wmfs", st[64];
long pid = (long)getpid();
char systray_atom[48];
s = screen_count();
net_atom = emalloc(net_last + s, sizeof(Atom));
net_atom = xcalloc(net_last + s, sizeof(Atom));
/* EWMH hints */
net_atom[net_supported] = ATOM("_NET_SUPPORTED");
@@ -58,7 +60,6 @@ ewmh_init_hints(void)
net_atom[net_current_desktop] = ATOM("_NET_CURRENT_DESKTOP");
net_atom[net_desktop_names] = ATOM("_NET_DESKTOP_NAMES");
net_atom[net_desktop_geometry] = ATOM("_NET_DESKTOP_GEOMETRY");
net_atom[net_workarea] = ATOM("_NET_WORKAREA");
net_atom[net_active_window] = ATOM("_NET_ACTIVE_WINDOW");
net_atom[net_close_window] = ATOM("_NET_CLOSE_WINDOW");
net_atom[net_wm_name] = ATOM("_NET_WM_NAME");
@@ -68,6 +69,7 @@ ewmh_init_hints(void)
net_atom[net_wm_icon_name] = ATOM("_NET_WM_ICON_NAME");
net_atom[net_wm_window_type] = ATOM("_NET_WM_WINDOW_TYPE");
net_atom[net_supporting_wm_check] = ATOM("_NET_SUPPORTING_WM_CHECK");
net_atom[net_wm_window_opacity] = ATOM("_NET_WM_WINDOW_OPACITY");
net_atom[net_wm_window_type_normal] = ATOM("_NET_WM_WINDOW_TYPE_NORMAL");
net_atom[net_wm_window_type_dock] = ATOM("_NET_WM_WINDOW_TYPE_DOCK");
net_atom[net_wm_window_type_splash] = ATOM("_NET_WM_WINDOW_TYPE_SPLASH");
@@ -75,7 +77,19 @@ ewmh_init_hints(void)
net_atom[net_wm_icon] = ATOM("_NET_WM_ICON");
net_atom[net_wm_state] = ATOM("_NET_WM_STATE");
net_atom[net_wm_state_fullscreen] = ATOM("_NET_WM_STATE_FULLSCREEN");
net_atom[net_wm_state_sticky] = ATOM("_NET_WM_STATE_STICKY");
net_atom[net_wm_state_demands_attention] = ATOM("_NET_WM_STATE_DEMANDS_ATTENTION");
net_atom[net_wm_system_tray_opcode] = ATOM("_NET_SYSTEM_TRAY_OPCODE");
net_atom[net_system_tray_message_data] = ATOM("_NET_SYSTEM_TRAY_MESSAGE_DATA");
net_atom[net_system_tray_visual] = ATOM("_NET_SYSTEM_TRAY_VISUAL");
snprintf(systray_atom, sizeof(systray_atom), "_NET_SYSTEM_TRAY_S%d", 0/*SCREEN*/);
net_atom[net_system_tray_s] = ATOM(systray_atom);
net_atom[net_system_tray_orientation] = ATOM("_NET_SYSTEM_TRAY_ORIENTATION");
net_atom[xembed] = ATOM("_XEMBED");
net_atom[xembedinfo] = ATOM("_XEMBED_INFO");
net_atom[manager] = ATOM("MANAGER");
net_atom[utf8_string] = ATOM("UTF8_STRING");
/* WMFS hints */
@@ -92,6 +106,7 @@ ewmh_init_hints(void)
net_atom[wmfs_nmaster] = ATOM("_WMFS_NMASTER");
net_atom[wmfs_function] = ATOM("_WMFS_FUNCTION");
net_atom[wmfs_cmd] = ATOM("_WMFS_CMD");
net_atom[wmfs_font] = ATOM("_WMFS_FONT");
/* Multi atom _WMFS_STATUSTEXT_<screennum> */
for(j = 0; j < s; ++j)
@@ -127,6 +142,54 @@ ewmh_init_hints(void)
return;
}
/** Send ewmh message
*/
void
ewmh_send_message(Window d, Window w, char *atom, long d0, long d1, long d2, long d3, long d4)
{
XClientMessageEvent e;
e.type = ClientMessage;
e.message_type = ATOM(atom);
e.window = w;
e.format = 32;
e.data.l[0] = d0;
e.data.l[1] = d1;
e.data.l[2] = d2;
e.data.l[3] = d3;
e.data.l[4] = d4;
XSendEvent(dpy, d, False, StructureNotifyMask, (XEvent*)&e);
XSync(dpy, False);
return;
}
/** Get xembed state
*/
long
ewmh_get_xembed_state(Window win)
{
Atom rf;
int f;
ulong n, il;
long ret = 0;
uchar *data = NULL;
if(XGetWindowProperty(dpy, win, net_atom[xembedinfo], 0L, 2, False,
net_atom[xembedinfo], &rf, &f, &n, &il, &data) != Success)
return 0;
if(rf == net_atom[xembedinfo] && n == 2)
ret = (long)data[1];
if(n && data)
XFree(data);
return ret;
}
/** Get the number of desktop (tag)
*/
void
@@ -191,7 +254,7 @@ ewmh_get_client_list(void)
int win_n;
for(win_n = 0, c = clients; c; c = c->next, ++win_n);
list = emalloc(win_n, sizeof(Window));
list = xcalloc(win_n, sizeof(Window));
for(win_n = 0, c = clients; c; c = c->next, ++win_n)
list[win_n] = c->win;
@@ -218,7 +281,7 @@ ewmh_get_desktop_names(void)
for(i = 1; i < conf.ntag[s] + 1; ++i)
len += strlen(tags[s][i].name);
str = emalloc(len + i + 1, sizeof(char*));
str = xcalloc(len + i + 1, sizeof(char*));
for(s = 0; s < S; ++s)
for(i = 1; i < conf.ntag[s] + 1; ++i, ++pos)
@@ -257,45 +320,13 @@ ewmh_set_desktop_geometry(void)
return;
}
/** Manage _NET_WORKAREA
*/
void
ewmh_set_workarea(void)
{
long *data;
int i, s, j, tag_c = 0, pos = 0;
s = screen_count();
for(i = 0; i < s; ++i)
tag_c += conf.ntag[i];
data = emalloc(tag_c * 4, sizeof(long));
for(i = 0; i < s; ++i)
for(j = 0; j < conf.ntag[i]; ++j)
{
data[pos++] = spgeo[i].x;
data[pos++] = spgeo[i].y;
data[pos++] = spgeo[i].width;
data[pos++] = spgeo[i].height;
}
XChangeProperty(dpy, ROOT, net_atom[net_workarea], XA_CARDINAL, 32,
PropModeReplace, (uchar*)data, 4 * tag_c);
free(data);
return;
}
/** Manage _NET_WM_STATE_* ewmh
*/
void
ewmh_manage_net_wm_state(long data_l[], Client *c)
{
/* Manage _NET_WM_STATE_FULLSCREEN */
if(data_l[1] == net_atom[net_wm_state_fullscreen])
if(data_l[1] == (long)net_atom[net_wm_state_fullscreen])
{
if(data_l[0] == _NET_WM_STATE_ADD && !(c->flags & FSSFlag))
{
@@ -306,6 +337,8 @@ ewmh_manage_net_wm_state(long data_l[], Client *c)
XResizeWindow(dpy, c->win,
spgeo[c->screen].width,
spgeo[c->screen].height);
XChangeProperty(dpy, c->win, net_atom[net_wm_state], XA_ATOM, 32,
PropModeReplace, (uchar *)&net_atom[net_wm_state_fullscreen], 1);
c->tmp_geo = c->geo;
@@ -320,17 +353,25 @@ ewmh_manage_net_wm_state(long data_l[], Client *c)
}
else if(data_l[0] == _NET_WM_STATE_REMOVE && (c->flags & FSSFlag))
{
XChangeProperty(dpy, c->win, net_atom[net_wm_state], XA_ATOM, 32, PropModeReplace, (uchar *)0, 0);
c->flags &= ~(FSSFlag | MaxFlag);
client_map(c);
XReparentWindow(dpy, c->win, c->frame, BORDH, TBARH);
client_moveresize(c, c->tmp_geo, False);
}
}
/* Manage _NET_WM_STATE_STICKY */
else if(data_l[1] == (long)net_atom[net_wm_state_sticky])
{
/* == client_ignore_tag */
c->tag = MAXTAG + 1;
arrange(c->screen, True);
}
/* Manage _NET_WM_STATE_DEMANDS_ATTENTION */
else if(data_l[1] == net_atom[net_wm_state_demands_attention])
else if(data_l[1] == (long)net_atom[net_wm_state_demands_attention])
{
if(data_l[0] == _NET_WM_STATE_ADD)
client_focus(c);
client_urgent(c, True);
if(data_l[0] == _NET_WM_STATE_REMOVE)
if(c == sel)
client_focus(NULL);
@@ -347,9 +388,10 @@ void
ewmh_manage_window_type(Client *c)
{
Atom *atom, rf;
int i, f;
ulong n, il;
int f;
ulong n, il, i;
uchar *data = NULL;
long ldata[5] = { 0 };
if(XGetWindowProperty(dpy, c->win, net_atom[net_wm_window_type], 0L, 0x7FFFFFFFL,
False, XA_ATOM, &rf, &f, &n, &il, &data) == Success && n)
@@ -372,16 +414,14 @@ ewmh_manage_window_type(Client *c)
XReparentWindow(dpy, c->win, ROOT, c->geo.x, c->geo.y);
XRaiseWindow(dpy, c->win);
/* This window will not be managed anymore,
* so let's detach it. */
client_detach(c);
c->flags |= DockFlag;
}
/* MANAGE _NET_WM_WINDOW_TYPE_DIALOG */
else if(atom[i] == net_atom[net_wm_window_type_dialog])
{
c->flags |= FreeFlag;
c->flags &= ~(TileFlag | MaxFlag | LMaxFlag);
client_moveresize(sel, sel->ogeo, True);
client_moveresize(c, c->ogeo, True);
client_focus(c);
tags[selscreen][seltag[selscreen]].layout.func(selscreen);
}
@@ -389,6 +429,21 @@ ewmh_manage_window_type(Client *c)
XFree(data);
}
/* Get NET_WM_STATE set without sending client message event */
if(XGetWindowProperty(dpy, c->win, net_atom[net_wm_state], 0L, 0x7FFFFFFFL,
False, XA_ATOM, &rf, &f, &n, &il, &data) == Success && n)
{
atom = (Atom*)data;
for(i = 0; i < n; ++i)
{
ldata[0] = _NET_WM_STATE_ADD;
ldata[1] = atom[i];
ewmh_manage_net_wm_state(ldata, c);
}
XFree(data);
}
return;
}

View File

@@ -83,7 +83,7 @@ frame_create(Client *c)
/* Buttons */
if(BUTTONWH >= 1)
{
c->button = emalloc(conf.titlebar.nbutton, sizeof(Window));
c->button = xcalloc(conf.titlebar.nbutton, sizeof(Window));
for(i = 0; i < conf.titlebar.nbutton; ++i)
{
CWIN(c->button[i], c->titlebar->win,
@@ -118,10 +118,13 @@ frame_create(Client *c)
/* Border (for shadow) */
if(conf.client.border_shadow)
{
CWIN(c->left, c->frame, 0, 0, SHADH, c->frame_geo.height, 0, CWBackPixel, color_enlight(c->colors.frame), &at);
CWIN(c->top, c->frame, 0, 0, c->frame_geo.width, SHADH, 0, CWBackPixel, color_enlight(c->colors.frame), &at);
CWIN(c->bottom, c->frame, 0, c->frame_geo.height - SHADH, c->frame_geo.width, SHADH, 0, CWBackPixel, SHADC, &at);
CWIN(c->right, c->frame, c->frame_geo.width - SHADH, 0, SHADH, c->frame_geo.height, 0, CWBackPixel, SHADC, &at);
c->colors.borddark = color_shade(c->colors.frame, conf.colors.client_dark_shade);
c->colors.bordlight = color_shade(c->colors.frame, conf.colors.client_light_shade);
CWIN(c->left, c->frame, 0, 0, SHADH, c->frame_geo.height, 0, CWBackPixel, c->colors.bordlight, &at);
CWIN(c->top, c->frame, 0, 0, c->frame_geo.width, SHADH, 0, CWBackPixel, c->colors.bordlight, &at);
CWIN(c->bottom, c->frame, 0, c->frame_geo.height - SHADH, c->frame_geo.width, SHADH, 0, CWBackPixel, c->colors.borddark, &at);
CWIN(c->right, c->frame, c->frame_geo.width - SHADH, 0, SHADH, c->frame_geo.height, 0, CWBackPixel, c->colors.borddark, &at);
}
/* Reparent window with the frame */
@@ -191,6 +194,44 @@ frame_moveresize(Client *c, XRectangle geo)
return;
}
/** Update frame colors for focus event
*\param c Client pointer
*/
void
frame_update_color(Client *c, Bool focused)
{
CHECK(c);
/* Not focused client */
if(focused)
{
c->colors.frame = conf.client.bordernormal;
c->colors.fg = conf.titlebar.fg_normal;
c->colors.resizecorner = conf.client.resizecorner_normal;
if(TBARH - BORDH && c->titlebar->stipple)
c->titlebar->stipple_color = conf.titlebar.stipple.colors.normal;
}
/* Focused */
else
{
c->colors.frame = conf.client.borderfocus;
c->colors.fg = conf.titlebar.fg_focus;
c->colors.resizecorner = conf.client.resizecorner_focus;
if(TBARH - BORDH && c->titlebar->stipple)
c->titlebar->stipple_color = conf.titlebar.stipple.colors.focus;
}
if(conf.client.border_shadow)
{
c->colors.borddark = color_shade(c->colors.frame, conf.colors.client_dark_shade);
c->colors.bordlight = color_shade(c->colors.frame, conf.colors.client_light_shade);
}
return;
}
/** Update the client frame; Set the new color
* and the title --> refresh
* \param c Client pointer
@@ -222,8 +263,10 @@ frame_update(Client *c)
XClearWindow(dpy, c->button[i]);
if((!conf.titlebar.button[i].flags)
|| ((conf.titlebar.button[i].flags & FreeFlag) && (c->flags & FreeFlag))
|| ((conf.titlebar.button[i].flags & MaxFlag) && (c->flags & MaxFlag))
|| ((conf.titlebar.button[i].flags & FreeFlag)
&& ((c->flags & FreeFlag) || !(c->flags & (TileFlag | LMaxFlag))))
|| ((conf.titlebar.button[i].flags & MaxFlag)
&& ((c->flags & MaxFlag) || (c->flags & LMaxFlag)))
|| ((conf.titlebar.button[i].flags & TileFlag) && (c->flags & TileFlag)))
{
@@ -256,10 +299,10 @@ frame_update(Client *c)
if(conf.client.border_shadow)
{
XSetWindowBackground(dpy, c->left, color_enlight(c->colors.frame));
XSetWindowBackground(dpy, c->top, color_enlight(c->colors.frame));
XSetWindowBackground(dpy, c->right, SHADC);
XSetWindowBackground(dpy, c->bottom, SHADC);
XSetWindowBackground(dpy, c->left, c->colors.bordlight);
XSetWindowBackground(dpy, c->top, c->colors.bordlight);
XSetWindowBackground(dpy, c->right, c->colors.borddark);
XSetWindowBackground(dpy, c->bottom, c->colors.borddark);
XClearWindow(dpy, c->left);
XClearWindow(dpy, c->top);

View File

@@ -42,7 +42,7 @@ uchar *ret;
/** Get information about tag (current, list, names)
*/
void
static void
getinfo_tag(void)
{
int tag = 0;
@@ -60,29 +60,29 @@ getinfo_tag(void)
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_CURRENT_TAG"), 0L, 4096,
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success && ret)
{
tag_name = _strdup((char*)ret);
tag_name = xstrdup((char*)ret);
XFree(ret);
}
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_TAG_LIST"), 0L, 4096,
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success && ret)
{
tag_list = _strdup((char*)ret);
tag_list = xstrdup((char*)ret);
XFree(ret);
}
printf("Current tag: %d - %s\n", tag, tag_name);
printf("Tag list: %s\n", tag_list);
IFREE(tag_name);
IFREE(tag_list);
free(tag_name);
free(tag_list);
return;
}
/** Get information about screens
*/
void
static void
getinfo_screen(void)
{
int screen = 1;
@@ -108,7 +108,7 @@ getinfo_screen(void)
/** Get current layout name
*/
void
static void
getinfo_layout(void)
{
char *layout = NULL;
@@ -116,20 +116,20 @@ getinfo_layout(void)
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_CURRENT_LAYOUT"), 0L, 4096,
False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, &ret) == Success && ret)
{
layout = _strdup((char*)ret);
layout = xstrdup((char*)ret);
XFree(ret);
}
printf("Current layout: %s\n", layout);
IFREE(layout);
free(layout);
return;
}
/** Get information about current mwfact
*/
void
static void
getinfo_mwfact(void)
{
char *mwfact = NULL;
@@ -137,20 +137,20 @@ getinfo_mwfact(void)
if(XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_MWFACT"), 0L, 4096,
False, XA_STRING, &rt, &rf, &ir, &il, &ret) == Success && ret)
{
mwfact = _strdup((char*)ret);
mwfact = xstrdup((char*)ret);
XFree(ret);
}
printf("Current mwfact: %s\n", mwfact);
IFREE(mwfact);
free(mwfact);
return;
}
/** Get information about current nmaster
*/
void
static void
getinfo_nmaster(void)
{
int nmaster = 1;
@@ -173,14 +173,10 @@ getinfo_nmaster(void)
void
getinfo(char *info)
{
long data[5];
if(!check_wmfs_running())
return;
data[4] = True;
send_client_event(data, "_WMFS_UPDATE_HINTS");
ewmh_send_message(ROOT, ROOT, "_WMFS_UPDATE_HINTS", 0, 0, 0, 0, True);
if(!strcmp(info, "tag"))
getinfo_tag();

View File

@@ -42,7 +42,7 @@ infobar_init(void)
s = screen_count();
if(!infobar)
infobar = emalloc(s, sizeof(InfoBar));
infobar = xcalloc(s, sizeof(InfoBar));
for(sc = 0; sc < s; ++sc)
{
@@ -95,7 +95,7 @@ infobar_init(void)
/* Create layout switch barwindow */
infobar[sc].layout_button = barwin_create(infobar[sc].bar->win,
((conf.layout_placement) ? 0 : (j + PAD / 2)), 0,
textw(tags[sc][seltag[sc]].layout.symbol) + PAD,
((conf.layout_button_width > 0) ? (uint)conf.layout_button_width : (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)),
infobar[sc].geo.height,
conf.colors.layout_bg, conf.colors.layout_fg,
False, False, conf.border.layout);
@@ -127,7 +127,7 @@ infobar_init(void)
barwin_refresh(infobar[sc].bar);
/* Default statustext is set here */
infobar[sc].statustext = _strdup(WMFS_VERSION);
infobar[sc].statustext = xstrdup(WMFS_VERSION);
infobar_draw(sc);
}
@@ -135,6 +135,24 @@ infobar_init(void)
return;
}
/** Draw the layout button in the InfoBar
*\param sc Screen number
*/
static void
infobar_draw_layout(int sc)
{
if(!conf.layout_placement)
barwin_move(infobar[sc].layout_button, infobar[sc].tags_board->geo.width + PAD / 2, 0);
barwin_resize(infobar[sc].layout_button, ((conf.layout_button_width > 0) ? (uint)conf.layout_button_width : (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)), infobar[sc].geo.height);
barwin_refresh_color(infobar[sc].layout_button);
if(tags[sc][seltag[sc]].layout.symbol)
barwin_draw_text(infobar[sc].layout_button, PAD / 2, FHINFOBAR, tags[sc][seltag[sc]].layout.symbol);
return;
}
/** Draw the Infobar
*\param sc Screen number
*/
@@ -150,24 +168,6 @@ infobar_draw(int sc)
return;
}
/** Draw the layout button in the InfoBar
*\param sc Screen number
*/
void
infobar_draw_layout(int sc)
{
if(!conf.layout_placement)
barwin_move(infobar[sc].layout_button, infobar[sc].tags_board->geo.width + PAD / 2, 0);
barwin_resize(infobar[sc].layout_button, textw(tags[sc][seltag[sc]].layout.symbol) + PAD, infobar[sc].geo.height);
barwin_refresh_color(infobar[sc].layout_button);
if(tags[sc][seltag[sc]].layout.symbol)
barwin_draw_text(infobar[sc].layout_button, PAD / 2, FHINFOBAR, tags[sc][seltag[sc]].layout.symbol);
return;
}
/** Draw Selbar (selected client title bar in infobar
*\param sc Screen Number
*/
@@ -179,20 +179,21 @@ infobar_draw_selbar(int sc)
if(!conf.bars.selbar)
return;
if(!sel)
if(!sel || (sel && sel->screen != sc))
{
barwin_unmap(infobar[sc].selbar);
return;
}
else if(sel && !infobar[sc].selbar->mapped)
barwin_map(infobar[sc].selbar);
if(conf.selbar.maxlenght >= 0 && sel)
if(conf.selbar.maxlength >= 0 && sel)
{
str = emalloc(conf.selbar.maxlenght + 4, sizeof(char));
strncpy(str, sel->title, conf.selbar.maxlenght);
str = xcalloc(conf.selbar.maxlength + 4, sizeof(char));
strncpy(str, sel->title, conf.selbar.maxlength);
if(strlen(sel->title) > conf.selbar.maxlenght)
if(strlen(sel->title) > (size_t)conf.selbar.maxlength)
strcat(str, "...");
}
@@ -208,7 +209,7 @@ infobar_draw_selbar(int sc)
barwin_refresh(infobar[sc].selbar);
IFREE(str);
free(str);
return;
}
@@ -219,21 +220,21 @@ infobar_draw_selbar(int sc)
void
infobar_draw_taglist(int sc)
{
int i, x, j;
Client *c;
Bool is_occupied[MAXTAG];
int i, x;
Client *c = NULL;
Bool is_occupied[MAXTAG + 1];
if(conf.layout_placement)
barwin_move(infobar[sc].tags_board, textw(tags[sc][seltag[sc]].layout.symbol) + PAD * 1.5, 0);
barwin_move(infobar[sc].tags_board, ((conf.layout_button_width > 0) ? (uint)conf.layout_button_width : (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)) + PAD / 2, 0);
for(i = 0; i < MAXTAG; i++)
is_occupied[i] = False;
for(c = clients; c; c = c->next)
if(c->screen == sc)
if(c->screen == sc && c->tag != MAXTAG + 1)
is_occupied[c->tag] = True;
for(i = 1, x = j = 0; i < conf.ntag[sc] + 1; ++i)
for(i = 1, x = 0; i < conf.ntag[sc] + 1; ++i)
{
/* Autohide tag feature */
if(conf.tagautohide)
@@ -267,8 +268,11 @@ infobar_draw_taglist(int sc)
? conf.colors.tagurfg
: ((i == seltag[sc] || tags[sc][seltag[sc]].tagad & TagFlag(i))
? conf.colors.tagselfg
: conf.colors.text);
: (is_occupied[i]
? conf.colors.tag_occupied_fg
: conf.colors.text));
barwin_color_set(infobar[sc].tags[i], infobar[sc].tags[i]->bg, infobar[sc].tags[i]->fg);
barwin_refresh_color(infobar[sc].tags[i]);
if(tags[sc][i].name)
@@ -317,7 +321,6 @@ infobar_update_taglist(int sc)
return;
}
/** Destroy the InfoBar
*/
void
@@ -378,7 +381,6 @@ infobar_set_position(int pos)
barwin_move(infobar[selscreen].bar, sgeo[selscreen].x - BORDH, infobar[selscreen].geo.y);
infobar_draw(selscreen);
ewmh_set_workarea();
arrange(selscreen, True);
return;
@@ -390,6 +392,7 @@ infobar_set_position(int pos)
void
uicb_infobar_togglepos(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
infobar_set_position((tags[selscreen][seltag[selscreen]].barpos
@@ -400,6 +403,29 @@ uicb_infobar_togglepos(uicb_t cmd)
return;
}
/** Toggle hide/display infobar
* \param cmd uicb_t type unused
*/
void
uicb_infobar_toggledisplay(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
int new_pos;
new_pos = (tags[selscreen][seltag[selscreen]].barpos
? 0 : (tags[selscreen][seltag[selscreen]].prev_barpos
? tags[selscreen][seltag[selscreen]].prev_barpos : 2
));
tags[selscreen][seltag[selscreen]].prev_barpos = tags[selscreen][seltag[selscreen]].barpos;
tags[selscreen][seltag[selscreen]].barpos = new_pos;
infobar_set_position(new_pos);
return;
}
/** Toggle the tag_autohide mode
* \param cmd uicb_t type unused
*/
@@ -407,6 +433,7 @@ void
uicb_toggle_tagautohide(uicb_t cmd)
{
int i, x;
(void)cmd;
screen_get_sel();
conf.tagautohide = !conf.tagautohide;

View File

@@ -40,13 +40,14 @@ const func_name_list_t layout_list[] =
{"tile_left", tile_left },
{"tile_top", tile_top },
{"tile_bottom", tile_bottom },
{"tile_grid", grid },
{"grid", grid },
{"tile_grid", grid_horizontal },
{"tile_grid_horizontal", grid_horizontal },
{"tile_grid_vertical", grid_vertical },
{"grid", grid_horizontal },
{"mirror_vertical", mirror_vertical },
{"tile_mirror_vertical", mirror_vertical },
{"mirror_horizontal", mirror_horizontal },
{"tile_mirror_horizontal", mirror_horizontal },
{"layer", layer },
{"max", maxlayout },
{"maxlayout", maxlayout },
{"freelayout", freelayout },
@@ -54,31 +55,9 @@ const func_name_list_t layout_list[] =
{ NULL, NULL }
};
/** Init WMFS
*/
void
init(void)
{
/* First init */
ewmh_init_hints();
init_conf();
init_gc();
init_font();
init_cursor();
init_key();
init_root();
screen_init_geo();
infobar_init();
init_status();
ewmh_update_current_tag_prop();
grabkeys();
return;
}
/** Init the font
*/
void
static void
init_font(void)
{
font = XftFontOpenName(dpy, SCREEN, conf.font);
@@ -89,12 +68,16 @@ init_font(void)
font = XftFontOpenName(dpy, SCREEN, "sans-10");
}
/* Set font in _WMFS_FONT for eventual status tools */
XChangeProperty(dpy, ROOT, net_atom[wmfs_font], net_atom[utf8_string], 8,
PropModeReplace, (uchar*)conf.font, strlen(conf.font));
return;
}
/** Init the graphic context
*/
void
static void
init_gc(void)
{
XGCValues gcv;
@@ -121,7 +104,7 @@ init_gc(void)
/** Init WMFS cursor
*/
void
static void
init_cursor(void)
{
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
@@ -135,7 +118,7 @@ init_cursor(void)
/** Init key modifier
*/
void
static void
init_key(void)
{
int i, j;
@@ -154,7 +137,7 @@ init_key(void)
/** Init root Window
*/
void
static void
init_root(void)
{
XSetWindowAttributes at;
@@ -177,7 +160,7 @@ init_root(void)
/** Init statustext shell script
*/
void
static void
init_status(void)
{
struct stat st;
@@ -194,20 +177,43 @@ init_status(void)
return;
}
conf.status_path = emalloc(strlen(home) + strlen(DEF_STATUS) + 2, sizeof(char));
conf.status_path = zmalloc(strlen(home) + strlen(DEF_STATUS) + 2);
sprintf(conf.status_path, "%s/"DEF_STATUS, home);
}
if (stat(conf.status_path, &st) == -1)
if (stat(patht(conf.status_path), &st) == -1)
{
warn("%s", conf.status_path);
warn("%s", patht(conf.status_path));
return;
}
if(st.st_size && st.st_mode & S_IXUSR)
estatus = True;
else
warnx("status file specified in configuratin (status_path) or present in wmfs directory can't be executed, try 'chmod +x %s'.", conf.status_path);
warnx("status file specified in configuratin (status_path) or present in wmfs directory can't be executed, try 'chmod +x %s'.", patht(conf.status_path));
return;
}
/** Init WMFS
*/
void
init(void)
{
/* First init */
ewmh_init_hints();
init_conf();
init_gc();
init_font();
init_cursor();
init_key();
init_root();
screen_init_geo();
infobar_init();
systray_acquire();
init_status();
ewmh_update_current_tag_prop();
grabkeys();
return;
}

View File

@@ -30,18 +30,155 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* conforming to glib use _GNU_SOURCE for asprintf declaration */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "wmfs.h"
/*
* Just search command in PATH.
* Return the characters to complete the command.
*/
static char *
complete_on_command(char *start, size_t hits)
{
char *path;
char *dirname;
char *ret = NULL;
DIR *dir;
struct dirent *content;
static char *complete_on_command(char*, size_t);
static char *complete_on_files(char*, size_t);
char **namelist = NULL;
int n = 0, i;
void
if (!getenv("PATH") || !start || hits <= 0)
return NULL;
path = xstrdup(getenv("PATH"));
dirname = strtok(path, ":");
/* recursively open PATH */
while (dirname != NULL)
{
if ((dir = opendir(dirname)))
{
while ((content = readdir(dir)))
{
if(strncmp(content->d_name, ".", 1))
{
if (!strncmp(content->d_name, start, strlen(start)))
{
namelist = xrealloc(namelist, ++n, sizeof(*namelist));
namelist[n-1] = xstrdup(content->d_name);
}
}
}
closedir(dir);
}
dirname = strtok(NULL, ":");
}
free(path);
if(n > 0)
{
qsort(namelist, n, sizeof(char *), qsort_string_compare);
ret = xstrdup(namelist[((hits > 0) ? hits - 1 : 0) % n] + strlen(start));
for(i = 0; i < n; i++)
free(namelist[i]);
free(namelist);
}
return ret;
}
/*
* Complete a filename or directory name.
* works like complete_on_command.
*/
static char *
complete_on_files(char *start, size_t hits)
{
char *ret = NULL;
char *p = NULL;
char *dirname = NULL;
char *path = NULL;
char *filepath = NULL;
DIR *dir = NULL;
struct dirent *content = NULL;
struct stat st;
size_t count = 0;
if (!start || hits <= 0 || !(p = strrchr(start, ' ')))
return NULL;
/*
* Search the directory to open and set
* the beginning of file to complete on pointer 'p'.
*/
if (*(++p) == '\0' || !strrchr(p, '/'))
path = xstrdup(".");
else
{
/* remplace ~ by $HOME in dirname */
if (!strncmp(p, "~/", 2) && getenv("HOME"))
xasprintf(&dirname, "%s%s", getenv("HOME"), p+1);
else
dirname = xstrdup(p);
/* Set p to filename to be complete
* and path the directory containing the file
* /foooooo/baaaaaar/somethinglikethis<tab>
* <---- path - ---><------- p ------>
*/
p = strrchr(dirname, '/');
if (p != dirname)
{
*(p++) = '\0';
path = xstrdup(dirname);
}
else
{
path = xstrdup("/");
p++;
}
}
if ((dir = opendir(path)))
{
while ((content = readdir(dir)))
{
if (!strcmp(content->d_name, ".") || !strcmp(content->d_name, ".."))
continue;
if (!strncmp(content->d_name, p, strlen(p)) && ++count == hits)
{
/* If it's a directory append '/' to the completion */
xasprintf(&filepath, "%s/%s", path, content->d_name);
if (filepath && stat(filepath, &st) != -1)
{
if (S_ISDIR(st.st_mode))
xasprintf(&ret, "%s/", content->d_name + strlen(p));
else
ret = xstrdup(content->d_name + strlen(p));
}
else
warn("%s", filepath);
free(filepath);
break;
}
}
closedir(dir);
}
free(dirname);
free(path);
return ret;
}
static void
launcher_execute(Launcher *launcher)
{
BarWindow *bw;
@@ -52,20 +189,23 @@ launcher_execute(Launcher *launcher)
char buf[512] = { 0 };
char tmpbuf[512] = { 0 };
char *complete;
int i, pos = 0, histpos = 0, x;
int i, pos = 0, histpos = 0, x, w;
int tabhits = 0;
KeySym ks;
XEvent ev;
screen_get_sel();
x = (infobar[selscreen].layout_button->geo.x
+ textw(tags[selscreen][seltag[selscreen]].layout.symbol) + PAD);
x = (conf.layout_placement)
? (infobar[selscreen].tags_board->geo.x + infobar[selscreen].tags_board->geo.width)
: (infobar[selscreen].layout_button->geo.x + infobar[selscreen].layout_button->geo.width);
XGrabKeyboard(dpy, ROOT, True, GrabModeAsync, GrabModeAsync, CurrentTime);
bw = barwin_create(infobar[selscreen].bar->win, x, 1,
infobar[selscreen].bar->geo.width - x - 1,
w = (launcher->width ? launcher->width : infobar[selscreen].bar->geo.width - x - 1);
bw = barwin_create(infobar[selscreen].bar->win, x, 1, w,
/* infobar[selscreen].bar->geo.width - x - 1, */
infobar[selscreen].bar->geo.height - 2,
infobar[selscreen].bar->bg,
infobar[selscreen].bar->fg,
@@ -76,9 +216,7 @@ launcher_execute(Launcher *launcher)
/* First draw of the cursor */
XSetForeground(dpy, gc, getcolor(infobar[selscreen].bar->fg));
/*XDrawLine(dpy, bw->dr, gc, 1 + textw(launcher->prompt) + textw(" "),
, 1 + textw(launcher->prompt) + textw(" "), INFOBARH - 4);
*/
XDrawLine(dpy, bw->dr, gc,
1 + textw(launcher->prompt) + textw(" ") + textw(buf), 2,
1 + textw(launcher->prompt) + textw(" ") + textw(buf), INFOBARH - 4);
@@ -113,14 +251,14 @@ launcher_execute(Launcher *launcher)
case XK_Up:
if(launcher->nhisto)
{
if(histpos >= launcher->nhisto)
if(histpos >= (int)launcher->nhisto)
histpos = 0;
strncpy(buf, launcher->histo[launcher->nhisto - ++histpos], sizeof(buf));
pos = strlen(buf);
}
break;
case XK_Down:
if(launcher->nhisto && histpos > 0 && histpos < launcher->nhisto)
if(launcher->nhisto && histpos > 0 && histpos < (int)launcher->nhisto)
{
strncpy(buf, launcher->histo[launcher->nhisto - --histpos], sizeof(buf));
pos = strlen(buf);
@@ -161,7 +299,7 @@ launcher_execute(Launcher *launcher)
else
{
tabhits = 1;
strcpy(tmpbuf, buf);
strncpy(tmpbuf, buf, sizeof(tmpbuf));
}
@@ -174,7 +312,7 @@ launcher_execute(Launcher *launcher)
if (complete)
{
strcpy(buf, tmpbuf);
strncpy(buf, tmpbuf, sizeof(buf));
strncat(buf, complete, sizeof(buf));
found = True;
free(complete);
@@ -184,7 +322,7 @@ launcher_execute(Launcher *launcher)
lastwastab = True;
/* start a new round of tabbing */
if (!found)
if (found == False)
tabhits = 0;
pos = strlen(buf);
@@ -242,135 +380,3 @@ uicb_launcher(uicb_t cmd)
return;
}
/*
* Just search command in PATH.
* Return the characters to complete the command.
*/
static char *
complete_on_command(char *start, size_t hits)
{
char *path;
char *dirname;
char *ret = NULL;
DIR *dir;
struct dirent *content;
size_t count = 0;
if (!getenv("PATH") || !start || hits <= 0)
return NULL;
path = _strdup(getenv("PATH"));
dirname = strtok(path, ":");
/* recursively open PATH */
while (dirname)
{
if ((dir = opendir(dirname)))
{
while ((content = readdir(dir)))
if (!strncmp(content->d_name, start, strlen(start)) && ++count == hits)
{
ret = _strdup(content->d_name + strlen(start));
break;
}
closedir(dir);
}
if (ret)
break;
dirname = strtok(NULL, ":");
}
free(path);
return ret;
}
/*
* Complete a filename or directory name.
* works like complete_on_command.
*/
static char *
complete_on_files(char *start, size_t hits)
{
char *ret = NULL;
char *p = NULL;
char *dirname = NULL;
char *path = NULL;
char *filepath = NULL;
DIR *dir = NULL;
struct dirent *content = NULL;
struct stat st;
size_t count = 0;
if (!start || hits <= 0 || !(p = strrchr(start, ' ')))
return NULL;
/*
* Search the directory to open and set
* the beginning of file to complete on pointer 'p'.
*/
if (*(++p) == '\0' || !strrchr(p, '/'))
path = _strdup(".");
else
{
/* remplace ~ by $HOME in dirname */
if (!strncmp(p, "~/", 2) && getenv("HOME"))
asprintf(&dirname, "%s%s", getenv("HOME"), p+1);
else
dirname = _strdup(p);
/* Set p to filename to be complete
* and path the directory containing the file
* /foooooo/baaaaaar/somethinglikethis<tab>
* <---- path - ---><------- p ------>
*/
p = strrchr(dirname, '/');
if (p != dirname)
{
*(p++) = '\0';
path = _strdup(dirname);
}
else
{
path = _strdup("/");
p++;
}
}
if ((dir = opendir(path)))
{
while ((content = readdir(dir)))
{
if (!strcmp(content->d_name, ".") || !strcmp(content->d_name, ".."))
continue;
if (!strncmp(content->d_name, p, strlen(p)) && ++count == hits)
{
/* If it's a directory append '/' to the completion */
asprintf(&filepath, "%s/%s", path, content->d_name);
if (filepath && stat(filepath, &st) != -1)
{
if (S_ISDIR(st.st_mode))
asprintf(&ret, "%s/", content->d_name + strlen(p));
else
ret = _strdup(content->d_name + strlen(p));
}
else
warn("%s", filepath);
IFREE(filepath);
break;
}
}
closedir(dir);
}
IFREE(dirname);
IFREE(path);
return ret;
}

View File

@@ -39,7 +39,7 @@ arrange(int screen, Bool update_layout)
{
Client *c;
if(screen < 0 || screen > screen_count())
if(screen < 0 || screen > screen_count() - 1)
screen = screen_get_sel();
for(c = clients; c; c = c->next)
@@ -51,10 +51,13 @@ arrange(int screen, Bool update_layout)
client_hide(c);
}
if(update_layout)
tags[screen][seltag[screen]].layout.func(screen);
if(tags[screen][seltag[screen]].layout.func)
{
if(update_layout)
tags[screen][seltag[screen]].layout.func(screen);
infobar_draw(screen);
infobar_draw(screen);
}
return;
}
@@ -65,6 +68,7 @@ void
freelayout(int screen)
{
Client *c;
(void)screen;
for(c = clients; c; c = c->next)
if(!ishide(c, selscreen)
@@ -92,7 +96,7 @@ layoutswitch(Bool b)
screen_get_sel();
if(tags[selscreen][seltag[selscreen]].layout.func == freelayout)
for(c = clients; c && (c->tag != seltag[selscreen] && c->screen != selscreen); c = c->next)
for(c = clients; c && (c->tag != (uint)seltag[selscreen] && c->screen != selscreen); c = c->next)
{
c->ogeo = c->geo;
c->free_geo = c->geo;
@@ -124,6 +128,7 @@ layoutswitch(Bool b)
void
uicb_layout_next(uicb_t cmd)
{
(void)cmd;
layoutswitch(True);
return;
@@ -135,11 +140,33 @@ uicb_layout_next(uicb_t cmd)
void
uicb_layout_prev(uicb_t cmd)
{
(void)cmd;
layoutswitch(False);
return;
}
/** Sort all the client that can be
* tiled
* \param c Client pointer
* \return a client pointer
*/
static Client*
tiled_client(int screen, Client *c)
{
for(;c && ((c->flags & MaxFlag)
|| (c->flags & FreeFlag)
|| (c->flags & FSSFlag)
|| (c->flags & AboveFlag)
|| c->screen != screen
|| ishide(c, screen)); c = c->next);
if(c)
c->flags |= FLayFlag;
return c;
}
/** Max layout function
*/
void
@@ -160,24 +187,6 @@ maxlayout(int screen)
return;
}
/** Sort all the client that can be
* tiled
* \param c Client pointer
* \return a client pointer
*/
Client*
tiled_client(int screen, Client *c)
{
for(;c && ((c->flags & MaxFlag)
|| (c->flags & FreeFlag)
|| (c->flags & FSSFlag)
|| (c->flags & AboveFlag)
|| c->screen != screen
|| ishide(c, screen)); c = c->next);
return c;
}
/** Set the mwfact
* \param cmd Mwfact (string)
*/
@@ -227,52 +236,15 @@ uicb_set_nmaster(uicb_t cmd)
return;
}
void
uicb_set_client_layer(uicb_t cmd)
{
int n = atoi(cmd);
screen_get_sel();
CHECK(sel);
if(sel->layer + n < 1
|| sel->layer + n > tags[selscreen][seltag[selscreen]].layers)
return;
sel->layer += n;
tags[selscreen][seltag[selscreen]].layout.func(selscreen);
return;
}
void
uicb_set_layer(uicb_t cmd)
{
int n = atoi(cmd);
screen_get_sel();
if(tags[selscreen][seltag[selscreen]].layers + n < 1)
return;
tags[selscreen][seltag[selscreen]].layers += n;
tags[selscreen][seltag[selscreen]].layout.func(selscreen);
return;
}
/** Grid layout function
*/
void
grid(int screen)
static void
grid(int screen, Bool horizontal)
{
Client *c;
XRectangle sg = sgeo[screen];
XRectangle cgeo = {sg.x, sg.y, 0, 0};
unsigned int i, n, cols, rows, cpcols = 0;
unsigned int i, n, temp, cols, rows, cpcols = 0;
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
CHECK(n);
@@ -285,6 +257,13 @@ grid(int screen)
? rows - 1
: rows;
if(!horizontal)
{
temp = cols;
cols = rows;
rows = temp;
}
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
{
/* Set client property */
@@ -324,7 +303,7 @@ grid(int screen)
/** Multi tile function
* \param type Postion type { Top, Bottom, Left, Right }
*/
void
static void
multi_tile(int screen, Position type)
{
Client *c;
@@ -348,15 +327,15 @@ multi_tile(int screen, Position type)
if(type == Top || type == Bottom)
{
if(type == Top)
mastergeo.y = (n <= nmaster) ? sg.y : sg.y + (sg.height - mwfact) - BORDH;
mastergeo.y = (n <= nmaster) ? (uint)sg.y : sg.y + (sg.height - mwfact) - BORDH;
mastergeo.width = (sg.width / nmaster) - (BORDH * 4);
mastergeo.height = (n <= nmaster) ? sg.height - BORDH : mwfact;
mastergeo.height = (n <= nmaster) ? (uint)(sg.height - BORDH) : mwfact;
}
else
{
if(type == Left)
mastergeo.x = (n <= nmaster) ? sg.x : (sg.x + sg.width) - mwfact - (BORDH * 2);
mastergeo.width = (n <= nmaster) ? sg.width - (BORDH * 2) : mwfact;
mastergeo.x = (n <= nmaster) ? (uint)sg.x : (sg.x + sg.width) - mwfact - (BORDH * 2);
mastergeo.width = (n <= nmaster) ? (uint)(sg.width - (BORDH * 2)) : mwfact;
mastergeo.height = (sg.height / nmaster) - BORDH;
}
@@ -454,19 +433,21 @@ multi_tile(int screen, Position type)
* \param screen Screen to execute this function
* \param horizont To specify the mirror mode (vertical/horizontal)
*/
void
static void
mirror(int screen, Bool horizontal)
{
Client *c;
XRectangle sg = sgeo[screen];
XRectangle mastergeo = {sg.x, sg.y, sg.width, sg.height};
XRectangle cgeo = {sg.x, sg.y , sg.width, sg.height};
XRectangle nextg[2] = { {0} };
XRectangle nextg[2];
uint i, n, tilesize = 0, mwfact;
uint nmaster = tags[screen][seltag[screen]].nmaster;
int pa, imp;
Bool isp = 0;
memset(nextg, 0, sizeof(nextg));
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
CHECK(n);
@@ -628,72 +609,6 @@ mirror(int screen, Bool horizontal)
return;
}
/** Layer layout function
*/
void
layer(int screen)
{
Client *c;
XRectangle geo = { 0 };
XRectangle sg = sgeo[screen];
int n, i, l = tags[screen][seltag[screen]].layers;
int *x = NULL;
int *nl = NULL;
int *ncl = NULL;
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
CHECK(n);
x = emalloc(l + 1, sizeof(int));
nl = emalloc(l + 1, sizeof(int));
ncl = emalloc(l + 1, sizeof(int));
for(i = 0; i < l + 1; ++i)
{
x[i] = sg.x;
nl[i] = 0;
ncl[i] = 0;
}
for(c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next))
{
for(; c->layer > l; --(c->layer));
++nl[c->layer];
}
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
{
/* Set client property */
c->flags &= ~(MaxFlag | LMaxFlag);
c->flags |= TileFlag;
++ncl[c->layer];
geo.x = x[c->layer];
geo.height = (sg.height / l) - (BORDH + TBARH);
geo.width = (sg.width / ((nl[c->layer]) ? nl[c->layer] : 1)) - BORDH * 2;
geo.y = sg.y + ((geo.height + TBARH + BORDH) * c->layer) - (geo.height + TBARH + BORDH);
if(c->layer == l)
geo.height = (sg.y + sg.height) - geo.y - BORDH;
if(ncl[c->layer] == nl[c->layer])
geo.width = sg.width - (geo.x - (sg.x - (BORDH * 2)));
client_moveresize(c, geo, False);
x[c->layer] = geo.x + geo.width + BORDH * 2;
}
free(x);
free(nl);
free(ncl);
ewmh_update_current_tag_prop();
return;
}
/** Tile Right function
*/
void
@@ -754,15 +669,29 @@ mirror_horizontal(int screen)
return;
}
/** Horizontal grid function
*/
void
grid_horizontal(int screen)
{
grid(screen, True);
return;
}
/** Vertical grid function
*/
void
grid_vertical(int screen)
{
grid(screen, False);
return;
}
/** Put the selected client to the master postion
* \param cmd uicb_t type unused
*/
void
uicb_tile_switch(uicb_t cmd)
{
layout_set_client_master (sel);
return;
}
/** Toggle the selected client to free
* \param cmd uicb_t type unused
@@ -770,6 +699,8 @@ uicb_tile_switch(uicb_t cmd)
void
uicb_togglefree(uicb_t cmd)
{
(void)cmd;
if(!sel || sel->screen != screen_get_sel() || (sel->flags & FSSFlag))
return;
@@ -794,13 +725,14 @@ uicb_togglefree(uicb_t cmd)
return;
}
/** Toggle the selected client to max
* \param cmd uicb_t type unused
*/
void
uicb_togglemax(uicb_t cmd)
{
(void)cmd;
if(!sel || ishide(sel, selscreen)
|| (sel->flags & HintFlag)|| (sel->flags & FSSFlag))
return;
@@ -811,12 +743,13 @@ uicb_togglemax(uicb_t cmd)
sel->free_geo = sel->geo;
sel->flags &= ~(TileFlag | FreeFlag);
client_maximize(sel);
client_raise(sel);
XRaiseWindow(dpy, sel->frame);
sel->flags |= MaxFlag;
}
else
{
sel->geo = sel->free_geo;
sel->geo = sel->ogeo;
client_moveresize(sel, sel->geo, True);
sel->flags &= ~MaxFlag;
tags[selscreen][seltag[selscreen]].layout.func(selscreen);
@@ -832,6 +765,7 @@ void
uicb_toggle_resizehint(uicb_t cmd)
{
screen_get_sel();
(void)cmd;
tags[selscreen][seltag[selscreen]].resizehint = !tags[selscreen][seltag[selscreen]].resizehint;
@@ -847,6 +781,7 @@ void
uicb_toggle_abovefc(uicb_t cmd)
{
Client *c;
(void)cmd;
screen_get_sel();
@@ -855,7 +790,7 @@ uicb_toggle_abovefc(uicb_t cmd)
for(c = clients; c; c = c->next)
if(c->flags & AboveFlag
&& c->screen == selscreen
&& c->tag == seltag[selscreen])
&& c->tag == (uint)seltag[selscreen])
{
c->flags &= ~AboveFlag;
break;
@@ -875,7 +810,7 @@ uicb_toggle_abovefc(uicb_t cmd)
void
uicb_set_layout(uicb_t cmd)
{
int i, j, n;
size_t i, j, n;
screen_get_sel();
@@ -883,7 +818,7 @@ uicb_set_layout(uicb_t cmd)
for(n = 0; layout_list[n].name != NULL && layout_list[n].func != NULL; ++n);
for(i = 0; i < n; ++i)
if(!strcmp(cmd, _strdup(layout_list[i].name)))
if(!strcmp(cmd, xstrdup(layout_list[i].name)))
for(j = 0; j < LEN(conf.layout); ++j)
if(layout_list[i].func == conf.layout[j].func)
tags[selscreen][seltag[selscreen]].layout = conf.layout[j];
@@ -910,7 +845,6 @@ layout_set_client_master(Client *c)
client_detach(c);
client_attach(c);
client_focus(c);
tags[selscreen][seltag[selscreen]].layout.func(selscreen);
@@ -923,6 +857,8 @@ layout_set_client_master(Client *c)
Bool
uicb_checkmax(uicb_t cmd)
{
(void)cmd;
if(!sel)
return False;
@@ -938,6 +874,8 @@ uicb_checkmax(uicb_t cmd)
Bool
uicb_checkfree(uicb_t cmd)
{
(void)cmd;
if(!sel)
return False;

View File

@@ -32,98 +32,124 @@
#include "wmfs.h"
void
menu_init(Menu *menu, char *name, int nitem, uint bg_f, char *fg_f, uint bg_n, char *fg_n)
static int
menu_get_longer_string(MenuItem *mi, int nitem)
{
/* Item */
menu->nitem = nitem;
menu->item = emalloc(sizeof(MenuItem), nitem);
menu->name = name;
int i, w, l = 0;
/* Colors */
menu->colors.focus.bg = bg_f;
menu->colors.focus.fg = fg_f;
menu->colors.normal.bg = bg_n;
menu->colors.normal.fg = fg_n;
for(i = 0; i < nitem; ++i)
if((w = textw(mi[i].name)) > l)
l = w;
return;
return l;
}
void
menu_new_item(MenuItem *mi, char *name, void *func, char *cmd)
static Bool
menu_get_checkstring_needed(MenuItem *mi, int nitem)
{
mi->name = name;
mi->func = func;
mi->cmd = cmd;
return;
(void)mi;
(void)nitem;
return True;
}
void
menu_draw(Menu menu, int x, int y)
static void
menu_draw_item_name(Menu *menu, int item, BarWindow *winitem[], int chcklen)
{
int i, width, height, out;
XEvent ev;
BarWindow *item[menu.nitem];
BarWindow *frame;
int x;
int width = menu_get_longer_string(menu->item, menu->nitem) + chcklen + PAD / 3;
width = menu_get_longer_string(menu.item, menu.nitem) + PAD * 3;
height = menu.nitem * (INFOBARH - SHADH);
/* Frame barwin */
screen_get_sel();
if((out = x + width - MAXW) > 0)
x -= out;
if((out = y + height - MAXH) > 0)
y -= out;
frame = barwin_create(ROOT, x, y, width + SHADH, height + SHADH * 2,
menu.colors.normal.bg, menu.colors.normal.fg, False, False, True);
barwin_map(frame);
barwin_map_subwin(frame);
barwin_refresh_color(frame);
for(i = 0; i < menu.nitem; ++i)
switch(menu->align)
{
item[i] = barwin_create(frame->win,
SHADH,
(i * (INFOBARH - SHADH) + SHADH),
width - SHADH,
INFOBARH - SHADH,
menu.colors.normal.bg,
menu.colors.normal.fg,
True, False, False);
case MA_Left:
x = chcklen + PAD / 2;
break;
case MA_Right:
x = width - textw(menu->item[item].name) + PAD * 3 / 2;
break;
default:
case MA_Center:
x = (width - (chcklen + PAD / 3)) / 2 - textw(menu->item[item].name) / 2 + chcklen + PAD / 3;
break;
}
barwin_draw_image_ofset_text(winitem[item], x, FHINFOBAR, menu->item[item].name, chcklen + PAD / 2, 0);
barwin_map(item[i]);
barwin_refresh_color(item[i]);
menu_draw_item_name(&menu, i, item);
barwin_refresh(item[i]);
if(menu->item[item].check)
if(menu->item[item].check(menu->item[item].cmd))
barwin_draw_image_ofset_text(winitem[item], PAD / 3, FHINFOBAR, conf.selected_layout_symbol, PAD / 3, 0);
if(menu->item[item].submenu)
barwin_draw_text(winitem[item], width + PAD * 2, FHINFOBAR, ">");
return;
}
static Bool
menu_activate_item(Menu *menu, int i)
{
int j, x, y;
int chcklen = 0;
if(menu_get_checkstring_needed(menu->item, menu->nitem))
chcklen = textw(conf.selected_layout_symbol) + PAD / 3;
if(menu->item[i].submenu)
{
for(j = 0; j < conf.nmenu; ++j)
if(!strcmp(menu->item[i].submenu, conf.menu[j].name))
{
y = menu->y + ((i - 1) * INFOBARH + PAD) - SHADH * 2;
x = menu->x + menu_get_longer_string(menu->item, menu->nitem) + chcklen + textw(">") + PAD * 3;
menu_draw(conf.menu[j], x, y);
return True;
}
}
else if(menu->item[i].func)
{
menu->item[i].func(menu->item[i].cmd);
return True;
}
/* Select the first item */
menu_focus_item(&menu, 0, item);
return False;
}
XGrabKeyboard(dpy, ROOT, True, GrabModeAsync, GrabModeAsync, CurrentTime);
static void
menu_focus_item(Menu *menu, int item, BarWindow *winitem[])
{
int i;
while(!menu_manage_event(&ev, &menu, item));
int chcklen = 0;
if(menu_get_checkstring_needed(menu->item, menu->nitem))
chcklen = textw(conf.selected_layout_symbol) + PAD / 3;
XUngrabKeyboard(dpy, CurrentTime);
menu->focus_item = item;
for(i = 0; i < menu.nitem; ++i)
barwin_delete(item[i]);
barwin_delete(frame);
if(menu->focus_item > menu->nitem - 1)
menu->focus_item = 0;
else if(menu->focus_item < 0)
menu->focus_item = menu->nitem - 1;
for(i = 0; i < menu->nitem; ++i)
{
winitem[i]->fg = ((i == menu->focus_item) ? menu->colors.focus.fg : menu->colors.normal.fg);
winitem[i]->bg = ((i == menu->focus_item) ? menu->colors.focus.bg : menu->colors.normal.bg);
barwin_refresh_color(winitem[i]);
menu_draw_item_name(menu, i, winitem, chcklen);
barwin_refresh(winitem[i]);
}
return;
}
Bool
static Bool
menu_manage_event(XEvent *ev, Menu *menu, BarWindow *winitem[])
{
int i, c = 0;
KeySym ks;
Bool quit = False;
char acc = 0;
switch(ev->type)
{
@@ -178,7 +204,20 @@ menu_manage_event(XEvent *ev, Menu *menu, BarWindow *winitem[])
/* For focus an item with the mouse */
for(i = 0; i < menu->nitem; ++i)
if(ev->xcrossing.window == winitem[i]->win)
{
acc = 1;
menu_focus_item(menu, i, winitem);
if(menu->item[i].submenu)
menu_activate_item(menu, menu->focus_item);
}
if(!acc)
{
if(ev->xcrossing.window)
XSendEvent(dpy, ev->xcrossing.window, False, StructureNotifyMask, ev);
return True;
}
break;
default:
@@ -190,102 +229,6 @@ menu_manage_event(XEvent *ev, Menu *menu, BarWindow *winitem[])
return quit;
}
Bool
menu_activate_item(Menu *menu, int i)
{
int j, x, y;
if(menu->item[i].submenu)
{
for(j = 0; j < conf.nmenu; ++j)
if(!strcmp(menu->item[i].submenu, conf.menu[j].name))
{
y = menu->y + ((i - 1) * INFOBARH + PAD) - SHADH * 2;
x = menu->x + menu_get_longer_string(menu->item, menu->nitem) + PAD * 3;
menu_draw(conf.menu[j], x, y);
return True;
}
}
else if(menu->item[i].func)
{
menu->item[i].func(menu->item[i].cmd);
return True;
}
return False;
}
void
menu_focus_item(Menu *menu, int item, BarWindow *winitem[])
{
int i;
menu->focus_item = item;
if(menu->focus_item > menu->nitem - 1)
menu->focus_item = 0;
else if(menu->focus_item < 0)
menu->focus_item = menu->nitem - 1;
for(i = 0; i < menu->nitem; ++i)
{
winitem[i]->fg = ((i == menu->focus_item) ? menu->colors.focus.fg : menu->colors.normal.fg);
winitem[i]->bg = ((i == menu->focus_item) ? menu->colors.focus.bg : menu->colors.normal.bg);
barwin_refresh_color(winitem[i]);
menu_draw_item_name(menu, i, winitem);
barwin_refresh(winitem[i]);
}
return;
}
void
menu_draw_item_name(Menu *menu, int item, BarWindow *winitem[])
{
int x;
int width = menu_get_longer_string(menu->item, menu->nitem);
switch(menu->align)
{
case MA_Left:
x = PAD * 3 / 2;
break;
case MA_Right:
x = width - textw(menu->item[item].name) + PAD * 3 / 2;
break;
default:
case MA_Center:
x = width / 2 - textw(menu->item[item].name) / 2 + PAD * 3 / 2;
break;
}
barwin_draw_text(winitem[item], x, FHINFOBAR, menu->item[item].name);
if(menu->item[item].check)
if(menu->item[item].check(menu->item[item].cmd))
barwin_draw_text(winitem[item], PAD / 3, FHINFOBAR, "*");
if(menu->item[item].submenu)
barwin_draw_text(winitem[item], width + PAD * 2, FHINFOBAR, ">");
return;
}
int
menu_get_longer_string(MenuItem *mi, int nitem)
{
int i, w, l = 0;
for(i = 0; i < nitem; ++i)
if((w = textw(mi[i].name)) > l)
l = w;
return l;
}
void
uicb_menu(uicb_t cmd)
{
@@ -319,9 +262,98 @@ uicb_menu(uicb_t cmd)
void
menu_clear(Menu *menu)
{
IFREE(menu->item);
free(menu->item);
menu->nitem = 0;
return;
}
void
menu_init(Menu *menu, char *name, int nitem, uint bg_f, char *fg_f, uint bg_n, char *fg_n)
{
/* Item */
menu->nitem = nitem;
menu->item = xcalloc(nitem, sizeof(*menu->item));
menu->name = name;
/* Colors */
menu->colors.focus.bg = bg_f;
menu->colors.focus.fg = fg_f;
menu->colors.normal.bg = bg_n;
menu->colors.normal.fg = fg_n;
return;
}
void
menu_new_item(MenuItem *mi, char *name, void *func, char *cmd)
{
mi->name = name;
mi->func = func;
mi->cmd = cmd;
return;
}
void
menu_draw(Menu menu, int x, int y)
{
int i, width, height, out;
XEvent ev;
BarWindow *item[menu.nitem];
BarWindow *frame;
int chcklen = 0;
if(menu_get_checkstring_needed(menu.item, menu.nitem))
chcklen = textw(conf.selected_layout_symbol) + PAD / 3;
width = menu_get_longer_string(menu.item, menu.nitem) + chcklen + textw(">") + PAD * 3;
height = menu.nitem * (INFOBARH - SHADH);
/* Frame barwin */
screen_get_sel();
if((out = x + width - MAXW) > 0)
x -= out;
if((out = y + height - MAXH) > 0)
y -= out;
frame = barwin_create(ROOT, x, y, width + SHADH, height + SHADH * 3,
menu.colors.normal.bg, menu.colors.normal.fg, False, False, True);
barwin_map(frame);
barwin_map_subwin(frame);
barwin_refresh_color(frame);
for(i = 0; i < menu.nitem; ++i)
{
item[i] = barwin_create(frame->win,
SHADH,
(i * (INFOBARH - SHADH) + SHADH),
width - SHADH,
INFOBARH,
menu.colors.normal.bg,
menu.colors.normal.fg,
True, False, False);
barwin_map(item[i]);
barwin_refresh_color(item[i]);
menu_draw_item_name(&menu, i, item, chcklen);
barwin_refresh(item[i]);
}
/* Select the first item */
menu_focus_item(&menu, 0, item);
XGrabKeyboard(dpy, ROOT, True, GrabModeAsync, GrabModeAsync, CurrentTime);
while(!menu_manage_event(&ev, &menu, item));
XUngrabKeyboard(dpy, CurrentTime);
for(i = 0; i < menu.nitem; ++i)
barwin_delete(item[i]);
barwin_delete(frame);
return;
}

View File

@@ -34,7 +34,7 @@
/** Draw the border when a client in dragging/resizing with mouse
*/
void
static void
mouse_dragborder(XRectangle geo, GC g)
{
XDrawRectangle(dpy, ROOT, g,
@@ -49,7 +49,7 @@ mouse_dragborder(XRectangle geo, GC g)
/** Move a client in tile grid with the mouse
*\param c Client double pointer
*/
void
static void
mouse_move_tile_client(Client **c)
{
Client *sc;
@@ -76,7 +76,7 @@ mouse_move_tile_client(Client **c)
/** Move a client from one tag to another with dah mouse
*\param c client pointer
*/
void
static void
mouse_move_tag_client(Client *c)
{
Window w;
@@ -102,13 +102,15 @@ mouse_move_tag_client(Client *c)
arrange(c->screen, True);
}
client_focus_next(c);
return;
}
/** Move the client with the mouse
* \param c Client pointer
*/
void
static void
mouse_move(Client *c)
{
int ocx, ocy, mx, my;
@@ -247,7 +249,8 @@ mouse_resize(Client *c)
{
/* To resize MWFACT in tile mode */
if((c->flags & TileFlag)
&& tags[selscreen][seltag[selscreen]].layout.func != grid)
&& tags[selscreen][seltag[selscreen]].layout.func != grid_vertical
&& tags[selscreen][seltag[selscreen]].layout.func != grid_horizontal)
{
if(tags[selscreen][seltag[selscreen]].layout.func == tile)
mwf += (ROUND(ev.xmotion.x_root) - omx) / (sgeo[c->screen].width);
@@ -316,7 +319,7 @@ mouse_resize(Client *c)
void
mouse_grabbuttons(Client *c, Bool focused)
{
int i;
size_t i;
uint but[] = {Button1, Button2, Button3, Button4, Button5};
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
@@ -345,6 +348,7 @@ mouse_grabbuttons(Client *c, Bool focused)
void
uicb_mouse_move(uicb_t cmd)
{
(void)cmd;
CHECK(sel);
mouse_move(sel);
@@ -358,6 +362,7 @@ uicb_mouse_move(uicb_t cmd)
void
uicb_mouse_resize(uicb_t cmd)
{
(void)cmd;
CHECK(sel);
mouse_resize(sel);

623
src/parse.c Normal file
View File

@@ -0,0 +1,623 @@
/*
* Copyright (c) 2010 Philippe Pepiot <phil@philpep.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <limits.h>
#include <unistd.h>
#include <fcntl.h>
#include <libgen.h>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <err.h>
#include "parse.h"
extern char *__progname;
enum keyword_t { SEC_START, SEC_END, INCLUDE, WORD, EQUAL, LIST_START, LIST_END, NONE };
#ifdef DEBUG
static struct {
const char *name;
enum keyword_t type;
} kw_t_name[] = {
{"SEC_START", SEC_START},
{"SEC_END", SEC_END},
{"INCLUDE", INCLUDE},
{"WORD", WORD},
{"EQUAL", EQUAL},
{"LIST_START", LIST_START},
{"LIST_END", LIST_END},
{"NONE", NONE},
};
#endif
struct files {
char *name;
struct files *parent;
};
struct keyword {
enum keyword_t type;
/* if WORD */
int line;
struct files *file;
char *name;
struct keyword *next;
};
struct state {
bool_t quote;
bool_t comment;
char quote_char;
};
/* TO REMOVE (use a identifier for config and fallback XDG in api functions) */
TAILQ_HEAD(, conf_sec) config;
static struct keyword *keywords = NULL;
static struct keyword *
push_keyword(struct keyword *tail, enum keyword_t type, char *buf, size_t *offset, struct files *file, int line)
{
struct keyword *kw;
#ifdef DEBUG
int i = 0;
#endif
if (type == WORD && *offset == 0)
return tail;
kw = zcalloc(sizeof(*kw));
kw->type = type;
kw->line = line;
kw->file = file;
kw->next = NULL;
if (*offset != 0) {
buf[*offset] = '\0';
if (!strcmp(buf, INCLUDE_CMD))
kw->type = INCLUDE;
else
kw->name = strdup(buf);
*offset = 0;
}
else
kw->name = NULL;
if (tail)
tail->next = kw;
#ifdef DEBUG
for (i = 0; kw_t_name[i].type != NONE; i++) {
if (kw_t_name[i].type == kw->type) {
warnx("%s %s %s:%d\n", kw_t_name[i].name,
(kw->name) ? kw->name : "",
kw->file->name, kw->line);
}
}
#endif
return kw;
}
static void
syntax(struct keyword *kw, const char *fmt, ...)
{
va_list args;
fprintf(stderr, "%s:", __progname);
if (kw && kw->file && kw->file->name)
fprintf(stderr, "%s:%d", kw->file->name, kw->line);
if (kw && kw->name)
fprintf(stderr, ", near '%s'", kw->name);
fprintf(stderr, ": ");
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
}
#define PUSH_KEYWORD(type) tail = push_keyword(tail, type, bufname, &j, file, line)
static struct keyword *
parse_keywords(const char *filename)
{
int fd;
struct stat st;
char *buf;
struct keyword *head = NULL;
struct keyword *tail = NULL;
struct files *file;
enum keyword_t type; /* keyword type to push */
struct state s = { False, False, '\0'};
char *bufname;
char path[PATH_MAX];
size_t i, j;
int line;
bool_t error = False;
if ((fd = open(filename, O_RDONLY)) == -1 || stat(filename, &st) == -1) {
warn("%s", filename);
return NULL;
}
if (st.st_size == 0) {
warnx("%s: empty file", filename);
close(fd);
return NULL;
}
if (!realpath(filename, path)) {
warn("%s", filename);
close(fd);
return NULL;
}
buf = zmalloc(st.st_size+1);
if (read(fd, buf, st.st_size) == -1) {
warn("%s", filename);
free(buf);
close(fd);
return NULL;
}
buf[st.st_size] = '\0';
file = zcalloc(sizeof(*file));
bufname = zcalloc(sizeof(*bufname) * BUFSIZ);
file->name = strdup(path);
file->parent = NULL;
for(i = 0, j = 0, line = 1; i < (size_t)st.st_size; i++) {
if (!head && tail)
head = tail;
if (buf[i] == '\n' && s.comment == True) {
line++;
s.comment = False;
continue;
}
if (buf[i] == '#' && s.quote == False) {
s.comment = True;
continue;
}
if (s.comment == True)
continue;
if (s.quote == True && buf[i] == s.quote_char) {
/* end of quotted string */
PUSH_KEYWORD(WORD);
s.quote = False;
continue;
}
if (s.quote == False) {
if ((buf[i] == '"' || buf[i] == '\'')) {
PUSH_KEYWORD(WORD);
/* begin quotted string */
s.quote_char = buf[i];
s.quote = True;
continue;
}
if (buf[i] == '[') {
PUSH_KEYWORD(WORD);
if (buf[i+1] == '/') {
i +=2;
type = SEC_END;
}
else {
i++;
type = SEC_START;
}
/* get section name */
while (buf[i] != ']') {
if (i >= ((size_t)st.st_size-1) || j >= (BUFSIZ-1)) {
bufname[j] = '\0';
syntax(NULL, "word too long in %s:%d near '%s'",
file->name, line, bufname);
error = True;
break;
}
bufname[j++] = buf[i++];
}
PUSH_KEYWORD(type);
continue;
}
if (buf[i] == '{') {
PUSH_KEYWORD(WORD);
PUSH_KEYWORD(LIST_START);
continue;
}
if (buf[i] == '}') {
PUSH_KEYWORD(WORD);
PUSH_KEYWORD(LIST_END);
continue;
}
if (buf[i] == ',') {
PUSH_KEYWORD(WORD);
continue;
}
if (buf[i] == '=') {
PUSH_KEYWORD(WORD);
PUSH_KEYWORD(EQUAL);
continue;
}
if (strchr("\t\n ", buf[i])) {
PUSH_KEYWORD(WORD);
if (buf[i] == '\n')
line++;
continue;
}
} /* s.quote == False */
if (j >= (BUFSIZ - 1)) {
bufname[j] = '\0';
syntax(NULL, "word too long in %s:%d near '%s'",
file->name, line, bufname);
error = True;
break;
}
bufname[j++] = buf[i];
}
free(buf);
free(bufname);
close(fd);
warnx("%s read", file->name);
return (error ? NULL: head);
}
/*
* return NULL on failure and head->next if
* no config found (of file doesn't exist)
* NOTE to devs: head->name is the file to include
*/
static struct keyword *
include(struct keyword *head)
{
struct keyword *kw;
struct keyword *tail;
struct files *file;
struct passwd *user;
char *filename = NULL;
char *base = NULL;
head = head->next;
if (!head || head->type != WORD) {
syntax(head, "missing filename to include");
return NULL;
}
/* replace ~ by user directory */
if (head->name && head->name[0] == '~') {
if ( (user = getpwuid(getuid())) && user->pw_dir)
xasprintf(&filename, "%s%s", user->pw_dir, head->name+1);
else if (getenv("HOME"))
xasprintf(&filename, "%s%s", getenv("HOME"), head->name+1);
else /* to warning ? */
filename = head->name;
}
/* relative path from parent file */
else if (head->name && head->name[0] != '/') {
base = strdup(head->file->name);
xasprintf(&filename, "%s/%s", dirname(base), head->name);
free(base);
}
else
filename = head->name;
if (!(kw = parse_keywords(filename))) {
warnx("no config found in include file %s", head->name);
if (filename != head->name)
free(filename);
return NULL;
}
kw->file->parent = head->file;
/* detect circular include */
for (file = kw->file->parent; file != NULL; file = file->parent) {
if (!strcmp(file->name, kw->file->name)) {
syntax(kw, "circular include of %s", kw->file->name);
if (filename != head->name)
free(filename);
return NULL;
}
}
head = head->next;
if (kw) {
for (tail = kw; tail->next; tail = tail->next);
tail->next = head;
}
return kw;
}
static void *
free_opt(struct conf_opt *o)
{
free(o);
return NULL;
}
static struct conf_opt *
get_option(struct keyword **head)
{
struct conf_opt *o;
size_t j = 0;
struct keyword *kw = *head;
o = zcalloc(sizeof(*o));
o->name = kw->name;
o->used = False;
o->line = kw->line;
o->filename = kw->file->name;
kw = kw->next;
if (kw->type != EQUAL) {
syntax(kw, "missing '=' here");
return free_opt(o);
}
kw = kw->next;
if (!kw) {
syntax(kw, "missing value");
return free_opt(o);
}
switch (kw->type) {
case INCLUDE:
if (!(kw = include(kw)))
return free_opt(o);
break;
case WORD:
o->val[0] = kw->name;
o->val[1] = NULL;
kw = kw->next;
break;
case LIST_START:
kw = kw->next;
while (kw && kw->type != LIST_END) {
switch (kw->type) {
case WORD:
if (j >= (PARSE_MAX_LIST - 1)) {
syntax(kw, "too much values in list");
return free_opt(o);
}
o->val[j++] = kw->name;
kw = kw->next;
break;
case INCLUDE:
if (!(kw = include(kw)))
return free_opt(o);
break;
default:
syntax(kw, "declaration into a list");
return free_opt(o);
break;
}
}
if (!kw) {
syntax(kw, "list unclosed");
return free_opt(o);
}
kw = kw->next;
break;
default:
syntax(kw, "missing value");
return free_opt(o);
break;
}
*head = kw;
return o;
}
static void *
free_sec(struct conf_sec *sec)
{
struct conf_opt *o;
struct conf_sec *s;
if (sec) {
while (!SLIST_EMPTY(&sec->optlist)) {
o = SLIST_FIRST(&sec->optlist);
SLIST_REMOVE_HEAD(&sec->optlist, entry);
free_opt(o);
}
while (!TAILQ_EMPTY(&sec->sub)) {
s = TAILQ_FIRST(&sec->sub);
TAILQ_REMOVE(&sec->sub, s, entry);
free_sec(s);
}
free(sec);
}
return NULL;
}
static struct conf_sec *
get_section(struct keyword **head)
{
struct conf_sec *s;
struct conf_opt *o;
struct conf_sec *sub;
struct keyword *kw = *head;
s = zcalloc(sizeof(*s));
s->name = kw->name;
TAILQ_INIT(&s->sub);
SLIST_INIT(&s->optlist);
kw = kw->next;
while (kw && kw->type != SEC_END) {
switch (kw->type) {
case INCLUDE:
if (!(kw = include(kw)))
return free_sec(s);
break;
case SEC_START:
if (!(sub = get_section(&kw)))
return free_sec(s);
TAILQ_INSERT_TAIL(&s->sub, sub, entry);
s->nsub++;
break;
case WORD:
if (!(o = get_option(&kw)))
return free_sec(s);
SLIST_INSERT_HEAD(&s->optlist, o, entry);
s->nopt++;
break;
default:
syntax(kw, "syntax error");
return free_sec(s);
break;
}
}
if (!kw || strcmp(kw->name, s->name)) {
syntax(kw, "missing end section %s", s->name);
return free_sec(s);
}
kw = kw->next;
*head = kw;
return s;
}
int
free_conf(void)
{
struct conf_sec *s;
struct keyword *kw, *nkw;
struct files **f = NULL;
int i, nf = 0;
while (!TAILQ_EMPTY(&config)) {
s = TAILQ_FIRST(&config);
TAILQ_REMOVE(&config, s, entry);
free_sec(s);
}
kw = keywords;
while (kw) {
nkw = kw->next;
free(kw->name);
for (i = 0; i < nf; i++) {
if (f[i] == kw->file) {
if (!(f = realloc(f, sizeof(*f) * (++i))))
err(EXIT_FAILURE, "realloc");
f[i-1] = kw->file;
}
}
kw = nkw;
}
if (nf > 0) {
for (i = 0; i < nf; i++) {
free(f[i]->name);
free(f[i]);
}
free(f);
}
return -1;
}
int
get_conf(const char *filename)
{
struct conf_sec *s;
struct keyword *head, *kw;
kw = head = parse_keywords(filename);
if (!head)
return -1; /* TODO ERREUR */
keywords = head;
TAILQ_INIT(&config);
while (kw) {
switch (kw->type) {
case INCLUDE:
if (!(kw = include(kw)))
return free_conf();
break;
case SEC_START:
if (!(s = get_section(&kw)))
return free_conf();
TAILQ_INSERT_TAIL(&config, s, entry);
break;
default:
syntax(kw, "out of any section");
return free_conf();
break;
}
}
return 0;
}

View File

@@ -17,14 +17,25 @@
#ifndef PARSE_H
#define PARSE_H
#include "wmfs.h"
#include <sys/queue.h>
#define INCLUDE_CMD "@include"
#define PARSE_MAX_LIST 32
#if defined(Bool)
#define bool_t Bool
#else
typedef enum { False, True } bool_t;
#endif /* Bool */
struct conf_opt {
char *name;
char *val[10];
char *val[PARSE_MAX_LIST];
size_t nval;
Bool used;
bool_t used;
int line;
char *filename;
SLIST_ENTRY(conf_opt) entry;
};
@@ -40,7 +51,7 @@ struct conf_sec {
struct opt_type {
long int num;
float fnum;
Bool bool;
bool_t bool;
char *str;
};
@@ -61,7 +72,7 @@ void print_unused(struct conf_sec *s);
* WARNING: This make all string
* returned by fetch_(opt|section)(_first) unusable.
*/
void free_conf(struct conf_sec *s);
int free_conf(void);
/*
* Get all subsection matching the given name on the given

View File

@@ -1,605 +0,0 @@
/*
* Copyright (c) 2010 Philippe Pepiot <phil@philpep.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <err.h>
#include "../wmfs.h"
#define TOKEN(t) \
do { \
kw->type = (t); \
TAILQ_INSERT_TAIL(&keywords, kw, entry); \
kw = malloc(sizeof(*kw)); \
} while (0)
#define NEW_WORD() \
do { \
if (j > 0) { \
e->name[j] = '\0'; \
e->line = file.line; \
TAILQ_INSERT_TAIL(&stack, e, entry); \
e = malloc(sizeof(*e)); \
j = 0; \
TOKEN(WORD); \
} \
} while (0)
enum conf_type { SEC_START, SEC_END, WORD, EQUAL, LIST_START, LIST_END, NONE };
struct conf_keyword {
enum conf_type type;
TAILQ_ENTRY(conf_keyword) entry;
};
struct conf_stack {
char name[BUFSIZ];
int line;
TAILQ_ENTRY(conf_stack) entry;
};
struct conf_state {
Bool quote;
Bool comment;
char quote_char;
};
static void get_keyword(const char *buf, size_t n);
static void pop_keyword(void);
static void pop_stack(void);
static struct conf_sec *get_section(void);
static struct conf_opt *get_option(void);
static struct opt_type string_to_opt(char *);
#ifdef DEBUG
static void print_kw_tree(void);
static char * get_kw_name(enum conf_type);
#endif
static TAILQ_HEAD(, conf_keyword) keywords;
static TAILQ_HEAD(, conf_stack) stack;
static TAILQ_HEAD(, conf_sec) config;
static struct conf_keyword *curk; /* current keyword */
static struct conf_stack *curw; /* current word */
static const struct opt_type opt_type_null = { 0, 0, False, NULL };
static struct {
const char *name;
int line;
} file = { NULL, 1 };
static void
get_keyword(const char *buf, size_t n)
{
struct conf_keyword *kw;
size_t j, i;
struct conf_state s = { False, False, '\0' };
struct conf_stack *e;
TAILQ_INIT(&stack);
TAILQ_INIT(&keywords);
kw = emalloc(1, sizeof(*kw));
e = emalloc(1, sizeof(*e));
for(i = 0, j = 0; i < n; i++)
{
if (buf[i] == '\n' && s.comment == True) {
file.line++;
s.comment = False;
continue;
}
if (buf[i] == '#' && s.quote == False) {
s.comment = True;
continue;
}
if (s.comment == True)
continue;
if (buf[i] == s.quote_char && s.quote == True) {
NEW_WORD();
s.quote = False;
continue;
}
if ((buf[i] == '"' || buf[i] == '\'') &&
s.quote == False)
{
s.quote_char = buf[i];
s.quote = True;
continue;
}
if (buf[i] == '[' && s.quote == False) {
NEW_WORD();
TOKEN((buf[i+1] == '/') ? SEC_END : SEC_START);
if (buf[i+1] == '/')
i++;
continue;
}
if (buf[i] == ']' && s.quote == False) {
NEW_WORD();
continue;
}
if (buf[i] == '{' && s.quote == False) {
NEW_WORD();
TOKEN(LIST_START);
continue;
}
if (buf[i] == '}' && s.quote == False) {
NEW_WORD();
TOKEN(LIST_END);
continue;
}
if (buf[i] == ',' && s.quote == False) {
NEW_WORD();
continue;
}
if (buf[i] == '=' && s.quote == False) {
NEW_WORD();
TOKEN(EQUAL);
continue;
}
if (strchr("\t\n ", buf[i]) && s.quote == False) {
NEW_WORD();
if (buf[i] == '\n')
file.line++;
continue;
}
e->name[j++] = buf[i];
}
}
#ifdef DEBUG
static void
print_kw_tree(void)
{
struct conf_keyword *k;
struct conf_stack *s;
s = TAILQ_FIRST(&stack);
TAILQ_FOREACH(k, &keywords, entry)
printf("%s ", get_kw_name(k->type));
printf("\n");
}
static char *
get_kw_name(enum conf_type type)
{
switch (type) {
case SEC_START:
return ("SEC_START");
break;
case SEC_END:
return ("SEC_END");
break;
case WORD:
return ("WORD");
break;
case LIST_START:
return ("LIST_START ");
break;
case LIST_END:
return ("LIST_END ");
break;
case EQUAL:
return ("EQUAL ");
break;
default:
return ("NONE ");
break;
}
}
#endif
int
get_conf(const char *name)
{
int fd;
struct stat st;
char *buf;
struct conf_sec *s;
if (!name)
return (-1);
if ((fd = open(name, O_RDONLY)) == -1 ||
stat(name, &st) == -1)
{
warn("%s", name);
return (-1);
}
buf = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, SEEK_SET);
if (buf == (char*) MAP_FAILED)
return -1;
get_keyword(buf, st.st_size);
munmap(buf, st.st_size);
close(fd);
warnx("%s read", name);
file.name = name;
curk = TAILQ_FIRST(&keywords);
curw = TAILQ_FIRST(&stack);
TAILQ_INIT(&config);
while (!TAILQ_EMPTY(&keywords)) {
switch (curk->type) {
case SEC_START:
s = get_section();
TAILQ_INSERT_TAIL(&config, s, entry);
break;
default:
errx(1, "%s:%d: near '%s', config out of any section",
file.name, curw->line, curw->name);
break;
}
}
return 0;
}
static struct conf_sec *
get_section(void)
{
struct conf_sec *s;
struct conf_opt *o;
struct conf_sec *sub;
s = emalloc(1, sizeof(*s));
s->name = strdup(curw->name);
TAILQ_INIT(&s->sub);
SLIST_INIT(&s->optlist);
pop_stack();
pop_keyword();
if (curk->type != WORD)
errx(1, "%s:%d: near '%s', missing section name",
file.name, curw->line, curw->name);
pop_keyword();
while (curk->type != SEC_END) {
switch (curk->type) {
case WORD:
o = get_option();
SLIST_INSERT_HEAD(&s->optlist, o, entry);
s->nopt++;
break;
case SEC_START:
sub = get_section();
TAILQ_INSERT_TAIL(&s->sub, sub, entry);
s->nsub++;
case SEC_END:
break;
default:
errx(1, "%s:%d: near '%s', syntax error",
file.name, curw->line, curw->name);
break;
}
}
pop_keyword();
if (curk->type != WORD)
errx(1, "%s:%d: near '%s', missing end-section name",
file.name, curw->line, curw->name);
if (strcmp(curw->name, s->name))
errx(1, "%s:%d: near '%s', non-closed section '%s'",
file.name, curw->line, curw->name, s->name);
pop_stack();
pop_keyword();
return s;
}
static struct conf_opt *
get_option(void)
{
struct conf_opt *o;
size_t j = 0;
o = emalloc(1, sizeof(*o));
o->name = strdup(curw->name);
o->used = False;
o->line = curw->line;
pop_stack();
pop_keyword();
if (curk->type != EQUAL)
errx(1, "%s:%d: near '%s', missing '=' here",
file.name, curw->line, curw->name);
pop_keyword();
switch (curk->type) {
case WORD:
o->val[0] = strdup(curw->name);
o->val[1] = NULL;
pop_stack();
break;
case LIST_START:
pop_keyword();
while (curk->type != LIST_END) {
if (curk->type != WORD)
errx(1, "%s:%d: near '%s', declaration into a list",
file.name, curw->line, curw->name);
o->val[j++] = strdup(curw->name);
pop_stack();
pop_keyword();
}
o->val[j] = NULL;
break;
default:
errx(1, "%s:%d: near '%s', syntax error",
file.name, curw->line, curw->name);
break;
}
pop_keyword();
return o;
}
static void
pop_keyword(void)
{
TAILQ_REMOVE(&keywords, curk, entry);
#ifdef DEBUG
warnx("%s", get_kw_name(curk->type));
#endif
free(curk);
curk = TAILQ_FIRST(&keywords);
}
static void
pop_stack(void)
{
TAILQ_REMOVE(&stack, curw, entry);
#ifdef DEBUG
warnx("%s", curw->name);
#endif
free(curw);
curw = TAILQ_FIRST(&stack);
}
void
print_unused(struct conf_sec *sec)
{
struct conf_sec *s;
struct conf_opt *o;
if (!sec)
{
TAILQ_FOREACH(s, &config, entry)
print_unused(s);
return;
}
SLIST_FOREACH(o, &sec->optlist, entry)
if (o->used == False)
warnx("%s:%d, unused param %s",
file.name, o->line, o->name);
TAILQ_FOREACH(s, &sec->sub, entry)
if (!TAILQ_EMPTY(&s->sub))
print_unused(s);
}
void
free_conf(struct conf_sec *sec)
{
struct conf_sec *s;
struct conf_opt *o;
size_t n;
if (!sec)
{
TAILQ_FOREACH(s, &config, entry)
{
free(s->name);
free_conf(s);
free(s);
}
return;
}
while (!SLIST_EMPTY(&sec->optlist))
{
o = SLIST_FIRST(&sec->optlist);
SLIST_REMOVE_HEAD(&sec->optlist, entry);
free(o->name);
for (n = 0; o->val[n]; n++)
free(o->val[n]);
free(o);
}
while (!TAILQ_EMPTY(&sec->sub))
{
s = TAILQ_FIRST(&sec->sub);
TAILQ_REMOVE(&sec->sub, s, entry);
free_conf(s);
}
}
struct conf_sec **
fetch_section(struct conf_sec *s, char *name)
{
struct conf_sec **ret;
struct conf_sec *sec;
size_t i = 0;
if (!name)
return NULL;
if (!s) {
ret = emalloc(2, sizeof(struct conf_sec *));
TAILQ_FOREACH(sec, &config, entry)
if (!strcmp(sec->name, name)) {
ret[0] = sec;
ret[1] = NULL;
break;
}
}
else {
ret = emalloc(s->nsub+1, sizeof(struct conf_sec *));
TAILQ_FOREACH(sec, &s->sub, entry) {
if (!strcmp(sec->name, name) && i < s->nsub)
ret[i++] = sec;
}
ret[i] = NULL;
}
return ret;
}
struct conf_sec *
fetch_section_first(struct conf_sec *s, char *name)
{
struct conf_sec *sec, *ret = NULL;
if (!name)
return NULL;
if (!s)
{
TAILQ_FOREACH(sec, &config, entry)
if (!strcmp(sec->name, name)) {
ret = sec;
break;
}
}
else
{
TAILQ_FOREACH(sec, &s->sub, entry)
if (!strcmp(sec->name, name)) {
ret = sec;
break;
}
}
return ret;
}
size_t
fetch_section_count(struct conf_sec **s)
{
size_t ret;
for (ret = 0; s[ret]; ret++);
return ret;
}
struct opt_type *
fetch_opt(struct conf_sec *s, char *dfl, char *name)
{
struct conf_opt *o;
struct opt_type *ret;
size_t i = 0;
if (!name)
return NULL;
ret = emalloc(10, sizeof(struct opt_type));
if (s) {
SLIST_FOREACH(o, &s->optlist, entry)
if (!strcmp(o->name, name)) {
while (o->val[i]) {
o->used = True;
ret[i] = string_to_opt(o->val[i]);
i++;
}
ret[i] = opt_type_null;
return ret;
}
}
ret[0] = string_to_opt(dfl);
ret[1] = opt_type_null;
return ret;
}
struct opt_type
fetch_opt_first(struct conf_sec *s, char *dfl, char *name)
{
struct conf_opt *o;
if (!name)
return opt_type_null;
else if (s)
SLIST_FOREACH(o, &s->optlist, entry)
if (!strcmp(o->name, name)) {
o->used = True;
return string_to_opt(o->val[0]);
}
return string_to_opt(dfl);
}
size_t
fetch_opt_count(struct opt_type *o)
{
size_t ret;
for(ret = 0; o[ret].str; ret++);
return ret;
}
static struct opt_type
string_to_opt(char *s)
{
struct opt_type ret = opt_type_null;
if (!s || !strlen(s))
return ret;
ret.num = strtol(s, (char**)NULL, 10);
ret.fnum = strtod(s, NULL);
if (!strcmp(s, "true") || !strcmp(s, "True") ||
!strcmp(s, "TRUE") || !strcmp(s, "1"))
ret.bool = True;
else
ret.bool = False;
ret.str = s;
return ret;
}

197
src/parse_api.c Normal file
View File

@@ -0,0 +1,197 @@
/*
* Copyright (c) 2010 Philippe Pepiot <phil@philpep.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#include <string.h>
#include <stdlib.h>
#include <err.h>
#include "parse.h"
extern TAILQ_HEAD(, conf_sec) config;
static const struct opt_type opt_type_null = { 0, 0, False, NULL };
static struct opt_type
string_to_opt(char *s)
{
struct opt_type ret = opt_type_null;
if (!s || !strlen(s))
return ret;
ret.num = strtol(s, (char**)NULL, 10);
ret.fnum = strtod(s, NULL);
if (!strcmp(s, "true") || !strcmp(s, "True") ||
!strcmp(s, "TRUE") || !strcmp(s, "1"))
ret.bool = True;
else
ret.bool = False;
ret.str = s;
return ret;
}
void
print_unused(struct conf_sec *sec)
{
struct conf_sec *s;
struct conf_opt *o;
if (!sec)
{
TAILQ_FOREACH(s, &config, entry)
print_unused(s);
return;
}
SLIST_FOREACH(o, &sec->optlist, entry)
if (o->used == False)
warnx("%s:%d, unused param %s",
o->filename, o->line, o->name);
TAILQ_FOREACH(s, &sec->sub, entry)
if (!TAILQ_EMPTY(&s->sub))
print_unused(s);
}
struct conf_sec **
fetch_section(struct conf_sec *s, char *name)
{
struct conf_sec **ret;
struct conf_sec *sec;
size_t i = 0;
if (!name)
return NULL;
if (!s) {
ret = xcalloc(2, sizeof(struct conf_sec *));
TAILQ_FOREACH(sec, &config, entry)
if (!strcmp(sec->name, name)) {
ret[0] = sec;
ret[1] = NULL;
break;
}
}
else {
ret = xcalloc(s->nsub+1, sizeof(struct conf_sec *));
TAILQ_FOREACH(sec, &s->sub, entry) {
if (!strcmp(sec->name, name) && i < s->nsub)
ret[i++] = sec;
}
ret[i] = NULL;
}
return ret;
}
struct conf_sec *
fetch_section_first(struct conf_sec *s, char *name)
{
struct conf_sec *sec, *ret = NULL;
if (!name)
return NULL;
if (!s)
{
TAILQ_FOREACH(sec, &config, entry)
if(sec->name && !strcmp(sec->name, name)) {
ret = sec;
break;
}
}
else
{
TAILQ_FOREACH(sec, &s->sub, entry)
if (sec->name && !strcmp(sec->name, name)) {
ret = sec;
break;
}
}
return ret;
}
size_t
fetch_section_count(struct conf_sec **s)
{
size_t ret;
for (ret = 0; s[ret]; ret++);
return ret;
}
struct opt_type *
fetch_opt(struct conf_sec *s, char *dfl, char *name)
{
struct conf_opt *o;
struct opt_type *ret;
size_t i = 0;
if (!name)
return NULL;
ret = xcalloc(10, sizeof(struct opt_type));
if (s) {
SLIST_FOREACH(o, &s->optlist, entry)
if (!strcmp(o->name, name)) {
while (o->val[i]) {
o->used = True;
ret[i] = string_to_opt(o->val[i]);
i++;
}
ret[i] = opt_type_null;
return ret;
}
}
ret[0] = string_to_opt(dfl);
ret[1] = opt_type_null;
return ret;
}
struct opt_type
fetch_opt_first(struct conf_sec *s, char *dfl, char *name)
{
struct conf_opt *o;
if (!name)
return opt_type_null;
else if (s)
SLIST_FOREACH(o, &s->optlist, entry)
if (!strcmp(o->name, name)) {
o->used = True;
return string_to_opt(o->val[0]);
}
return string_to_opt(dfl);
}
size_t
fetch_opt_count(struct opt_type *o)
{
size_t ret;
for(ret = 0; o[ret].str; ret++);
return ret;
}

View File

@@ -91,6 +91,8 @@ screen_get_geo(int s)
XFree(xsi);
}
#else
(void)s;
#endif /* HAVE_XINERAMA */
return geo;
@@ -123,7 +125,8 @@ screen_set_sel(int screen)
if(screen < 0 || screen > screen_count() - 1)
screen = 0;
prevselscreen = selscreen;
if(selscreen != screen)
prevselscreen = selscreen;
client_focus(NULL);
XWarpPointer(dpy, None, ROOT, 0, 0, 0, 0,
@@ -162,7 +165,7 @@ screen_get_sel(void)
XChangeProperty(dpy, ROOT, net_atom[wmfs_current_screen], XA_CARDINAL, 32,
PropModeReplace, (uchar*)&selscreen, 1);
if(os != selscreen)
if(os != selscreen && os != prevselscreen)
prevselscreen = os;
return selscreen;
@@ -176,8 +179,8 @@ screen_init_geo(void)
int i;
int s = screen_count();
sgeo = emalloc(s, sizeof(XRectangle));
spgeo = emalloc(s, sizeof(XRectangle));
sgeo = xcalloc(s, sizeof(XRectangle));
spgeo = xcalloc(s, sizeof(XRectangle));
for(i = 0; i < s; ++i)
sgeo[i] = screen_get_geo(i);
@@ -214,7 +217,6 @@ screen_init_geo(void)
#endif /* HAVE_XRANDR */
ewmh_set_desktop_geometry();
ewmh_set_workarea();
return;
}
@@ -236,11 +238,15 @@ uicb_screen_select(uicb_t cmd)
void
uicb_screen_next(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
selscreen = (selscreen + 1 > screen_count() - 1) ? 0 : selscreen + 1;
if(screen_count() > 1)
{
selscreen = (selscreen + 1 > screen_count() - 1) ? 0 : selscreen + 1;
screen_set_sel(selscreen);
screen_set_sel(selscreen);
}
return;
}
@@ -251,6 +257,7 @@ uicb_screen_next(uicb_t cmd)
void
uicb_screen_prev(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
selscreen = (selscreen - 1 < 0) ? screen_count() - 1 : selscreen - 1;
@@ -266,6 +273,7 @@ uicb_screen_prev(uicb_t cmd)
void
uicb_screen_prev_sel(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
screen_set_sel(prevselscreen);

View File

@@ -38,13 +38,13 @@
*\param str String
*\return n Length of r
*/
int
static int
statustext_rectangle(StatusRec *r, char *str)
{
char as;
int n, i, j, k;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
for(i = j = n = 0; i < (int)strlen(str); ++i, ++j)
if(sscanf(&str[i], "\\b[%d;%d;%d;%d;#%x]%c", &r[n].x, &r[n].y, &r[n].w, &r[n].h, &r[n].color, &as) == 6
&& as == '\\')
for(++n, ++i, --j; str[i] != as || str[i - 1] != ']'; ++i);
@@ -62,13 +62,13 @@ statustext_rectangle(StatusRec *r, char *str)
*\param str String
*\return n Length of g
*/
int
static int
statustext_graph(StatusGraph *g, char *str)
{
char as, c, *p;
int n, i, j, k, m, w;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
for(i = j = n = 0; i < (int)strlen(str); ++i, ++j)
if(sscanf(&str[i], "\\g[%d;%d;%d;%d;#%x;%512[^]]]%c",
&g[n].x, &g[n].y, &g[n].w, &g[n].h, &g[n].color, g[n].data, &as) == 7
&& as == '\\')
@@ -84,7 +84,7 @@ statustext_graph(StatusGraph *g, char *str)
/* height limits */
if(c < 0)
c = 0;
if(c > g[n].h)
if(c > (char)g[n].h)
c = g[n].h;
g[n].data[m] = c;
p = strtok(NULL, ";");
@@ -112,13 +112,13 @@ statustext_graph(StatusGraph *g, char *str)
*\param str String
*\return n Length of s
*/
int
static int
statustext_text(StatusText *s, char *str)
{
char as;
int n, i, j, k;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
for(i = j = n = 0; i < (int)strlen(str); ++i, ++j)
if(sscanf(&str[i], "\\s[%d;%d;%7[^;];%512[^]]]%c", &s[n].x, &s[n].y, s[n].color, s[n].text, &as) == 5
&& as == '\\')
for(++n, ++i, --j; str[i] != as || str[i - 1] != ']'; ++i);
@@ -135,15 +135,18 @@ statustext_text(StatusText *s, char *str)
*\param sc Screen
*\param str String
*/
void
static void
statustext_normal(int sc, char *str)
{
char strwc[MAXSTATUS] = { 0 };
char buf[MAXSTATUS] = { 0 };
char col[8] = { 0 };
int n, i, j, k;
int n, i, j, k, sw = 0;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
if(sc == conf.systray.screen)
sw = systray_get_width();
for(i = j = n = 0; i < (int)strlen(str); ++i, ++j)
if(str[i] == '\\' && str[i + 1] == '#' && str[i + 8] == '\\')
{
++n;
@@ -154,29 +157,29 @@ statustext_normal(int sc, char *str)
strwc[j] = str[i];
/* Draw normal text without any blocks */
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(strwc),
FHINFOBAR, infobar[sc].bar->fg, 0, strwc);
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - (textw(strwc) + sw),
FHINFOBAR, infobar[sc].bar->fg, strwc);
if(n)
{
strcpy(buf, strwc);
strncpy(buf, strwc, sizeof(buf));
for(i = k = 0; i < strlen(str); ++i, ++k)
for(i = k = 0; i < (int)strlen(str); ++i, ++k)
if(str[i] == '\\' && str[i + 1] == '#' && str[i + 8] == '\\')
{
/* Store current color in col[] */
for(j = 0, ++i; str[i] != '\\'; col[j++] = str[i++]);
/* Draw a rectangle with the bar color to draw the text properly */
draw_rectangle(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(&buf[k]),
draw_rectangle(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - (textw(&buf[k]) + sw),
0, INFOBARH - (sgeo[sc].width - SHADH) - textw(&buf[k]),
INFOBARH, conf.colors.bar);
/* Draw text with its color */
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(&buf[k]),
FHINFOBAR, col, 0, &buf[k]);
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - (textw(&buf[k]) + sw),
FHINFOBAR, col, &buf[k]);
strcpy(buf, strwc);
strncpy(buf, strwc, sizeof(buf));
++i;
}
}
@@ -192,7 +195,7 @@ void
statustext_handle(int sc, char *str)
{
char *lastst;
int i, nr, ng, ns, len;
int i, nr, ng, ns, sw = 0;
StatusRec r[128];
StatusGraph g[128];
StatusText s[128];
@@ -201,13 +204,15 @@ statustext_handle(int sc, char *str)
if(!str)
return;
if(sc == conf.systray.screen)
sw = systray_get_width();
barwin_refresh_color(infobar[sc].bar);
/* save last status text address (for free at the end) */
lastst = infobar[sc].statustext;
infobar[sc].statustext = _strdup(str);
len = ((strlen(str) > MAXSTATUS) ? MAXSTATUS : strlen(str));
infobar[sc].statustext = xstrdup(str);
/* Store rectangles, located text & images properties. */
nr = statustext_rectangle(r, str);
@@ -219,15 +224,15 @@ statustext_handle(int sc, char *str)
/* Draw rectangles with stored properties. */
for(i = 0; i < nr; ++i)
draw_rectangle(infobar[sc].bar->dr, r[i].x, r[i].y, r[i].w, r[i].h, r[i].color);
draw_rectangle(infobar[sc].bar->dr, r[i].x - sw, r[i].y, r[i].w, r[i].h, r[i].color);
/* Draw graphs with stored properties. */
for(i = 0; i < ng; ++i)
draw_graph(infobar[sc].bar->dr, g[i].x, g[i].y, g[i].w, g[i].h, g[i].color, g[i].data);
draw_graph(infobar[sc].bar->dr, g[i].x - sw, g[i].y, g[i].w, g[i].h, g[i].color, g[i].data);
/* Draw located text with stored properties. */
for(i = 0; i < ns; ++i)
draw_text(infobar[sc].bar->dr, s[i].x, s[i].y, s[i].color, 0, s[i].text);
draw_text(infobar[sc].bar->dr, s[i].x - sw, s[i].y, s[i].color, s[i].text);
barwin_refresh(infobar[sc].bar);

View File

@@ -51,6 +51,8 @@
#define FSSFlag (1 << 8)
#define AboveFlag (1 << 9)
#define UrgentFlag (1 << 10)
#define FLayFlag (1 << 11)
#define DockFlag (1 << 12)
#define TagFlag(t) (1 << (t))
@@ -106,7 +108,6 @@ enum
net_current_desktop,
net_desktop_names,
net_desktop_geometry,
net_workarea,
net_active_window,
net_close_window,
net_wm_icon_name,
@@ -114,6 +115,7 @@ enum
net_wm_pid,
net_showing_desktop,
net_supporting_wm_check,
net_wm_window_opacity,
net_wm_window_type_normal,
net_wm_window_type_dock,
net_wm_window_type_splash,
@@ -122,7 +124,16 @@ enum
net_wm_icon,
net_wm_state,
net_wm_state_fullscreen,
net_wm_state_sticky,
net_wm_state_demands_attention,
net_wm_system_tray_opcode,
net_system_tray_message_data,
net_system_tray_s,
net_system_tray_visual,
net_system_tray_orientation,
xembed,
xembedinfo,
manager,
utf8_string,
/* WMFS HINTS */
wmfs_running,
@@ -138,6 +149,7 @@ enum
wmfs_screen_count,
wmfs_function,
wmfs_cmd,
wmfs_font,
wmfs_statustext,
net_last
};
@@ -173,6 +185,7 @@ struct Client
char *title;
/* Tag num */
uint tag;
int focusontag;
/* Screen */
int screen;
/* Layer */
@@ -203,6 +216,7 @@ struct Client
uint frame;
char *fg;
uint resizecorner;
uint bordlight, borddark;
} colors;
/* Client Information by flags */
uint flags;
@@ -250,6 +264,15 @@ typedef struct
void (*func)(int screen);
} Layout;
/* Systray Structure */
typedef struct Systray Systray;
struct Systray
{
Window win;
XRectangle geo;
Systray *next, *prev;
};
/* Tag Structure */
typedef struct
{
@@ -264,10 +287,12 @@ typedef struct
Bool request_update;
Bool abovefc;
int barpos;
int prev_barpos;
Layout layout;
uint tagad;
MouseBinding *mouse;
int nmouse;
Bool stay_last;
} Tag;
/* Menu Item Struct */
@@ -312,6 +337,7 @@ typedef struct
char *command;
char histo[HISTOLEN][512];
uint nhisto;
int width;
} Launcher;
/* Button struct */
@@ -331,6 +357,20 @@ typedef struct
char *content;
} Alias;
/* Rule struct */
typedef struct
{
char *class;
char *instance;
char *role;
int screen;
int tag;
Bool free;
Bool max;
Bool ignoretags;
Bool follow_client;
} Rule;
/* Configuration structure */
typedef struct
{
@@ -339,12 +379,15 @@ typedef struct
/* Misc option */
char *font;
uint opacity;
Bool raisefocus;
Bool raiseswitch;
Bool focus_fmouse;
Bool focus_fmov;
Bool focus_pclick;
Bool ignore_next_client_rules;
Bool tagautohide;
Bool tagnamecount;
Tag default_tag;
uint pad;
int status_timing;
char *status_path;
@@ -364,9 +407,14 @@ typedef struct
uint tagurbg;
uint tagselbg;
uint tag_occupied_bg;
char *tag_occupied_fg;
uint tagbord;
char *layout_fg;
uint layout_bg;
float client_light_shade;
float client_dark_shade;
float bar_light_shade;
float bar_dark_shade;
} colors;
struct
{
@@ -379,7 +427,7 @@ typedef struct
{
char *fg;
uint bg;
int maxlenght;
int maxlength;
MouseBinding *mouse;
int nmouse;
} selbar;
@@ -394,14 +442,19 @@ typedef struct
Bool set_new_win_master;
Bool place_at_mouse;
Bool border_shadow;
Bool new_client_get_mouse;
int borderheight;
char *autofree, *automax;
uint bordernormal;
uint borderfocus;
uint resizecorner_normal;
uint resizecorner_focus;
uint mod;
uint padding;
MouseBinding *mouse;
int nmouse;
uint default_open_tag;
int default_open_screen;
} client;
struct
{
@@ -424,21 +477,37 @@ typedef struct
Bool tag;
Bool layout;
} border;
struct
{
Bool active;
int screen;
int spacing;
} systray;
Alias alias[256];
uint mouse_tag_action[TagActionLast];
int layout_button_width;
Layout layout[NUM_OF_LAYOUT];
Menu *menu;
Launcher *launcher;
Rule *rule;
int *ntag;
Bool tag_round;
Bool tag_auto_prev;
Bool client_round;
Bool client_auto_center;
Bool client_tile_raise;
Bool layout_system; /* Switch: False, Menu: True. */
Bool layout_placement; /* Right (normal): False, Left: True. */
Bool keep_layout_geo;
char *tag_expose_name;
char *expose_layout;
char *selected_layout_symbol;
/* Number of... */
int nkeybind;
int nlayout;
int nmenu;
int nlauncher;
int nrule;
} Conf;
typedef struct
@@ -492,4 +561,10 @@ typedef struct
char *uicb;
} vicmd_to_uicb;
typedef struct
{
int version;
int flags;
} xembed_info;
#endif /* STRUCTS_H */

234
src/systray.c Normal file
View File

@@ -0,0 +1,234 @@
/*
* systray.c
* Copyright © 2008, 2009, 2010 Martin Duquesnoy <xorg62@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "wmfs.h"
#define TRAY_DWIDTH (infobar[conf.systray.screen].bar->geo.height + conf.systray.spacing)
Bool
systray_acquire(void)
{
XSetWindowAttributes wattr;
if(!conf.systray.active || traywin)
return False;
if(XGetSelectionOwner(dpy, net_atom[net_system_tray_s]) != None)
{
warnx("Can't initialize system tray: owned by another process");
return False;
}
/* Init traywin window */
wattr.event_mask = ButtonPressMask | ExposureMask;
wattr.override_redirect = True;
wattr.background_pixmap = ParentRelative;
wattr.background_pixel = conf.colors.bar;
traywin = XCreateSimpleWindow(dpy, infobar[conf.systray.screen].bar->win, -1, -1, 1, 1, 0, 0, conf.colors.bar);
XChangeWindowAttributes(dpy, traywin, CWEventMask | CWOverrideRedirect | CWBackPixel, &wattr);
XSelectInput(dpy, traywin, KeyPressMask | ButtonPressMask);
XMapRaised(dpy, traywin);
XSetSelectionOwner(dpy, net_atom[net_system_tray_s], traywin, CurrentTime);
if(XGetSelectionOwner(dpy, net_atom[net_system_tray_s]) != traywin)
{
systray_freeicons();
warnx("System tray: can't get systray manager");
return False;
}
ewmh_send_message(ROOT, ROOT, "MANAGER", CurrentTime, net_atom[net_system_tray_s], traywin, 0, 0);
XSync(dpy, False);
return True;
}
void
systray_add(Window win)
{
Systray *s;
if(!conf.systray.active)
return;
s = xcalloc(1, sizeof(Systray));
s->win = win;
s->geo.height = infobar[conf.systray.screen].bar->geo.height;
s->geo.width = TRAY_DWIDTH;
setwinstate(s->win, WithdrawnState);
XSelectInput(dpy, s->win, StructureNotifyMask | PropertyChangeMask| EnterWindowMask | FocusChangeMask);
XReparentWindow(dpy, s->win, traywin, 0, 0);
ewmh_send_message(s->win, s->win, "_XEMBED", CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0, traywin, 0);
/* Attach */
if(trayicons)
trayicons->prev = s;
s->next = trayicons;
trayicons = s;
return;
}
void
systray_del(Systray *s)
{
Systray **ss;
if(!conf.systray.active)
return;
for(ss = &trayicons; *ss && *ss != s; ss = &(*ss)->next);
*ss = s->next;
free(s);
return;
}
void
systray_state(Systray *s)
{
long flags;
int code = 0;
if(!(flags = ewmh_get_xembed_state(s->win)) || !conf.systray.active)
return;
if(flags & XEMBED_MAPPED)
{
code = XEMBED_WINDOW_ACTIVATE;
XMapRaised(dpy, s->win);
setwinstate(s->win, NormalState);
}
else
{
code = XEMBED_WINDOW_DEACTIVATE;
XUnmapWindow(dpy, s->win);
setwinstate(s->win, WithdrawnState);
}
ewmh_send_message(s->win, s->win, "_XEMBED", CurrentTime, code, 0, 0, 0);
return;
}
void
systray_freeicons(void)
{
Systray *i;
if(!conf.systray.active)
return;
for(i = trayicons; i; i = i->next)
{
XUnmapWindow(dpy, i->win);
XReparentWindow(dpy, i->win, ROOT, 0, 0);
free(i);
}
XSetSelectionOwner(dpy, net_atom[net_system_tray_s], None, CurrentTime);
XDestroyWindow(dpy, traywin);
XSync(dpy, 0);
return;
}
Systray*
systray_find(Window win)
{
Systray *i;
if(!conf.systray.active)
return NULL;
for(i = trayicons; i; i = i->next)
if(i->win == win)
return i;
return NULL;
}
int
systray_get_width(void)
{
int w = 0;
Systray *i;
if(!conf.systray.active)
return 0;
for(i = trayicons; i; i = i->next)
w += i->geo.width + conf.systray.spacing + 1;
return w;
}
void
systray_update(void)
{
Systray *i;
int x = 1;
if(!conf.systray.active)
return;
if(!trayicons)
{
XMoveResizeWindow(dpy, traywin, infobar[conf.systray.screen].bar->geo.width - 1, 0, 1, 1);
return;
}
for(i = trayicons; i; i = i->next)
{
XMapWindow(dpy, i->win);
XMoveResizeWindow(dpy, i->win, (i->geo.x = x), 0, i->geo.width, i->geo.height);
x += i->geo.width + conf.systray.spacing;
}
XMoveResizeWindow(dpy, traywin, infobar[conf.systray.screen].bar->geo.width - x,
0, x, infobar[conf.systray.screen].bar->geo.height);
return;
}

315
src/tag.c
View File

@@ -42,23 +42,30 @@ tag_set(int tag)
Bool al = False;
int i;
if(tag < 0 || tag > MAXTAG)
return;
screen_get_sel();
prevseltag[selscreen] = seltag[selscreen];
if(seltag[selscreen] != tag)
prevseltag[selscreen] = seltag[selscreen];
else if(tag == seltag[selscreen] && tag != prevseltag[selscreen] && conf.tag_auto_prev)
tag = seltag[selscreen] = prevseltag[selscreen];
else
seltag[selscreen] = tag;
if(conf.tag_round)
{
if(tag <= 0)
seltag[selscreen] = conf.ntag[selscreen];
else if(tag > conf.ntag[selscreen])
else if(tag > conf.ntag[selscreen])
seltag[selscreen] = 1;
else
seltag[selscreen] = tag;
}
else
{
if(!tag || tag == seltag[selscreen]
|| tag > conf.ntag[selscreen])
if(!tag || tag > conf.ntag[selscreen])
return;
seltag[selscreen] = tag;
@@ -67,12 +74,18 @@ tag_set(int tag)
ewmh_update_current_tag_prop();
/* Arrange infobar position */
if(tags[selscreen][prevseltag[selscreen]].barpos != tags[selscreen][seltag[selscreen]].barpos)
if(tags[selscreen][prevseltag[selscreen]].barpos != tags[selscreen][seltag[selscreen]].barpos
|| prevseltag[selscreen] == seltag[selscreen])
infobar_set_position(tags[selscreen][seltag[selscreen]].barpos);
/* Check if a layout update is needed with additional tags */
if(tags[selscreen][seltag[selscreen]].tagad)
al = True;
else if(tags[selscreen][seltag[selscreen]].request_update)
{
al = True;
tags[selscreen][seltag[selscreen]].request_update = False;
}
for(i = 1; i < conf.ntag[selscreen] + 1; ++i)
if(tags[selscreen][i].tagad & TagFlag(seltag[selscreen]))
@@ -97,11 +110,17 @@ tag_set(int tag)
tags[selscreen][tag].request_update = False;
}
/* To focus the first client in the new tag */
/* To focus selected client of the via focusontag option */
for(c = clients; c; c = c->next)
if(c->tag == seltag[selscreen] && c->screen == selscreen)
if(c->focusontag == tag && c->screen == selscreen)
break;
/* No focusontag option found on any client, try to find the first of the tag */
if(!c)
for(c = clients; c; c = c->next)
if(c->tag == (uint)seltag[selscreen] && c->screen == selscreen)
break;
client_focus((c) ? c : NULL);
return;
@@ -118,7 +137,7 @@ tag_transfert(Client *c, int tag)
CHECK(c);
if(!tag)
if(tag <= 0)
tag = 1;
if(tag > conf.ntag[selscreen])
@@ -129,8 +148,7 @@ tag_transfert(Client *c, int tag)
arrange(c->screen, True);
if(c == sel && c->tag != tag)
client_focus(NULL);
client_focus_next(c);
client_update_attributes(c);
@@ -161,6 +179,7 @@ uicb_tag(uicb_t cmd)
void
uicb_tag_next(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
tag_set(seltag[selscreen] + 1);
@@ -174,6 +193,7 @@ uicb_tag_next(uicb_t cmd)
void
uicb_tag_prev(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
tag_set(seltag[selscreen] - 1);
@@ -190,6 +210,7 @@ uicb_tag_next_visible(uicb_t cmd)
int i, tag;
Client *c;
Bool is_occupied[MAXTAG];
(void)cmd;
screen_get_sel();
@@ -233,6 +254,7 @@ uicb_tag_prev_visible(uicb_t cmd)
int i, tag;
Client *c;
Bool is_occupied[MAXTAG];
(void)cmd;
screen_get_sel();
@@ -267,6 +289,104 @@ uicb_tag_prev_visible(uicb_t cmd)
return;
}
/** Go to the last tag
*\param cmd uicb_t type unused
*/
void
uicb_tag_last(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
tag_set(conf.ntag[selscreen]);
return;
}
/**
*\param selscreen int
*/
static void
remove_old_last_tag(int selscreen)
{
int i;
for(i = 0; i <= conf.ntag[selscreen]; i++)
{
if(tags[selscreen][i].stay_last)
{
tags[selscreen][i].stay_last = False;
break;
}
}
return;
}
/** Swap 2 tags
*\param s Screen
*\param t1 Tag 1
*\param t2 Tag 2
*/
static void
tag_swap(int s, int t1, int t2)
{
Client *c;
Tag t;
if(t1 > conf.ntag[s] || t1 < 1
|| t2 > conf.ntag[s] || t2 < 1 || t1 == t2)
return;
t = tags[s][t1];
tags[s][t1] = tags[s][t2];
tags[s][t2] = t;
for(c = clients; c; c = c->next)
{
if(c->screen == s && c->tag == (uint)t1)
c->tag = t2;
else if(c->screen == s && c->tag == (uint)t2)
c->tag = t1;
}
infobar_update_taglist(s);
tag_set(t2);
return;
}
/** Keep that tag the last one
*\param cmd uicb_t type unused
*/
void
uicb_tag_stay_last(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
if(tags[selscreen][seltag[selscreen]].stay_last)
tags[selscreen][seltag[selscreen]].stay_last = False;
else
{
int i;
remove_old_last_tag(selscreen);
for(i = seltag[selscreen]; i <= conf.ntag[selscreen]; i++)
{
tag_swap(selscreen, seltag[selscreen], seltag[selscreen] + 1);
}
tag_set(conf.ntag[selscreen]);
tags[selscreen][seltag[selscreen]].stay_last = True;
arrange(selscreen, True);
}
return;
}
/** Transfert the selected client to
* the wanted tag
* \param cmd Wanted tag, uicb_t type
@@ -287,6 +407,7 @@ uicb_tagtransfert(uicb_t cmd)
void
uicb_tag_prev_sel(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
tag_set(prevseltag[selscreen]);
@@ -302,6 +423,7 @@ uicb_tagtransfert_next(uicb_t cmd)
{
CHECK(sel);
int tag = seltag[selscreen] + 1;
(void)cmd;
if(tag > conf.ntag[selscreen])
{
@@ -322,6 +444,7 @@ uicb_tagtransfert_prev(uicb_t cmd)
{
CHECK(sel);
int tag = seltag[selscreen] - 1;
(void)cmd;
if(tag <= 0)
{
@@ -343,6 +466,8 @@ uicb_tag_urgent(uicb_t cmd)
Client *c;
Bool b = False;
(void)cmd;
/* Check if there is a urgent client */
for(c = clients; c; c = c->next)
if(c->flags & UrgentFlag)
@@ -393,39 +518,6 @@ uicb_tag_toggle_additional(uicb_t cmd)
return;
}
/** Swap 2 tags
*\param s Screen
*\param t1 Tag 1
*\param t2 Tag 2
*/
void
tag_swap(int s, int t1, int t2)
{
Client *c;
Tag t;
if(t1 > conf.ntag[s] || t1 < 1
|| t2 > conf.ntag[s] || t2 < 1 || t1 == t2)
return;
t = tags[s][t1];
tags[s][t1] = tags[s][t2];
tags[s][t2] = t;
for(c = clients; c; c = c->next)
{
if(c->screen == s && c->tag == t1)
c->tag = t2;
else if(c->screen == s && c->tag == t2)
c->tag = t1;
}
infobar_update_taglist(s);
tag_set(t2);
return;
}
/** Swap current tag with a specified tag
*\param cmd uicb_t type
*/
@@ -445,9 +537,18 @@ uicb_tag_swap(uicb_t cmd)
void
uicb_tag_swap_next(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
tag_swap(selscreen, seltag[selscreen], seltag[selscreen] + 1);
/* Check if the next one does have the stay_last bool */
if(!tags[selscreen][conf.ntag[selscreen]].stay_last)
{
tag_swap(selscreen, seltag[selscreen], seltag[selscreen] + 1);
}
else
{
warnx("The next tag is set to always stay the last one");
}
return;
}
@@ -458,6 +559,7 @@ uicb_tag_swap_next(uicb_t cmd)
void
uicb_tag_swap_previous(uicb_t cmd)
{
(void)cmd;
screen_get_sel();
tag_swap(selscreen, seltag[selscreen], seltag[selscreen] - 1);
@@ -469,11 +571,11 @@ uicb_tag_swap_previous(uicb_t cmd)
*\param s Screen number
*\param name New tag name
*/
void
static void
tag_new(int s, char *name)
{
Tag t = { NULL, NULL, 0, 0, 0.65, 1, False, False, False, False, IB_Top,
layout_name_to_struct(conf.layout, "tile_right", conf.nlayout, layout_list), 0, NULL, 0 };
char * displayedName;
int goToTag;
if(conf.ntag[s] + 1 > MAXTAG)
{
@@ -484,13 +586,41 @@ tag_new(int s, char *name)
++conf.ntag[s];
/* TODO: memleak here */
if(!name || strlen(name) == 0)
{
if(conf.tagnamecount)
{
/* displayedName = zmalloc(2); */
xasprintf(&displayedName, "[%d]", conf.ntag[s]);
}
else
displayedName = conf.default_tag.name;
}
else
displayedName = xstrdup(name);
Tag t = { displayedName, NULL, 0, 0,
conf.default_tag.mwfact, conf.default_tag.nmaster,
False, conf.default_tag.resizehint, False, False,
conf.default_tag.barpos, conf.default_tag.barpos, conf.default_tag.layout,
0, NULL, 0, False };
tags[s][conf.ntag[s]] = t;
tags[s][conf.ntag[s]].name = _strdup((name ? name : "new tag"));
/* For stay_last_tag */
if(tags[s][conf.ntag[s]-1].stay_last)
{
tag_swap(s, conf.ntag[s], conf.ntag[s]-1);
goToTag = conf.ntag[s]-1;
}
else
goToTag = conf.ntag[s];
infobar_update_taglist(s);
infobar_draw(s);
tag_set(conf.ntag[s]);
tag_set(goToTag);
return;
}
@@ -512,18 +642,20 @@ uicb_tag_new(uicb_t cmd)
*\param s Screen number
*\param tag Tag number
*/
void
static void
tag_delete(int s, int tag)
{
Tag t = { 0 };
Tag t;
Client *c;
int i;
size_t i;
memset(&t, 0, sizeof(t));
if(tag < 0 || tag > conf.ntag[s] || conf.ntag[s] == 1)
return;
for(c = clients; c; c = c->next)
if(c->screen == s && c->tag == tag)
if(c->screen == s && c->tag == (uint)tag)
{
warnx("Client(s) present in this tag, can't delete it");
@@ -535,7 +667,7 @@ tag_delete(int s, int tag)
tags[s][tag] = t;
infobar[s].tags[tag] = NULL;
for(i = tag; i < conf.ntag[s] + 1; ++i)
for(i = tag; i < (size_t)conf.ntag[s] + 1; ++i)
{
/* Set clients tag because of shift */
for(c = clients; c; c = c->next)
@@ -574,3 +706,78 @@ uicb_tag_del(uicb_t cmd)
return;
}
/** Rename the selected tag
*\param cmd uicb_t type
*/
void
uicb_tag_rename(uicb_t cmd)
{
screen_get_sel();
char *str;
size_t len;
if(!cmd || !strlen(cmd))
return;
str = tags[selscreen][seltag[selscreen]].name;
len = strlen(str);
/* TODO: if strlen(cmd) > len, the tag name
* will be truncated...
* We can't do a realloc because if the pointer change
* free() on paser will segfault.on free_conf()...
*/
strncpy(str, cmd, len);
infobar_update_taglist(selscreen);
infobar_draw(selscreen);
return;
}
void
uicb_tag_toggle_expose(uicb_t cmd)
{
(void)cmd;
int i, j;
screen_get_sel();
for(i = 1; i <= conf.ntag[selscreen]; i++)
{
if(strcmp(tags[selscreen][i].name, conf.tag_expose_name) == 0)
{
if(clients && sel->tag)
tag_set(sel->tag);
tag_delete(selscreen, i);
for(j = 0; j < conf.ntag[selscreen]; j++)
tags[selscreen][j].request_update = True;
arrange(selscreen, True);
return;
}
}
tag_new(selscreen, conf.tag_expose_name);
for(i = 0; i < conf.nlayout; ++i)
{
if(strcmp(conf.expose_layout, conf.layout[i].type) == 0)
{
tags[selscreen][conf.ntag[selscreen]].layout = conf.layout[i];
}
}
for(i = 1; i < conf.ntag[selscreen]; ++i)
{
tags[selscreen][conf.ntag[selscreen]].tagad ^= TagFlag(i);
}
tags[selscreen][conf.ntag[selscreen]].request_update = True;
arrange(selscreen, True);
return;
}

View File

@@ -30,24 +30,103 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _GNU_SOURCE
#include "wmfs.h"
/** Calloc with an error message if there is a probleme
* \param element Element
* \param size Size
* \return void pointer
*/
void*
emalloc(uint element, uint size)
/** malloc with error support and size_t overflow protection
* \param nmemb number of objects
* \param size size of single object
* \return non null void pointer
*/
void *
xmalloc(size_t nmemb, size_t size)
{
void *ret = calloc(element, size);
void *ret;
if(!ret)
warn("calloc()");
if (SIZE_MAX / nmemb < size)
err(EXIT_FAILURE, "xmalloc(%zu, %zu), "
"size_t overflow detected", nmemb, size);
if ((ret = malloc(nmemb * size)) == NULL)
err(EXIT_FAILURE, "malloc(%zu)", nmemb * size);
return ret;
}
/** calloc with error support
* \param nmemb Number of objects
* \param size size of single object
* \return non null void pointer
*/
void *
xcalloc(size_t nmemb, size_t size)
{
void *ret;
if ((ret = calloc(nmemb, size)) == NULL)
err(EXIT_FAILURE, "calloc(%zu * %zu)", nmemb, size);
return ret;
}
/** realloc with error support and size_t overflow check
* \param ptr old pointer
* \param nmemb number of objects
* \param size size of single object
* \return non null void pointer
*/
void *
xrealloc(void *ptr, size_t nmemb, size_t size)
{
void *ret;
if (SIZE_MAX / nmemb < size)
err(EXIT_FAILURE, "xrealloc(%p, %zu, %zu), "
"size_t overflow detected", ptr, nmemb, size);
if ((ret = realloc(ptr, nmemb * size)) == NULL)
err(EXIT_FAILURE, "realloc(%p, %zu)", ptr, nmemb * size);
return ret;
}
/** strdup with error support
* \param str char pointer
* \retun non null void pointer
*/
char *
xstrdup(const char *str)
{
char *ret;
if (str == NULL || (ret = strdup(str)) == NULL)
err(EXIT_FAILURE, "strdup(%s)", str);
return ret;
}
/** asprintf wrapper
* \param strp target string
* \param fmt format
* \return non zero integer
*/
int
xasprintf(char **strp, const char *fmt, ...)
{
int ret;
va_list args;
va_start(args, fmt);
ret = vasprintf(strp, fmt, args);
va_end(args);
if (ret == -1)
err(EXIT_FAILURE, "asprintf(%s)", fmt);
return ret;
}
/** Get a color with a string
* \param color Color string
* \return Color pixel
@@ -63,21 +142,6 @@ getcolor(char *color)
return xcolor.pixel;
}
/** Enlight an hexadecimal color
* \param col Color
* \return The clarified color
*/
ulong
color_enlight(ulong col)
{
if((col + 0x330000) < 0xffffff
&& (col + 0x003300) < 0xffffff
&& (col + 0x000033) < 0xffffff)
return col + 0x333333;
else
return col;
}
/** Set the window WM State
* \param win Window target
* \param state WM State
@@ -93,20 +157,6 @@ setwinstate(Window win, long state)
return;
}
/** My strdup. the strdup of string.h isn't ansi compatible..
* Thanks linkdd.
* \param str char pointer
*/
char*
_strdup(const char *str)
{
char *ret = emalloc(strlen(str) + 1, sizeof(char));
strcpy(ret, str);
return ret;
}
/* The following function are for configuration
usage. {{{
*/
@@ -160,56 +210,20 @@ layout_name_to_struct(Layout lt[], char *name, int n, const func_name_list_t lli
return lt[0];
}
char*
alias_to_str(char *conf_choice)
{
int i;
char *tmpchar = NULL;
if(!conf_choice)
return 0;
if(conf.alias)
for(i = 0; conf.alias[i].name; i++)
if(!strcmp(conf_choice, conf.alias[i].name))
tmpchar = conf.alias[i].content;
if(tmpchar)
return _strdup(tmpchar);
else
return _strdup(conf_choice);
return NULL;
}
/* }}} */
/** Get the mouse pointer position.
*/
XRectangle
get_mouse_pos(void)
{
Window dum;
int d, u;
XRectangle ret;
XQueryPointer(dpy, ROOT, &dum, &dum, (int*)&ret.x, (int*)&ret.y, &d, &d, (uint *)&u);
return ret;
}
/** Execute a sh command
* \param cmd Command
* \return child pid
*/
int
pid_t
spawn(const char *format, ...)
{
char *sh = NULL;
char cmd[512];
va_list ap;
pid_t pid, ret;
int p[2], len;
pid_t pid;
size_t len;
va_start(ap, format);
len = vsnprintf(cmd, sizeof(cmd), format, ap);
@@ -224,45 +238,19 @@ spawn(const char *format, ...)
if(!(sh = getenv("SHELL")))
sh = "/bin/sh";
if (pipe(p) == -1)
{
warn("pipe");
return -1;
}
if((pid = fork()) == 0)
{
close(p[0]);
if((pid = fork()) == 0)
{
if(dpy)
close(ConnectionNumber(dpy));
setsid();
execl(sh, sh, "-c", cmd, (char*)NULL);
exit(EXIT_FAILURE);
}
write(p[1], &pid, sizeof(pid_t));
close(p[1]);
exit(EXIT_SUCCESS);
if(dpy)
close(ConnectionNumber(dpy));
setsid();
if (execl(sh, sh, "-c", cmd, (char*)NULL) == -1)
warn("execl(sh -c %s)", cmd);
exit(EXIT_FAILURE);
}
else if (pid != -1)
{
close(p[1]);
if (sizeof(pid_t) != read(p[0], &ret, sizeof(pid_t)))
{
warn("read");
ret = -1;
}
close(p[0]);
waitpid(pid, NULL, 0);
}
else
{
else if (pid == -1)
warn("fork");
ret = -1;
}
return ret;
return pid;
}
/** Swap two pointer.
@@ -304,7 +292,7 @@ parse_image_block(ImageAttr *im, char *str)
char as;
int n, i, j, k;
for(i = j = n = 0; i < strlen(str); ++i, ++j)
for(i = j = n = 0; i < (int)strlen(str); ++i, ++j)
if(sscanf(&str[i], "\\i[%d;%d;%d;%d;%512[^]]]%c", &im[n].x, &im[n].y, &im[n].w, &im[n].h, im[n].name, &as) == 6
&& as == '\\')
for(++n, ++i, --j; str[i] != as || str[i - 1] != ']'; ++i);
@@ -323,7 +311,7 @@ clean_value(char *str)
int i;
char c, *p;
if(!str || !(p = _strdup(str)))
if(!str || !(p = xstrdup(str)))
return NULL;
/* Remove useless spaces */
@@ -340,3 +328,26 @@ clean_value(char *str)
return p;
}
/* To use ~/ shortcut.. */
char*
patht(char *path)
{
static char ret[512];
if(!path)
return NULL;
strncpy(ret, path, sizeof(ret));
ret[sizeof(ret) - 1] = 0;
if(strstr(path, "~/"))
snprintf(ret, sizeof(ret), "%s/%s", getenv("HOME"), path + 2);
return ret;
}
int
qsort_string_compare (const void * a, const void * b)
{
return (strcmp(*(char **)a, *(char **)b));
}

View File

@@ -32,7 +32,7 @@
#include "wmfs.h"
vicmd_to_uicb vicmd[] =
static vicmd_to_uicb vicmd[] =
{
{"r", "reload"},
{"q", "quit"},
@@ -62,10 +62,10 @@ vicmd_to_uicb vicmd[] =
{"tf", "toggle_free"},
};
void
static void
viwmfs_help(void)
{
int i;
size_t i;
char s[20];
printf("ViWMFS commands list:\n");
@@ -85,7 +85,7 @@ viwmfs_help(void)
void
viwmfs(int argc, char **argv)
{
int i;
size_t i;
char *cmd, str[256] = { 0 };
Bool e;
@@ -94,7 +94,7 @@ viwmfs(int argc, char **argv)
if(argc > 3)
{
for(i = 2; i < argc; ++i)
for(i = 2; i < (size_t)argc; ++i)
{
strcat(str, argv[i]);
@@ -103,7 +103,7 @@ viwmfs(int argc, char **argv)
}
}
else
strcpy(str, argv[2]);
strncpy(str, argv[2], sizeof(str));
if(!strcmp(str, "help"))
{
@@ -116,7 +116,7 @@ viwmfs(int argc, char **argv)
{
for(i = 0; i < strlen(str); str[i] = str[i + 1], ++i);
cmd = _strdup(str);
cmd = xstrdup(str);
for(i = 0; cmd[i] && cmd[i] != ' '; ++i);
cmd[i] = '\0';

View File

@@ -32,11 +32,13 @@
#include "wmfs.h"
static volatile Bool exiting = False, sig_chld = False;
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
int
errorhandler(Display *d, XErrorEvent *event)
{
char mess[256];
Client *c;
/* Check if there is another WM running */
if(BadAccess == event->error_code
@@ -48,7 +50,7 @@ errorhandler(Display *d, XErrorEvent *event)
* 42 = X_SetInputFocus
* 28 = X_GrabButton
*/
if((c = client_gb_win(event->resourceid)))
if(client_gb_win(event->resourceid))
if(event->error_code == BadWindow
|| event->request_code == 42
|| event->request_code == 28)
@@ -68,6 +70,8 @@ errorhandler(Display *d, XErrorEvent *event)
int
errorhandlerdummy(Display *d, XErrorEvent *event)
{
(void)d;
(void)event;
return 0;
}
@@ -77,7 +81,7 @@ void
quit(void)
{
Client *c;
int i;
size_t i, len;
/* Set the silent error handler */
XSetErrorHandler(errorhandlerdummy);
@@ -89,8 +93,10 @@ quit(void)
XReparentWindow(dpy, c->win, ROOT, c->geo.x, c->geo.y);
}
IFREE(tags);
IFREE(seltag);
free(tags);
free(seltag);
systray_freeicons();
XftFontClose(dpy, font);
for(i = 0; i < CurLast; ++i)
@@ -98,87 +104,107 @@ quit(void)
XFreeGC(dpy, gc_stipple);
infobar_destroy();
IFREE(sgeo);
IFREE(spgeo);
IFREE(infobar);
IFREE(keys);
IFREE(func_list);
IFREE(net_atom);
free(sgeo);
free(spgeo);
free(infobar);
free(keys);
free(net_atom);
/* Clean conf alloced thing */
IFREE(menulayout.item);
free(menulayout.item);
if(conf.menu)
{
for(i = 0; i < LEN(conf.menu); ++i)
IFREE(conf.menu[i].item);
IFREE(conf.menu);
len = LEN(conf.menu);
for(i = 0; i < len; ++i)
free(conf.menu[i].item);
free(conf.menu);
}
IFREE(conf.launcher);
free(conf.launcher);
free(conf.rule);
IFREE(conf.bars.mouse);
IFREE(conf.selbar.mouse);
IFREE(conf.titlebar.button);
IFREE(conf.client.mouse);
IFREE(conf.root.mouse);
free(conf.bars.mouse);
free(conf.selbar.mouse);
free(conf.titlebar.button);
free(conf.client.mouse);
free(conf.root.mouse);
free_conf(NULL);
free_conf();
XSync(dpy, False);
XCloseDisplay(dpy);
/* kill status script */
if (conf.status_pid != (pid_t)-1)
kill(conf.status_pid, SIGQUIT);
kill(conf.status_pid, SIGTERM);
return;
}
void *
thread_process(void *arg)
static void
wait_childs_and_status(void)
{
XEvent ev;
int pid;
/* X event loop */
if(arg)
{
while(!exiting && !XNextEvent(dpy, &ev))
getevent(ev);
pthread_mutex_lock(&mtx);
if (sig_chld) {
while ((pid = waitpid(-1, NULL, WNOHANG)) > 0)
if (pid == conf.status_pid)
conf.status_pid = -1;
sig_chld = False;
}
/* Status checking loop with timing */
else
pthread_mutex_unlock(&mtx);
}
static void *
thread_status(void *arg)
{
(void)arg;
int left = conf.status_timing;
pthread_detach(pthread_self());
do
{
pthread_detach(pthread_self());
do
{
wait_childs_and_status();
pthread_mutex_lock(&mtx);
if (conf.status_pid == -1)
conf.status_pid = spawn(conf.status_path);
sleep(conf.status_timing);
} while (!exiting && conf.status_timing != 0);
}
pthread_mutex_unlock(&mtx);
while ((left = sleep(left)) > 0);
left = conf.status_timing;
} while (!exiting);
pthread_exit(NULL);
}
/** WMFS main loop.
*/
void
static void
mainloop(void)
{
XEvent ev;
pthread_t evloop, evstatus;
void *ret;
pthread_t th_status;
if(!estatus)
while(!exiting && !XNextEvent(dpy, &ev))
getevent(ev);
else
{
pthread_create(&evloop, NULL, thread_process, "1");
pthread_create(&evstatus, NULL, thread_process, NULL);
(void)pthread_join(evloop, &ret);
if (estatus && conf.status_timing == 0)
conf.status_pid = spawn(conf.status_path);
else if (estatus && pthread_create(&th_status, NULL, thread_status, NULL) != 0) {
warnx("pthread_create");
estatus = False;
}
while (!exiting && !XNextEvent(dpy, &ev)) {
getevent(ev);
wait_childs_and_status();
}
if (estatus)
pthread_join(th_status, NULL);
return;
}
@@ -190,6 +216,7 @@ mainloop(void)
void
uicb_quit(uicb_t cmd)
{
(void)cmd;
exiting = True;
return;
@@ -198,14 +225,14 @@ uicb_quit(uicb_t cmd)
/** Scan if there are windows on X
* for manage it
*/
void
static void
scan(void)
{
uint i, n;
uint n;
XWindowAttributes wa;
Window usl, usl2, *w = NULL;
Atom rt;
int s, rf, tag = -1, screen = -1, free = -1;
int s, rf, tag = -1, screen = -1, free = -1, i;
ulong ir, il;
uchar *ret;
Client *c;
@@ -214,26 +241,27 @@ scan(void)
if(XQueryTree(dpy, ROOT, &usl, &usl2, &w, &n))
for(i = n - 1; i != -1; --i)
if(XGetWindowAttributes(dpy, w[i], &wa)
&& !(wa.override_redirect || XGetTransientForHint(dpy, w[i], &usl))
&& wa.map_state == IsViewable)
{
XGetWindowAttributes(dpy, w[i], &wa);
if(!wa.override_redirect && wa.map_state == IsViewable)
{
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_TAG"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
{
tag = *ret;
XFree(ret);
}
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_SCREEN"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
{
screen = *ret;
XFree(ret);
}
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_ISFREE"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
{
free = *ret;
XFree(ret);
@@ -250,11 +278,12 @@ scan(void)
client_update_attributes(c);
}
}
/* Set update layout request */
for(c = clients; c; c = c->next)
{
if(c->tag > conf.ntag[c->screen])
if(c->tag > (uint)conf.ntag[c->screen])
c->tag = conf.ntag[c->screen];
tags[c->screen][c->tag].request_update = True;
}
@@ -273,11 +302,13 @@ scan(void)
void
uicb_reload(uicb_t cmd)
{
(void)cmd;
quit();
for(; argv_global[0] && argv_global[0] == ' '; ++argv_global);
execlp(argv_global, argv_global, NULL);
/* add -C to always load the same config file */
execvp(argv_global, all_argv);
return;
}
@@ -319,15 +350,11 @@ check_wmfs_running(void)
void
exec_uicb_function(char *func, char *cmd)
{
long data[5];
/* Check if wmfs is running (this function is executed when wmfs
is already running normally...) */
if(!check_wmfs_running())
return;
data[4] = True;
XChangeProperty(dpy, ROOT, ATOM("_WMFS_FUNCTION"), ATOM("UTF8_STRING"),
8, PropModeReplace, (uchar*)func, strlen(func));
@@ -337,7 +364,7 @@ exec_uicb_function(char *func, char *cmd)
XChangeProperty(dpy, ROOT, ATOM("_WMFS_CMD"), ATOM("UTF8_STRING"),
8, PropModeReplace, (uchar*)cmd, strlen(cmd));
send_client_event(data, "_WMFS_FUNCTION");
ewmh_send_message(ROOT, ROOT, "_WMFS_FUNCTION", 0, 0, 0, 0, True);
return;
}
@@ -345,15 +372,12 @@ exec_uicb_function(char *func, char *cmd)
/** Set statustext
*\param str Statustext string
*/
void
static void
set_statustext(int s, char *str)
{
int i;
long data[5];
char atom_name[64];
data[4] = True;
if(!str)
return;
@@ -366,7 +390,7 @@ set_statustext(int s, char *str)
XChangeProperty(dpy, ROOT, ATOM(atom_name), ATOM("UTF8_STRING"),
8, PropModeReplace, (uchar*)str, strlen(str));
send_client_event(data, atom_name);
ewmh_send_message(ROOT, ROOT, atom_name, 0, 0, 0, 0, True);
}
}
else
@@ -376,7 +400,7 @@ set_statustext(int s, char *str)
XChangeProperty(dpy, ROOT, ATOM(atom_name), ATOM("UTF8_STRING"),
8, PropModeReplace, (uchar*)str, strlen(str));
send_client_event(data, atom_name);
ewmh_send_message(ROOT, ROOT, atom_name, 0, 0, 0, 0, True);
}
return;
@@ -384,29 +408,32 @@ set_statustext(int s, char *str)
/** Update status script by ewmh hint
*/
void
static void
update_status(void)
{
long data[5];
if(!check_wmfs_running())
return;
data[4] = True;
send_client_event(data, "_WMFS_UPDATE_STATUS");
ewmh_send_message(ROOT, ROOT, "_WMFS_UPDATE_STATUS", 0, 0, 0, 0, True);
return;
}
/** Signal handle function
*/
void
static void
signal_handle(int sig)
{
exiting = True;
quit();
exit(EXIT_SUCCESS);
switch (sig)
{
case SIGQUIT:
case SIGTERM:
exiting = True;
break;
case SIGCHLD:
sig_chld = True;
break;
}
return;
}
@@ -421,8 +448,12 @@ main(int argc, char **argv)
{
int i;
char *ol = "csgVS";
extern char *optarg;
extern int optind;
struct sigaction sa;
argv_global = _strdup(argv[0]);
argv_global = xstrdup(argv[0]);
all_argv = argv;
sprintf(conf.confpath, "%s/"DEF_CONF, getenv("HOME"));
while((i = getopt(argc, argv, "hviSc:s:g:C:V:")) != -1)
@@ -455,11 +486,7 @@ main(int argc, char **argv)
break;
case 'v':
printf("WMFS version : "WMFS_VERSION"\n"
" Compilation settings :\n"
" - Flags : "WMFS_COMPILE_FLAGS"\n"
" - Linked Libs : "WMFS_LINKED_LIBS"\n"
" - On "WMFS_COMPILE_MACHINE" by "WMFS_COMPILE_BY".\n");
printf("WMFS "WMFS_VERSION"\n");
exit(EXIT_SUCCESS);
break;
@@ -470,7 +497,7 @@ main(int argc, char **argv)
break;
case 'C':
strcpy(conf.confpath, optarg);
strncpy(conf.confpath, optarg, sizeof(conf.confpath));
break;
case 'c':
@@ -506,8 +533,12 @@ main(int argc, char **argv)
errx(EXIT_FAILURE, "cannot open X server.");
/* Set signal handler */
(void)signal(SIGTERM, &signal_handle);
(void)signal(SIGINT, &signal_handle);
memset(&sa, 0, sizeof(sa));
sa.sa_handler = signal_handle;
sigemptyset(&sa.sa_mask);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGCHLD, &sa, NULL);
/* Check if an other WM is already running; set the error handler */
XSetErrorHandler(errorhandler);

View File

@@ -33,13 +33,12 @@
#ifndef WMFS_H
#define WMFS_H
#define _BSD_SOURCE /* vsnprintf */
#define _POSIX_SOURCE /* kill */
/* Lib headers */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdint.h>
#include <signal.h>
#include <unistd.h>
#include <ctype.h>
@@ -53,14 +52,14 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
#include <X11/Xft/Xft.h>
/* Local headers */
#include "parse/parse.h"
#include "config.h"
#include "parse.h"
#include "structs.h"
/* Optional dependencies */
@@ -87,7 +86,6 @@
#define INFOBARH ((conf.bars.height > 0) ? conf.bars.height : (font->height * 1.5))
#define FHINFOBAR ((font->height - font->descent) + (INFOBARH - font->height) / 2)
#define SHADH (1)
#define SHADC (0x000000) /* 'Cause i don't know how darken a color yet */
#define BORDH conf.client.borderheight
#define TBARH ((conf.titlebar.height < BORDH) ? BORDH : conf.titlebar.height)
#define RESHW (6 * (BORDH))
@@ -109,7 +107,6 @@
#define FRAMEH(h) ((h) + (BORDH + TBARH))
#define ROUND(x) (float)((x > 0) ? x + (float)0.5 : x - (float)0.5)
#define CHECK(x) if(!(x)) return
#define IFREE(x) if(x) free(x)
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
#define MAXCLIST (64)
@@ -122,6 +119,8 @@ BarWindow *barwin_create(Window parent,
Bool stipple,
Bool border);
void barwin_draw_text(BarWindow *bw, int x, int y, char *text);
void barwin_draw_image_ofset_text(BarWindow *bw, int x, int y, char *text, int x_image_ofset, int y_image_ofset);
void barwin_color_set(BarWindow *bw, uint bg, char *fg);
void barwin_delete(BarWindow *bw);
void barwin_delete_subwin(BarWindow *bw);
void barwin_map(BarWindow *bw);
@@ -134,36 +133,30 @@ void barwin_refresh_color(BarWindow *bw);
void barwin_refresh(BarWindow *bw);
/* draw.c */
void draw_text(Drawable d, int x, int y, char* fg, int pad, char *str);
void draw_text(Drawable d, int x, int y, char* fg, char *str);
void draw_image_ofset_text(Drawable d, int x, int y, char* fg, char *str, int x_image_ofset, int y_image_ofset);
void draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color);
void draw_graph(Drawable dr, int x, int y, uint w, uint h, uint color, char *data);
#ifdef HAVE_IMLIB
void draw_image(Drawable dr, int x, int y, int w, int h, char *name);
#endif /* HAVE_IMLIB */
ushort textw(char *text);
/* infobar.c */
void infobar_init(void);
void infobar_draw(int sc);
void infobar_draw_layout(int sc);
void infobar_draw_selbar(int sc);
void infobar_draw_taglist(int sc);
void infobar_update_taglist(int sc);
void infobar_destroy(void);
void infobar_set_position(int pos);
void uicb_infobar_togglepos(uicb_t);
void uicb_infobar_toggledisplay(uicb_t);
void uicb_toggle_tagautohide(uicb_t);
/* client.c */
void client_attach(Client *c);
void client_configure(Client *c);
void client_detach(Client *c);
void client_above(Client *c);
void client_focus(Client *c);
Client* client_get_next(void);
Client* client_get_prev(void);
/* client_gb_*() {{{ */
Client* client_gb_win(Window w);
Client* client_gb_frame(Window w);
@@ -184,34 +177,41 @@ void client_size_hints(Client *c);
void client_swap(Client *c1, Client *c2);
void client_raise(Client *c);
void client_unhide(Client *c);
void client_focus_next(Client *c);
void client_unmanage(Client *c);
void client_unmap(Client *c);
void client_set_wanted_tag(Client *c);
void client_update_attributes(Client *c);
void client_urgent(Client *c, Bool u);
void uicb_client_raise(uicb_t);
void uicb_client_next(uicb_t);
void uicb_client_prev(uicb_t);
void uicb_client_swap_next(uicb_t);
void uicb_client_swap_prev(uicb_t);
void uicb_client_focus_right(uicb_t cmd);
void uicb_client_focus_left(uicb_t cmd);
void uicb_client_focus_top(uicb_t cmd);
void uicb_client_focus_bottom(uicb_t cmd);
void uicb_client_kill(uicb_t);
void uicb_client_screen_next(uicb_t);
void uicb_client_screen_prev(uicb_t);
void uicb_client_screen_set(uicb_t);
void uicb_client_move(uicb_t cmd);
void uicb_client_resize(uicb_t cmd);
void uicb_ignore_next_client_rules(uicb_t cmd);
void uicb_clientlist(uicb_t cmd);
void uicb_client_select(uicb_t cmd);
Bool uicb_checkclist(uicb_t);
void uicb_client_ignore_tag(uicb_t);
void uicb_client_set_master(uicb_t);
/* ewmh.c */
void ewmh_init_hints(void);
void ewmh_send_message(Window d, Window w, char *atom, long d0, long d1, long d2, long d3, long d4);
long ewmh_get_xembed_state(Window win);
void ewmh_get_number_of_desktop(void);
void ewmh_update_current_tag_prop(void);
void ewmh_get_client_list(void);
void ewmh_get_desktop_names(void);
void ewmh_set_desktop_geometry(void);
void ewmh_set_workarea(void);
void ewmh_manage_net_wm_state(long data_l[], Client *c);
void ewmh_manage_window_type(Client *c);
@@ -219,73 +219,60 @@ void ewmh_manage_window_type(Client *c);
void frame_create(Client *c);
void frame_delete(Client *c);
void frame_moveresize(Client *c, XRectangle geo);
void frame_update_color(Client *c, Bool focused);
void frame_update(Client *c);
/* config.c */
void init_conf(void);
/* color.c */
uint color_shade(uint, double);
/* event.c */
void buttonpress(XButtonEvent *ev);
void configureevent(XConfigureRequestEvent *ev);
void clientmessageevent(XClientMessageEvent *ev);
void destroynotify(XDestroyWindowEvent *ev);
void enternotify(XCrossingEvent *ev);
void expose(XExposeEvent *ev);
void focusin(XFocusChangeEvent *ev);
void grabkeys(void);
void keypress(XKeyPressedEvent *ev);
void mappingnotify(XMappingEvent *ev);
void maprequest(XMapRequestEvent *ev);
void propertynotify(XPropertyEvent *ev);
void unmapnotify(XUnmapEvent *ev);
void send_client_event(long data[5], char *atom_name);
void getevent(XEvent ev);
/* menu.c */
void menu_init(Menu *menu, char *name, int nitem, uint bg_f, char *fg_f, uint bg_n, char *fg_n);
void menu_new_item(MenuItem *mi, char *name, void *func, char *cmd);
void menu_draw(Menu menu, int x, int y);
Bool menu_manage_event(XEvent *ev, Menu *menu, BarWindow *winitem[]);
Bool menu_activate_item(Menu *menu, int i);
void menu_focus_item(Menu *menu, int item, BarWindow *winitem[]);
void menu_draw_item_name(Menu *menu, int item, BarWindow *winitem[]);
int menu_get_longer_string(MenuItem *mi, int nitem);
void uicb_menu(uicb_t cmd);
void menu_clear(Menu *menu);
/* launcher.c */
void launcher_execute(Launcher *launcher);
void uicb_launcher(uicb_t);
/* mouse.c */
void mouse_dragborder(XRectangle geo, GC g);
void mouse_move_tile_client(Client **c);
void mouse_move_tag_client(Client *c);
void mouse_move(Client *c);
void mouse_resize(Client *c);
void mouse_grabbuttons(Client *c, Bool focused);
void uicb_mouse_move(uicb_t);
void uicb_mouse_resize(uicb_t);
/* util.c */
ulong color_enlight(ulong col);
void *emalloc(uint element, uint size);
void *xmalloc(size_t, size_t);
void *xcalloc(size_t, size_t);
void *xrealloc(void *, size_t, size_t);
/* simples wrappers for allocating only one object */
#define zmalloc(size) xmalloc(1, (size))
#define zcalloc(size) xcalloc(1, (size))
#define zrealloc(ptr, size) xrealloc((ptr), 1, (size))
char *xstrdup(const char *);
int xasprintf(char **, const char *, ...);
long getcolor(char *color);
void setwinstate(Window win, long state);
char* _strdup(char const *str);
/* Conf usage {{{ */
void* name_to_func(char *name, const func_name_list_t *l);
ulong char_to_modkey(char *name, key_name_list_t key_l[]);
uint char_to_button(char *name, name_to_uint_t blist[]);
Layout layout_name_to_struct(Layout lt[], char *name, int n, const func_name_list_t llist[]);
char* alias_to_str(char *conf_choice);
/* }}} */
XRectangle get_mouse_pos(void);
char *char_to_str(const char c);
int spawn(const char *str, ...);
pid_t spawn(const char *str, ...);
void swap_ptr(void **x, void **y);
void uicb_spawn(uicb_t);
char *clean_value(char *str);
char* patht(char *path);
int qsort_string_compare (const void * a, const void * b);
#ifdef HAVE_IMLIB
int parse_image_block(ImageAttr *im, char *str);
@@ -306,14 +293,15 @@ void uicb_tagtransfert_prev(uicb_t);
void uicb_tag_urgent(uicb_t cmd);
void tag_additional(int sc, int tag, int adtag);
void uicb_tag_toggle_additional(uicb_t);
void tag_swap(int s, int t1, int t2);
void uicb_tag_swap(uicb_t);
void uicb_tag_swap_next(uicb_t);
void uicb_tag_swap_previous(uicb_t);
void tag_new(int s, char *name);
void uicb_tag_new(uicb_t);
void tag_delete(int s, int tag);
void uicb_tag_del(uicb_t);
void uicb_tag_rename(uicb_t cmd);
void uicb_tag_last(uicb_t cmd);
void uicb_tag_stay_last(uicb_t cmd);
void uicb_tag_toggle_expose(uicb_t cmd);
/* screen.c */
int screen_count(void);
@@ -328,27 +316,32 @@ void uicb_screen_prev(uicb_t);
void uicb_screen_prev_sel(uicb_t);
/* status.c */
int statustext_rectangle(StatusRec *r, char *str);
int statustext_graph(StatusGraph *g, char *str);
int statustext_text(StatusText *s, char *str);
void statustext_normal(int sc, char *str);
void statustext_handle(int sc, char *str);
/* systray.c */
Bool systray_acquire(void);
void systray_add(Window win);
void systray_del(Systray *s);
void systray_state(Systray *s);
void systray_freeicons(void);
Systray* systray_find(Window win);
int systray_get_width(void);
void systray_update(void);
/* layout.c */
void arrange(int screen, Bool update_layout);
void freelayout(int screen);
void layoutswitch(Bool b);
void maxlayout(int screen);
Client *tiled_client(int screen, Client *c);
/* tile {{{ */
void grid(int screen);
void tile(int screen);
void tile_left(int screen);
void tile_top(int screen);
void tile_bottom(int screen);
void mirror_vertical(int screen);
void mirror_horizontal(int screen);
void layer(int screen);
void grid_vertical(int screen);
void grid_horizontal(int screen);
/* }}} */
void uicb_togglemax(uicb_t);
void uicb_togglefree(uicb_t);
@@ -359,8 +352,6 @@ void uicb_set_nmaster(uicb_t);
void uicb_set_layout(uicb_t);
void uicb_toggle_resizehint(uicb_t);
void uicb_toggle_abovefc(uicb_t cmd);
void uicb_set_layer(uicb_t cmd);
void uicb_set_client_layer(uicb_t cmd);
void layout_set_client_master(Client *c);
Bool uicb_checkmax(uicb_t);
Bool uicb_checkfree(uicb_t);
@@ -368,20 +359,8 @@ Bool uicb_checklayout(uicb_t);
/* init.c */
void init(void);
void init_root(void);
void init_font(void);
void init_gc(void);
void init_cursor(void);
void init_key(void);
void init_geometry(void);
void init_status(void);
/* getinfo.c */
void getinfo_tag(void);
void getinfo_screen(void);
void getinfo_layout(void);
void getinfo_mwfact(void);
void getinfo_nmaster(void);
void getinfo(char *info);
/* viwmfs.c */
@@ -392,12 +371,8 @@ int errorhandler(Display *d, XErrorEvent *event);
int errorhandlerdummy(Display *d, XErrorEvent *event);
void quit(void);
void *thread_process(void *arg);
void mainloop(void);
void scan(void);
Bool check_wmfs_running(void);
void exec_uicb_function(char *func, char *cmd);
void set_statustext(int s, char *str);
void update_status(void);
void handle_signal(int signum);
void uicb_quit(uicb_t);
void uicb_reload(uicb_t);
@@ -411,11 +386,12 @@ int selscreen;
int prevselscreen;
Conf conf;
Key *keys;
Bool exiting, estatus;
Bool estatus;
XRectangle *sgeo;
XRectangle *spgeo;
Cursor cursor[CurLast];
char *argv_global;
char **all_argv;
int xrandr_event;
uint timing;
@@ -424,6 +400,7 @@ XftFont *font;
/* Atoms list */
Atom *net_atom;
Atom trayatom;
/* InfoBar/Tags */
InfoBar *infobar;
@@ -444,9 +421,12 @@ Client *clients;
Client *sel;
/* Other */
func_name_list_t *func_list;
extern const func_name_list_t func_list[];
extern const func_name_list_t layout_list[];
uint numlockmask;
Systray *trayicons;
Window traywin;
int tray_width;
#endif /* WMFS_H */

8
wmfs.1
View File

@@ -62,7 +62,7 @@ Print help information, then exit\&.
.PP
\fB\-i\fR
.RS 4
Print WMFS informations
Print WMFS information
.RE
.SH "DEFAULT KEY BINDINGS"
.PP
@@ -143,7 +143,7 @@ Increase the nmaster (+1)\fR
.PP
\fBAlt\-Shift + d\fR
.RS 4
Decrease the nmaster (-1)\fR
Decrease the nmaster (\-1)\fR
.RE
.PP
\fBAlt + t\fR
@@ -163,7 +163,7 @@ Make a launcher in the infobar to run an unix command\fR
.PP
\fBAlt + Escape\fR
.RS 4
Set WMFS in ViWMFS mode. (see wmfs -V)\fR
Set WMFS in ViWMFS mode. (see wmfs \-V)\fR
.RE
.PP
\fBAlt\-Shift + p\fR
@@ -193,7 +193,7 @@ Martin Duquesnoy <\fIxorg62@gmail\&.com\fR\&[1]>\&.
Main site: \fIhttp://wmfs\&.info\fR Bug tracker: \fIhttp://bugs\&.wmfs\&.info\fR
.sp
.SH "COPYING"
WMFS is under the BSD license\&. See COPYING for more informations\&.
WMFS is under the BSD license\&. See COPYING for more information\&.
.sp
.SH "NOTES"
.IP " 1." 4

View File

@@ -1,6 +1,5 @@
[Desktop Entry]
[Desktop Entry]
Encoding=UTF-8
Name=wmfs
Comment=Window manager from scratch
TryExec=wmfs
Exec=wmfs
Comment=Window Manager From Scratch
Exec=ck-launch-session wmfs

View File

@@ -73,7 +73,7 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = @SOURCE_DIR@/src
INPUT = src
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.h \

View File

@@ -3,30 +3,52 @@
# ~/.config/wmfs/wmfsrc and edit it.
#
# Include file to split configuration
# @include "~/.config/wmfs/menu-wmfsrc"
[misc]
font = "dejavu-10"
raisefocus = false
focus_follow_mouse = true
font = "dejavu-10"
raisefocus = true
raiseswitch = false
focus_follow_mouse = true
focus_follow_movement = false
opacity = 255
# focus_pointer_click: click on unfocused client area:
# true -- default, set focus
# false -- click go to client; including dockapps
focus_pointer_click = true
status_timing = 1 #seconds
# status_path = "~/.config/wmfs/status.sh"
[/misc]
[bar]
bg = "#191919"
fg = "#D4D4D4"
border = true
# selbar = false #not worked now, see section [selbar]
#height = "-1"
light_shade = 0.10
dark_shade = -0.10
[systray]
# Enable/disable systray
active = true
# Screen of systray
screen = 0
# Spacing between tray icons
spacing = 3
[/systray]
# Remove this section to disable the selbar.
[selbar]
bg = "#191919"
fg = "#D4D4ff"
# Cut title lenght
# max_lenght = 25
# Cut title length
# max_length = 25
[mouse] button = "3" func = "clientlist" [/mouse]
[mouse] button = "4" func = "client_next" [/mouse]
@@ -48,14 +70,24 @@
# Value left or right.
placement = "right"
# Keep layout geo for free layout
keep_layout_geo = false
# Symbol displayed for the selected layout in the list
selected_layout_symbol = "*"
# Width of layout button
# layout_button_width = x
# Tiling layouts.
[layout] type = "tile_right" symbol = "RIGHT" [/layout]
[layout] type = "tile_left" symbol = "LEFT" [/layout]
[layout] type = "tile_top" symbol = "TOP" [/layout]
[layout] type = "tile_bottom" symbol = "BOTTOM" [/layout]
[layout] type = "tile_grid" symbol = "GRID" [/layout]
[layout] type = "mirror_vertical" symbol = "MIRROR_V" [/layout]
[layout] type = "mirror_horizontal" symbol = "MIRROR_H" [/layout]
[layout] type = "tile_right" symbol = "RIGHT" [/layout]
[layout] type = "tile_left" symbol = "LEFT" [/layout]
[layout] type = "tile_top" symbol = "TOP" [/layout]
[layout] type = "tile_bottom" symbol = "BOTTOM" [/layout]
[layout] type = "tile_grid" symbol = "GRID_H" [/layout]
[layout] type = "tile_grid_vertical" symbol = "GRID_V" [/layout]
[layout] type = "mirror_vertical" symbol = "MIRROR_V" [/layout]
[layout] type = "mirror_horizontal" symbol = "MIRROR_H" [/layout]
# Other layouts.
[layout] type = "max" symbol = "MAX" [/layout]
@@ -64,18 +96,42 @@
[/layouts]
[tags]
tag_round = false
occupied_bg = "#003366"
sel_fg = "#191919"
sel_bg = "#7E89A2"
urgent_bg = "#DD1111"
urgent_fg = "#000000"
[default_tag]
name = "new tag"
mwfact = 0.5
nmaster = 1
layout = "tile_right"
resizehint = false
infobar_position = "top"
[/default_tag]
# whether client_next on the last tag will send you on the first
# and client_prev on the first tag will send you on the last one
tag_round = false
# Going twice on the same tag will bring you back on the previous one
tag_auto_prev = true
occupied_bg = "#003366"
occupied_fg = "#D4D4D4"
sel_fg = "#191919"
sel_bg = "#7E89A2"
urgent_bg = "#DD1111"
urgent_fg = "#000000"
# If true, number of the tag will be used for name
name_count = false
#default_name = "new tag" # deprecated, use [default_tag] instead
#default_layout = "tile_right" # deprecated, use [default_tag] instead
expose_name = "EXPOSE"
expose_layout = "tile_left"
# Border around the tag buttons.
border = true
# Hide empty tags in tag list
autohide = false
autohide = true
# Mouse buttons action on tag.
mouse_button_tag_sel = "1"
@@ -92,10 +148,11 @@
layout = "tile_right"
resizehint = false
infobar_position = "top"
above_fc = false
#[mouse] [/mouse] Possible multi mouse section
[/tag]
# clients option is *DEPRECATED* but works, see [rules] section
[tag] name = "two" clients = {"Browser"} [/tag]
[tag] name = "three" [/tag]
[tag] name = "four" [/tag]
@@ -117,15 +174,37 @@
[client]
client_round = true
client_auto_center = false
border_height = 3
border_shadow = true
border_normal = "#191919"
border_focus = "#003366"
place_at_mouse = false
resize_corner_normal = "#191919"
resize_corner_focus = "#003366"
set_new_win_master = true
client_tile_raise = false
new_client_get_mouse = false
# send all client that have no tag rule in this default tag
#default_open_tag = 4
# same as above but for the screen
#default_open_screen = 1
# Space between tiled clients
padding = 0
# Modifier for mouse use
modifier = "Alt"
light_shade = 0.10
dark_shade = -0.10
# *DEPRECATED* but works, see [rules] section
# Set automatic free or max client
# autofree = "xterm|MPlayer"
# automax = "Navigator"
[mouse] button = "1" func = "client_raise" [/mouse]
[mouse] button = "1" func = "mouse_move" [/mouse]
[mouse] button = "3" func = "client_raise" [/mouse]
@@ -144,7 +223,7 @@
[mouse] button = "3" func = "mouse_resize" [/mouse]
[button]
# Available "free", "max", "tile" flags of button.
# Available "free", "max", "tile" flags or button.
flags = "free,max,tile"
[mouse] button = "1" func = "client_kill" [/mouse]
[mouse] button = "3" func = "menu" cmd = "clientmenu" [/mouse]
@@ -156,6 +235,21 @@
[/titlebar]
[/client]
[rules]
# Example of rule for MPlayer
[rule]
instance = "xv" # First part of WM_CLASS
class = "MPlayer" # Seconf part of WM_CLASS, not needed if first part is correct
# role = "" # WM_WINDOW_ROLE
screen = 0 # Screen to use
tag = 2 # Tag number of apps
free = true # Set automatic free client
max = false # Set automatic maximized client
follow_client = false # follow the client
ignore_tags = false # ignore tag (free mode)
[/rule]
[/rules]
[menu]
# Default menu, binded on the root window, button 3.
[set_menu]
@@ -170,7 +264,7 @@
fg_focus = "#191919" bg_focus = "#7E89A2"
fg_normal = "#9F9AB3" bg_normal = "#191919"
[item] name = "Terminal" func = "spawn" cmd = "@WMFS_TERM@" [/item]
[item] name = "Terminal" func = "spawn" cmd = "urxvt || xterm || gnome-terminal" [/item]
[item] name = "Applications" submenu = "appmenu" [/item]
[item] name = "Next tag" func = "tag_next" [/item]
[item] name = "Previous tag" func = "tag_prev" [/item]
@@ -206,6 +300,9 @@
[launcher]
[set_launcher]
# Limit size of the launcher window (px)
width_limit = 300
name = "launcher_exec"
prompt = "Exec: "
command = "exec"
@@ -224,7 +321,7 @@
[key] mod = {"Alt", "Control"} key = "r" func = "reload" [/key]
# Open a terminal.
[key] mod = {"Control"} key = "Return" func = "spawn" cmd = "@WMFS_TERM@" [/key]
[key] mod = {"Control"} key = "Return" func = "spawn" cmd = "xterm" [/key]
# Kill the selected client.
[key] mod = {"Alt"} key = "q" func = "client_kill" [/key]
@@ -237,6 +334,9 @@
# Swap current client with the previous.
[key] mod = {"Alt", "Shift"} key = "t" func = "client_swap_prev" [/key]
# Set the selected client as Master
[key] mod = {"Control"} key = "m" func = "client_set_master" [/key]
# Toggle maximum the selected client
[key] mod = {"Alt"} key = "m" func = "toggle_max" [/key]
@@ -246,6 +346,7 @@
# Toggle the position of the infobar.
[key] mod = {"Alt"} key = "b" func = "toggle_infobar_position" [/key]
[key] mod = {"Alt", "Shift"} key = "b" func = "toggle_infobar_display" [/key]
# Toggle the resizehint of the current tag/screen
[key] mod = {"Shift", "Control"} key = "r" func = "toggle_resizehint" [/key]
@@ -328,6 +429,27 @@
[key] mod = {"Alt", "Super"} key = "F8" func = "tag_toggle_additional" cmd ="8" [/key]
[key] mod = {"Alt", "Super"} key = "F9" func = "tag_toggle_additional" cmd ="9" [/key]
# change screen
[key] mod = {"Super"} key = "Tab" func = "screen_next" [/key]
[key] mod = {"Super", "Shift"} key = "Tab" func = "screen_prev" [/key]
# swap client in the next/prev screen
[key] mod = {"Super", "Shift"} key = "a" func = "client_screen_next" [/key]
[key] mod = {"Super", "Shift"} key = "z" func = "client_screen_prev" [/key]
[key] mod = {"Alt"} key = "e" func = "toggle_tag_expose" [/key]
# unlisted fonctions that can be used in [key] func = ""
# client_focus_{right, left, top, bottom}
# client_ignore_tag # Toggle the client in ignore_tag (display the client on all tags)
# tag_prev_sel # go back to the previous selected tag
# tag_transfert_{next, prev}
# tag_urgent # go to the urgent tag
# tag_swap_{next, prev} # swap tag with the previous/next one
# tag_last # go to the last tag
# tag_stay_last # toggle the current tag as the last one
# toggle_abovefc
# screen_prev_sel # go to the previous screen selected
# set_layout # set layout. need to be called with cmd = "<layout_name>"
# ignore_next_client_rules # ignore the rule the next time a rule is called
[/keys]