Skip to content

Commit

Permalink
API update:
Browse files Browse the repository at this point in the history
	BScreen::getCurrentWorkspace() -> removed
	BScreen::getCurrentWorkspaceID() -> currentWorkspace()
	BScreen::changeWorkspaceID() -> setCurrentWorkspace()

	BlackboxWindow::getWorkspaceNumber() -> workspace()
	BlackboxWindow::getWindowNumber() -> windowNumber()

fixed code to continue working after the change
  • Loading branch information
bradleyhughes committed Nov 14, 2003
1 parent 1940a13 commit 02c61e1
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 105 deletions.
4 changes: 2 additions & 2 deletions src/Clientmenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ void Clientmenu::itemClicked(unsigned int id, unsigned int button) {
BlackboxWindow *window = _screen.getWindow(_workspace, id);
assert(window != 0);

if (_workspace != _screen.getCurrentWorkspaceID()) {
if (_workspace != _screen.currentWorkspace()) {
if (button == 2) window->deiconify(true, false);
else _screen.changeWorkspaceID(_workspace);
else _screen.setCurrentWorkspace(_workspace);
}

_screen.raiseWindow(window);
Expand Down
99 changes: 51 additions & 48 deletions src/Screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) :
workspacemenu->insertWorkspace(wkspc);
}

current_workspace = workspacesList.front();
current_workspace_id = current_workspace->id();
workspacemenu->setWorkspaceChecked(current_workspace_id, true);
current_workspace = workspacesList.front()->id();
workspacemenu->setWorkspaceChecked(current_workspace, true);

// the Slit will be created on demand
_slit = 0;
Expand Down Expand Up @@ -416,8 +415,8 @@ void BScreen::LoadStyle(void) {
void BScreen::iconifyWindow(BlackboxWindow *w) {
assert(w != 0);

if (w->getWorkspaceNumber() != bt::BSENTINEL) {
Workspace* wkspc = getWorkspace(w->getWorkspaceNumber());
if (w->workspace() != bt::BSENTINEL) {
Workspace* wkspc = getWorkspace(w->workspace());
wkspc->removeWindow(w);
w->setWorkspace(bt::BSENTINEL);
}
Expand All @@ -431,7 +430,7 @@ void BScreen::iconifyWindow(BlackboxWindow *w) {
void BScreen::removeIcon(BlackboxWindow *w) {
assert(w != 0);
iconList.remove(w);
iconmenu->removeItem(w->getWindowNumber());
iconmenu->removeItem(w->windowNumber());
}


Expand Down Expand Up @@ -469,8 +468,8 @@ unsigned int BScreen::removeLastWorkspace(void) {
Workspace *wkspc = workspacesList.back();
workspacesList.pop_back();

if (current_workspace->id() == wkspc->id())
changeWorkspaceID(current_workspace->id() - 1);
if (current_workspace == wkspc->id())
setCurrentWorkspace(current_workspace - 1);

wkspc->transferWindows(*(workspacesList.back()));

Expand All @@ -488,23 +487,22 @@ unsigned int BScreen::removeLastWorkspace(void) {
}


void BScreen::changeWorkspaceID(unsigned int id) {
if (! current_workspace || id == current_workspace->id()) return;
void BScreen::setCurrentWorkspace(unsigned int id) {
if (id == current_workspace) return;

current_workspace->hide();
assert(id < workspacesList.size());

workspacemenu->setWorkspaceChecked(current_workspace_id, false);
workspacemenu->setWorkspaceChecked(current_workspace, false);
getWorkspace(current_workspace)->hide();

current_workspace = getWorkspace(id);
current_workspace_id = current_workspace->id();
current_workspace = id;

current_workspace->show();
workspacemenu->setWorkspaceChecked(current_workspace, true);
getWorkspace(current_workspace)->show();

workspacemenu->setWorkspaceChecked(current_workspace_id, true);
if (_toolbar) _toolbar->redrawWorkspaceLabel();

blackbox->netwm().setCurrentDesktop(screen_info.rootWindow(),
current_workspace->id());
current_workspace);
}


Expand All @@ -531,8 +529,9 @@ void BScreen::manageWindow(Window w) {
return;

Workspace* wkspc =
(win->getWorkspaceNumber() >= _resource.numberOfWorkspaces()) ?
current_workspace : getWorkspace(win->getWorkspaceNumber());
getWorkspace(win->workspace() >= _resource.numberOfWorkspaces()
? current_workspace
: win->workspace());

bool place_window = True;
if (blackbox->startingUp() ||
Expand Down Expand Up @@ -560,9 +559,9 @@ void BScreen::unmanageWindow(BlackboxWindow *w, bool remap) {

if (w->isModal()) w->setModal(False);

if (w->getWorkspaceNumber() != bt::BSENTINEL &&
w->getWindowNumber() != bt::BSENTINEL)
getWorkspace(w->getWorkspaceNumber())->removeWindow(w);
if (w->workspace() != bt::BSENTINEL &&
w->windowNumber() != bt::BSENTINEL)
getWorkspace(w->workspace())->removeWindow(w);
else if (w->isIconic())
removeIcon(w);

Expand All @@ -583,13 +582,13 @@ void BScreen::unmanageWindow(BlackboxWindow *w, bool remap) {


void BScreen::raiseWindow(BlackboxWindow *w) {
Workspace *wkspc = getWorkspace(w->getWorkspaceNumber());
Workspace *wkspc = getWorkspace(w->workspace());
wkspc->raiseWindow(w);
}


void BScreen::lowerWindow(BlackboxWindow *w) {
Workspace *wkspc = getWorkspace(w->getWorkspaceNumber());
Workspace *wkspc = getWorkspace(w->workspace());
wkspc->lowerWindow(w);
}

Expand Down Expand Up @@ -625,77 +624,81 @@ void BScreen::reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id) {
if (! w) return;

if (wkspc_id == bt::BSENTINEL)
wkspc_id = current_workspace->id();
wkspc_id = current_workspace;

if (w->getWorkspaceNumber() == wkspc_id)
if (w->workspace() == wkspc_id)
return;

if (w->isIconic()) {
removeIcon(w);
getWorkspace(wkspc_id)->addWindow(w);
} else {
getWorkspace(w->getWorkspaceNumber())->removeWindow(w);
getWorkspace(w->workspace())->removeWindow(w);
getWorkspace(wkspc_id)->addWindow(w);
}
}


void BScreen::propagateWindowName(const BlackboxWindow *w) {
if (! w->isIconic()) {
Clientmenu *clientmenu = getWorkspace(w->getWorkspaceNumber())->menu();
clientmenu->changeItem(w->getWindowNumber(),
Clientmenu *clientmenu = getWorkspace(w->workspace())->menu();
clientmenu->changeItem(w->windowNumber(),
bt::ellideText(w->getTitle(), 60, "..."));

if (_toolbar && blackbox->getFocusedWindow() == w)
_toolbar->redrawWindowLabel();
} else {
iconmenu->changeItem(w->getWindowNumber(), w->getIconTitle());
iconmenu->changeItem(w->windowNumber(), w->getIconTitle());
}
}


void BScreen::nextFocus(void) const {
BlackboxWindow *focused = blackbox->getFocusedWindow(),
*next = focused;
*next = focused;
Workspace *workspace = getWorkspace(current_workspace);
assert(workspace != 0);

if (focused &&
focused->getScreen()->screen_info.screenNumber() ==
screen_info.screenNumber() &&
current_workspace->windowCount() > 1) {
workspace->windowCount() > 1) {
do {
next = current_workspace->getNextWindowInList(next);
next = workspace->getNextWindowInList(next);
} while(next != focused && ! next->setInputFocus());

if (next != focused)
current_workspace->raiseWindow(next);
} else if (current_workspace->windowCount() > 0) {
next = current_workspace->getTopWindowOnStack();
workspace->raiseWindow(next);
} else if (workspace->windowCount() > 0) {
next = workspace->getTopWindowOnStack();

next->setInputFocus();
current_workspace->raiseWindow(next);
workspace->raiseWindow(next);
}
}


void BScreen::prevFocus(void) const {
BlackboxWindow *focused = blackbox->getFocusedWindow(),
*next = focused;
*next = focused;
Workspace *workspace = getWorkspace(current_workspace);
assert(workspace != 0);

if (focused &&
focused->getScreen()->screen_info.screenNumber() ==
screen_info.screenNumber() &&
current_workspace->windowCount() > 1) {
workspace->windowCount() > 1) {
do {
next = current_workspace->getPrevWindowInList(next);
next = workspace->getPrevWindowInList(next);
} while(next != focused && ! next->setInputFocus());

if (next != focused)
current_workspace->raiseWindow(next);
} else if (current_workspace->windowCount() > 0) {
next = current_workspace->getTopWindowOnStack();
workspace->raiseWindow(next);
} else if (workspace->windowCount() > 0) {
next = workspace->getTopWindowOnStack();

next->setInputFocus();
current_workspace->raiseWindow(next);
workspace->raiseWindow(next);
}
}

Expand All @@ -708,7 +711,7 @@ void BScreen::raiseFocus(void) const {
// if on this Screen, raise it
if (focused->getScreen()->screen_info.screenNumber() ==
screen_info.screenNumber()) {
Workspace *workspace = getWorkspace(focused->getWorkspaceNumber());
Workspace *workspace = getWorkspace(focused->workspace());
workspace->raiseWindow(focused);
}
}
Expand Down Expand Up @@ -1273,8 +1276,8 @@ void BScreen::clientMessageEvent(const XClientMessageEvent * const event) {
} else if (event->message_type == blackbox->netwm().currentDesktop()) {
const unsigned int workspace = event->data.l[0];
if (workspace < _resource.numberOfWorkspaces() &&
workspace != getCurrentWorkspaceID())
changeWorkspaceID(workspace);
workspace != current_workspace)
setCurrentWorkspace(workspace);
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/Screen.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ private:

Slit *_slit;
Toolbar *_toolbar;
Workspace *current_workspace;
unsigned int current_workspace_id;
unsigned int current_workspace;
Workspacemenu *workspacemenu;

unsigned int geom_w, geom_h;
Expand Down Expand Up @@ -130,12 +129,12 @@ public:

Workspace *getWorkspace(unsigned int index) const;

Workspace *getCurrentWorkspace(void) { return current_workspace; }

Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }

unsigned int getCurrentWorkspaceID(void) const
{ return current_workspace_id; }
inline unsigned int currentWorkspace(void)
{ return current_workspace; }
void setCurrentWorkspace(unsigned int id);

unsigned int getIconCount(void) const { return iconList.size(); }

BlackboxWindow* getWindow(unsigned int workspace, unsigned int id);
Expand All @@ -154,7 +153,6 @@ public:

unsigned int addWorkspace(void);
unsigned int removeLastWorkspace(void);
void changeWorkspaceID(unsigned int id);

void iconifyWindow(BlackboxWindow *w);
void removeIcon(BlackboxWindow *w);
Expand Down
22 changes: 12 additions & 10 deletions src/Toolbar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ void Toolbar::redrawWindowLabel(void) {

void Toolbar::redrawWorkspaceLabel(void) {
const std::string& name =
_screen->resource().nameOfWorkspace(_screen->getCurrentWorkspaceID());
_screen->resource().nameOfWorkspace(_screen->currentWorkspace());
const ScreenResource::ToolbarStyle* const style =
_screen->resource().toolbarStyle();

Expand Down Expand Up @@ -729,20 +729,21 @@ void Toolbar::buttonReleaseEvent(const XButtonEvent *re) {
redrawPrevWorkspaceButton(False);

if (bt::within(re->x, re->y, frame.button_w, frame.button_w)) {
if (_screen->getCurrentWorkspaceID() > 0)
_screen->changeWorkspaceID(_screen->getCurrentWorkspaceID() - 1);
if (_screen->currentWorkspace() > 0)
_screen->setCurrentWorkspace(_screen->currentWorkspace() - 1);
else
_screen->changeWorkspaceID(_screen->resource().numberOfWorkspaces() - 1);
_screen->setCurrentWorkspace(_screen->resource().
numberOfWorkspaces() - 1);
}
} else if (re->window == frame.nsbutton) {
redrawNextWorkspaceButton(False);

if (bt::within(re->x, re->y, frame.button_w, frame.button_w))
if (_screen->getCurrentWorkspaceID() <
if (_screen->currentWorkspace() <
_screen->resource().numberOfWorkspaces() - 1)
_screen->changeWorkspaceID(_screen->getCurrentWorkspaceID() + 1);
_screen->setCurrentWorkspace(_screen->currentWorkspace() + 1);
else
_screen->changeWorkspaceID(0);
_screen->setCurrentWorkspace(0);
} else if (re->window == frame.pwbutton) {
redrawPrevWindowButton(False);

Expand Down Expand Up @@ -823,12 +824,13 @@ void Toolbar::keyPressEvent(const XKeyEvent *ke) {
else
blackbox->setFocusedWindow(0);

_screen->resource().saveWorkspaceName(_screen->getCurrentWorkspaceID(),
_screen->resource().saveWorkspaceName(_screen->currentWorkspace(),
new_workspace_name);

_screen->getWorkspacemenu()->
changeItem(_screen->getCurrentWorkspaceID(),
_screen->resource().nameOfWorkspace(_screen->getCurrentWorkspaceID()));
changeItem(_screen->currentWorkspace(),
_screen->resource().
nameOfWorkspace(_screen->currentWorkspace()));
_screen->updateDesktopNamesHint();

new_workspace_name.erase();
Expand Down
10 changes: 5 additions & 5 deletions src/Window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) {
client.state.maximized = 0;
client.state.skip = SKIP_NONE;
client.state.layer = StackingList::LayerNormal;
client.workspace = screen->getCurrentWorkspaceID();
client.workspace = screen->currentWorkspace();
window_number = bt::BSENTINEL;
client.normal_hint_flags = 0;
client.window_group = None;
Expand Down Expand Up @@ -309,7 +309,7 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) {
// prepare the window to be iconified
client.current_state = IconicState;
client.state.iconic = False;
} else if (client.workspace != screen->getCurrentWorkspaceID()) {
} else if (client.workspace != screen->currentWorkspace()) {
client.current_state = WithdrawnState;
}

Expand Down Expand Up @@ -1630,7 +1630,7 @@ void BlackboxWindow::show(void) {
void BlackboxWindow::deiconify(bool reassoc, bool raise) {
if (client.state.iconic || reassoc)
screen->reassociateWindow(this, bt::BSENTINEL);
else if (client.workspace != screen->getCurrentWorkspaceID())
else if (client.workspace != screen->currentWorkspace())
return;

show();
Expand Down Expand Up @@ -2353,8 +2353,8 @@ void BlackboxWindow::clientMessageEvent(const XClientMessageEvent* const ce) {
if (client.state.iconic)
deiconify(False, False);

if (client.workspace != screen->getCurrentWorkspaceID())
screen->changeWorkspaceID(client.workspace);
if (client.workspace != screen->currentWorkspace())
screen->setCurrentWorkspace(client.workspace);

if (setInputFocus())
screen->raiseWindow(this);
Expand Down
Loading

0 comments on commit 02c61e1

Please sign in to comment.