~mc-return/compiz/compiz.merge-fix1166195-fix1166196-fix116245-resizeinfo-fixes

« back to all changes in this revision

Viewing changes to plugins/showdesktop/src/showdesktop.h

Show Desktop Upgrade:

Renamed "Show desktop" to "Show Desktop" (uppercase).

New features:

* Added individual movement options for all 4 corners.

* Implemented the new movement direction option "Intelligent Random".
  This option will make windows slide out of view in one of 3
  random directions (Top/Bottom / Left/Right / ToCorners) using the
  shortest movement distance, when Show Desktop is invoked.

* Also implemented a "Fully Random" movement direction mode, which will
  move every window out of view using one of 8 randomly chosen directions
  (one of 4 corners or one of 4 edges of the virtual screen).

enum IRDirection represents allowed directions in Intelligent Random
Direction mode, while enum FRDirection represents allowed directions
in Fully Random Direction mode.

Refactored ShowdesktopPlacer:
1. Removed #define macros and replaced them with inline functions in ::.
2. Refactored out the offset algorithms into separate functions.
3. Placed the actual offset + setting algorithms into ShowdesktopPlacer
and re-used where appropriate. This reduces the size of
ShowdesktopWindow::repositionPlacer.

Simplified void ShowdesktopScreen::donePaint () and removed redundant
damageScreen () call.

Removal of redundant brackets, declaration and assignment of variables in
the same line, indentation fixes, readability improvements and general
cleanup.

(LP: #1161343). Fixes: https://bugs.launchpad.net/bugs/1161343.

Approved by PS Jenkins bot, MC Return.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
#include "showdesktop_options.h"
43
43
 
44
 
#define WIN_X(w) ((w)->x () - (w)->border ().left)
45
 
#define WIN_Y(w) ((w)->y () - (w)->border ().top)
46
 
#define WIN_W(w) ((w)->width () + (w)->border ().left + (w)->border ().right)
47
 
#define WIN_H(w) ((w)->height () + (w)->border ().top + (w)->border ().bottom)
48
 
 
49
 
#define OFF_LEFT(w) ((w)->width () + (w)->border ().right)
50
 
#define OFF_RIGHT(w) ((w)->border ().left)
51
 
#define OFF_TOP(w) ((w)->height () + (w)->border ().bottom)
52
 
#define OFF_BOTTOM(w) ((w)->border ().top)
53
 
 
54
 
#define MOVE_LEFT(w) ((WIN_X (w) + (WIN_W (w) / 2)) < (screen->width () / 2))
55
 
#define MOVE_UP(w) ((WIN_Y (w) + (WIN_H (w) / 2)) < (screen->height () / 2))
56
 
 
57
44
extern const unsigned short SD_STATE_OFF;
58
45
extern const unsigned short SD_STATE_ACTIVATING;
59
46
extern const unsigned short SD_STATE_ON;
60
47
extern const unsigned short SD_STATE_DEACTIVATING;
61
48
 
 
49
/* Initialize the enums containing allowed directions
 
50
 * for intelligent random and fully random direction modes */
 
51
 
 
52
enum IRDirection
 
53
{
 
54
    IntelligentRandomToCorners,
 
55
    IntelligentRandomUpDown,
 
56
    IntelligentRandomLeftRight
 
57
};
 
58
 
 
59
enum FRDirection
 
60
{
 
61
    FullRandomUp,
 
62
    FullRandomDown,
 
63
    FullRandomLeft,
 
64
    FullRandomRight,
 
65
    FullRandomTopLeft,
 
66
    FullRandomBottomLeft,
 
67
    FullRandomTopRight,
 
68
    FullRandomBottomRight
 
69
};
 
70
 
62
71
class ShowdesktopPlacer
63
72
{
64
73
    public:
65
74
        ShowdesktopPlacer ();
66
75
 
 
76
        void up (const CompRect                         &workArea,
 
77
                 const compiz::window::Geometry         &geometry,
 
78
                 const compiz::window::extents::Extents &border,
 
79
                 int                                    partSize);
 
80
 
 
81
        void down (const CompRect                         &workArea,
 
82
                   const compiz::window::Geometry         &geometry,
 
83
                   const compiz::window::extents::Extents &border,
 
84
                   int                                    partSize);
 
85
 
 
86
        void left (const CompRect                         &workArea,
 
87
                   const compiz::window::Geometry         &geometry,
 
88
                   const compiz::window::extents::Extents &border,
 
89
                   int                                    partSize);
 
90
 
 
91
        void right (const CompRect                         &workArea,
 
92
                    const compiz::window::Geometry         &geometry,
 
93
                    const compiz::window::extents::Extents &border,
 
94
                    int                                    partSize);
 
95
 
 
96
        void topLeft (const CompRect                         &workArea,
 
97
                      const compiz::window::Geometry         &geometry,
 
98
                      const compiz::window::extents::Extents &border,
 
99
                      int                                    partSize);
 
100
 
 
101
        void topRight (const CompRect                         &workArea,
 
102
                       const compiz::window::Geometry         &geometry,
 
103
                       const compiz::window::extents::Extents &border,
 
104
                       int                                    partSize);
 
105
 
 
106
        void bottomLeft (const CompRect                         &workArea,
 
107
                         const compiz::window::Geometry         &geometry,
 
108
                         const compiz::window::extents::Extents &border,
 
109
                         int                                    partSize);
 
110
 
 
111
        void bottomRight (const CompRect                         &workArea,
 
112
                          const compiz::window::Geometry         &geometry,
 
113
                          const compiz::window::extents::Extents &border,
 
114
                          int                                    partSize);
 
115
 
 
116
        void upOrDown (const CompRect                         &workArea,
 
117
                       const compiz::window::Geometry         &geometry,
 
118
                       const compiz::window::extents::Extents &border,
 
119
                       const CompSize                         &screen,
 
120
                       int                                    partSize);
 
121
 
 
122
        void leftOrRight (const CompRect                         &workArea,
 
123
                          const compiz::window::Geometry         &geometry,
 
124
                          const compiz::window::extents::Extents &border,
 
125
                          const CompSize                         &screen,
 
126
                          int                                    partSize);
 
127
 
 
128
        void closestCorner (const CompRect                         &workArea,
 
129
                            const compiz::window::Geometry         &geometry,
 
130
                            const compiz::window::extents::Extents &border,
 
131
                            const CompSize                         &screen,
 
132
                            int                                    partSize);
 
133
 
 
134
        void partRandom (const CompRect                         &workArea,
 
135
                         const compiz::window::Geometry         &geometry,
 
136
                         const compiz::window::extents::Extents &border,
 
137
                         const CompSize                         &screen,
 
138
                         int                                    partSize);
 
139
 
 
140
        void random (const CompRect                         &workArea,
 
141
                     const compiz::window::Geometry         &geometry,
 
142
                     const compiz::window::extents::Extents &border,
 
143
                     int                                    partSize);
 
144
 
67
145
        int placed;
68
146
        int onScreenX, onScreenY;
69
147
        int offScreenX, offScreenY;
112
190
 
113
191
        int
114
192
        prepareWindows (int oldState);
115
 
 
116
 
 
117
 
 
118
193
};
119
194
 
120
195
class ShowdesktopWindow: