new focus code! working better than ever!
This commit is contained in:
parent
9b295857eb
commit
f00ed578ba
5 changed files with 45 additions and 47 deletions
|
@ -1979,8 +1979,7 @@ void BScreen::changeWorkspaceID(int id) {
|
|||
if (openbox.focusedWindow() &&
|
||||
openbox.focusedWindow()->getScreen() == this &&
|
||||
(! openbox.focusedWindow()->isStuck())) {
|
||||
current_workspace->setLastFocusedWindow(openbox.focusedWindow());
|
||||
openbox.focusWindow((OpenboxWindow *) 0);
|
||||
openbox.focusWindow(0);
|
||||
}
|
||||
|
||||
current_workspace = getWorkspace(id);
|
||||
|
@ -1991,9 +1990,9 @@ void BScreen::changeWorkspaceID(int id) {
|
|||
|
||||
current_workspace->showAll();
|
||||
|
||||
if (resource.focus_last && current_workspace->getLastFocusedWindow()) {
|
||||
if (resource.focus_last && current_workspace->lastFocusedWindow()) {
|
||||
XSync(openbox.getXDisplay(), False);
|
||||
current_workspace->getLastFocusedWindow()->setInputFocus();
|
||||
current_workspace->lastFocusedWindow()->setInputFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,13 +63,11 @@ typedef std::vector<Rect> rectList;
|
|||
|
||||
Workspace::Workspace(BScreen &scrn, int i) : screen(scrn) {
|
||||
cascade_x = cascade_y = 0;
|
||||
_focused = (OpenboxWindow *) 0;
|
||||
_focused = _last = (OpenboxWindow *) 0;
|
||||
id = i;
|
||||
|
||||
clientmenu = new Clientmenu(*this);
|
||||
|
||||
lastfocus = (OpenboxWindow *) 0;
|
||||
|
||||
name = (char *) 0;
|
||||
setName(screen.getNameOfWorkspace(id));
|
||||
}
|
||||
|
@ -86,6 +84,8 @@ Workspace::~Workspace(void) {
|
|||
const int Workspace::addWindow(OpenboxWindow *w, Bool place) {
|
||||
if (! w) return -1;
|
||||
|
||||
if (place) placeWindow(*w);
|
||||
|
||||
w->setWorkspace(id);
|
||||
w->setWindowNumber(_windows.size());
|
||||
|
||||
|
@ -99,8 +99,6 @@ const int Workspace::addWindow(OpenboxWindow *w, Bool place) {
|
|||
|
||||
raiseWindow(w);
|
||||
|
||||
if (place) placeWindow(*w);
|
||||
|
||||
return w->getWindowNumber();
|
||||
}
|
||||
|
||||
|
@ -111,21 +109,22 @@ const int Workspace::removeWindow(OpenboxWindow *w) {
|
|||
_zorder.remove(w);
|
||||
|
||||
if (w->isFocused()) {
|
||||
if (w == _last)
|
||||
_last = (OpenboxWindow *) 0;
|
||||
|
||||
OpenboxWindow *fw = (OpenboxWindow *) 0;
|
||||
if (w->isTransient() && w->getTransientFor() &&
|
||||
w->getTransientFor()->isVisible()) {
|
||||
w->getTransientFor()->setInputFocus();
|
||||
} else {
|
||||
if (screen.sloppyFocus() || // sloppy focus
|
||||
_zorder.empty() || // click focus but no windows
|
||||
!_zorder.front()->setInputFocus()) { // tried window, but wont focus
|
||||
screen.getOpenbox().focusWindow((OpenboxWindow *) 0);
|
||||
}
|
||||
}
|
||||
w->getTransientFor()->isVisible())
|
||||
fw = w->getTransientFor();
|
||||
else if (screen.sloppyFocus()) // sloppy focus
|
||||
fw = (OpenboxWindow *) 0;
|
||||
else if (!_zorder.empty()) // click focus
|
||||
fw = _zorder.front();
|
||||
|
||||
if (!(fw != (OpenboxWindow *) 0 && fw->setInputFocus()))
|
||||
screen.getOpenbox().focusWindow(0);
|
||||
}
|
||||
|
||||
if (lastfocus == w)
|
||||
lastfocus = (OpenboxWindow *) 0;
|
||||
|
||||
_windows.erase(_windows.begin() + w->getWindowNumber());
|
||||
clientmenu->remove(w->getWindowNumber());
|
||||
clientmenu->update();
|
||||
|
@ -146,6 +145,8 @@ void Workspace::focusWindow(OpenboxWindow *win) {
|
|||
if (_focused != (OpenboxWindow *) 0)
|
||||
clientmenu->setItemSelected(_focused->getWindowNumber(), false);
|
||||
_focused = win;
|
||||
if (win != (OpenboxWindow *) 0)
|
||||
_last = win;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ class Rect;
|
|||
class Workspace {
|
||||
private:
|
||||
BScreen &screen;
|
||||
OpenboxWindow *lastfocus;
|
||||
Clientmenu *clientmenu;
|
||||
|
||||
typedef std::vector<OpenboxWindow *> winVect;
|
||||
|
@ -49,7 +48,10 @@ private:
|
|||
char *name;
|
||||
int id, cascade_x, cascade_y;
|
||||
|
||||
OpenboxWindow *_focused;
|
||||
OpenboxWindow *_focused, *_last; // last is the same as focused except
|
||||
// that when focus is removed from all
|
||||
// windows on the workspace, last doesnt
|
||||
// change to NULL
|
||||
|
||||
protected:
|
||||
void placeWindow(OpenboxWindow &);
|
||||
|
@ -64,12 +66,11 @@ public:
|
|||
~Workspace(void);
|
||||
|
||||
inline BScreen &getScreen(void) { return screen; }
|
||||
inline OpenboxWindow *getLastFocusedWindow(void) { return lastfocus; }
|
||||
inline Clientmenu *getMenu(void) { return clientmenu; }
|
||||
inline const char *getName(void) const { return name; }
|
||||
inline const int &getWorkspaceID(void) const { return id; }
|
||||
inline void setLastFocusedWindow(OpenboxWindow *w) { lastfocus = w; }
|
||||
inline OpenboxWindow *focusedWindow() { return _focused; }
|
||||
inline OpenboxWindow *lastFocusedWindow() { return _last; }
|
||||
void focusWindow(OpenboxWindow *win);
|
||||
OpenboxWindow *getWindow(int);
|
||||
Bool isCurrent(void);
|
||||
|
|
|
@ -186,8 +186,8 @@ Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
|||
resource.titlebar_layout = NULL;
|
||||
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
|
||||
|
||||
focused_screen = (BScreen *) 0;
|
||||
masked_window = NULL;
|
||||
current_screen = (BScreen *) 0;
|
||||
masked_window = (OpenboxWindow *) 0;
|
||||
masked = None;
|
||||
|
||||
load();
|
||||
|
@ -213,7 +213,7 @@ Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
|||
"Openbox::Openbox: no managable screens found, aborting.\n"));
|
||||
::exit(3);
|
||||
}
|
||||
focused_screen = screenList.front();
|
||||
current_screen = screenList.front();
|
||||
|
||||
// save current settings and default values
|
||||
save();
|
||||
|
@ -229,7 +229,7 @@ Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
|||
|
||||
ungrab();
|
||||
|
||||
focusWindow((OpenboxWindow *) 0);
|
||||
focusWindow(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -868,11 +868,11 @@ void Openbox::restart(const char *prog) {
|
|||
void Openbox::shutdown() {
|
||||
BaseDisplay::shutdown();
|
||||
|
||||
focusWindow((OpenboxWindow *) 0);
|
||||
|
||||
std::for_each(screenList.begin(), screenList.end(),
|
||||
std::mem_fun(&BScreen::shutdown));
|
||||
|
||||
focusWindow(0);
|
||||
|
||||
XSync(getXDisplay(), False);
|
||||
}
|
||||
|
||||
|
@ -1063,12 +1063,11 @@ void Openbox::timeout() {
|
|||
|
||||
|
||||
OpenboxWindow *Openbox::focusedWindow() {
|
||||
if (focused_screen == (BScreen *) 0)
|
||||
return (OpenboxWindow *) 0;
|
||||
Workspace *w = focused_screen->getCurrentWorkspace();
|
||||
if (w == (Workspace *) 0)
|
||||
return (OpenboxWindow *) 0;
|
||||
return w->focusedWindow();
|
||||
Workspace *w;
|
||||
if (current_screen)
|
||||
if ((w = current_screen->getCurrentWorkspace()))
|
||||
return w->focusedWindow();
|
||||
return (OpenboxWindow *) 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1083,28 +1082,26 @@ void Openbox::focusWindow(OpenboxWindow *win) {
|
|||
old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber());
|
||||
old_tbar = old_screen->getToolbar();
|
||||
|
||||
old_win->setFocusFlag(False);
|
||||
old_win->setFocusFlag(false);
|
||||
old_wkspc->focusWindow((OpenboxWindow *) 0);
|
||||
}
|
||||
|
||||
if (win && !win->isIconic()) {
|
||||
focused_screen = win->getScreen();
|
||||
tbar = focused_screen->getToolbar();
|
||||
wkspc = focused_screen->getWorkspace(win->getWorkspaceNumber());
|
||||
current_screen = win->getScreen();
|
||||
tbar = current_screen->getToolbar();
|
||||
wkspc = current_screen->getWorkspace(win->getWorkspaceNumber());
|
||||
win->setFocusFlag(true);
|
||||
wkspc->focusWindow(win);
|
||||
|
||||
if (tbar)
|
||||
tbar->redrawWindowLabel(true);
|
||||
focused_screen->updateNetizenWindowFocus();
|
||||
current_screen->updateNetizenWindowFocus();
|
||||
} else {
|
||||
ASSERT(focused_screen != (BScreen *) 0);
|
||||
XSetInputFocus(getXDisplay(), focused_screen->getRootWindow(),
|
||||
None, CurrentTime);
|
||||
XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
|
||||
}
|
||||
|
||||
if (old_tbar && old_tbar != tbar)
|
||||
old_tbar->redrawWindowLabel(true);
|
||||
if (old_screen && old_screen != focused_screen)
|
||||
if (old_screen && old_screen != current_screen)
|
||||
old_screen->updateNetizenWindowFocus();
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ private:
|
|||
typedef std::list<BScreen*> ScreenList;
|
||||
ScreenList screenList;
|
||||
|
||||
BScreen *focused_screen;
|
||||
BScreen *current_screen;
|
||||
OpenboxWindow *masked_window;
|
||||
BTimer *timer;
|
||||
|
||||
|
|
Loading…
Reference in a new issue