Add support for window tiling to the taskbar and window's popup menus. This relates to TDE/tdebase#349.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 4cd5817775)
r14.1.x
Michele Calgaro 3 months ago
parent 673e48af90
commit 72fce97c2e
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <tqimage.h>
#include <tqtimer.h>
#include <tdeapplication.h>
#include <tdeconfig.h>
#include <kdebug.h>
#include <tdeglobal.h>
@ -36,6 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <twinmodule.h>
#include <kxerrorhandler.h>
#include <netwm.h>
#include "dcopclient.h"
#include "taskmanager.h"
#include "taskmanager.moc"
@ -1452,6 +1454,14 @@ void Task::updateWindowPixmap()
#endif // THUMBNAILING_POSSIBLE
}
void Task::tileTo(int position)
{
TQByteArray params;
TQDataStream stream(params, IO_WriteOnly);
stream << _win << position;
TDEApplication::kApplication()->dcopClient()->send("twin", "KWinInterface", "tileWindowToBorder(unsigned long int, int)", params);
}
Startup::Startup(const TDEStartupInfoId& id, const TDEStartupInfoData& data,
TQObject * parent, const char *name)
: TQObject(parent, name), _id(id), _data(data)

@ -423,6 +423,12 @@ public slots:
*/
void updateThumbnail();
/**
* Tile the task's window to the specified position. The position is one of the
* valid value for ActiveBorder enum
*/
void tileTo(int);
signals:
/**
* Indicates that this task has changed in some way.

@ -68,9 +68,14 @@ void TaskRMBMenu::fillMenu(Task::Ptr t)
int id;
setCheckable(true);
insertItem(i18n("Ad&vanced"), makeAdvancedMenu(t));
bool checkActions = KWin::allowedActionsSupported();
insertItem(i18n("Ad&vanced"), makeAdvancedMenu(t));
id = insertItem(i18n("T&ile"), makeTileMenu(t));
setItemEnabled(id, !checkActions ||
(t->info().actionSupported(NET::ActionMove) && t->info().actionSupported(NET::ActionResize)));
if (TaskManager::the()->numberOfDesktops() > 1)
{
id = insertItem(i18n("To &Desktop"), makeDesktopsMenu(t));
@ -280,6 +285,33 @@ TQPopupMenu* TaskRMBMenu::makeDesktopsMenu()
return m;
}
TQPopupMenu* TaskRMBMenu::makeTileMenu(Task::Ptr t)
{
TQPopupMenu *m = new TQPopupMenu( this );
// Tile to side (the menu id matched the ActiveBorder index used for tiling)
int id = m->insertItem( i18n("&Left"), this, TQ_SLOT( slotTileTo(int) ) );
m->setItemParameter( id, 6 );
id = m->insertItem( i18n("&Right"), this, TQ_SLOT( slotTileTo(int) ) );
m->setItemParameter( id, 2 );
id = m->insertItem( i18n("&Top"), this, TQ_SLOT( slotTileTo(int) ) );
m->setItemParameter( id, 0 );
id = m->insertItem( i18n("&Bottom"), this, TQ_SLOT( slotTileTo(int) ) );
m->setItemParameter( id, 4 );
// Tile to corner (the menu id matched the ActiveBorder index used for tiling)
id = m->insertItem( i18n("Top &Left"), this, TQ_SLOT( slotTileTo(int) ) );
m->setItemParameter( id, 7 );
id = m->insertItem( i18n("Top &Right"), this, TQ_SLOT( slotTileTo(int) ) );
m->setItemParameter( id, 1 );
id = m->insertItem( i18n("Bottom L&eft"), this, TQ_SLOT( slotTileTo(int) ) );
m->setItemParameter( id, 5 );
id = m->insertItem( i18n("&Bottom R&ight"), this, TQ_SLOT( slotTileTo(int) ) );
m->setItemParameter( id, 3 );
return m;
}
void TaskRMBMenu::slotMinimizeAll()
{
Task::List::iterator itEnd = tasks.end();
@ -342,3 +374,12 @@ void TaskRMBMenu::slotAllToCurrentDesktop()
(*it)->toCurrentDesktop();
}
}
void TaskRMBMenu::slotTileTo(int position)
{
Task::List::iterator itEnd = tasks.end();
for (Task::List::iterator it = tasks.begin(); it != itEnd; ++it)
{
(*it)->tileTo(position);
}
}

@ -38,9 +38,10 @@ public:
private:
void fillMenu(Task::Ptr);
void fillMenu();
TQPopupMenu* makeAdvancedMenu(Task::Ptr);
TQPopupMenu* makeAdvancedMenu(Task::Ptr);
TQPopupMenu* makeDesktopsMenu(Task::Ptr);
TQPopupMenu* makeDesktopsMenu();
TQPopupMenu* makeTileMenu(Task::Ptr);
private slots:
void slotMinimizeAll();
@ -48,8 +49,9 @@ private slots:
void slotRestoreAll();
void slotShadeAll();
void slotCloseAll();
void slotAllToDesktop( int desktop );
void slotAllToDesktop(int desktop);
void slotAllToCurrentDesktop();
void slotTileTo(int position);
private:
Task::List tasks;

@ -44,6 +44,33 @@ namespace KWinInternal
// Workspace
//****************************************
TQPopupMenu* Workspace::makeTileMenu()
{
TQPopupMenu *m = new TQPopupMenu;
// Tile to side (the menu id matched the ActiveBorder index used for tiling)
int id = m->insertItem( i18n("&Left"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
m->setItemParameter( id, 6 );
id = m->insertItem( i18n("&Right"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
m->setItemParameter( id, 2 );
id = m->insertItem( i18n("&Top"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
m->setItemParameter( id, 0 );
id = m->insertItem( i18n("&Bottom"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
m->setItemParameter( id, 4 );
// Tile to corner (the menu id matched the ActiveBorder index used for tiling)
id = m->insertItem( i18n("Top &Left"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
m->setItemParameter( id, 7 );
id = m->insertItem( i18n("Top &Right"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
m->setItemParameter( id, 1 );
id = m->insertItem( i18n("Bottom L&eft"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
m->setItemParameter( id, 5 );
id = m->insertItem( i18n("&Bottom R&ight"), this, TQ_SLOT( tileCurrentWindowToBorder(int) ) );
m->setItemParameter( id, 3 );
return m;
}
TQPopupMenu* Workspace::clientPopup()
{
if ( !popup )
@ -76,6 +103,7 @@ TQPopupMenu* Workspace::clientPopup()
advanced_popup->insertItem( SmallIconSet( "wizard" ), i18n("&Special Application Settings…"), Options::ApplicationRulesOp );
popup->insertItem(i18n("Ad&vanced"), advanced_popup );
tile_popup_index = popup->insertItem(i18n("T&ile"), makeTileMenu());
desk_popup_index = popup->count();
if (options->useTranslucency){
@ -179,10 +207,11 @@ void Workspace::clientPopupAboutToShow()
advanced_popup->setItemEnabled( Options::ResumeWindowOp, active_popup_client->isResumeable() );
advanced_popup->setItemChecked( Options::NoBorderOp, active_popup_client->noBorder() );
advanced_popup->setItemEnabled( Options::NoBorderOp, active_popup_client->userCanSetNoBorder() );
advanced_popup->setItemEnabled( Options::ShadowOp, (options->shadowWindowType(active_popup_client->windowType()) && options->shadowEnabled(active_popup_client->isActive())) );
advanced_popup->setItemChecked( Options::ShadowOp, active_popup_client->isShadowed() );
popup->setItemEnabled( tile_popup_index, active_popup_client->isMovable() && active_popup_client->isResizable());
popup->setItemEnabled( Options::MinimizeOp, active_popup_client->isMinimizable() );
popup->setItemEnabled( Options::CloseOp, active_popup_client->isCloseable() );
if (options->useTranslucency)
@ -664,6 +693,14 @@ void Workspace::showWindowMenu( unsigned long window )
}
}
void Workspace::tileCurrentWindowToBorder(int position)
{
Client *c = active_popup_client ? active_popup_client : active_client;
if (!c) return;
c->tileToBorder((ActiveBorder)position);
}
void Workspace::tileWindowToBorder(unsigned long w1, int location) {
if (location < ActiveTop || location >= ACTIVE_BORDER_COUNT) return;

@ -415,6 +415,7 @@ class Workspace : public TQObject, public KWinInterface, public KDecorationDefin
void writeWindowRules();
void kipcMessage( int id, int data );
void updateActiveBorders();
void tileCurrentWindowToBorder(int position);
// kompmgr
void setPopupClientOpacity(int v);
void resetClientOpacity();
@ -506,6 +507,7 @@ class Workspace : public TQObject, public KWinInterface, public KDecorationDefin
void calcDesktopLayout(int &x, int &y) const;
TQPopupMenu* makeTileMenu();
TQPopupMenu* clientPopup();
void closeActivePopup();
@ -590,6 +592,7 @@ class Workspace : public TQObject, public KWinInterface, public KDecorationDefin
TQPopupMenu *advanced_popup;
TQPopupMenu *desk_popup;
int desk_popup_index;
int tile_popup_index;
TDEGlobalAccel *keys;
TDEGlobalAccel *client_keys;

Loading…
Cancel
Save