added autogrouping-from-tab patch from Steve Cooper

This commit is contained in:
fluxgen 2002-08-02 12:58:37 +00:00
parent 378c946d89
commit c28bd74feb
8 changed files with 119 additions and 30 deletions

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 #ifndef BASEMENU_HH
#define BASEMENU_HH #define BASEMENU_HH
@ -126,6 +126,8 @@ protected:
int x= -1, int y= -1, unsigned int width= 0, unsigned int height= 0); int x= -1, int y= -1, unsigned int width= 0, unsigned int height= 0);
virtual void redrawTitle(); virtual void redrawTitle();
virtual void internal_hide(); virtual void internal_hide();
inline Basemenu *GetParent() { return m_parent; }
inline const Basemenu *GetParent() const { return m_parent; }
}; };
class BasemenuItem { class BasemenuItem {

View file

@ -50,7 +50,10 @@
#endif // MAXPATHLEN #endif // MAXPATHLEN
Rootmenu::Rootmenu(BScreen *scrn) : Basemenu(scrn) { Rootmenu::Rootmenu(BScreen *scrn)
: Basemenu(scrn),
auto_group_window(0)
{
screen = scrn; screen = scrn;
} }
@ -73,7 +76,10 @@ void Rootmenu::itemSelected(int button, unsigned int index) {
sprintf(displaystring + strlen(displaystring) - 1, "%d", sprintf(displaystring + strlen(displaystring) - 1, "%d",
screen->getScreenNumber()); screen->getScreenNumber());
screen->setAutoGroupWindow(useAutoGroupWindow());
bexec(item->exec().c_str(), displaystring); bexec(item->exec().c_str(), displaystring);
#else // __EMX__ #else // __EMX__
spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL); spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL);
#endif // !__EMX__ #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<Rootmenu*>(GetParent());
if (parent)
w = parent->useAutoGroupWindow();
}
return w;
}

View file

@ -32,6 +32,7 @@ class BScreen;
class Rootmenu : public Basemenu { class Rootmenu : public Basemenu {
private: private:
BScreen *screen; BScreen *screen;
Window auto_group_window;
protected: protected:
@ -40,6 +41,11 @@ protected:
public: public:
Rootmenu(BScreen *); Rootmenu(BScreen *);
void setAutoGroupWindow(Window window);
private:
Window useAutoGroupWindow();
}; };

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 //use GNU extensions
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
@ -474,7 +474,7 @@ namespace {
} }
} }
BScreen::~BScreen(void) { BScreen::~BScreen() {
#ifdef GNOME #ifdef GNOME
XDestroyWindow(getBaseDisplay()->getXDisplay(), gnome_win); XDestroyWindow(getBaseDisplay()->getXDisplay(), gnome_win);
#endif #endif
@ -548,7 +548,7 @@ BScreen::~BScreen(void) {
} }
void BScreen::reconfigure(void) { void BScreen::reconfigure() {
#ifdef DEBUG #ifdef DEBUG
cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl; cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl;
#endif #endif
@ -653,7 +653,7 @@ void BScreen::reconfigure(void) {
} }
void BScreen::rereadMenu(void) { void BScreen::rereadMenu() {
initMenu(); initMenu();
raiseWindows(0, 0); raiseWindows(0, 0);
@ -661,11 +661,11 @@ void BScreen::rereadMenu(void) {
} }
void BScreen::removeWorkspaceNames(void) { void BScreen::removeWorkspaceNames() {
workspaceNames.erase(workspaceNames.begin(), workspaceNames.end()); workspaceNames.erase(workspaceNames.begin(), workspaceNames.end());
} }
void BScreen::updateWorkspaceNamesAtom(void) { void BScreen::updateWorkspaceNamesAtom() {
#ifdef GNOME #ifdef GNOME
XTextProperty text; XTextProperty text;
@ -741,7 +741,7 @@ FluxboxWindow *BScreen::getIcon(unsigned int index) {
} }
int BScreen::addWorkspace(void) { int BScreen::addWorkspace() {
Workspace *wkspc = new Workspace(this, workspacesList.size()); Workspace *wkspc = new Workspace(this, workspacesList.size());
workspacesList.push_back(wkspc); workspacesList.push_back(wkspc);
//add workspace to workspacemenu //add workspace to workspacemenu
@ -760,7 +760,7 @@ int BScreen::addWorkspace(void) {
} }
int BScreen::removeLastWorkspace(void) { int BScreen::removeLastWorkspace() {
if (workspacesList.size() > 1) { if (workspacesList.size() > 1) {
Workspace *wkspc = workspacesList.back(); Workspace *wkspc = workspacesList.back();
@ -888,7 +888,7 @@ void BScreen::removeNetizen(Window w) {
} }
void BScreen::updateNetizenCurrentWorkspace(void) { void BScreen::updateNetizenCurrentWorkspace() {
#ifdef NEWWMSPEC #ifdef NEWWMSPEC
//update _NET_WM_CURRENT_DESKTOP //update _NET_WM_CURRENT_DESKTOP
int workspace = getCurrentWorkspaceID(); 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 = netizenList.begin();
Netizens::iterator it_end = netizenList.end(); 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 = netizenList.begin();
Netizens::iterator it_end = netizenList.end(); Netizens::iterator it_end = netizenList.end();
@ -1194,7 +1194,7 @@ void BScreen::prevFocus(int opts) {
//--------- raiseFocus ----------- //--------- raiseFocus -----------
// Raise the current focused window // Raise the current focused window
//-------------------------------- //--------------------------------
void BScreen::raiseFocus(void) { void BScreen::raiseFocus() {
bool have_focused = false; bool have_focused = false;
int focused_window_number = -1; int focused_window_number = -1;
@ -1210,7 +1210,7 @@ void BScreen::raiseFocus(void) {
raiseWindow(fluxbox->getFocusedWindow()); raiseWindow(fluxbox->getFocusedWindow());
} }
void BScreen::initMenu(void) { void BScreen::initMenu() {
I18n *i18n = I18n::instance(); I18n *i18n = I18n::instance();
if (rootmenu) { 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(); fluxbox->grab();
XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask); 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) { if (geom_visible) {
XUnmapWindow(getBaseDisplay()->getXDisplay(), geom_window); XUnmapWindow(getBaseDisplay()->getXDisplay(), geom_window);
geom_visible = false; geom_visible = false;
@ -1735,8 +1735,17 @@ bool BScreen::doSkipWindow(const FluxboxWindow *w, int opts) {
(opts & CYCLESKIPSHADED) != 0 && w->isShaded()); // skip if shaded (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 #ifdef GNOME
void BScreen::initGnomeAtoms(void) { void BScreen::initGnomeAtoms() {
/* create the GNOME window */ /* create the GNOME window */
gnome_win = XCreateSimpleWindow(getBaseDisplay()->getXDisplay(), gnome_win = XCreateSimpleWindow(getBaseDisplay()->getXDisplay(),

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 #ifndef SCREEN_HH
#define SCREEN_HH #define SCREEN_HH
@ -181,6 +181,7 @@ public:
inline void saveDesktopWheeling(bool s) { resource.desktop_wheeling = s; } inline void saveDesktopWheeling(bool s) { resource.desktop_wheeling = s; }
inline void iconUpdate(void) { iconmenu->update(); } inline void iconUpdate(void) { iconmenu->update(); }
inline Iconmenu *getIconmenu(void) { return iconmenu; } inline Iconmenu *getIconmenu(void) { return iconmenu; }
inline void setAutoGroupWindow(Window w = 0) { auto_group_window = w; }
#ifdef HAVE_STRFTIME #ifdef HAVE_STRFTIME
@ -230,6 +231,8 @@ public:
void showGeometry(unsigned int, unsigned int); void showGeometry(unsigned int, unsigned int);
void hideGeometry(void); void hideGeometry(void);
FluxboxWindow* useAutoGroupWindow(void);
void updateNetizenCurrentWorkspace(void); void updateNetizenCurrentWorkspace(void);
void updateNetizenWorkspaceCount(void); void updateNetizenWorkspaceCount(void);
void updateNetizenWindowFocus(void); void updateNetizenWindowFocus(void);
@ -294,6 +297,8 @@ private:
WorkspaceNames workspaceNames; WorkspaceNames workspaceNames;
Workspaces workspacesList; Workspaces workspacesList;
Window auto_group_window;
struct ScreenResource { struct ScreenResource {
ScreenResource(ResourceManager &rm, const std::string &scrname, ScreenResource(ResourceManager &rm, const std::string &scrname,
const std::string &altscrname); const std::string &altscrname);

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #include "Tab.hh"
@ -654,11 +654,25 @@ void Tab::buttonPressEvent(XButtonEvent *be) {
//draw in pressed mode //draw in pressed mode
draw(true); draw(true);
//set window to titlewindow so we can take advatage of drag function //invoke root menu with auto-glueing?
be->window = m_win->frame.title; 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 //call windows buttonpress eventhandler
m_win->buttonPressEvent(be); m_win->buttonPressEvent(be);
}
} }
//----------- buttonReleaseEvent ---------- //----------- buttonReleaseEvent ----------
@ -1186,3 +1200,17 @@ Tab::Alignment Tab::getTabAlignmentNum(const char *string) {
} }
return ANONE; 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;
}

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 #ifndef TAB_HH
#define TAB_HH #define TAB_HH
@ -81,14 +81,17 @@ public:
const Tab *first() const { return getFirst(const_cast<Tab *>(this)); } const Tab *first() const { return getFirst(const_cast<Tab *>(this)); }
const FluxboxWindow *getWindow() const { return m_win; } const FluxboxWindow *getWindow() const { return m_win; }
Window getTabWindow() const { return m_tabwin; }
unsigned int getTabWidth() const { return m_size_w; } unsigned int getTabWidth() const { return m_size_w; }
unsigned int getTabHeight() const { return m_size_h; } unsigned int getTabHeight() const { return m_size_h; }
void resizeGroup(void); // used when (un)shading windows void resizeGroup(); // used when (un)shading windows
void calcIncrease(void); void calcIncrease();
bool configured() const { return m_configured; } bool configured() const { return m_configured; }
void draw(bool pressed) const; void draw(bool pressed) const;
bool addWindowToGroup(FluxboxWindow *window);
static Tab *getFirst(Tab *current); static Tab *getFirst(Tab *current);
static Tab *getLast(Tab *current); static Tab *getLast(Tab *current);

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #include "Window.hh"
@ -2788,6 +2788,17 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent *ne) {
visible = true; visible = true;
iconic = false; 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(); fluxbox->ungrab();
} }
} }