1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-24 15:12:32 +01:00
Commit Graph

119 Commits

Author SHA1 Message Date
Rodolfo García Peñas (kix)
ca86f5594d New function update_icon_title
The function update_icon_title() updates the icon title.

The code comes from the function wIconPaint().
2013-04-08 22:06:26 +01:00
Rodolfo García Peñas (kix)
2c0a449f00 drawIconTitle renamed
The function drawIconTitle() only draw the icon title square, without
the title. The title must be set later, because yet is not initialized,
so is NULL.

Then, the right function name should be drawIconTitleBackground.

This patch also removes the variable titled.
2013-04-08 22:06:26 +01:00
Rodolfo García Peñas (kix)
b3ca57674d Dockapps don't have title
The dockapps don't have title, so this code must be removed.
The title height is 0 then and the variable title_height can
be removed.
2013-04-08 22:06:26 +01:00
Rodolfo García Peñas (kix)
4093d24625 wIconUpdate removed image argument
The argument image is not used in any call, so can be removed.
2013-04-08 22:06:26 +01:00
Rodolfo García Peñas (kix)
c24499f6ad wIconChangeImageFile use set_icon_image_from_image
The function wIconChangeImageFile() now use set_icon_image_from_image()
then:

1. Don't need call unset_icon_image() because the memory is free in the
   function set_icon_image_from_image().
2. After update the icon info, it must set the file name.
3. The pixmap image could be updated.
2013-04-08 22:06:26 +01:00
Rodolfo García Peñas (kix)
c088aba057 New function set_icon_image_from_image
The new function set_icon_image_from_image() sets the icon image using
a image provided as argument.

This function will be used to avoid call wIconUpdate() with the image
argument, doing the code easier and faster.

This patch calls unset_icon_image(), to free the icon image, to avoid
lost memory. After this patch, in winspector.c, the wIconUpdate() call
don't free the memory before update it.
2013-04-08 22:06:26 +01:00
Rodolfo García Peñas (kix)
25d083a85f Removed extra XClearWindow call
The function XClearWindow() is called twice, we can remove one.
See the asterisks (**):

Before the call to wIconPaint():
-----------------8<--------------------------
+++ b/src/icon.c
@@ -621,7 +621,6 @@ void update_icon_pixmap(WIcon *icon)
                XSetWindowBackgroundPixmap(dpy, icon->core->window, icon->pixmap);

        /* Paint it */
**      XClearWindow(dpy, icon->core->window);
        wIconPaint(icon);
 }
-----------------8<--------------------------

First call in wIconPaint() function:
-----------------8<--------------------------
void wIconPaint(WIcon *icon)
{
        WScreen *scr = icon->core->screen_ptr;
        int x, l, w;
        char *tmp;

**      XClearWindow(dpy, icon->core->window);
-----------------8<--------------------------
2013-03-21 10:01:04 +00:00
Rodolfo García Peñas (kix)
bb48c35522 Window attributes moved to wCoreCreateTopLevel
The function wCoreCreateTopLevel() is used in two files (icon.c and
framewin.c), but after create the window, some attributes are changed.

This patch moves the change inside the wCoreCreateTopLevel(), avoiding to
call XChangeWindowAttributes() after the window creation. Now the window
is created in only one step, with all the final attributes.

Some details:

- The function wCoreCreateTopLevel() has now one argument more, the
  border pixel color. This attribute was used always as the screen
  frame_border_pixel, but in icon.c the attribute is changed to
  white_pixel. Now the function wCoreCreateTopLevel() receives the
  value frame_border_pixel in framewin.c and scr->white_pixel in
  icon.c, as argument.

- The vmask and attribs variables and the call to XChangeWindowAttributes()
  are removed in framewin.c and icon.c. The values CWSaveUnder for vmask and
  attribs.save_under = True are used if wPreferences.use_saveunders is True.

- CWBorderPixel is not needed in icon.c, because was previously set in wcore.c!
2013-03-21 10:01:04 +00:00
Rodolfo García Peñas (kix)
97d7c32184 New function set_icon_image_from_database
The new function set_icon_image_from_database() removes the dup code
from these functions:

icon.c:icon_create_for_dock()
icon.c:icon_create_for_wwindow()
appicon.c:removeAppIconFor()

The only different change is that in the functions icon_create_for_dock()
and icon_create_for_wwindow(), the icon->tile_type assignment is done
before set the icon image filename and icon image, but this variable
is not used in these functions (is used in wIconUpdate function) but in both
functions the icon->tile_type assignment is done before wIconUpdate(), like
the code previous to this patch, so there is no problem moving icon->tile_type.
2013-01-22 21:46:39 +00:00
Rodolfo García Peñas (kix)
3f2c87fb06 get_rimage_icon_from_wm_hints returns image
The function get_rimage_icon_from_wm_hints now returns an image.
2012-11-17 21:10:24 +01:00
Rodolfo García Peñas (kix)
5bfac9036d wIconChangeImageFile set the file image
The function wIconChangeImageFile set the file_image variable directly,
now the code is faster and the assigned image is used.

Before this patch, the assigned file couldn't be used, because wIconUpdate
serached the icon using different methods.
2012-11-17 20:38:50 +01:00
Rodolfo García Peñas (kix)
0a06ddd9e3 wIconUpdate wwin checks
The variable wwin is only used in one block of the if, so should be moved
inside this block. OTOH, is better check if the variabl exists before
assign it. The code now is more stable and avoid crashes.
2012-11-17 20:38:45 +01:00
Rodolfo García Peñas (kix)
4b4c5513ce update_icon_pixmap don't paint dock icon
The dock applications has their icon image set in icon->file_image
to draw the icon if the application is not running. But if the
application is running, the icon mustn't be show. This patch don't
paint the icon for docks.
2012-11-17 20:38:40 +01:00
Rodolfo García Peñas (kix)
522d84b0ef wIconUpdate image preselected
The function wIconUpdate can receive a image to setup as icon image.
If image is NULL, then use the original method, using different procedures
to get the image.
2012-11-17 20:38:36 +01:00
BALATON Zoltan
c7e3666e62 Made highlighting the AppIcon of the active app configurable at run time 2012-11-17 20:32:10 +01:00
Rodolfo García Peñas (kix)
2eb1107e20 wIconUpdate removed scr variable
The variable scr is not used, so MUST be removed.

This variable can cause a segfault because icon could not exist.
2012-11-14 22:55:45 +00:00
Rodolfo García Peñas (kix)
78ff715d39 wIconValidateIconSize checks the width and height
The function wIconValidateIconSize checks if the width size and height size are
less than the preference size (and left space for the border). If the width
size or height size is greater than the preference, then checks what is the
bigger size of them. Then resize it using the bigger value and holding the
aspect ratio.

Before this patch, wIconValidateIconSize didn't check if height was bigger
than width and always suppose that width was greater than height.
2012-11-14 22:48:08 +00:00
Rodolfo García Peñas (kix)
5956d71d77 get_wwindow_image_from_wmhints scale image
The function get_wwindow_image_from_wmhints returns a image from WM Hints,
but the image could be larger than the desired.

Then, the image can be resized using wIconValidateIconSize(). The resize
should be done in get_rimage_icon_from_wm_hints(), not in the function
get_wwindow_image_from_wmhints(). This is because the function
get_wwindow_image_from_wmhints() is used in wIconStore() too. If we resize
the image before save it to disk, then if we change the icon/dock size, then
the image saved will have a different size than the curren icon size. Is
better resize the image when is painted in the screen, not the image saved.
2012-11-14 22:47:26 +00:00
Rodolfo García Peñas (kix)
ead0fb2e4b Remove dup set icon file to NULL
Remove the icon->file = NULL because was set in unset_icon_image().
2012-11-14 22:40:00 +00:00
Christophe CURIS
7746fe7c5a Added reset of pointer after memory free to avoid double-free crash
As reported by Rodolfo, there are some cases when working with icons
where a crash can occur, which is related to trying to re-release
some memory that have been already freed previously.

This patch adds a reset-to-NULL of the corresponding pointers so that
on next usage wmaker will know there's no more memory associated with
these pointers.
2012-11-14 22:39:37 +00:00
Rodolfo García Peñas (kix)
e192302bd7 force_paint removed
The WIcon variable force_paint can be removed, because now is possible
update the icon directly in the function wAppIconPaint.

Now wAppIconPaint creates the RImage file if needed, and then paint it.
2012-11-11 11:57:58 +00:00
Rodolfo García Peñas (kix)
c3a1c76b44 get_default_icon_filename rewritten
The function get_default_icon_filename(), now get_icon_filename(),
was working in a bad way. Before this patch, the function always
searched the default icon in the second search:

-     file_name = wDefaultGetIconFile(winstance, wclass, True);
+     file_name = wDefaultGetIconFile(winstance, wclass, False);

For this reason, the argument default_icon didn't work.

This patch change it. Now, if the default_icon is false, the function
can return NULL, then other functions can do the correct work. For
example, now wDefaultGetImage() doesn't need do nothing, because the
default_icon is set to True. get_icon_filename() checks if the
icon exists in the disk before returning it (except for default icon
in get_default_image_path(scr).
2012-11-10 19:42:24 +00:00
Rodolfo García Peñas (kix)
fd9bb936aa appearanceObserver doesn't create icon again
The function appearanceObserver() is now faster because it doesn't
re-create the icon. Now it only draws the icon pixmap.
2012-11-04 12:54:16 +00:00
Rodolfo García Peñas (kix)
cca2814afe wIconSetHighlited: Do not create the icon again
The function wIconSetHighlited() is now faster because it doesn't
re-create the icon before setting the Highlited status. Now it only
draws the icon pixmap.
2012-11-04 12:54:16 +00:00
Rodolfo García Peñas (kix)
c97bf19079 New function update_icon_pixmap
The new function update_icon_pixmap() updates the pixmap for a icon task.
Now, wIconCreate() creates the image and sets the icon->file and
icon->file_image variables and update_icon_pixmap() updates the icon->pixmap.

This is interesting because we can update the pixmaps without creating the
image again.
2012-11-04 12:54:16 +00:00
Rodolfo García Peñas (kix)
6bfb175b19 wIconUpdate create rimage and then pixmap
The function wIconUpdate now create the rimage for the icon, using
different functions. When the icon is created, then the pixmap is
generated using this rimage.
2012-11-04 12:54:15 +00:00
Rodolfo García Peñas (kix)
7246fa2d4c Split get_pixmap_icon_from_icon_win()
The function get_pixmap_icon_from_icon_win(), before this patch,
creates the pixmap icon for dockapps (docks with a mini application
inside). The function did three steps:

1. Create the (r)image
2. Create the pixmap using the image
3. Put the application inside the image

Now these three steps are three functions:

step 1: static void get_rimage_icon_from_icon_win(WIcon *icon);
step 2: static void get_pixmap_icon_from_icon_win(WIcon *icon);
step 3: static void set_dockapp_in_icon(WIcon *icon);

These functions contains the same code, that before the changes.
The original function get_pixmap_icon_from_icon_win() includes the
calls to the new functions get_rimage_icon_from_icon_win() and
set_dockapp_in_icon()
2012-11-04 12:54:15 +00:00
Rodolfo García Peñas (kix)
529276a395 Solved bug if icon doesn't exists
There is a bug in wmaker with icon files set in config files, but
that doesn't exist in the disk. For example, if the config files have:

etc/WindowMaker/WMWindowAttributes:
  xcalc = {AlwaysUserIcon = Yes;Icon = "HP-16C-48.xpm";};
share/WindowMaker/IconSets/Default.iconset:
  xcalc = {AlwaysUserIcon = Yes;Icon = "HP-16C-48.xpm";};

But the icon "HP-16C-48.xpm" doesn't exist in the disk, wmaker does:

1. Load the config file in memory, in a database
2. When the application is launched, wmaker tries to find their icon in
   the database (using wDefaultGetIconFile), the icon is found: HP-16C-48.xpm
3. When WindowMaker try to find the full path for the icon, using FindImage(),
   WindowMaker cannot find the icon, and returns NULL.
   Even, if the user set the default_icon boolean variable to True, wmaker
   finds in the database the wrong icon.

This patch checks that the icon exists both in the database AND in the disk. If the
icon doesn't exist in the disk and the default_icon variable is set to True,
then windowmaker loads the default icon using the function get_default_image()
because this function searches the default icon directly.

The function get_default_image() is moved from icon.c to wdefaults.c because
it is now used in both places. This function is now splitted, to find the file
(get_default_image_path) path and the file image (get_default_image)
2012-11-04 12:54:15 +00:00
Rodolfo García Peñas (kix)
314f1dc907 get_pixmap_icon_from_icon_win rewritten
The function get_pixmap_icon_from_icon_win() is now rewritten.

This function now creates the icon using the function get_window_image_from_x11(),
using itself as Window and updates the icon using icon_update_pixmap().

At this point the Pixmap is only the icon background. Now we must put inside the
dockapp, in the correct position. Then the funcion get the dock application size,
(the max size is wPreferences.icon_size, because get_window_image_from_x11() checks
the valid size), checks if the icon has title and then reparents the dockapp to put
it inside the icon.

This patch includes a lot of comments to better understand the code.
2012-11-04 12:54:15 +00:00
Rodolfo García Peñas (kix)
3e83e9d5ae New functions get_*_icon_from_x11
A new functions get_pixmap_icon_from_x11 and get_rimage_icon_from_x11
are included in icon.h

1. get_pixmap_icon_from_x11, set the rimage at icon->file_image
   The code sets net_icon_image in icon->file_image
2. The get_rimage_icon_from_x11 function, only converts
   the icon->file_image in icon->pixmap
2012-11-04 00:35:21 +00:00
Rodolfo García Peñas (kix)
ceedad4231 Split get_pixmap_icon_from_wm_hints() into two
The function get_pixmap_icon_from_wm_hints() is splitted in two
functions now:

1. get_rimage_icon_from_wm_hints, set the rimage at icon->image
   The code comes from the function get_pixmap_icon_from_default_icon()
2. The get_pixmap_icon_from_wm_hints() function, but now only converts
   the icon->file_image in icon->pixmap
2012-11-04 00:30:53 +00:00
Rodolfo García Peñas (kix)
c79eaa59b2 Split get_pixmap_icon_from_user_icon() into two
The function get_pixmap_icon_from_user_icon() is splitted in two
functions now:

1. get_rimage_icon_from_user_icon, set the rimage at icon->image
   The code comes from the function get_pixmap_icon_from_default_icon()
2. The get_pixmap_icon_from_user_icon() function, but now only converts
   the icon->file_image in icon->pixmap
2012-11-04 00:27:46 +00:00
Rodolfo García Peñas (kix)
8349a018f0 Split get_pixmap_icon_from_default_icon() into two
The function get_pixmap_icon_from_default_icon() is splitted in two
functions now:

1. get_rimage_icon_from_default_icon, set the rimage at icon->image
   The code comes from the function get_pixmap_icon_from_default_icon()
2. The get_pixmap_icon_from_default_icon(), but now only converts
   the icon->file_image in icon->pixmap
2012-11-04 00:26:01 +00:00
Rodolfo García Peñas (kix)
2ff138f311 New helper function unset_icon_image()
The new function unset_icon_image() removes the RImage and the
file path for a given icon.
2012-11-03 19:52:30 +00:00
Rodolfo García Peñas (kix)
0106b2a4e9 get_pixmap_icon_from_wm_hints rewritten
The function get_pixmap_icon_from_wm_hints() is now rewritten using
the functions get_wwindow_image_from_wmhints() and icon_update_pixmap().

Now, the function creates a new RImage using get_wwindow_image_from_wmhints()
and then updates the Pixmap using the function icon_update_pixmap().
2012-10-31 22:57:31 +00:00
Rodolfo García Peñas (kix)
0493974cbc get_pixmap_icon_from_wm_hints uses getSize
The function get_pixmap_icon_from_wm_hints() now uses getSize() and
the code dup is removed.
2012-10-31 22:54:42 +00:00
Rodolfo García Peñas (kix)
d5e5ae6ca0 getSize returns XGetGeometry exit
The function getSize now returns the returned value by XGetGeometry.
The function now is not INLINE.
2012-10-31 22:52:53 +00:00
Rodolfo García Peñas (kix)
5728b6436d wIconChangeImageFile change image only if found
This patch changes the behavior of wIconChangeImageFile.

Before apply this patch the behavior was:

The image (file_image) is set to NULL, then the function tried to find
a new image. If the new image was not found, the variable file_image contains
NULL when the function returns, and the return code was 1.

With this patch the image is changed only if a new image is found.
2012-10-31 22:24:28 +00:00
Rodolfo García Peñas (kix)
3d0223ded4 wIconChangeImageFile removed dup code
This patch removes the dup code with get_rimage_from_file.
2012-10-31 22:24:28 +00:00
Rodolfo García Peñas (kix)
156d8ebfa5 wIconChangeImageFile don't update without file
The function wIconChangeImageFile mustn't update the icon if
no file is set.

This is a bug. To reproduce it:

1. Right click on dock icon. Select "Settings"
2. Erase the Icon Image contents (set empty)
3. Click "OK" -> Exit, no changes... no?
4. Right click on the same dock icon. Select "Settings"
5. Erase the Icon Image contents (set empty)
6. Click "OK" -> Crash

If wmaker don't crash, watch the file ~/GNUstep/Defaults/WMWindowAttributes,
the default icon ("*" has trash in the name). Probably something is not fine
at wIconUpdate.
2012-10-31 22:24:27 +00:00
Rodolfo García Peñas (kix)
280e1e099d Removed dup code at get_default_image
This patch removes the code dup at get_default_image. Now,
this function calls get_rimage_from_file()
2012-10-31 22:24:27 +00:00
Rodolfo García Peñas (kix)
206fe5e821 Changed get_default_icon_rimage function name
The function get_default_icon_rimage name is not correct, because
the function doesn't return the default icon rimage, returns the
rimage from a file name. So the correct function name should be
get_rimage_from_file.
2012-10-28 10:58:43 +00:00
Rodolfo García Peñas (kix)
b8025ee899 New helper function get_pixmap_icon_from_default_icon
The new helper function get_pixmap_icon_from_default_icon search
the default icon in the disk and return it.

Now get_pixmap_icon_from_user_icon() returns do the work about
search the user icon, and the work about default icon is splitted
in the function get_pixmap_icon_from_user_icon.
2012-10-28 10:58:43 +00:00
Rodolfo García Peñas (kix)
f3d36b1c26 Function makeIcon removed
The function makeIcon is only used in icon_update_pixmap(), so
both functions can be joined. Now the function icon_update_pixmap()
includes the contents of makeIcon.
2012-10-28 10:58:43 +00:00
Rodolfo García Peñas (kix)
ff9f942c47 Better default icon management
This patch replaces the Pixmap icons from screen.h with only one
RImage. This image is not processed yet, therefore could be used
for icons with title or without it (replacing def_ticon_pixmap and
def_icon_pixmap variables).

Now the code is better because the Pixmap is generated and saved in
the icon structure.

See that before this patch, the icon->pixmap was set to None!!
With this patch, the icon->pixmap is saved, using the common
method used in the other functions to create Pixmaps, the function
icon_update_pixmap().
2012-10-28 10:58:43 +00:00
Rodolfo García Peñas (kix)
4f4b7655de New helper function get_default_image
The new function get_default_image creates a RImage with the default
icon. Now the function get_pixmap_icon_from_user_icon() is more clear
and show that, first try to get the user selected image, if not set,
then it gets the default icon.
2012-10-28 10:58:43 +00:00
Rodolfo García Peñas (kix)
399d476126 declare get_pixmap_icon_from_* as static functions
The functions:

void get_pixmap_icon_from_icon_win(WIcon *icon);
int get_pixmap_icon_from_wm_hints(WIcon *icon);
void get_pixmap_icon_from_user_icon(WIcon *icon);

should be static, because are only used in icon.c
2012-10-28 10:58:42 +00:00
Rodolfo García Peñas (kix)
948dde0abd New icon_update_pixmap helper function
The function icon_update_pixmap updates the WIcon's pixmap,
using the values in the WIcon struct.

This function provices a clear function to update the icon,
using only the icon, and the new image to set. This option is
better than using "makeIcon" function, with a lot of arguments.

This patch also changes the variable name "icon" to "image",
because is type rimage and then both functions uses the same name.
2012-10-28 10:58:42 +00:00
Rodolfo García Peñas (kix)
f9847da97c get_pixmap_icon_from_wm_hints removed extra arguments
The function get_pixmap_icon_from_wm_hints has two extra arguments
(WScreen and WWindow) not needed, because these arguments can be
accessed using the argument WIcon.

This function removes them in the function definition and provides
them in the function code.
2012-10-28 10:58:42 +00:00
Rodolfo García Peñas (kix)
362915a7b3 get_pixmap_icon_from_user_icon extra argument removed
The function get_pixmap_icon_from_user_icon uses the argument
scr (WScreen) that is not needed, because the argument is in the
struct WIcon, the other function argument.

This patch removes the argument WScreen and provides it in the function
using WIcon.
2012-10-28 10:58:42 +00:00