1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 04:48:06 +01:00
Commit Graph

1882 Commits

Author SHA1 Message Date
Martin Dietze
19f110d26e Add two menu files from the Debian package 2009-08-24 11:55:20 +02:00
Martin Dietze
3f6ae395ce Add GLOBAL_DEFAULTS_SUBDIR and fix a syntax error in wmlib/Makefile.am 2009-08-24 11:55:20 +02:00
Martin Dietze
ba027149bd Up the version number for the GIT version to 0.93.0-pre wmaker-0.93.0-crm 2009-08-24 11:55:20 +02:00
Tamas TEVESZ
f893728d2d Fix format strings 2009-08-23 21:10:02 +02:00
Alexey Voinov
01dddf00c8 swpanel: Consider also the release of FOCUSPREV
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]
2009-08-23 20:03:21 +02:00
Carlos R. Mafra
fe736e849c Remove LITE config option
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.
2009-08-23 18:45:30 +02:00
Carlos R. Mafra
874b0fadf5 Add spaces to gcc 'case' range extension
According to the gcc manual, that is safer.
2009-08-23 17:28:04 +02:00
Carlos R. Mafra
31f16389f6 Fix function prototype declaration
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
2009-08-23 15:15:29 +02:00
Pedro Martelletto
2706f7217c WPrefs: Fix crash due to wtokenfree() memory leak fix
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]
2009-08-22 20:51:47 +02:00
Tobias Stoeckmann
e522ca734d WINGs: Fix memory leak in wtokenfree()
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. ]
2009-08-22 20:40:27 +02:00
Nicolas Bonifas
3a0eb643d9 swpanel: Start with the first window when all are minimized
When all windows are minimized, the switch panel cursor is
initially on the second window in the list. With this patch
it will be on the first window.
2009-08-22 13:03:56 +02:00
Carlos R. Mafra
f79379c090 swpanel: Fix stacking issue with swpanel escape handling
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().
2009-08-22 03:08:05 +02:00
Carlos R. Mafra
001bc28037 swpanel: Factor out if (swpanel) test
We can remove redundand tests in each "case:" inside the
switch if we do it in the beginning.
2009-08-22 03:08:05 +02:00
Carlos R. Mafra
203eba8937 swpanel: Clean up "case ButtonRelease"
Get rid of 2 tabs indentation by removing a
not-strictly-necessary temporary variable.
2009-08-22 03:08:05 +02:00
Carlos R. Mafra
d27e43e6b5 swpanel: Clean up StartWindozeCycle() a bit more
We can put the test for 'newFocused' inside change_focus_and_raise()
to clean up the code a little bit.
2009-08-22 03:07:34 +02:00
Tobias Stoeckmann
1db15a3543 Fix multiple errors in findfile.c
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>
2009-08-21 12:13:12 +02:00
Daniel Déchelotte
c970c94f82 Remove useless tests
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]
2009-08-21 04:57:08 +02:00
Carlos R. Mafra
570df8316d Fix use of uninitialized variable
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.
2009-08-21 02:20:27 +02:00
Vladimir Nadvornik
21b5df494b Less strict font requirements
Fixes bug:

  https://bugzilla.novell.com/show_bug.cgi?id=154758
2009-08-21 02:10:50 +02:00
Vladimir Nadvornik
e113ec10c9 Fix findBestIcon()
This patch fixes the issue described here:

https://bugzilla.novell.com/show_bug.cgi?id=371974
2009-08-21 01:54:26 +02:00
Daniel Déchelotte
95a576bd62 Fix "smart" placement bug when there are shaded windows in other workspaces
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.
2009-08-20 23:59:41 +02:00
Daniel Déchelotte
3f7110b120 Fix focus issues with the switch panel and auto-focus
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.
2009-08-20 22:07:10 +02:00
Carlos R. Mafra
f9bb2a428a Escape key handling in switchpanel
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.
2009-08-20 16:00:26 +02:00
Carlos R. Mafra
333dbf5418 Use helper function in StartWindozeCycle()
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.
2009-08-20 15:46:45 +02:00
Carlos R. Mafra
a9238c99b9 Clean up coding style in StartWindozeCycle()
No functional changes were made apart from
setting the various KeyCode variables at the
same time as defining them.
2009-08-20 15:09:07 +02:00
Carlos R. Mafra
4a041b6f0a Clean up StartWindozeCycle()
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.
2009-08-20 04:07:15 +02:00
Carlos R. Mafra
688a56e8ab Change to the linux kernel coding style
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 :-)
2009-08-20 00:59:40 +02:00
Carlos R. Mafra
59fc927dc9 Make drawIconProc() static
It is used only inside src/dialog.c
2009-08-20 00:57:03 +02:00
Carlos R. Mafra
066af13b5c Clean up case switching in handleKeyPress()
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
2009-08-19 22:11:15 +02:00
Carlos R. Mafra
e2d8cbe238 Remove unsigned type from 'mask'
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.
2009-08-18 16:28:43 +02:00
Carlos R. Mafra
cb31fd374c Sanitize calling sites of wDefaultsCheckDomains()
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");
2009-08-18 16:20:18 +02:00
Carlos R. Mafra
f4fd88b8a9 Make loop variable be unsigned int
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.
2009-08-18 16:19:48 +02:00
Carlos R. Mafra
f36ab39680 Fix variable shadowing
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'.
2009-08-18 16:17:28 +02:00
Carlos R. Mafra
0a32ecf1fe WMCreateFont: Add missing wfree()'s
I removed (forgot) them when in commit ee28b0257a ("Avoid returning
font=NULL in WMCreateFont()"). Add them back.
2009-08-18 04:33:39 +02:00
Carlos R. Mafra
9baff1363c handleKeyPress: Fix shadowing of global 'index' variable
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.
2009-08-18 00:56:09 +02:00
Carlos R. Mafra
f18567db9a inotifyHandleEvents: Reduce buffer size to avoid huge memory consumption
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.
2009-08-18 00:39:45 +02:00
Carlos R. Mafra
be0d694dc2 real_main: Use setenv() instead of putenv() in remaining places
It simplifies the code a bit.
2009-08-17 22:42:38 +02:00
Carlos R. Mafra
6310e40d47 real_main: Use setenv() instead of putenv()
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.
2009-08-17 22:19:58 +02:00
Carlos R. Mafra
7a84127a27 Fix improper use of function sentinel
This patch addresses this warning of gcc:

wfontpanel.c: In function 'listFamilies':
wfontpanel.c:588: warning: missing sentinel in function call

Fix it by using the 'NULL' pointer instead of 0 (zero) as the
sentinel.

For more information, see
http://www.linuxonly.nl/docs/2/2_GCC_4_warnings_about_sentinels.html
in particular,

   "On most systems, there is no difference between 0 and (char *)0.
    On 64 bit systems, however, the integer 0 is 32 bits and the
    pointer 0 is 64 bits. The compiler does not know whether it is
    an integer or a pointer, and defaults for the integer. This will
    not clear the upper 32 bits and the function will not stop
    scanning its parameters."

Note that here in my 64-bit Mandriva I don't need to cast (char *)NULL.
2009-08-17 18:13:58 +02:00
Carlos R. Mafra
288853e44f WPrefs: Remove unused function updateThemeList() 2009-08-17 17:44:00 +02:00
Carlos R. Mafra
09a8911b6f Remove unused variables
GCC -Wall complains about them.
2009-08-17 17:35:48 +02:00
Carlos R. Mafra
ceeca912cd Make compilation even less verbose
Add "-s" flag to MAKEFLAGS if --disable-verbose-compile
is enabled.
2009-08-17 16:49:22 +02:00
Carlos R. Mafra
7a3b139dcb Remove prototype of unused function StartLogShell 2009-08-16 11:14:40 +02:00
Tamas TEVESZ
e2b6a85e80 Fix buffer overflow in SendHelperMessage()
The following fixes a buffer overflow in SendHelperMessage() which i
started seeing recently on x64.
2009-08-16 01:05:23 +02:00
John H. Robinson, IV
38074e7bd5 Remove unused StartLogShell function.
Based upon a patch by Tobias Stoeckmann

Small code size reduction,

   text    data     bss     dec     hex filename
 620412   19144    8544  648100   9e3a4 src/.libs/wmaker
 621347   19152    8544  649043   9e753 src/.libs/wmaker.old
2009-08-16 00:35:54 +02:00
Tobias Stoeckmann
f516213bf3 Check for argc==0 when calling wtokensplit()
The WINGs-function wtokensplit does not set argv to NULL if no string has been
split - instead argc is set to 0.

You can only observe this issue if you compile Window Maker without any
optimization:

compile Window Maker with CFLAGS=""
run Window Maker and save a session
change session-file and replace a 'command xyz' line with 'command " "'
restart Window Maker
watch "Fatal error"-message

Retrieved-from: http://paldium.homeunix.org/tobias/wmaker/
Submitted-by: Gilbert Ashley <amigo@ibiblio.org>
2009-08-16 00:16:58 +02:00
Iain Patterson
bbc52564d0 xinerama switchpanel corruption fix
This is a small patch to fix an issue with the switchpanel and a large number
of windows which happens only on a Xinerama setup.

When the number of open windows is so large that displaying all of them would
cause the switchpanel to be too wide for the screen, the panel is supposed to
shrink and scroll to accomodate them all.

In Window Maker 0.92.0 this works for single head displays but not for
Xinerama. The panel extends to the next head and gets garbled. This patch fixes
the issue by correctly constraining the panel to the head with the cursor.

Submitted-by: Gilbert Ashley <amigo@ibiblio.org>
2009-08-16 00:06:31 +02:00
David Benbennick
3e9aae7a91 Fix mixing pixels when maximizing borderless windows
A minor bug has been bothering me for a long time. When you maximize a
borderless window in Window Maker, the window ends up too narrow and too short
by two pixels.

Submitted-by: Gilbert Ashley  <amigo@ibiblio.org>
2009-08-15 23:59:45 +02:00
Samir SAADA
9fa4fbef91 Fix workspace limit segfault
wmaker keeps the names of all workspaces together in
the string 'buf' with fixed length of 1024, therefore
allowing buffer overflows if the number of workspaces
is big enough.

For the default names "Workspace X" (from 1 to 9)
and "Workspace XX" (from 10 to 99) etc, the approximate
number of workspaces necessary to make the buffer
overflow occur is 80, because

(11*9) + (71*12) + 80 = 1031

The fix is to set the size of 'buf' as
the maximum number of workspaces times their maximum
name length.

The problem was reported by John H. Robinson in the wmaker-dev
list ( http://lists.windowmaker.info/dev/msg00214.html ):

 "http://www.youtube.com/watch?v=fkNJZvKwmhE

  Michael reported a problem with Window Maker where it crashes with a
  SIGSGV when trying to create an 82nd workspace.

  /usr/local/WindowMaker-0.92.1pre/bin/wmaker warning: Window Maker exited
  due to a crash (signal 11) and will be restarted.

  I was able to reproduce it by making 81 workspaces, then creating an 82nd."

[ crmafra: Wrote the changelog ]
2009-08-09 02:34:21 +02:00
Tamas TEVESZ
f21ce5768b avoid integer overflow
Actually, the whole thing is so chock full of signed vs unsigned
mixups and the assumption of all the world is 32-bit that i'm not sure
anymore that correcting them one by one is a good idea.

what would probably work best is that if someone deeply familiar with
the code (*looks in dan's general direction*) cleaned the data types
up, then legions of grunts like myself could start cleaning the rest
with relative confidence...
2009-08-09 01:53:12 +02:00