Search code examples
clinuxuser-interfacewindow-managers

Developing a simple windowed app for Linux


Okay, I'd like to write a simple C app for Linux (say Ubuntu with Gnome) that would do the following:

  1. Open a Window
  2. Draw something in that window using a main loop, e.g. the current loop number. I don't want to use controls, but to draw directly on the window surface
  3. Close the window & the app

I can do that in Windows, but I've no idea how I could do that in Linux.

Thanks!


Solution

  • There are various "Hello World" examples for X11 programming.

    Using GTK+: http://library.gnome.org/devel/gtk-tutorial/2.13/c39.html

    Using Qt: http://doc.qt.nokia.com/latest/tutorials-widgets-toplevel.html

    Using wxWidgets: http://www.wxwidgets.org/docs/tutorials/hello.htm

    There are a lot more toolkits: Fox, FLTK, Tk, EFL ...

    So far these have all been cross-platform, so let's have a look at X11-specific exampls:

    This is using Xlib: http://en.literateprograms.org/Special:Downloadcode/Hello_World_(C,_Xlib)

    And this is using Xcb: http://xcb.freedesktop.org/tutorial/basicwindowsanddrawing/