OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [mw/] [src/] [demos/] [nanowm/] [nanowm.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
/*
2
 * NanoWM - Window Manager for Nano-X
3
 *
4
 * Copyright (C) 2000 Greg Haerr <greg@censoft.com>
5
 * Copyright (C) 2000 Alex Holden <alex@linuxhacker.org>
6
 * Parts based on npanel.c Copyright (C) 1999 Alistair Riddoch.
7
 */
8
#include <stdio.h>
9
#include <stdlib.h>
10
#define MWINCLUDECOLORS
11
#include "nano-X.h"
12
/* Uncomment this if you want debugging output from this file */
13
/*#define DEBUG*/
14
 
15
#include "nanowm.h"
16
 
17
GR_SCREEN_INFO si;
18
 
19
int main(int argc, char *argv[])
20
{
21
        GR_EVENT event;
22
        GR_WM_PROPERTIES props;
23
        win window;
24
 
25
        if(GrOpen() < 0) {
26
                fprintf(stderr, "Couldn't connect to Nano-X server!\n");
27
                exit(1);
28
        }
29
 
30
        /* pass errors through main loop, don't exit*/
31
        GrSetErrorHandler(NULL);
32
 
33
        GrGetScreenInfo(&si);
34
 
35
        /* add root window*/
36
        window.wid = GR_ROOT_WINDOW_ID;
37
        window.pid = GR_ROOT_WINDOW_ID;
38
        window.type = WINDOW_TYPE_ROOT;
39
        window.clientid = 1;
40
        window.sizing = GR_FALSE;
41
        window.active = 0;
42
        window.data = NULL;
43
        add_window(&window);
44
 
45
        GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_CHLD_UPDATE);
46
 
47
        /* Set new root window background color*/
48
        props.flags = GR_WM_FLAGS_BACKGROUND;
49
        props.background = GrGetSysColor(GR_COLOR_DESKTOP);
50
        GrSetWMProperties(GR_ROOT_WINDOW_ID, &props);
51
 
52
        while(1) {
53
                GrGetNextEvent(&event);
54
 
55
                switch(event.type) {
56
                        case GR_EVENT_TYPE_ERROR:
57
                                printf("nanowm: error %d\n", event.error.code);
58
                                break;
59
                        case GR_EVENT_TYPE_EXPOSURE:
60
                                do_exposure(&event.exposure);
61
                                break;
62
                        case GR_EVENT_TYPE_BUTTON_DOWN:
63
                                do_button_down(&event.button);
64
                                break;
65
                        case GR_EVENT_TYPE_BUTTON_UP:
66
                                do_button_up(&event.button);
67
                                break;
68
                        case GR_EVENT_TYPE_MOUSE_ENTER:
69
                                do_mouse_enter(&event.general);
70
                                break;
71
                        case GR_EVENT_TYPE_MOUSE_EXIT:
72
                                do_mouse_exit(&event.general);
73
                                break;
74
                        case GR_EVENT_TYPE_MOUSE_POSITION:
75
                                do_mouse_moved(&event.mouse);
76
                                break;
77
                        case GR_EVENT_TYPE_KEY_DOWN:
78
                                do_key_down(&event.keystroke);
79
                                break;
80
                        case GR_EVENT_TYPE_KEY_UP:
81
                                do_key_up(&event.keystroke);
82
                                break;
83
                        case GR_EVENT_TYPE_FOCUS_IN:
84
                                do_focus_in(&event.general);
85
                                break;
86
                        case GR_EVENT_TYPE_CHLD_UPDATE:
87
                                do_update(&event.update);
88
                                break;
89
                        default:
90
                                fprintf(stderr, "Got unexpected event %d\n",
91
                                                                event.type);
92
                                break;
93
                }
94
        }
95
 
96
        GrClose();
97
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.