New patches: [obey some size hints pdewacht@gmail.com**20070430212947] { hunk ./Operations.hs 152 - moveResizeWindow d w (rect_x r) (rect_y r) - (rect_width r - bw*2) - (rect_height r - bw*2) + (width, height) <- applySizeHints d w (rect_width r - bw*2) + (rect_height r - bw*2) + moveResizeWindow d w (rect_x r) (rect_y r) width height + +applySizeHints :: Display -> Window -> Dimension -> Dimension -> IO (Dimension, Dimension) +applySizeHints d win w h = do + sh <- getWMNormalHints d win + let (bw, bh) = maybe (0, 0) id (sh_base_size sh) + let size = (fromIntegral w - fromIntegral bw, fromIntegral h - fromIntegral bh) + let size' = maybe size (applyAspectHint size) (sh_aspect sh) + let size'' = maybe size' (applyResizeIncHint size') (sh_resize_inc sh) + let (w', h') = maybe size'' (applyMaxSizeHint size'') (sh_max_size sh) + return (fromIntegral w' + fromIntegral bw, fromIntegral h' + fromIntegral bh) + +applyAspectHint :: (Integral a) => (a, a) -> ((a, a), (a, a)) -> (a, a) +applyAspectHint (w, h) ((minx, miny), (maxx, maxy)) + | or [minx < 1, miny < 1, maxx < 1, maxy < 1] = (w, h) + | w * maxy > h * maxx = (h * maxx `div` maxy, h) + | w * miny < h * minx = (w, w * miny `div` minx) + | otherwise = (w, h) + +applyResizeIncHint :: (Integral a) => (a, a) -> (a, a) -> (a, a) +applyResizeIncHint (w, h) (iw, ih) + | iw > 0 && ih > 0 = (w - w `mod` iw, h - h `mod` ih) + | otherwise = (w, h) + +applyMaxSizeHint :: (Integral a) => (a, a) -> (a, a) -> (a, a) +applyMaxSizeHint (w, h) (maxw, maxh) + | maxw > 0 && maxh > 0 = (min w maxw, min h maxh) + | otherwise = (w, h) } [clean up of the size hints code pdewacht@gmail.com**20070501205701] { hunk ./Operations.hs 152 - (width, height) <- applySizeHints d w (rect_width r - bw*2) - (rect_height r - bw*2) - moveResizeWindow d w (rect_x r) (rect_y r) width height + sh <- getWMNormalHints d w + moveResizeWindow d w (rect_x r) (rect_y r) `uncurry` + applySizeHints sh ((rect_width r - bw*2), + (rect_height r - bw*2)) hunk ./Operations.hs 157 -applySizeHints :: Display -> Window -> Dimension -> Dimension -> IO (Dimension, Dimension) -applySizeHints d win w h = do - sh <- getWMNormalHints d win - let (bw, bh) = maybe (0, 0) id (sh_base_size sh) - let size = (fromIntegral w - fromIntegral bw, fromIntegral h - fromIntegral bh) - let size' = maybe size (applyAspectHint size) (sh_aspect sh) - let size'' = maybe size' (applyResizeIncHint size') (sh_resize_inc sh) - let (w', h') = maybe size'' (applyMaxSizeHint size'') (sh_max_size sh) - return (fromIntegral w' + fromIntegral bw, fromIntegral h' + fromIntegral bh) +-- | Reduce the dimensions if needed to comply to the given SizeHints. +applySizeHints :: SizeHints -> (Dimension, Dimension) -> (Dimension, Dimension) +applySizeHints sh = + maybe id applyMaxSizeHint (sh_max_size sh) . + maybe id (\(bw, bh) (w, h) -> (w+bw, h+bh)) (sh_base_size sh) . + maybe id applyResizeIncHint (sh_resize_inc sh) . + maybe id applyAspectHint (sh_aspect sh) . + maybe id (\(bw, bh) (w, h) -> (w-bw, h-bh)) (sh_base_size sh) hunk ./Operations.hs 166 -applyAspectHint :: (Integral a) => (a, a) -> ((a, a), (a, a)) -> (a, a) -applyAspectHint (w, h) ((minx, miny), (maxx, maxy)) +-- | Reduce the dimensions so their aspect ratio falls between the two given aspect ratios. +applyAspectHint :: ((Dimension, Dimension), (Dimension, Dimension)) -> (Dimension, Dimension) -> (Dimension, Dimension) +applyAspectHint ((minx, miny), (maxx, maxy)) (w, h) hunk ./Operations.hs 174 -applyResizeIncHint :: (Integral a) => (a, a) -> (a, a) -> (a, a) -applyResizeIncHint (w, h) (iw, ih) +-- | Reduce the dimensions so they are a multiple of the size increments. +applyResizeIncHint :: (Dimension, Dimension) -> (Dimension, Dimension) -> (Dimension, Dimension) +applyResizeIncHint (iw, ih) (w, h) hunk ./Operations.hs 180 -applyMaxSizeHint :: (Integral a) => (a, a) -> (a, a) -> (a, a) -applyMaxSizeHint (w, h) (maxw, maxh) +-- | Reduce the dimensions if they exceed the given maximum dimensions. +applyMaxSizeHint :: (Dimension, Dimension) -> (Dimension, Dimension) -> (Dimension, Dimension) +applyMaxSizeHint (maxw, maxh) (w, h) } Context: [elaborate description in .cabal Don Stewart **20070501035414] [use -fasm by default. Much faster Don Stewart **20070501031220] [check we never generate invalid stack sets Don Stewart **20070430065946] [Make border width configurable Spencer Janssen **20070430163515] [Add Config.hs-boot, remove defaultLayoutDesc from XConf Spencer Janssen **20070430162647] [Comment only Spencer Janssen **20070430161635] [Comment only Spencer Janssen **20070430161511] [view n . shift n . view i . shift i) x == x --> shift + view is invertible Don Stewart **20070430062901] [add rotate all and view idempotency tests Don Stewart **20070430055751] [Add XConf for values that don't change. Spencer Janssen **20070430054715] [Control.Arrow is suspicious, add an explicit import Spencer Janssen **20070430053623] [push is idempotent Don Stewart **20070430054345] [add two properties relating to empty window managers Don Stewart **20070430051016] [new QC property: opening a window only affects the current screen Don Stewart **20070430050133] [configurable border colors Jason Creighton **20070430043859 This also fixes a bug where xmonad was assuming a 24-bit display, and just using, eg, 0xff0000 as an index into a colormap without querying the X server to determine the proper pixel value for "red". ] [a bit more precise about building non-empty stacksets for one test Don Stewart **20070430035729] [remove redundant call to 'delete' in 'shift' Don Stewart **20070430031151] [clean 'delete' a little Don Stewart **20070430025319] [shrink 'swap' Don Stewart **20070430024813] [shrink 'rotate' a little Don Stewart **20070430024525] [move size into Properties.hs Don Stewart **20070430021758] [don't need 'size' operation on StackSet Don Stewart **20070430015927] [add homepage: field to .cabal file Don Stewart **20070429041011] [add fromList to Properties.hs Don Stewart **20070429035823] [move fromList into Properties.hs, -17 loc Don Stewart **20070429035804] [avoid grabbing all keys when a keysym is undefined Jason Creighton **20070428180046 XKeysymToKeycode() returns zero if the keysym is undefined. Zero also happens to be the value of AnyKey. ] [Further refactoring Spencer Janssen **20070426212257] [Refactor in Config.hs (no real changes) Spencer Janssen **20070426211407] [Add the manpage to extra-source-files Spencer Janssen **20070426014105] [add xmonad manpage David Lazar **20070426010812] [Remove toList Spencer Janssen **20070426005713] [Ignore numlock and capslock in keybindings Jason Creighton **20070424013357] [Clear numlock bit Spencer Janssen **20070424010352] [force window border to 1px Jason Creighton **20070423050824] [s/creigh// Don Stewart **20070423024026] [some other things to do Don Stewart **20070423023151] [Start TODOs for 0.2 Spencer Janssen **20070423021526] [update readme Don Stewart **20070422090507] [TAG 0.1 Spencer Janssen **20070422083033] Patch bundle hash: 2d1493df5872dcdbc3e73dc1b8f7b3575b3e43cc