Comments (2)
% ghc-pkg describe X11
name: X11
version: 1.6.1.1
id: X11-1.6.1.1-fbec979d1d48ed93a7f4090c1fc46e9c
license: BSD3
copyright: Alastair Reid, 1999-2003, [email protected] 2003-2007, Don Stewart 2007-2009, Spencer Janssen 2007-2009, Daniel Wagner 2009-2011.
maintainer: Daniel Wagner <[email protected]>
stability:
homepage: https://github.com/haskell-pkg-janitors/X11
package-url:
synopsis: A binding to the X11 graphics library
description: A Haskell binding to the X11 graphics library.
The binding is a direct translation of the C binding; for
documentation of these calls, refer to "The Xlib Programming
Manual", available online at <http://tronche.com/gui/x/xlib/>.
category: Graphics
author:
exposed: True
exposed-modules: Graphics.X11 Graphics.X11.Types Graphics.X11.Xlib
Graphics.X11.Xlib.Atom Graphics.X11.Xlib.Color
Graphics.X11.Xlib.Context Graphics.X11.Xlib.Cursor
Graphics.X11.Xlib.Display Graphics.X11.Xlib.Event
Graphics.X11.Xlib.Font Graphics.X11.Xlib.Misc
Graphics.X11.Xlib.Region Graphics.X11.Xlib.Screen
Graphics.X11.Xlib.Types Graphics.X11.Xlib.Window
Graphics.X11.Xlib.Image Graphics.X11.Xlib.Extras
Graphics.X11.Xinerama Graphics.X11.Xrandr Graphics.X11.XScreenSaver
Graphics.X11.ExtraTypes Graphics.X11.ExtraTypes.AP
Graphics.X11.ExtraTypes.DEC Graphics.X11.ExtraTypes.HP
Graphics.X11.ExtraTypes.Sun Graphics.X11.ExtraTypes.XF86
Graphics.X11.ExtraTypes.XorgDefault
hidden-modules: Graphics.X11.Xlib.Internal
trusted: False
import-dirs: /nix/store/ln6152i7m5jgfbyg28zwxylw6s15q5yn-haskell-X11-ghc7.6.3-1.6.1.1/lib/ghc-7.6.3/X11-1.6.1.1
library-dirs: /nix/store/ln6152i7m5jgfbyg28zwxylw6s15q5yn-haskell-X11-ghc7.6.3-1.6.1.1/lib/ghc-7.6.3/X11-1.6.1.1
/nix/store/0sh2jja121096l63nvhryy2yj4apgp2b-libX11-1.6.2/lib
/nix/store/cfdzbci9pc3kzn7v4qh8dllvh2bqmlfk-libXext-1.3.2/lib
/nix/store/liy7pyxz3chfp2bff9nk0ck4m45v2dfy-libXinerama-1.1.3/lib
/nix/store/j28hs13ms7241pliaz8plj24wfdsgspx-libXrandr-1.4.2/lib
/nix/store/bdb55pcvzbn8gkzzq1h0d3li0cl1nj2y-libXrender-0.9.8/lib
hs-libraries: HSX11-1.6.1.1
extra-libraries: Xinerama Xext X11 Xrandr Xext
extra-ghci-libraries:
include-dirs: /nix/store/0sh2jja121096l63nvhryy2yj4apgp2b-libX11-1.6.2/include
/nix/store/cfdzbci9pc3kzn7v4qh8dllvh2bqmlfk-libXext-1.3.2/include
/nix/store/liy7pyxz3chfp2bff9nk0ck4m45v2dfy-libXinerama-1.1.3/include
/nix/store/j28hs13ms7241pliaz8plj24wfdsgspx-libXrandr-1.4.2/include
/nix/store/bdb55pcvzbn8gkzzq1h0d3li0cl1nj2y-libXrender-0.9.8/include
/nix/store/ln6152i7m5jgfbyg28zwxylw6s15q5yn-haskell-X11-ghc7.6.3-1.6.1.1/lib/ghc-7.6.3/X11-1.6.1.1/include
includes: HsXlib.h HsAllKeysyms.h
depends: base-4.6.0.1-02ac91ff7de681afee6a8fa62f0c87f3
data-default-0.5.3-690cbd65b712475fa704cfcf6dff3163
hugs-options:
cc-options:
ld-options:
framework-dirs:
frameworks:
haddock-interfaces: /nix/store/ln6152i7m5jgfbyg28zwxylw6s15q5yn-haskell-X11-ghc7.6.3-1.6.1.1/share/doc/X11-1.6.1.1/html/X11.haddock
haddock-html: /nix/store/ln6152i7m5jgfbyg28zwxylw6s15q5yn-haskell-X11-ghc7.6.3-1.6.1.1/share/doc/X11-1.6.1.1/html
pkgroot: "/nix/store/n1drkghiakkwv23vz2qfbddbgyr1hh0r-haskell-env-ghc-7.6.3/lib/ghc-7.6.3"
from x11.
It seems Xlib Screen
and Display
sizes treat all outputs as one monitor, but the below RandR
code does what I want:
{-# LANGUAGE LambdaCase #-}
import Control.Arrow ((&&&))
import Data.Maybe (catMaybes)
import Control.Monad (liftM2)
import Control.Applicative ((<$>))
import Foreign.C.Types (CULong)
import Graphics.X11.Xlib (Display, Window, openDisplay, defaultScreen, rootWindow, createSimpleWindow, blackPixel)
import Graphics.X11.Xrandr (XRROutputInfo(..), XRRScreenResources(..), xrrGetOutputInfo, xrrGetScreenResources)
getPhysicalSize :: XRROutputInfo -> (CULong, CULong)
getPhysicalSize = xrr_oi_mm_width &&& xrr_oi_mm_height
getScreenResources :: Display -> IO (Maybe XRRScreenResources)
getScreenResources = liftM2 (>>=) emptyWindow xrrGetScreenResources
displays :: IO [(CULong, CULong)]
displays = openDisplay [] >>= \display -> getScreenResources display >>= \case
Just resources -> fmap getPhysicalSize . catMaybes <$> xrrGetOutputInfo display resources `mapM` xrr_sr_outputs resources
Nothing -> return []
emptyWindow :: Display -> IO Window
emptyWindow display = do
let screen = defaultScreen display
pixel = blackPixel display screen
root <- rootWindow display screen
createSimpleWindow display root 0 0 1 1 0 pixel pixel
from x11.
Related Issues (20)
- Any planned newer Hackage releases? HOT 4
- Dependencies HOT 1
- Install on nixos? HOT 8
- createFontSet broken with libX11-1.6.4 HOT 6
- Create "safe" functions that return `Maybe a` instead of throwing an exception HOT 35
- rawGetWindowProperty should perhaps return an array instead of a list HOT 3
- Cabal build does not actually use the library search paths that Autoconf has found HOT 11
- Uninitialized memory access in queryTree HOT 2
- XScreenSaver module API depends on build environment HOT 7
- CI fails because the lack of xrandr HOT 1
- Shouldn't openDisplay take a Maybe String instead of a String? HOT 3
- Graphics.X11.Types could include Thai etc. keybindings HOT 3
- New release needed to support ghc 8.8.1 HOT 4
- Tag for release 1.9 is missing
- Switch from data-default to data-default-class
- Hackage documentation is broken because of build error HOT 2
- Build from git fails with cabal new-build HOT 3
- Incorrect documentation in README HOT 1
- Why does getWindowProperty32 return IO (Maybe [CLong]) HOT 2
- Installation fails with GHC < 8 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x11.