This adds Left Half / Right Half Maximize capability to WindowMaker.
It allows you to maximize a window to only the left or right half
of your screen.
It is useful on widescreen displays where one might to bring up
two different windows side-by-side.
This patch cleans up an obvious code duplication case in the
different "placement" algorithms.
Avoid this needless repetition by using a helper function,
which in turn lets those functions a bit easier to read and
also makes wmaker 0.11% smaller :-)
[mafra@Pilar:wmaker.git]$ size src/.libs/wmaker.*
text data bss dec hex filename
619824 19160 8544 647528 9e168 src/.libs/wmaker.new
620552 19160 8544 648256 9e440 src/.libs/wmaker.old
The "Kill Application" dialog window doesn't always show the
application name when killing DockApps. It shows its wm_class
instead, which is not always the same as the app name.
This patch allows the Kill Application dialog window to show
the application name in the window -- as expressed by using the
basename of the path to the application.
[crmafra: Added wtokensplit() to get only the app name]
These are some of the fixes sent to the wmaker-dev list by
Vladimir Nadvornik, with minor modifications to address Dan
Pascu's concerns.
Original-post: http://lists.windowmaker.info/dev/msg00293.html
In commit d6c134f420 ("Do not switch
workspace to follow new windows in others") the default behavior
was changed, and workspace switching to follow focus requests was
strictly forbidden.
Although that seems to be a sane thing to do by default, that raises
concerns about whether Window Maker could be more flexible in that
respect -- allowing the user to choose which applications are or
are not allowed to do that.
This patch adds such configuration, located in the "Advanced Options"
submenu of the top-level "Attributes" menu.
New windows should only be focused if they are in the current workspace.
Not performing this check can lead to WM switching workspaces if a
window is opened which:
(a) is configured to appear in a particular workspace
and
(b) sends a _NET_ACTIVE_WINDOW message to give focus to
something, e.g. a sub window.
This behaviour was observed with firefox if a session with more
than one tab open was restored at startup because:
"If a Client wants to activate another window, it MUST send a
_NET_ACTIVE_WINDOW client message to the root window:"
Original-post: http://lists.windowmaker.info/dev/msg00442.html
[crmafra: Added comment]
The switch panel was not being destroyed with the realease of
FOCUSPREV, only with FOCUSNEXT. Fix this.
One can reproduce this bug as follows.
In the "Keyboard Shortcut Preferences" of WPrefs set "Focus next window"
to e.g. "Alt+Tab" and "Focus previous window" to "Ctrl+Tab".
The switchpanel is not destroyed if we release "Ctrl+Tab" but it
is upon releasing of "Alt+Tab".
Retrieved-from: http://git.altlinux.org/people/voins/packages/?p=WindowMaker.git;a=commit;h=51c95a55c9310f499b1fdeca138106ca7bf74423
[crmafra: Commit log]
Why?
1. The reason for its existence is to "Disable some stuff that are
duplicated in kde", and I don't think I will ever need that.
Furthermore, even the description in the configure script reads
"disable some stuff (dont use it)".
2. It makes the code uglier at some places, e.g.,
#ifdef LITE
{
#if 0
}
#endif
#else
if (!wRootMenuPerformShortcut(event)) {
#endif
which by the way is the ugliness which motivated this patch.
3. Does not even compile anymore. It fails with
CC dockedapp.o
CC event.o
event.c: In function 'executeButtonAction:
event.c:711: error: WScreen has no member named root_menu
event.c:712: error: WScreen has no member named root_menu
event.c:713: error: WScreen has no member named root_menu
event.c:715: error: WScreen has no member named root_menu
event.c:720: error: WScreen has no member named switch_menu
event.c:721: error: WScreen has no member named switch_menu
event.c:722: error: WScreen has no member named switch_menu
event.c:724: error: WScreen has no member named switch_menu
make[2]: *** [event.o] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1
But instead of fixing this (it would be trivial), let's get
rid of the whole ugliness altogether.
It is safer if the functions are declared with proper
prototype specifications.
This patch addresses some of the warnings with -Wstrict-prototype,
like this:
event.c:105: warning: function declaration isn't a prototype
After the fix to avoid a memory leak in wtokenfree(), WPrefs crashes
when opening the 'Applications Menu Definition' dialogue.
The problem is that WPrefs code relied on the fact that the first token
in the array would not be free'd by wtokenfree(), a misbehaviour which
is correctly addressed with this patch.
Retrieved-from: http://www.mail-archive.com/ports@openbsd.org/msg12731.html
[crmafra: small changes in the commit log from the webpage]
wtokenfree() does not free the first entry of an array.
If count is 1 then
while (--count)
will be
while (0)
and the inner body of that while-loop will not be entered.
Therefore a memory leak happens every time wtokenfree() is called.
Retrieved-from: http://paldium.homeunix.org/tobias/wmaker/patches/
[crmafra: This patch, altough correct, breaks WPrefs.app, which will be
fixed by the next patch. ]
Daniel Déchelotte reported one problem with the escape handling in
the switchpanel:
"Start with two windows: a fullscreen one, and a smaller window
that appears above the fullscreen one. With the mouse, focus the
bigger window. Start alt-tabbing, then press Escape. The bigger
window will then be focused (good) *and raised* (small problem)."
Fix this by adding a test for the escape key before calling
raiseWindow().
Problems:
1.
During expansion of path, the resulting path can overflow the supplied
area of PATH_MAX+2 (buffer as well as buffer2). A tampered environment
variable can be used to modify program flow.
Proof:
[note: wmaker has been compiled with propolice]
$ export A="[tested with 4096x A]"
$ GNUSTEP_USER_ROOT="\$A\$A/\$A/\$A/" wmaker --for-real
*** stack smashing detected ***: wmaker terminated
Aborted
2.
Way too many functions handle a return value of NULL for wexpandpath
improperly, resulting in segfaults (and maybe other problems). To
prove the existance of these issues:
Proof:
$ GNUSTEP_USER_ROOT=~nouser wmaker --for-real
wmaker error: could not get password entry for user nouser: Success
Segmentation fault
Solution:
hard exit with error message about what is going on.
3.
The improper parsing of environment variables can lead to expansion
of path names that were not intended to be expanded.
(a) If a string like "$(var" is found, Window Maker tries to expand "var"
(environment variable) although the syntax is wrong.
Proof:
$ export PROOF=foo
$ GNUSTEP_USER_ROOT=/\$\(PROOF wmaker --for-real
wmaker warning: could not find user GNUstep directory (/foo/Defaults/WindowMaker).
(b) If the variable out of a) cannot be resolved, a closing bracket will be
added.
Proof:
$ unset PROOF
$ GNUSTEP_USER_ROOT=/\$\(PROOF wmaker --for-real
./wmaker warning: could not find user GNUstep directory ($(PROOF)/Defaults/WindowMaker).
Author: Tobias Stoeckmann
Retrieved-from: http://paldium.homeunix.org/tobias/wmaker/
Submitted-by: Gilbert Ashley <amigo@ibiblio.org>
There is no point in checking
if (dock_state)
if the function would have already returned with
the check if(!dock_state) right above.
Retrived from http://yo.dan.free.fr/wmaker.phtml.en
[crmafra: wrote the commit message]
Gcc-4.3.2 warns:
texture.c: In function 'wTextureMakeFunction':
texture.c:393: warning: 'fallbackColor.pixel' is used uninitialized in this function
Based on a patch by Vladimir Nadvornik.
Bug overview:
New windows are sometimes mis-placed when the "smart" algorithm is used.
How to reproduce it:
be sure (with WPrefs.app, for instance) to use the so-called "smart"
window placement algorithm. In an empty workspace, open a first window
(for instance, an xterm). The window should appear at the upper left corner.
Shade it (hide its contents below its title bar by double-clicking on it)
and select another empty workspace. Open another window. Instead of placing
it at the exact same place as the first window, wmaker places the new
window a little bit lower, or frankly to the right.
Explanation and correction:
when placing a new window, wmaker avoided all shaded windows, instead of
only avoiding the shaded windows on the active workspace.
1. Setup two windows in a workspace, one at the center and the
other at a corner. Move the mouse to the center of the screen, so
that the focus goes to the center window. Now, with the help of the
keyboard (with Alt-tab, typically), try and switch the focus to the
other window. In doing so, the switch panel shows up, gives the
focus to the other window and then disappears. However, its
disappearance make it seem to wmaker that the mouse has just
entered the center window, so wmaker gives the focus to that
window again.
2. It is a lit bit more involved. "Raise window when switching
focus with keyboard" needs to be set. In a given workspace, maximize
a first window A, then setup "above" window A two windows B and C
(one in the upper left corner and the other one in the lower right
corner, for example). Move the mouse so as to give the focus to
window B. Press the Alt key, hit the key tab once (window A moves
up to the "top"), then another time (window C is then selected).
Eventually relase the Alt key: window B is given the focus again.
Correction: it is a matter of ignoring some (EnterNotify) events
when the switch panel is active or has just been used.
Pressing the escape key (ESC) while the switchpanel is active
cancels it and gives the focus back to the window which had it
before the switchpanel was invoked.
If all windows are minimized before the switchpanel was called,
they will continue to be if ESC is pressed.
In other words, pressing ESC is like going to the parallel universe
where you never entered the switchpanel in the first place.
Based on a patch by Nicolas Bonifas from 17.08.2009.
This way we avoid code duplication in 6 places.
This changes the previous behavior of the first
instance because the helper function has an extra
CommitStacking(scr);
compared to the original code. But it should not
hurt to have it.
We can get rid of one overall tab by moving the
if(swpanel)
test -- which was done everytime in each individual case --
to the beginning, therefore encompassing all cases.
for arq in `git ls-files *.c`; do
echo $arq;
indent -linux -l115 $arq;
done
The different line break at 115 columns is because
I use a widescreen monitor :-)
GCC has an extension to deal with ranges within case statements.
Let's use it to make the code more readable and ~5% smaller,
[mafra@Pilar:wmaker.git]$ size src/event.o.*
text data bss dec hex filename
13087 0 1056 14143 373f src/event.o.new
13711 0 1056 14767 39af src/event.o.old
gcc-4.3.2 warns:
defaults.c: In function 'getModMask':
defaults.c:2586: warning: comparison of unsigned expression < 0 is always false
The line in question is
if (mask < 0)
and 'mask' is the return of wXModifierFromKey() which is an 'int' and can
indeed return a negative value (see src/xmodifier.c), so let 'mask' be
an 'int' too.
There is no point in having parameter in wDefaultsCheckDomains() and
not using it, so let's simply remove the parameter altogether and
avoid silly-looking things like
wDefaultsCheckDomains("bla");
gcc was complaining in a few places things like:
defaults.c:890: warning: comparison between signed and unsigned
so let's just make the loop counting variables be unsigned, as
the never get negative anyway.
I also spotted other two variables which can be unsigned too.
gcc-4.3.2 warns:
defaults.c:3136: warning: declaration of 'index' shadows a global declaration
/usr/include/string.h:309: warning: shadowed declaration is here
and in a few other places too. Fix this by renaming 'index' to 'widx'.
GCC warns:
event.c: In function 'handleDestroyNotify':
event.c:676: warning: declaration of 'index' shadows a global declaration
/usr/include/string.h:309: warning: shadowed declaration is here
event.c: In function 'handleKeyPress':
event.c:1435: warning: declaration of 'index' shadows a global declaration
/usr/include/string.h:309: warning: shadowed declaration is here
So let's rename "index" to "widx".
Note that there is a more serious shadowing in this same function,
event.c:1686: warning: declaration of 'wwin' shadows a previous local
but this is more complicated to solve.
inotifyHandleEvents() was allocating a buffer of size
(sizeof(struct inotify_event) + FILENAME_MAX)*1024
where FILENAME_MAX is #defined to be 4096 in stdio_lim.h, therefore
it was more than 4 MB!
Reduce it by using 16 instead of FILENAME_MAX and 512 instead of 1024.
Now valgrind does not complain about things like
Invalid write of size 8
at 0x42002F: inotifyHandleEvents (event.c:323)
by 0x7FF00020F: ???
Address 0x7febfc148 is on thread 1's stack
I also made some small coding style changes.
When investigating possible memory leaks with 'valgrind' I noticed
this leak report:
602 bytes in 13 blocks are definitely lost in loss record 77 of 128
at 0x4C2362E: malloc (vg_replace_malloc.c:207)
by 0x4576ED: wmalloc (memory.c:88)
by 0x45B4F7: wstrconcat (string.c:214)
by 0x426FC2: main (main.c:608)
which happens here,
str = wstrconcat("WMAKER_BIN_NAME=", argv[0]);
putenv(str);
There is a comment further below (in another context)
/* return of wstrconcat should not be free-ed! read putenv man page */
so this leak report is probably a false positive anyway. However,
https://www.securecoding.cert.org/confluence/display/seccode/POS34-C.+Do+not+call+putenv%28%29+with+a+pointer+to+an+automatic+variable+as+the+argument
has some nice discussion about putenv() and after reading it I decided to
use setenv() instead, making 'valgrind' happy along the way. It also
makes the code a bit simpler, avoiding a call to wstrconcat().
I also changed the name of another variable called 'str' to 'pos', just
in case.