2
// -------------------------------------------
4
// $Date: 2003/07/04 10:12:01 $
6
// $Source: /cvsroot/miwm/miwm/miwm/wspace.cc,v $
7
// $Id: wspace.cc,v 1.3 2003/07/04 10:12:01 sgbeal Exp $
8
// $RCSfile: wspace.cc,v $
9
// -------------------------------------------
10
// Copyright by Ben Paul Wise.
11
// -------------------------------------------
12
// This program is free software; you can redistribute it and/or modify
13
// it under the terms of the GNU General Public License as published by
14
// the Free Software Foundation; either version 2 of the License, or
15
// (at your option) any later version.
17
// This program is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
// GNU General Public License for more details.
22
// You should have received a copy of the GNU General Public License
23
// along with this program; if not, write to the Free Software
24
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
// -------------------------------------------
26
// this defines the functions for workspace-related
28
// -------------------------------------------
32
#include "miwm_framework.h"
33
#include "EStringList.h"
35
// -------------------------------------------
38
WindowManager::setupWS() {
41
allWorkSpaces = (WorkSpace**) malloc (maxNumWorkSpaces * sizeof (WorkSpace));
43
previewedWorkSpace = NULL; // and likely to stay that way
45
std::string spacenames = miwm::config().getString( "workspace_names", "One Two Three Four Five Six" );
46
EStringList list = EStringList::tokenize( spacenames );
50
wsname = list.shift();
51
if( wsname.empty() ) break;
52
addWorkSpace( wsname.c_str() );
59
WindowManager::addWorkSpace(const char* wsName) {
61
if (numWorkSpaces < maxNumWorkSpaces) {
62
WorkSpace* ws = new WorkSpace(wsName);
63
allWorkSpaces[numWorkSpaces] = ws;
64
numWorkSpaces = numWorkSpaces + 1;
65
if (1 == numWorkSpaces)
69
cout << "Maximum number of workspaces ("<<maxNumWorkSpaces<<") reached." << endl;
70
cout << "Therefore, workspace " << wsName<<" will not be added"<<endl;
76
// -------------------------------------------
78
// I defocus everything right before moving it off screen, for two reasons.
79
// First: if I did not, things that were in focus but are now
80
// offscreen get redrawn (with defocused border) when I set focus in
82
// Second: it prevents things like offscreen-xterms from accidentally
83
// getting keyboard input, doing deletes in the wrong directory, etc.
86
WindowManager::changeWorkSpace(WorkSpace* ws1, WorkSpace* ws2) {
94
for (cND = allClients->first; cND != NULL; cND = allClients->nextNode(cND)) {
95
c = ((Client*) cND->data);
97
// if this client is NULL, we are in deep doo doo
101
if (c->workSpace == ws1) {
102
// I marked the following 'if' as suspicious,
103
// but now I don't recall why
104
if (False == c->hidden)
105
if (c->sticky == 0) {
107
setactive(current , 0 , 0L);
110
innerSendClienttoWS(c, 0); // hide it
112
else { // c->sticky == 1
117
if (c->workSpace == ws2) {
118
if (c->sticky == 0) {
119
if (False == c->hidden)
120
innerSendClienttoWS(c, 1); // actually show it
123
// do nothing: it is sticky and already in this WS
129
focusOn(NULL); // arrive defocused
134
WindowManager::sendClientToWorkSpace(Client* client, WorkSpace* ws2) {
135
assert (NULL != ws2);
136
if (NULL != client) { // client did not die during the operation
137
if ((ws2 != workSpace) || (ws2 != client->workSpace)) {
139
client->workSpace = ws2;
141
// is this one in focus?
142
if (client == current) {
143
setactive(current, 0, 0L); // copied from disp.cc
147
innerSendClienttoWS(client, 0); // make it invisible
149
assert (client->workSpace == ws2);
151
if (1 == followClientToWS) {
152
changeWorkSpace(workSpace, client->workSpace);
153
followClientToWS = 0;
156
else { // client died during the operation. CYA
157
XUnmapWindow(dpy, popup);
165
WindowManager::innerSendClienttoWS(Client* client, int visibleP) {
167
if (visibleP == 0) {// slide it away
168
// set normalX, normalY just prior to pushing it off the screen.
169
client->normalX = client->size.x;
170
client->normalY = client->size.y;
171
client->normalW = client->size.width;
172
client->normalH = client->size.height;
174
XMoveWindow(dpy, client->parent,
175
client->size.x + offWorkSpace,
176
client->size.y + offWorkSpace);
177
// note that I do not do any configure notification.
178
// if the client pops up an emergency dialog box, I want it to show.
180
else { // slide it back
181
XMoveWindow(dpy, client->parent,
184
// XMapWindow(dpy, client->parent);
189
// -------------------------------------------
191
WorkSpace::WorkSpace(const char* n) {
196
WorkSpace::~WorkSpace() {
201
WindowManager::rotateWSClients() {
202
Client *c1 = current;
206
int numClients = allClients->length() ;
213
cND = allClients->first;
214
c1 = ((Client*) cND->data);
217
cND = allClients->inList(c1);
219
while ((c2 == NULL) && ( i < numClients + 2)) {
220
cND = allClients->nextNode(cND);
222
cND = allClients->first;
225
c1 = ((Client*) cND->data);
227
// if this client is NULL, we are in deep doo doo
231
if ((False == c1->hidden) && (workSpace == c1->workSpace))
242
// -------------------------------------------
244
// -------------------------------------------