[go: up one dir, main page]

File:Xlib square example.png

Xlib_square_example.png (200 × 200 pixels, file size: 674 bytes, MIME type: image/png)

Summary

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

Licensing

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

/*
  * 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;
}

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

copyrighted<\/a>"}},"text\/plain":{"en":{"P6216":"copyrighted"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P6216 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">
Creative Commons Attribution-ShareAlike 3.0 Unported<\/a>"}},"text\/plain":{"en":{"P275":"Creative Commons Attribution-ShareAlike 3.0 Unported"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P275 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">

31 December 2013

original creation by uploader<\/a>"}},"text\/plain":{"en":{"P7482":"original creation by uploader"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P7482 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">

File history

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

Date/TimeThumbnailDimensionsUserComment
current10:41, 31 December 2013Thumbnail for version as of 10:41, 31 December 2013200 × 200 (674 bytes)SkimUser created page with UploadWizard

The following page uses this file:

Global file usage

The following other wikis use this file:

  • Usage on cs.wikipedia.org
  • Usage on es.wikipedia.org

Metadata