Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:21:40+00:00 2026-06-14T09:21:40+00:00

I was trying to follow the tutorial on X11 haskell library, but got a

  • 0

I was trying to follow the tutorial on X11 haskell library, but got a problem –
the created window is positioned in lower left corner of a screen, instead of top left corner, and the drawing (in method drawInWin) doesn’t seem to do anything.

#!/usr/bin/runghc -Wall

module Main where
import Graphics.X11.Xlib
import System.Exit (exitWith, ExitCode(..))
import Control.Concurrent (threadDelay)

main :: IO ()
main = do
 dpy <- openDisplay ""
 let dflt = defaultScreen dpy
     border = blackPixel dpy dflt
     background = whitePixel dpy dflt
 rootw <- rootWindow dpy dflt
 win <- createSimpleWindow dpy rootw 0 0 100 100 1 border background
 setTextProperty dpy win "Hello World" wM_NAME
 mapWindow dpy win
 drawInWin dpy win
 sync dpy False
 threadDelay (10 * 1000000)
 exitWith ExitSuccess

drawInWin :: Display -> Window -> IO ()
drawInWin dpy win = do
 bgcolor <- initColor dpy "green"
 fgcolor <- initColor dpy "blue"
 gc <- createGC dpy win
 setForeground dpy gc bgcolor
 fillRectangle dpy win gc 0 0 100 100
 setForeground dpy gc fgcolor
 fillRectangle dpy win gc 2 2 96 96
 freeGC dpy gc

initColor :: Display -> String -> IO Pixel
initColor dpy color = do
 let colormap = defaultColormap dpy (defaultScreen dpy)
 (apros,real) <- allocNamedColor dpy colormap color
 return $ color_pixel apros

Basically, I need to create a simple window with a canvas, on which I will draw some lines.

What am I doing wrong in that snippet?

Versions:

X11 - 1.5.0.1
GHC - 6.12.1
OS - Linux Mint 10
Xorg - 1:7.5
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:21:42+00:00Added an answer on June 14, 2026 at 9:21 am

    There are a number of bugs related to 64-bit-correctness in the 1.5 release of the X11 bindings. These have been fixed in the 1.6 release, so upgrading should resolve these issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to follow a tutorial for the Diagrams library for haskell. I've installed
I'm trying to follow this tutorial but with the immediate window in vs2010 rather
I'm trying to follow this tutorial. I've got a non empty db. But the
I am trying to follow the basic tutorial for Spring MVC but got lost
I'm trying to follow this tutorial on Seesaw Window Building . During the step
I'm trying to follow this tutorial: http://jqueryfordesigners.com/fixed-floating-elements/ . The problem is that whenever the
I'm trying to follow this tutorial but instead of generating the expected hbm.xml files
I'm trying to follow this tutorial from Cython: http://docs.cython.org/docs/tutorial.html#the-basics-of-cython and I'm having a problem.
I am trying to follow this tutorial http://damianm.com/tech/nhibernate-mvc-and-ninject/ but I am running into some
I'm trying to follow this tutorial, but VS debugger keep asking me for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.