Type error in Structs.hsc #27

Closed
edsko opened this Issue Apr 25, 2014 · 3 comments

Comments

Projects
None yet
3 participants
@edsko

edsko commented Apr 25, 2014

After I configure with

cabal configure --with-gcc=gcc-4.9

and then build, I get

Graphics/UI/Gtk/General/Structs.hsc:660:3:
    Couldn't match type `CInt' with `Ptr a0'
    Expected type: IO (Ptr a0)
      Actual type: IO CInt
    In the return type of a call of `\ (Drawable drawable)
                                       -> withForeignPtr drawable gdk_x11_drawable_get_xid'
    In the second argument of `($)', namely
      `(\ (Drawable drawable)
          -> withForeignPtr drawable gdk_x11_drawable_get_xid)
         (toDrawable d)'
    In the expression:
      liftM toNativeWindowId
      $ (\ (Drawable drawable)
           -> withForeignPtr drawable gdk_x11_drawable_get_xid)
          (toDrawable d)

If instead I configure with the -fhave-quartz-gtk flag (which is what I actually really wanted), then I get a different error

Graphics/UI/Gtk/General/Structs.hsc:660:3:
    Couldn't match type `Maybe DrawWindow' with `Ptr a0'
    Expected type: IO (Ptr a0)
      Actual type: IO (Maybe DrawWindow)
    In the return type of a call of `\ (Drawable drawable)
                                       -> return $ Just (DrawWindow drawable)'
    In the second argument of `($)', namely
      `(\ (Drawable drawable) -> return $ Just (DrawWindow drawable))
         (toDrawable d)'
    In the expression:
      liftM toNativeWindowId
      $ (\ (Drawable drawable) -> return $ Just (DrawWindow drawable))
          (toDrawable d)

Graphics/UI/Gtk/General/Structs.hsc:675:32:
    Couldn't match type `Drawable' with `DrawWindow'
    Expected type: ForeignPtr DrawWindow
      Actual type: ForeignPtr Drawable
    In the first argument of `DrawWindow', namely `drawable'
    In the first argument of `Just', namely `(DrawWindow drawable)'
    In the second argument of `($)', namely
      `Just (DrawWindow drawable)'

This is on OSX Mavericks, ghc 7.6.3, GTK+ built from source, version 2.24.21.

@edsko edsko changed the title from Type error in to Type error in Structs.hsc Apr 25, 2014

@edsko

This comment has been minimized.

Show comment
Hide comment
@edsko

edsko Apr 27, 2014

I did a bit of digging. The error is in drawableGetID; in gtk-0.12.4 this function returns an error when HAVE_QUARTZ_GTK is defined. In gtk-0.12.5.* it doesn't, but it seems to make an assumption that NativeWindowId is defined as

newtype NativeWindowId = NativeWindowId (Maybe DrawWindow) deriving (Eq)

However, recent versions of gtk+ do define GTK_NATIVE_WINDOW_POINTER (https://mail.gnome.org/archives/commits-list/2013-March/msg20190.html) and hence we have

newtype NativeWindowId = NativeWindowId (Ptr ()) deriving (Eq, Show)

instead. At this point I don't know what the right resolution is. For now I have just disabled drawableGetID completely and that seems to work ok.

edsko commented Apr 27, 2014

I did a bit of digging. The error is in drawableGetID; in gtk-0.12.4 this function returns an error when HAVE_QUARTZ_GTK is defined. In gtk-0.12.5.* it doesn't, but it seems to make an assumption that NativeWindowId is defined as

newtype NativeWindowId = NativeWindowId (Maybe DrawWindow) deriving (Eq)

However, recent versions of gtk+ do define GTK_NATIVE_WINDOW_POINTER (https://mail.gnome.org/archives/commits-list/2013-March/msg20190.html) and hence we have

newtype NativeWindowId = NativeWindowId (Ptr ()) deriving (Eq, Show)

instead. At this point I don't know what the right resolution is. For now I have just disabled drawableGetID completely and that seems to work ok.

@cchantep

This comment has been minimized.

Show comment
Hide comment
@cchantep

cchantep May 14, 2014

Contributor

I guess gdk_quartz_window_get_nswindow can be used when HAVE_QUARTZ_GTK is defined.

It allows to get ref to ObjC NSWindow, which expose unique windowNumber which could possibly be used.

Contributor

cchantep commented May 14, 2014

I guess gdk_quartz_window_get_nswindow can be used when HAVE_QUARTZ_GTK is defined.

It allows to get ref to ObjC NSWindow, which expose unique windowNumber which could possibly be used.

@cchantep

This comment has been minimized.

Show comment
Hide comment
@cchantep

cchantep Jul 27, 2014

Contributor

@hamishmack this one could be closed as #40 fixes issue.

Contributor

cchantep commented Jul 27, 2014

@hamishmack this one could be closed as #40 fixes issue.

@hamishmack hamishmack closed this Jul 27, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment