File:Xlib square example with ICEWM decorations.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Xlib_square_example_with_ICEWM_decorations.png(208 × 228 pixels, file size: 2 KB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
Čeština: Jednoduchá Xlib aplikace vykreslující čtvereček a text v okně. S dekoracemi správce oken IceWM.
English: Simple Xlib application drawing a box and text in a window. With IceWM window manager decorations.
Date
Source Own work
Author Skim

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

C source code

[edit]
/*
  * Simple Xlib application drawing a box in a window.
  * gcc input.c -o output -lX11
  */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <X11/Xlib.h>

int
main(int argc, char **argv)
{
        Display *display;
        Window window;
        XEvent event;
        char *msg = "Hello, World!";
        int s;

        /* Open connection with the server. */
        display = XOpenDisplay(NULL);
        if(display == NULL){
                fprintf(stderr, "Cannot open display\n");
                exit(1);
        }

        s = DefaultScreen(display);

        /* Create window. */
        window = XCreateSimpleWindow(display, RootWindow(display, s), 10, 10,
                200, 200, 1, BlackPixel(display, s), WhitePixel(display, s));

        /* Select kind of events we are interested in. */
        XSelectInput(display, window, ExposureMask | KeyPressMask);

        /* Map (show) the window. */
        XMapWindow(display, window);

        /* Event loop. */
        for(;;){
                XNextEvent(display, &event);

                /* Draw or redraw the window. */
                if(event.type == Expose){
                        XFillRectangle(display, window, DefaultGC(display, s),
                                20, 20, 10, 10);
                        XDrawString(display, window, DefaultGC(display, s), 50,
                                50, msg, strlen(msg));
                }

                /* Exit on key press. */
                if(event.type == KeyPress)
                        break;
        }

        /* Close connection to server. */
        XCloseDisplay(display);

        return 0;
}

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current09:28, 1 January 2014Thumbnail for version as of 09:28, 1 January 2014208 × 228 (2 KB)Skim (talk | contribs)User created page with UploadWizard

The following page uses this file:

File usage on other wikis

The following other wikis use this file:

  • Usage on cs.wikipedia.org
  • Usage on en.wikipedia.org
  • Usage on es.wikipedia.org
  • Usage on fi.wikipedia.org
  • Usage on it.wikipedia.org
  • Usage on uk.wikipedia.org
  • Usage on www.wikidata.org

Metadata