The call to wIconUpdate() can be changed by call to update_icon_pixmap(),
because the icon doesn't need to be changed.
Now, the icon pixmap is updated faster.
This change is more difficult to see, this is the explanation:
1. wIconUpdate() updates the icon for the applications, then call
update_icon_pixmap() to re-create the pixmap.
2. tileObserver() is used if the event WNIconTileSettingsChanged() is
launched. This event is used in the Notification for docks and wwindows:
WMAddNotificationObserver(tileObserver, icon, WNIconTileSettingsChanged, icon);
3. The function WNIconTileSettingsChanged() is used if the icon need refresh,
used in the wReadDefaults() function. See code below. This function is used
in the wmaker startup.
if (needs_refresh & REFRESH_ICON_TILE)
WMPostNotificationName(WNIconTileSettingsChanged, NULL, NULL);
4. Finally, the flag to refresh the icon tile is throw by setIconTile():
return (reset ? REFRESH_ICON_TILE : 0);
And this function only changes the the icon tile if reset is "1", that
happend if src->icon_tile:
if (scr->icon_tile) {
reset = 1;
RReleaseImage(scr->icon_tile);
XFreePixmap(dpy, scr->icon_tile_pixmap);
}
5. Then, we can drop the function wIconUpdate(), because the change is in the
icon_tile variable, used only in icon_update_pixmap(). This function is
only used in update_icon_pixmap() (not in wIconUpdate):
kix@kentin:~/src/wmaker/git/wmaker-crm/src$ grep icon_tile icon.c
tile = RCloneImage(scr->icon_tile);
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->icon_tile_pixmap);
kix@kentin:~/src/wmaker/git/wmaker-crm/src$
static void icon_update_pixmap(WIcon *icon, RImage *image)
{
[snip]
if (icon->tile_type == TILE_NORMAL) {
tile = RCloneImage(scr->icon_tile);
} else {
assert(scr->clip_tile);
tile = RCloneImage(scr->clip_tile);
}
[snip]
The XSetWindowBackgroundPixmap() call doesn't matter here.
The call to wIconUpdate() can be changed by call to update_icon_pixmap(),
because the icon doesn't need to be changed. This update is only for change
the icon pixmap to un-shadowed.
Now, the icon pixmap is updated faster.
The call to wIconUpdate() can be changed by call to update_icon_pixmap(),
because the icon doesn't need to be changed. This update is only for change
the icon pixmap to un-shadowed.
Now, the icon pixmap is updated faster.
The call to wIconUpdate() can be changed by call to update_icon_pixmap(),
because the icon doesn't need to be changed. This update is only for change
the icon pixmap to shadowed.
Now, the icon pixmap is updated faster.
The call to wIconUpdate() can be changed by call to update_icon_pixmap(),
because the icon doesn't need to be changed. This update is only for change
the icon pixmap to shadowed.
Now, the icon pixmap is updated faster.
The function set_icon_image_from_database() set the icon from the
database, but wIconUpdate() update the icon using different methods
, like for example get the image from X11. So, is better move the
wIconUpdate() to the function who call set_icon_image_from_database(),
to avoid understanding problems.
The function wIconChangeTitle() function calls wIconUpdate() or
wIconPaint() depending of changed. In both cases the icon->file_image
doesn't change, only the icon title, so we can use the same image
and we don't need update it. Because the variable changed is removed,
we can use wIconPaint() here.
Then the variable changed is not used, and these lines can be removed.
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.
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.
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.
The definition and call for wGetRectForHead is moved inside the
if block where is used. This code adds a WScreen pointer to make
the line shorter.
If menu->frame is NULL, then was NULL before this patch, so this
code doesn't include an error about this.
This patch will used with next patch to move the code inside the
block to an specific function.
Added MoveToWorkspace*Key, MoveToNextWorkspaceKey,
MoveToPrevWorkspaceKey, MoveToLastWorkspaceKey,
MoveToNextWorkspaceLayerKey and MoveToPrevWorkspaceLayerKey to the
keyboard shortcut panel of WPrefs.
Added new keyboard shortcuts for moving windows between workspaces.
MoveToWorkspace1Key moves the active window directly to workspace 1.
Similarly for MoveToWorkspace2Key through MoveToWorkspace10Key.
MoveToNextWorkspaceKey moves the window to the next workspace,
MoveToPrevWorkspaceKey moves the window to the previous workspace.
Both keys respect the ws_advance and ws_cycle preferences.
MoveToNextWorkspaceLayerKey moves the window ten workspaces "forward" if
possible.
MoveToPrevWorkspaceLayerKey moves the window ten workspaces "back" if
possible.
A number of functions relating to the Workspaces menu assume that the
menu contains at least three entries: New, Destroy Last and Workspace1.
Because it is assumed that index 1 contains the Destroy Last entry and
index 2 contains the first workspace entry there are several occurrences
throughout workspace.c of magic numbers relating to those indices.
Replace the magic numbers with some #defines, making the code more
readable and allowing the menu to be expanded later.
The function getShortcutString() was defined statically in winmenu.c.
Replace it with the new function GetShortcutKey() which calls the
existing function GetShortcutString() so it can be used elsewhere and
cut down on code duplication.
A result of this change is that shortcuts are now labelled consistently.
Previously the format was different in generated menus, which used, for
example, M1 to refer to Mod1 whereas window menus used the full string
Mod1. Now both use the shorter form.
One could argue that the new function name is more consistent, as now
GetShortcutString() takes a char * argument and GetShortcutKey() takes a
WShortcutKey argument. That argument assumes that the original
intention behind the name of GetShortcutString() was not to hint that it
returns a String...
This code was used to create the window where the workspace name was showed
to the user. The code now use the standar balloon system, therefore this code
is not used anymore and can be removed.
Other toggle menu items such as Maximize and Shade change their text
labels according to the action which will be performed. A shaded window
has its Shade menu item text changed to Unshade, for instance.
As well as maintaining consistency with other menu items, changing the
Select menu entry's text to Deselect for current selected windows
provides another (the only) way of reporting that a window is selected
when its border has been disabled. Currently the only indication that a
window is selected is that its border colour will change.
Use the new preferences FrameBorderColor and FrameSelectedBorderColor to
set the border colour of frame windows and selected frame windows
respectively.
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<--------------------------
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!
The dock types NORMAL_DOCK and EXTENDED_DOCK are never used
so can be removed.
kix@debian:~/src/wmaker/git/wmaker-crm-base$ rgrep NORMAL_DOCK *
src/dock.h:#define NORMAL_DOCK WM_DOCK
kix@debian:~/src/wmaker/git/wmaker-crm-base$ rgrep EXTENDED_DOCK *
src/dock.h:#define EXTENDED_DOCK WM_CLIP
kix@debian:~/src/wmaker/git/wmaker-crm-base$
The function wSessionRestoreState() calls execCommand()
with the argument "host", but this argument is never used,
so we can remove the argument and the code to make that
argument, dead code at wSessionRestoreState.
From 35f19d77874d1b50de5505b6b1cb31531e1c055a Mon Sep 17 00:00:00 2001
From: Andreas Bierfert <andreas.bierfert@lowlatency.de>
Date: Thu, 31 Jan 2013 22:35:42 +0100
Subject: [PATCH 3/3] Teach WPrefs about OPEN_PLMENU
Add option to WPrefs to read, add and edit OPEN_PLMENU menu entries
This patch adds the OPEN_PLMENU options which behaves similar to OPEN_MENU but
can be used to parse command generated proplists. This can be used e.g. in
conjunction with wmmenugen like:
(
"Generated PL Submenu",
OPEN_PLMENU,
"|| find /usr/share/applications -type f -name '*desktop' | xargs
wmmenugen -parser:xdg"
)
v2: code cleanup
This functions reads a proplist from a pipe instead of a file (like
WMReadPropListFromFile does). It uses a call to popen to open the desired
command, reads data into a buffer till EOF and passes the data to getPropList
for parsing.
v2: code cleanup
There can be these 4 situations:
1. ignore flag + file set
2. no ignore flag + file set
3. ignore flag + no file set
4. no ignore flag + no file set
If the "ignore client supplied icon flag" is not set it means the user wants to use the client-provided icon,
so the eventual file name which might be in the entry field is ignored.
If the user sets the ignore flag and sets the icon name all is fine and Option 1 is done.
If the user tries to set an icon (ignore flag is set) but the file textbox is not set we show the
warning:
"Ignore client supplied icon is set, but icon filename textbox is empty. Using client supplied icon"
and use the client-supplied icon instead.
This patch removes all the appicon stuff from the application creation
to the appicon creation. Now, the application only calls one function
(create_appicon_for_application()) and this function do all the work.
The function do the same code than the code before this patch, but the
only change is that the "if" test to check if the appicon was found in
the docks now is negated, removing the return and doing the appicon_save
inside the function.
Finally, the old makeAppIconFor is now create_appicon_for_application().
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.
This patch sets the correct icon after kill a docked application.
To reproduce the problem (as Carlos reported to me), follow these
steps:
1. With a docked application, not running, set the icon image.
2. Launch the docked application.
3. Kill the application, using for example the app dock menu.
The icon is lost. But if wmaker is restarted, the icon backs again.
The problem is because when the application is closed, the function
removeAppIconFor() calls wIconUpdate(), but this function doesn't
find the icon in the file system again. The icon is loaded from the
filesystem only when the application is created.
This patch creates the icon image again, then calls wIconUpdate() to
set the icon image or the default icon image if the icon image was
not found, then wPaint it.
These lines comes from the create_appicon_from_* functions, used
to set the icon image for docks and applications. Are copy/pasted.
When the "Center" choice for window position is chosen, really enforce
the center position for all windows, instead of falling back to "Auto"
when there are already windows on the workspace.
Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>