From: Christophe CURIS <[email protected]>
Re-indentation, aeration and a few alignment to coding style;
Added the licence and usual #ifdef protection to the new header
---
src/event.c | 10 ++++---
src/workspace.c | 8 +++---
src/wsmap.c | 82 +++++++++++++++++++++++++++++++++++----------------------
src/wsmap.h | 25 ++++++++++++++++++
4 files changed, 86 insertions(+), 39 deletions(-)
diff --git a/src/event.c b/src/event.c
index 0f6eddc..6b2e0db 100644
--- a/src/event.c
+++ b/src/event.c
@@ -1607,10 +1607,12 @@ static void handleKeyPress(XEvent * event)
wSelectWindow(wwin, !wwin->flags.selected);
}
break;
- case WKBD_WORKSPACEMAP:
- if (!wPreferences.disable_workspace_pager)
- StartWorkspaceMap(scr);
- break;
+
+ case WKBD_WORKSPACEMAP:
+ if (!wPreferences.disable_workspace_pager)
+ StartWorkspaceMap(scr);
+ break;
+
case WKBD_FOCUSNEXT:
StartWindozeCycle(wwin, event, True, False);
break;
diff --git a/src/workspace.c b/src/workspace.c
index 6e83986..165e301 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -161,8 +161,8 @@ Bool wWorkspaceDelete(WScreen * scr, int workspace)
} else {
if (scr->workspaces[i]->name)
wfree(scr->workspaces[i]->name);
- if (scr->workspaces[i]->map)
- RReleaseImage(scr->workspaces[i]->map);
+ if (scr->workspaces[i]->map)
+ RReleaseImage(scr->workspaces[i]->map);
wfree(scr->workspaces[i]);
}
}
@@ -476,8 +476,8 @@ void wWorkspaceForceChange(WScreen * scr, int workspace)
if (workspace >= MAX_WORKSPACES || workspace < 0)
return;
- if (!wPreferences.disable_workspace_pager &&
!process_workspacemap_event)
- wWorkspaceMapUpdate(scr);
+ if (!wPreferences.disable_workspace_pager &&
!process_workspacemap_event)
+ wWorkspaceMapUpdate(scr);
SendHelperMessage(scr, 'C', workspace + 1, NULL);
diff --git a/src/wsmap.c b/src/wsmap.c
index 25c565f..e1064fc 100755
--- a/src/wsmap.c
+++ b/src/wsmap.c
@@ -20,28 +20,32 @@
*/
#include "wconfig.h"
+
#include <stdlib.h>
#include <stdio.h>
+#ifdef USE_XSHAPE
+#include <X11/extensions/shape.h>
+#endif
+
#include "screen.h"
#include "window.h"
#include "misc.h"
#include "workspace.h"
#include "wsmap.h"
-#include "WINGs/WINGs/WINGsP.h"
-#ifdef USE_XSHAPE
-#include <X11/extensions/shape.h>
-#endif
+#include "WINGs/WINGsP.h"
+
static const int WORKSPACE_MAP_RATIO = 10;
static const int WORKSPACE_SEPARATOR_WIDTH = 12;
static const int mini_workspace_per_line = 5;
-/* used to store the index of the tenth displayed mini workspace
- will be 0 for workspaces number 0 to 9
- 1 for workspaces number 10 -> 19
-*/
+/*
+ * Used to store the index of the tenth displayed mini workspace
+ * will be 0 for workspaces number 0 to 9
+ * 1 for workspaces number 10 -> 19
+ */
int wsmap_bulk_index;
WMPixmap *frame_bg_focused;
WMPixmap *frame_bg_unfocused;
@@ -66,19 +70,24 @@ void wWorkspaceMapUpdate(WScreen *scr)
XImage *pimg;
pimg = XGetImage(dpy, scr->root_win, 0, 0,
- scr->scr_width, scr->scr_height,
- AllPlanes, ZPixmap);
- if (pimg) {
- RImage *apercu = RCreateImageFromXImage(scr->rcontext, pimg,
NULL);
+ scr->scr_width, scr->scr_height,
+ AllPlanes, ZPixmap);
+ if (pimg) {
+ RImage *apercu;
+
+ apercu = RCreateImageFromXImage(scr->rcontext, pimg, NULL);
XDestroyImage(pimg);
if (apercu) {
RImage *tmp =
scr->workspaces[scr->current_workspace]->map;
+
if (tmp)
RReleaseImage(tmp);
- scr->workspaces[scr->current_workspace]->map =
RSmoothScaleImage(apercu,
-
scr->scr_width / WORKSPACE_MAP_RATIO,
-
scr->scr_height / WORKSPACE_MAP_RATIO);
+
+ scr->workspaces[scr->current_workspace]->map =
+ RSmoothScaleImage(apercu,
+ scr->scr_width /
WORKSPACE_MAP_RATIO,
+ scr->scr_height /
WORKSPACE_MAP_RATIO);
RReleaseImage(apercu);
}
}
@@ -104,9 +113,11 @@ static void workspace_map_destroy(WWorkspaceMap *wsmap)
{
workspace_map_unslide(wsmap);
WMUnmapWidget(wsmap->win);
+
if (wsmap->win) {
Window info_win = wsmap->scr->info_window;
XEvent ev;
+
ev.xclient.type = ClientMessage;
ev.xclient.message_type = w_global.atom.wm.ignore_focus_events;
ev.xclient.format = 32;
@@ -118,6 +129,7 @@ static void workspace_map_destroy(WWorkspaceMap *wsmap)
ev.xclient.data.l[0] = False;
XSendEvent(dpy, info_win, True, EnterWindowMask, &ev);
WMDestroyWidget(wsmap->win);
+
if (frame_bg_focused)
WMReleasePixmap(frame_bg_focused);
if (frame_bg_unfocused)
@@ -133,6 +145,7 @@ static void selected_workspace_callback(WMWidget *w, void
*data)
if (w && wsmap) {
int workspace_id = atoi(WMGetButtonText(click_button));
+
wWorkspaceChange(wsmap->scr, workspace_id);
process_workspacemap_event = False;
}
@@ -141,15 +154,19 @@ static void selected_workspace_callback(WMWidget *w, void
*data)
static void set_workspace_map_background_image(WWorkspaceMap *wsmap)
{
Pixmap pixmap, mask;
+
if (wPreferences.wsmbackTexture->any.type == WTEX_PIXMAP) {
RImage *tmp = wTextureRenderImage(wPreferences.wsmbackTexture,
wsmap->wswidth, wsmap->wsheight, WREL_FLAT);
+
if (!tmp)
return;
+
RConvertImageMask(wsmap->scr->rcontext, tmp, &pixmap, &mask,
250);
RReleaseImage(tmp);
if (!pixmap)
return;
+
XSetWindowBackgroundPixmap(dpy, WMWidgetXID(wsmap->win),
pixmap);
#ifdef USE_XSHAPE
@@ -274,25 +291,26 @@ static void show_mini_workspace(WWorkspaceMap *wsmap,
W_WorkspaceMap *wsmap_arra
for (index = 0; index < max_mini_workspace; index++) {
int i , j;
- i = 0;
j = index;
if (index >= mini_workspace_per_line) {
i = 1;
j -= mini_workspace_per_line;
+ } else {
+ i = 0;
}
if (wsmap_array[index].workspace_img_button) {
WMResizeWidget(wsmap_array[index].workspace_img_button,
wsmap->mini_workspace_width, wsmap->mini_workspace_height);
WMMoveWidget(wsmap_array[index].workspace_img_button, j
* wsmap->mini_workspace_width + (j + 1) * space_width,
-
border_width_adjustement + WORKSPACE_SEPARATOR_WIDTH +
- i *
(wsmap->mini_workspace_height + 2 * WORKSPACE_SEPARATOR_WIDTH) + font_height);
+ border_width_adjustement +
WORKSPACE_SEPARATOR_WIDTH +
+ i * (wsmap->mini_workspace_height + 2 *
WORKSPACE_SEPARATOR_WIDTH) + font_height);
WMMapWidget(wsmap_array[index].workspace_img_button);
}
if (wsmap_array[index].workspace_label) {
WMResizeWidget(wsmap_array[index].workspace_label,
wsmap->mini_workspace_width, font_height);
WMMoveWidget(wsmap_array[index].workspace_label, j *
wsmap->mini_workspace_width + (j + 1) * space_width,
-
border_width_adjustement + WORKSPACE_SEPARATOR_WIDTH +
- i *
(wsmap->mini_workspace_height + 2 * WORKSPACE_SEPARATOR_WIDTH));
+ border_width_adjustement +
WORKSPACE_SEPARATOR_WIDTH +
+ i * (wsmap->mini_workspace_height + 2 *
WORKSPACE_SEPARATOR_WIDTH));
WMMapWidget(wsmap_array[index].workspace_label);
}
}
@@ -412,7 +430,7 @@ static void update_mini_workspace(WWorkspaceMap *wsmap,
W_WorkspaceMap *wsmap_ar
if (bulk_of_ten < 0)
return;
-
+
if (wsmap->scr->workspace_count <= bulk_of_ten * 2 *
mini_workspace_per_line)
return;
@@ -444,10 +462,10 @@ static void update_mini_workspace(WWorkspaceMap *wsmap,
W_WorkspaceMap *wsmap_ar
WMSetButtonImage(wsmap_array[local_index].workspace_img_button, icon);
WMReleasePixmap(icon);
}
- }
- else
+ } else {
if (local_index < wsmap->scr->workspace_count)
hide_mini_workspace(wsmap_array, local_index);
+ }
}
show_mini_workspace(wsmap, wsmap_array, mini_workspace_cnt);
}
@@ -456,17 +474,17 @@ static void handle_event(WWorkspaceMap *wsmap,
W_WorkspaceMap *wsmap_array)
{
XEvent ev;
int modifiers;
- KeyCode escKey = XKeysymToKeycode(dpy, XK_Escape);
+ KeyCode escKey = XKeysymToKeycode(dpy, XK_Escape);
XGrabKeyboard(dpy, WMWidgetXID(wsmap->win), False, GrabModeAsync,
GrabModeAsync, CurrentTime);
XGrabPointer(dpy, WMWidgetXID(wsmap->win), True,
- ButtonMotionMask | ButtonReleaseMask |
ButtonPressMask,
- GrabModeAsync, GrabModeAsync,
WMWidgetXID(wsmap->win), None, CurrentTime);
+ ButtonMotionMask | ButtonReleaseMask | ButtonPressMask,
+ GrabModeAsync, GrabModeAsync, WMWidgetXID(wsmap->win),
None, CurrentTime);
process_workspacemap_event = True;
while (process_workspacemap_event) {
WMMaskEvent(dpy, KeyPressMask | KeyReleaseMask | ExposureMask
- | PointerMotionMask | ButtonPressMask |
ButtonReleaseMask | EnterWindowMask, &ev);
+ | PointerMotionMask | ButtonPressMask |
ButtonReleaseMask | EnterWindowMask, &ev);
if (!wsmap)
break;
@@ -475,8 +493,8 @@ static void handle_event(WWorkspaceMap *wsmap,
W_WorkspaceMap *wsmap_array)
switch (ev.type) {
case KeyPress:
if (ev.xkey.keycode == escKey ||
(wKeyBindings[WKBD_WORKSPACEMAP].keycode != 0 &&
-
wKeyBindings[WKBD_WORKSPACEMAP].keycode == ev.xkey.keycode &&
-
wKeyBindings[WKBD_WORKSPACEMAP].modifier == modifiers)) {
+
wKeyBindings[WKBD_WORKSPACEMAP].keycode == ev.xkey.keycode &&
+
wKeyBindings[WKBD_WORKSPACEMAP].modifier == modifiers)) {
process_workspacemap_event = False;
} else {
KeySym ks;
@@ -490,14 +508,14 @@ static void handle_event(WWorkspaceMap *wsmap,
W_WorkspaceMap *wsmap_array)
else
if (ks == XK_Left)
bulk_id = wsmap_bulk_index - 1;
- else
- if (ks == XK_Right)
+ else if (ks == XK_Right)
bulk_id =
wsmap_bulk_index + 1;
if (bulk_id >= 0)
update_mini_workspace(wsmap,
wsmap_array, bulk_id);
}
break;
+
case ButtonPress:
switch (ev.xbutton.button) {
case Button6:
@@ -510,6 +528,7 @@ static void handle_event(WWorkspaceMap *wsmap,
W_WorkspaceMap *wsmap_array)
WMHandleEvent(&ev);
}
break;
+
default:
WMHandleEvent(&ev);
break;
@@ -518,6 +537,7 @@ static void handle_event(WWorkspaceMap *wsmap,
W_WorkspaceMap *wsmap_array)
XUngrabPointer(dpy, CurrentTime);
XUngrabKeyboard(dpy, CurrentTime);
+
if (wsmap)
workspace_map_destroy(wsmap);
}
diff --git a/src/wsmap.h b/src/wsmap.h
index 484068f..2133bd5 100644
--- a/src/wsmap.h
+++ b/src/wsmap.h
@@ -1,3 +1,28 @@
+/*
+ * Window Maker window manager
+ *
+ * Copyright (c) 2014 Window Maker Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program, see the file COPYING.
+ */
+
+#ifndef WSMAP_H
+#define WSMAP_H
+
Bool process_workspacemap_event;
+
void wWorkspaceMapUpdate(WScreen *scr);
void StartWorkspaceMap(WScreen *scr);
+
+#endif
--
2.1.3
--
To unsubscribe, send mail to [email protected].