From c28bd74febd7587a2ab10c5b1b6554f6ed8a5ff3 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 2 Aug 2002 12:58:37 +0000 Subject: added autogrouping-from-tab patch from Steve Cooper --- src/Basemenu.hh | 4 +++- src/Rootmenu.cc | 27 ++++++++++++++++++++++++++- src/Rootmenu.hh | 6 ++++++ src/Screen.cc | 41 +++++++++++++++++++++++++---------------- src/Screen.hh | 7 ++++++- src/Tab.cc | 38 +++++++++++++++++++++++++++++++++----- src/Tab.hh | 9 ++++++--- src/Window.cc | 17 ++++++++++++++--- 8 files changed, 119 insertions(+), 30 deletions(-) diff --git a/src/Basemenu.hh b/src/Basemenu.hh index 137eb8e..4e48f4c 100644 --- a/src/Basemenu.hh +++ b/src/Basemenu.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Basemenu.hh,v 1.14 2002/05/19 12:57:47 fluxgen Exp $ +// $Id: Basemenu.hh,v 1.15 2002/08/02 12:52:44 fluxgen Exp $ #ifndef BASEMENU_HH #define BASEMENU_HH @@ -126,6 +126,8 @@ protected: int x= -1, int y= -1, unsigned int width= 0, unsigned int height= 0); virtual void redrawTitle(); virtual void internal_hide(); + inline Basemenu *GetParent() { return m_parent; } + inline const Basemenu *GetParent() const { return m_parent; } }; class BasemenuItem { diff --git a/src/Rootmenu.cc b/src/Rootmenu.cc index 5339630..66df012 100644 --- a/src/Rootmenu.cc +++ b/src/Rootmenu.cc @@ -50,7 +50,10 @@ #endif // MAXPATHLEN -Rootmenu::Rootmenu(BScreen *scrn) : Basemenu(scrn) { +Rootmenu::Rootmenu(BScreen *scrn) +: Basemenu(scrn), + auto_group_window(0) +{ screen = scrn; } @@ -73,7 +76,10 @@ void Rootmenu::itemSelected(int button, unsigned int index) { sprintf(displaystring + strlen(displaystring) - 1, "%d", screen->getScreenNumber()); + screen->setAutoGroupWindow(useAutoGroupWindow()); + bexec(item->exec().c_str(), displaystring); + #else // __EMX__ spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL); #endif // !__EMX__ @@ -113,3 +119,22 @@ void Rootmenu::itemSelected(int button, unsigned int index) { } } +void Rootmenu::setAutoGroupWindow(Window window) +{ + auto_group_window = window; +} + +Window Rootmenu::useAutoGroupWindow() +{ + // Return and clear the auto-grouping state. + Window w = auto_group_window; + if (w) + auto_group_window = 0; // clear it immediately + // If not set check the parent and the parent's parent, ... + else { + Rootmenu* parent = dynamic_cast(GetParent()); + if (parent) + w = parent->useAutoGroupWindow(); + } + return w; +} diff --git a/src/Rootmenu.hh b/src/Rootmenu.hh index d8b7d95..16efb62 100644 --- a/src/Rootmenu.hh +++ b/src/Rootmenu.hh @@ -32,6 +32,7 @@ class BScreen; class Rootmenu : public Basemenu { private: BScreen *screen; + Window auto_group_window; protected: @@ -40,6 +41,11 @@ protected: public: Rootmenu(BScreen *); + void setAutoGroupWindow(Window window); + + +private: + Window useAutoGroupWindow(); }; diff --git a/src/Screen.cc b/src/Screen.cc index 6a2485e..cdc6bcd 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.58 2002/07/23 17:11:59 fluxgen Exp $ +// $Id: Screen.cc,v 1.59 2002/08/02 12:52:44 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -474,7 +474,7 @@ namespace { } } -BScreen::~BScreen(void) { +BScreen::~BScreen() { #ifdef GNOME XDestroyWindow(getBaseDisplay()->getXDisplay(), gnome_win); #endif @@ -548,7 +548,7 @@ BScreen::~BScreen(void) { } -void BScreen::reconfigure(void) { +void BScreen::reconfigure() { #ifdef DEBUG cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"< 1) { Workspace *wkspc = workspacesList.back(); @@ -888,7 +888,7 @@ void BScreen::removeNetizen(Window w) { } -void BScreen::updateNetizenCurrentWorkspace(void) { +void BScreen::updateNetizenCurrentWorkspace() { #ifdef NEWWMSPEC //update _NET_WM_CURRENT_DESKTOP int workspace = getCurrentWorkspaceID(); @@ -914,7 +914,7 @@ void BScreen::updateNetizenCurrentWorkspace(void) { } -void BScreen::updateNetizenWorkspaceCount(void) { +void BScreen::updateNetizenWorkspaceCount() { Netizens::iterator it = netizenList.begin(); Netizens::iterator it_end = netizenList.end(); @@ -941,7 +941,7 @@ void BScreen::updateNetizenWorkspaceCount(void) { } -void BScreen::updateNetizenWindowFocus(void) { +void BScreen::updateNetizenWindowFocus() { Netizens::iterator it = netizenList.begin(); Netizens::iterator it_end = netizenList.end(); @@ -1194,7 +1194,7 @@ void BScreen::prevFocus(int opts) { //--------- raiseFocus ----------- // Raise the current focused window //-------------------------------- -void BScreen::raiseFocus(void) { +void BScreen::raiseFocus() { bool have_focused = false; int focused_window_number = -1; @@ -1210,7 +1210,7 @@ void BScreen::raiseFocus(void) { raiseWindow(fluxbox->getFocusedWindow()); } -void BScreen::initMenu(void) { +void BScreen::initMenu() { I18n *i18n = I18n::instance(); if (rootmenu) { @@ -1571,7 +1571,7 @@ void BScreen::createStyleMenu(Rootmenu *menu, bool newmenu, const char *label, c } -void BScreen::shutdown(void) { +void BScreen::shutdown() { fluxbox->grab(); XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask); @@ -1688,7 +1688,7 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) { } -void BScreen::hideGeometry(void) { +void BScreen::hideGeometry() { if (geom_visible) { XUnmapWindow(getBaseDisplay()->getXDisplay(), geom_window); geom_visible = false; @@ -1735,8 +1735,17 @@ bool BScreen::doSkipWindow(const FluxboxWindow *w, int opts) { (opts & CYCLESKIPSHADED) != 0 && w->isShaded()); // skip if shaded } +//----------- useAutoGroupWindow ------------- +// Access and clear the auto-group window +//-------------------------------------------- +FluxboxWindow* BScreen::useAutoGroupWindow() { + Window w = auto_group_window; + auto_group_window = 0; + return w ? Fluxbox::instance()->searchWindow(w) : 0; +} + #ifdef GNOME -void BScreen::initGnomeAtoms(void) { +void BScreen::initGnomeAtoms() { /* create the GNOME window */ gnome_win = XCreateSimpleWindow(getBaseDisplay()->getXDisplay(), diff --git a/src/Screen.hh b/src/Screen.hh index 00d429d..1f4cf89 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.39 2002/07/23 18:37:05 fluxgen Exp $ +// $Id: Screen.hh,v 1.40 2002/08/02 12:52:44 fluxgen Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -181,6 +181,7 @@ public: inline void saveDesktopWheeling(bool s) { resource.desktop_wheeling = s; } inline void iconUpdate(void) { iconmenu->update(); } inline Iconmenu *getIconmenu(void) { return iconmenu; } + inline void setAutoGroupWindow(Window w = 0) { auto_group_window = w; } #ifdef HAVE_STRFTIME @@ -230,6 +231,8 @@ public: void showGeometry(unsigned int, unsigned int); void hideGeometry(void); + FluxboxWindow* useAutoGroupWindow(void); + void updateNetizenCurrentWorkspace(void); void updateNetizenWorkspaceCount(void); void updateNetizenWindowFocus(void); @@ -293,6 +296,8 @@ private: WorkspaceNames workspaceNames; Workspaces workspacesList; + + Window auto_group_window; struct ScreenResource { ScreenResource(ResourceManager &rm, const std::string &scrname, diff --git a/src/Tab.cc b/src/Tab.cc index a98aef6..ebe8760 100644 --- a/src/Tab.cc +++ b/src/Tab.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Tab.cc,v 1.29 2002/07/23 17:11:59 fluxgen Exp $ +// $Id: Tab.cc,v 1.30 2002/08/02 12:57:19 fluxgen Exp $ #include "Tab.hh" @@ -654,11 +654,25 @@ void Tab::buttonPressEvent(XButtonEvent *be) { //draw in pressed mode draw(true); - //set window to titlewindow so we can take advatage of drag function - be->window = m_win->frame.title; + //invoke root menu with auto-glueing? + if (be->button == 3) { + BScreen *screen = m_win->getScreen(); + Rootmenu *rootmenu = screen->getRootmenu(); + if (! rootmenu->isVisible()) { + Fluxbox::instance()->checkMenu(); + screen->getRootmenu()->move(be->x_root, be->y_root-rootmenu->titleHeight()); + rootmenu->setAutoGroupWindow(m_win->getClientWindow()); + rootmenu->show(); + } + } + //otherwise let the window handle the event + else { + //set window to titlewindow so we can take advantage of drag function + be->window = m_win->frame.title; - //call windows buttonpress eventhandler - m_win->buttonPressEvent(be); + //call windows buttonpress eventhandler + m_win->buttonPressEvent(be); + } } //----------- buttonReleaseEvent ---------- @@ -1186,3 +1200,17 @@ Tab::Alignment Tab::getTabAlignmentNum(const char *string) { } return ANONE; } + +//---------- addWindowToGroup ------------ +// Add a window the the tabbed group +//---------------------------------------- +bool Tab::addWindowToGroup(FluxboxWindow *otherWindow) +{ + if (!otherWindow || otherWindow == m_win) + return false; + Tab *otherTab = otherWindow->getTab(); + if (!otherTab) + return false; + insert(otherTab); + return true; +} diff --git a/src/Tab.hh b/src/Tab.hh index e3abf51..9c73f20 100644 --- a/src/Tab.hh +++ b/src/Tab.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Tab.hh,v 1.13 2002/05/19 15:35:39 fluxgen Exp $ +// $Id: Tab.hh,v 1.14 2002/08/02 12:57:19 fluxgen Exp $ #ifndef TAB_HH #define TAB_HH @@ -81,14 +81,17 @@ public: const Tab *first() const { return getFirst(const_cast(this)); } const FluxboxWindow *getWindow() const { return m_win; } + Window getTabWindow() const { return m_tabwin; } unsigned int getTabWidth() const { return m_size_w; } unsigned int getTabHeight() const { return m_size_h; } - void resizeGroup(void); // used when (un)shading windows - void calcIncrease(void); + void resizeGroup(); // used when (un)shading windows + void calcIncrease(); bool configured() const { return m_configured; } void draw(bool pressed) const; + bool addWindowToGroup(FluxboxWindow *window); + static Tab *getFirst(Tab *current); static Tab *getLast(Tab *current); diff --git a/src/Window.cc b/src/Window.cc index 9683e5e..85f8d23 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.63 2002/07/23 17:11:59 fluxgen Exp $ +// $Id: Window.cc,v 1.64 2002/08/02 12:58:37 fluxgen Exp $ #include "Window.hh" @@ -758,7 +758,7 @@ void FluxboxWindow::grabButtons() { frame.plate, True, ButtonPressMask, GrabModeSync, GrabModeSync, None, None); XUngrabButton(display, Button1, Mod1Mask|Mod2Mask|Mod3Mask, frame.plate); - + XGrabButton(display, Button1, Mod1Mask, frame.window, True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, @@ -768,7 +768,7 @@ void FluxboxWindow::grabButtons() { grabButton(display, Button1, frame.window, fluxbox->getMoveCursor()); XGrabButton(display, Button2, Mod1Mask, frame.window, True, - ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); + ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None); XGrabButton(display, Button3, Mod1Mask, frame.window, True, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, @@ -2788,6 +2788,17 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent *ne) { visible = true; iconic = false; + // Auto-group? + if (!transient) { + // Grab and clear the auto-group window + FluxboxWindow* autoGroupWindow = screen->useAutoGroupWindow(); + if (autoGroupWindow) { + Tab *groupTab = autoGroupWindow->getTab(); + if (groupTab) + groupTab->addWindowToGroup(this); + } + } + fluxbox->ungrab(); } } -- cgit v0.11.2