2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
2008-09-22 13:03:00 +00:00
|
|
|
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifndef KWIN_PRESENTWINDOWS_H
|
|
|
|
#define KWIN_PRESENTWINDOWS_H
|
|
|
|
|
2009-02-06 10:15:06 +00:00
|
|
|
#include "presentwindows_proxy.h"
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <kwineffects.h>
|
2009-03-30 11:27:57 +00:00
|
|
|
#include <kshortcut.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expose-like effect which shows all windows on current desktop side-by-side,
|
|
|
|
* letting the user select active window.
|
|
|
|
**/
|
|
|
|
class PresentWindowsEffect
|
|
|
|
: public QObject, public Effect
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2008-09-22 13:03:00 +00:00
|
|
|
private:
|
|
|
|
// Structures
|
|
|
|
struct WindowData
|
|
|
|
{
|
|
|
|
bool visible;
|
2009-07-14 09:06:37 +00:00
|
|
|
bool deleted;
|
|
|
|
bool referenced;
|
2008-09-22 13:03:00 +00:00
|
|
|
double opacity;
|
|
|
|
double highlight;
|
|
|
|
int slot;
|
|
|
|
int slot_distance;
|
2009-02-22 13:04:16 +00:00
|
|
|
EffectFrame* textFrame;
|
|
|
|
EffectFrame* iconFrame;
|
2008-09-22 13:03:00 +00:00
|
|
|
};
|
|
|
|
typedef QHash<EffectWindow*, WindowData> DataHash;
|
|
|
|
struct GridSize
|
|
|
|
{
|
|
|
|
int columns;
|
|
|
|
int rows;
|
|
|
|
};
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
public:
|
|
|
|
PresentWindowsEffect();
|
|
|
|
virtual ~PresentWindowsEffect();
|
|
|
|
|
2008-10-02 09:27:32 +00:00
|
|
|
virtual void reconfigure( ReconfigureFlags );
|
2009-09-02 02:30:22 +00:00
|
|
|
virtual void* proxy();
|
2009-02-06 10:15:06 +00:00
|
|
|
|
2008-09-22 13:03:00 +00:00
|
|
|
// Screen painting
|
|
|
|
virtual void prePaintScreen( ScreenPrePaintData &data, int time );
|
|
|
|
virtual void paintScreen( int mask, QRegion region, ScreenPaintData &data );
|
2007-04-29 17:35:43 +00:00
|
|
|
virtual void postPaintScreen();
|
|
|
|
|
2008-09-22 13:03:00 +00:00
|
|
|
// Window painting
|
|
|
|
virtual void prePaintWindow( EffectWindow *w, WindowPrePaintData &data, int time );
|
|
|
|
virtual void paintWindow( EffectWindow *w, int mask, QRegion region, WindowPaintData &data );
|
|
|
|
|
|
|
|
// User interaction
|
|
|
|
virtual void windowAdded( EffectWindow *w );
|
|
|
|
virtual void windowClosed( EffectWindow *w );
|
2008-09-23 03:16:36 +00:00
|
|
|
virtual void windowDeleted( EffectWindow *w );
|
2007-04-29 17:35:43 +00:00
|
|
|
virtual bool borderActivated( ElectricBorder border );
|
2008-09-22 13:03:00 +00:00
|
|
|
virtual void windowInputMouseEvent( Window w, QEvent *e );
|
|
|
|
virtual void grabbedKeyboardEvent( QKeyEvent *e );
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-09-22 13:03:00 +00:00
|
|
|
// Tab box
|
2008-08-13 12:25:19 +00:00
|
|
|
virtual void tabBoxAdded( int mode );
|
|
|
|
virtual void tabBoxClosed();
|
|
|
|
virtual void tabBoxUpdated();
|
2009-10-30 09:16:41 +00:00
|
|
|
virtual void tabBoxKeyEvent( QKeyEvent* event );
|
2008-08-13 12:25:19 +00:00
|
|
|
|
2009-06-27 10:21:49 +00:00
|
|
|
// atoms
|
|
|
|
virtual void propertyNotify( EffectWindow* w, long atom );
|
|
|
|
|
2008-08-25 09:17:15 +00:00
|
|
|
enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes
|
2009-06-27 10:21:49 +00:00
|
|
|
enum PresentWindowsMode
|
|
|
|
{
|
|
|
|
ModeAllDesktops, // Shows windows of all desktops
|
|
|
|
ModeCurrentDesktop, // Shows windows on current desktop
|
|
|
|
ModeSelectedDesktop, // Shows windows of selected desktop via property (m_desktop)
|
2009-06-30 19:11:02 +00:00
|
|
|
ModeWindowGroup, // Shows windows selected via property
|
|
|
|
ModeWindowClass // Shows all windows of same class as selected class
|
2009-06-27 10:21:49 +00:00
|
|
|
};
|
2009-06-28 17:17:29 +00:00
|
|
|
enum WindowMouseAction
|
|
|
|
{
|
2009-06-28 17:56:06 +00:00
|
|
|
WindowNoAction = 0, // Nothing
|
|
|
|
WindowActivateAction = 1, // Activates the window and deactivates the effect
|
|
|
|
WindowExitAction = 2, // Deactivates the effect without activating new window
|
|
|
|
WindowToCurrentDesktopAction = 3, // Brings window to current desktop
|
|
|
|
WindowToAllDesktopsAction = 4, // Brings window to all desktops
|
|
|
|
WindowMinimizeAction = 5, // Minimize the window
|
|
|
|
WindowCloseAction = 6 // Closes the window
|
2009-06-28 17:17:29 +00:00
|
|
|
};
|
|
|
|
enum DesktopMouseAction
|
|
|
|
{
|
2009-06-28 17:56:06 +00:00
|
|
|
DesktopNoAction = 0, // nothing
|
|
|
|
DesktopActivateAction = 1, // Activates the window and deactivates the effect
|
|
|
|
DesktopExitAction = 2, // Deactivates the effect without activating new window
|
|
|
|
DesktopShowDesktopAction = 3 // Minimizes all windows
|
2009-06-28 17:17:29 +00:00
|
|
|
};
|
2008-08-25 09:17:15 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
public slots:
|
2008-12-13 09:02:27 +00:00
|
|
|
void setActive( bool active, bool closingTab = false ); // HACK: closingTab shouldn't be needed
|
2009-06-27 10:21:49 +00:00
|
|
|
void toggleActive() { m_mode = ModeCurrentDesktop; setActive( !m_activated ); }
|
|
|
|
void toggleActiveAllDesktops() { m_mode = ModeAllDesktops; setActive( !m_activated ); }
|
2009-06-30 19:11:02 +00:00
|
|
|
void toggleActiveClass();
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-03-30 11:27:57 +00:00
|
|
|
// slots for global shortcut changed
|
|
|
|
// needed to toggle the effect
|
|
|
|
void globalShortcutChanged( const QKeySequence& seq );
|
|
|
|
void globalShortcutChangedAll( const QKeySequence& seq );
|
2009-06-30 19:11:02 +00:00
|
|
|
void globalShortcutChangedClass( const QKeySequence& seq );
|
2009-03-30 11:27:57 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
protected:
|
2008-09-22 13:03:00 +00:00
|
|
|
// Window rearranging
|
2007-04-29 17:35:43 +00:00
|
|
|
void rearrangeWindows();
|
2008-09-22 13:03:00 +00:00
|
|
|
void calculateWindowTransformationsClosest( EffectWindowList windowlist, int screen );
|
|
|
|
void calculateWindowTransformationsKompose( EffectWindowList windowlist, int screen );
|
|
|
|
void calculateWindowTransformationsNatural( EffectWindowList windowlist, int screen );
|
|
|
|
|
|
|
|
// Helper functions for window rearranging
|
|
|
|
inline double aspectRatio( EffectWindow *w )
|
|
|
|
{ return w->width() / double( w->height() ); }
|
|
|
|
inline int widthForHeight( EffectWindow *w, int height )
|
|
|
|
{ return int(( height / double( w->height() )) * w->width() ); }
|
|
|
|
inline int heightForWidth( EffectWindow *w, int width )
|
|
|
|
{ return int(( width / double( w->width() )) * w->height() ); }
|
|
|
|
void assignSlots( EffectWindowList windowlist, const QRect &area, int columns, int rows );
|
2008-06-10 15:49:49 +00:00
|
|
|
void getBestAssignments( EffectWindowList windowlist );
|
2008-09-22 13:03:00 +00:00
|
|
|
bool isOverlappingAny( EffectWindow *w, const QHash<EffectWindow*, QRect> &targets, const QRegion &border );
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-09-22 13:03:00 +00:00
|
|
|
// Filter box
|
2009-02-21 04:53:13 +00:00
|
|
|
void updateFilterFrame();
|
2007-07-05 11:41:02 +00:00
|
|
|
|
2008-09-22 13:03:00 +00:00
|
|
|
// Helper functions
|
|
|
|
bool isSelectableWindow( EffectWindow *w );
|
|
|
|
bool isVisibleWindow( EffectWindow *w );
|
|
|
|
void setHighlightedWindow( EffectWindow *w );
|
|
|
|
EffectWindow* relativeWindow( EffectWindow *w, int xdiff, int ydiff, bool wrap ) const;
|
2007-11-21 11:57:09 +00:00
|
|
|
EffectWindow* findFirstWindow() const;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-06-28 17:17:29 +00:00
|
|
|
// Helper functions for mouse actions
|
|
|
|
void mouseActionWindow( WindowMouseAction& action );
|
|
|
|
void mouseActionDesktop( DesktopMouseAction& action );
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
private:
|
2009-02-06 10:15:06 +00:00
|
|
|
PresentWindowsEffectProxy m_proxy;
|
|
|
|
friend class PresentWindowsEffectProxy;
|
|
|
|
|
2008-09-22 13:03:00 +00:00
|
|
|
// User configuration settings
|
2009-03-29 12:57:20 +00:00
|
|
|
QList<ElectricBorder> m_borderActivate;
|
|
|
|
QList<ElectricBorder> m_borderActivateAll;
|
2008-09-22 13:03:00 +00:00
|
|
|
int m_layoutMode;
|
|
|
|
bool m_showCaptions;
|
|
|
|
bool m_showIcons;
|
|
|
|
bool m_tabBoxAllowed;
|
2009-09-13 11:36:45 +00:00
|
|
|
bool m_tabBoxAlternativeAllowed;
|
2008-09-22 13:03:00 +00:00
|
|
|
int m_accuracy;
|
|
|
|
bool m_fillGaps;
|
|
|
|
double m_fadeDuration;
|
2009-01-13 10:19:47 +00:00
|
|
|
bool m_showPanel;
|
2008-09-22 13:03:00 +00:00
|
|
|
|
|
|
|
// Activation
|
|
|
|
bool m_activated;
|
2008-10-21 07:15:35 +00:00
|
|
|
bool m_ignoreMinimized;
|
2008-09-22 13:03:00 +00:00
|
|
|
double m_decalOpacity;
|
|
|
|
Window m_input;
|
|
|
|
bool m_hasKeyboardGrab;
|
|
|
|
bool m_tabBoxEnabled;
|
2009-06-27 10:21:49 +00:00
|
|
|
PresentWindowsMode m_mode;
|
|
|
|
int m_desktop;
|
|
|
|
EffectWindowList m_selectedWindows;
|
|
|
|
EffectWindow *m_managerWindow;
|
2009-06-30 19:11:02 +00:00
|
|
|
QString m_class;
|
2008-09-22 13:03:00 +00:00
|
|
|
|
|
|
|
// Window data
|
|
|
|
WindowMotionManager m_motionManager;
|
|
|
|
DataHash m_windowData;
|
|
|
|
EffectWindow *m_highlightedWindow;
|
|
|
|
|
|
|
|
// Grid layout info
|
|
|
|
QList<GridSize> m_gridSizes;
|
|
|
|
|
|
|
|
// Filter box
|
2009-02-21 04:53:13 +00:00
|
|
|
EffectFrame m_filterFrame;
|
2008-09-22 13:03:00 +00:00
|
|
|
QString m_windowFilter;
|
2009-03-30 11:27:57 +00:00
|
|
|
|
|
|
|
// Shortcut - needed to toggle the effect
|
|
|
|
KShortcut shortcut;
|
|
|
|
KShortcut shortcutAll;
|
2009-06-30 19:11:02 +00:00
|
|
|
KShortcut shortcutClass;
|
2009-06-27 10:21:49 +00:00
|
|
|
|
|
|
|
// Atoms
|
|
|
|
// Present windows for all windows of given desktop
|
|
|
|
// -1 for all desktops
|
|
|
|
long m_atomDesktop;
|
|
|
|
// Present windows for group of window ids
|
|
|
|
long m_atomWindows;
|
2009-06-28 17:17:29 +00:00
|
|
|
|
|
|
|
// Mouse Actions
|
|
|
|
WindowMouseAction m_leftButtonWindow;
|
|
|
|
WindowMouseAction m_middleButtonWindow;
|
|
|
|
WindowMouseAction m_rightButtonWindow;
|
|
|
|
DesktopMouseAction m_leftButtonDesktop;
|
|
|
|
DesktopMouseAction m_middleButtonDesktop;
|
|
|
|
DesktopMouseAction m_rightButtonDesktop;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|