Merge lp:~smspillaz/compiz-core/compiz-core.maximization into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 2809
Proposed branch: lp:~smspillaz/compiz-core/compiz-core.maximization
Merge into: lp:compiz-core/0.9.5
Diff against target: 279 lines (+177/-52)
1 file modified
src/window.cpp (+177/-52)
To merge this branch: bzr merge lp:~smspillaz/compiz-core/compiz-core.maximization
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+68135@code.launchpad.net

Description of the change

Tries to work around some of the problems in maximizing windows which must be larger than the available screen size.

The old behaviour was to try and position these windows so that they were never offscreen. That resulted in jumping windows. The new behaviour is to now remove CompWindowActionMaximize*Mask from wmActions if it is not possible to sanely maximize that window (for example, the output is too small). However, if there is another monitor that could accomadate the application specified window size then we will maximize to the closest possible monitor that can do that.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

On Sat, 16 Jul 2011 09:29:53 you wrote:
> Sam Spilsbury has proposed merging
> lp:~smspillaz/compiz-core/compiz-core.maximization into lp:compiz-core.

         int distance = 999999;

Please use std::numeric_limits<int>::max rather than the rather mystic
999999.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Mon, Jul 18, 2011 at 9:16 AM, Tim Penhey <email address hidden> wrote:
> On Sat, 16 Jul 2011 09:29:53 you wrote:
>> Sam Spilsbury has proposed merging
>> lp:~smspillaz/compiz-core/compiz-core.maximization into lp:compiz-core.
>
>         int        distance = 999999;
>
> Please use  std::numeric_limits<int>::max  rather than the rather mystic
> 999999.

Ah, didn't know that existed. Was looking for something to replace MAXINT

>
> --
> https://code.launchpad.net/~smspillaz/compiz-core/compiz-core.maximization/+merge/68135
> You are the owner of lp:~smspillaz/compiz-core/compiz-core.maximization.
>

--
Sam Spilsbury

2780. By Sam Spilsbury

Use std::numeric_limits <int>::max () rather than a constant

Revision history for this message
Marco Biscaro (marcobiscaro2112) wrote :

Sam, there is another 999999 (now, in height verification). I think it should be replaced to std::numeric_limits <int>::max (), right?

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Yes

On Tue, Jul 19, 2011 at 9:38 PM, Marco Biscaro
<email address hidden> wrote:
> Sam, there is another 999999 (now, in height verification). I think it should be replaced to std::numeric_limits <int>::max (), right?
> --
> https://code.launchpad.net/~smspillaz/compiz-core/compiz-core.maximization/+merge/68135
> You are the owner of lp:~smspillaz/compiz-core/compiz-core.maximization.
>

--
Sam Spilsbury

Revision history for this message
Neil J. Patel (njpatel) wrote :

Sam, please update the 999999 to what Tim suggests before merge, but apart from that it looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/window.cpp'
--- src/window.cpp 2011-06-24 14:43:00 +0000
+++ src/window.cpp 2011-07-18 06:31:20 +0000
@@ -623,6 +623,32 @@
623 CompWindowActionMaximizeVertMask |623 CompWindowActionMaximizeVertMask |
624 CompWindowActionFullscreenMask);624 CompWindowActionFullscreenMask);
625625
626 /* Don't allow maximization or fullscreen
627 * of windows which are too big to fit
628 * the screen */
629 bool foundVert = false;
630 bool foundHorz = false;
631
632 foreach (CompOutput &o, screen->outputDevs ())
633 {
634 if (o.width () > (priv->sizeHints.min_width + priv->border.left + priv->border.right))
635 foundHorz = true;
636 if (o.height () > (priv->sizeHints.min_height + priv->border.top + priv->border.bottom))
637 foundVert = true;
638 }
639
640 if (!foundHorz)
641 {
642 actions &= ~(CompWindowActionMaximizeHorzMask |
643 CompWindowActionFullscreenMask);
644 }
645
646 if (!foundVert)
647 {
648 actions &= ~(CompWindowActionMaximizeVertMask |
649 CompWindowActionFullscreenMask);
650 }
651
626 if (!(priv->mwmFunc & MwmFuncAll))652 if (!(priv->mwmFunc & MwmFuncAll))
627 {653 {
628 if (!(priv->mwmFunc & MwmFuncResize))654 if (!(priv->mwmFunc & MwmFuncResize))
@@ -2764,7 +2790,7 @@
2764 CompRect workArea;2790 CompRect workArea;
2765 int mask = 0;2791 int mask = 0;
2766 int x, y;2792 int x, y;
2767 int output;2793 CompOutput *output;
2768 CompPoint viewport;2794 CompPoint viewport;
27692795
2770 screen->viewportForGeometry (old, viewport);2796 screen->viewportForGeometry (old, viewport);
@@ -2772,8 +2798,80 @@
2772 x = (viewport.x () - screen->vp ().x ()) * screen->width ();2798 x = (viewport.x () - screen->vp ().x ()) * screen->width ();
2773 y = (viewport.y () - screen->vp ().y ()) * screen->height ();2799 y = (viewport.y () - screen->vp ().y ()) * screen->height ();
27742800
2775 output = screen->outputDeviceForGeometry (old);2801 /* Try to select and output device that the window is on first
2776 workArea = screen->getWorkareaForOutput (output);2802 * and make sure if we are fullscreening or maximizing that the
2803 * window is actually able to fit on this output ... otherwise
2804 * we're going to have to use another output device which sucks
2805 * but at least the user will be able to see all of the window */
2806 output = &screen->outputDevs ().at (screen->outputDeviceForGeometry (old));
2807
2808 if (state & CompWindowStateFullscreenMask ||
2809 state & CompWindowStateMaximizedHorzMask)
2810 {
2811 int width = (mask & CWWidth) ? xwc->width : old.width ();
2812 int height = (mask & CWHeight) ? xwc->height : old.height ();
2813
2814 window->constrainNewWindowSize (width, height, &width, &height);
2815
2816 if (width > output->width ())
2817 {
2818 int distance = std::numeric_limits <int>::max ();
2819 CompOutput *selected = output;
2820 /* That's no good ... try and find the closest output device to this one
2821 * which has a large enough size */
2822 foreach (CompOutput &o, screen->outputDevs ())
2823 {
2824 if (o.workArea ().width () > width)
2825 {
2826 int tDistance = sqrt (pow (abs (o.x () - output->x ()), 2) +
2827 pow (abs (o.y () - output->y ()), 2));
2828
2829 if (tDistance < distance)
2830 {
2831 selected = &o;
2832 tDistance = distance;
2833 }
2834 }
2835 }
2836
2837 output = selected;
2838 }
2839 }
2840
2841 if (state & CompWindowStateFullscreenMask ||
2842 state & CompWindowStateMaximizedVertMask)
2843 {
2844 int width = (mask & CWWidth) ? xwc->width : old.width ();
2845 int height = (mask & CWHeight) ? xwc->height : old.height ();
2846
2847 window->constrainNewWindowSize (width, height, &width, &height);
2848
2849 if (height > output->height ())
2850 {
2851 int distance = 999999;
2852 CompOutput *selected = output;
2853 /* That's no good ... try and find the closest output device to this one
2854 * which has a large enough size */
2855 foreach (CompOutput &o, screen->outputDevs ())
2856 {
2857 if (o.workArea ().height () > height)
2858 {
2859 int tDistance = sqrt (pow (abs (o.x () - output->x ()), 2) +
2860 pow (abs (o.y () - output->y ()), 2));
2861
2862 if (tDistance < distance)
2863 {
2864 selected = &o;
2865 tDistance = distance;
2866 }
2867 }
2868 }
2869
2870 output = selected;
2871 }
2872 }
2873
2874 workArea = output->workArea ();
27772875
2778 if (type & CompWindowTypeFullscreenMask)2876 if (type & CompWindowTypeFullscreenMask)
2779 {2877 {
@@ -2788,10 +2886,10 @@
2788 }2886 }
2789 else2887 else
2790 {2888 {
2791 xwc->x = x + screen->outputDevs ()[output].x ();2889 xwc->x = x + output->x ();
2792 xwc->y = y + screen->outputDevs ()[output].y ();2890 xwc->y = y + output->y ();
2793 xwc->width = screen->outputDevs ()[output].width ();2891 xwc->width = output->width ();
2794 xwc->height = screen->outputDevs ()[output].height ();2892 xwc->height = output->height ();
2795 }2893 }
27962894
2797 xwc->border_width = 0;2895 xwc->border_width = 0;
@@ -2801,7 +2899,6 @@
2801 else2899 else
2802 {2900 {
2803 mask |= restoreGeometry (xwc, CWBorderWidth);2901 mask |= restoreGeometry (xwc, CWBorderWidth);
2804
2805 if (state & CompWindowStateMaximizedVertMask)2902 if (state & CompWindowStateMaximizedVertMask)
2806 {2903 {
2807 saveGeometry (CWY | CWHeight);2904 saveGeometry (CWY | CWHeight);
@@ -2888,55 +2985,83 @@
28882985
2889 if (state & CompWindowStateMaximizedVertMask)2986 if (state & CompWindowStateMaximizedVertMask)
2890 {2987 {
2891 if (old.y () < y + workArea.y () + input.top)2988 /* If the window is still offscreen, then we need to constrain it
2892 {2989 * by the gravity value (so that the corner that the gravity specifies
2893 xwc->y = y + workArea.y () + input.top;2990 * is 'anchored' to that edge of the workarea) */
2894 mask |= CWY;2991
2895 }2992 xwc->y = y + workArea.y () + input.top;
2896 else2993 mask |= CWY;
2897 {2994
2898 height = xwc->height + old.border () * 2;2995 switch (priv->sizeHints.win_gravity)
28992996 {
2900 max = y + workArea.bottom ();2997 case SouthWestGravity:
2901 if (old.y () + (int) old.height () + input.bottom > max)2998 case SouthEastGravity:
2902 {2999 case SouthGravity:
2903 xwc->y = max - height - input.bottom;3000 /* Shift the window so that the bottom meets the top of the bottom */
2904 mask |= CWY;3001 height = xwc->height + old.border () * 2;
2905 }3002
2906 else if (old.y () + height + input.bottom > max)3003 max = y + workArea.bottom ();
2907 {3004 if (xwc->y + xwc->height + input.bottom > max)
2908 xwc->y = y + workArea.y () +3005 {
2909 (workArea.height () - input.top - height -3006 xwc->y = max - height - input.bottom;
2910 input.bottom) / 2 + input.top;3007 mask |= CWY;
2911 mask |= CWY;3008 }
2912 }3009 break;
3010 /* For EastGravity, WestGravity and CenterGravity we default to the top
3011 * of the window since the user should at least be able to close it
3012 * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since
3013 * that indicates that the application has requested positioning in that area
3014 */
3015 case EastGravity:
3016 case WestGravity:
3017 case CenterGravity:
3018 case NorthWestGravity:
3019 case NorthEastGravity:
3020 case NorthGravity:
3021 default:
3022 /* Shift the window so that the top meets the top of the screen */
3023 break;
2913 }3024 }
2914 }3025 }
29153026
2916 if (state & CompWindowStateMaximizedHorzMask)3027 if (state & CompWindowStateMaximizedHorzMask)
2917 {3028 {
2918 if (old.x () < x + workArea.x () + input.left)3029 xwc->x = x + workArea.x () + input.left;
2919 {3030 mask |= CWX;
2920 xwc->x = x + workArea.x () + input.left;3031
2921 mask |= CWX;3032 switch (priv->sizeHints.win_gravity)
2922 }3033 {
2923 else3034 case NorthEastGravity:
2924 {3035 case SouthEastGravity:
2925 width = xwc->width + old.border () * 2;3036 case EastGravity:
29263037 width = xwc->width + old.border () * 2;
2927 max = x + workArea.right ();3038
2928 if (old.x () + (int) old.width () + input.right > max)3039 max = x + workArea.right ();
2929 {3040 if (old.x () + (int) old.width () + input.right > max)
2930 xwc->x = max - width - input.right;3041 {
2931 mask |= CWX;3042 xwc->x = max - width - input.right;
2932 }3043 mask |= CWX;
2933 else if (old.x () + width + input.right > max)3044 }
2934 {3045 else if (old.x () + width + input.right > max)
2935 xwc->x = x + workArea.x () +3046 {
2936 (workArea.width () - input.left - width -3047 xwc->x = x + workArea.x () +
2937 input.right) / 2 + input.left;3048 (workArea.width () - input.left - width -
2938 mask |= CWX;3049 input.right) / 2 + input.left;
2939 }3050 mask |= CWX;
3051 }
3052 /* For NorthGravity, SouthGravity and CenterGravity we default to the top
3053 * of the window since the user should at least be able to close it
3054 * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since
3055 * that indicates that the application has requested positioning in that area
3056 */
3057 case NorthGravity:
3058 case SouthGravity:
3059 case CenterGravity:
3060 case NorthWestGravity:
3061 case SouthWestGravity:
3062 case WestGravity:
3063 default:
3064 break;
2940 }3065 }
2941 }3066 }
2942 }3067 }

Subscribers

People subscribed via source and target branches