1 |
matty |
6 |
/* |
2 |
|
|
rdesktop: A Remote Desktop Protocol client. |
3 |
|
|
User interface services - X-Windows |
4 |
|
|
Copyright (C) Matthew Chapman 1999-2000 |
5 |
|
|
|
6 |
|
|
This program is free software; you can redistribute it and/or modify |
7 |
|
|
it under the terms of the GNU General Public License as published by |
8 |
|
|
the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
(at your option) any later version. |
10 |
|
|
|
11 |
|
|
This program is distributed in the hope that it will be useful, |
12 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
GNU General Public License for more details. |
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License |
17 |
|
|
along with this program; if not, write to the Free Software |
18 |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include "includes.h" |
22 |
|
|
|
23 |
|
|
HWINDOW ui_create_window(int width, int height) |
24 |
|
|
{ |
25 |
|
|
struct window *wnd; |
26 |
|
|
Display *display; |
27 |
|
|
Window window; |
28 |
|
|
int black; |
29 |
|
|
GC gc; |
30 |
|
|
|
31 |
|
|
display = XOpenDisplay(NULL); |
32 |
|
|
if (display == NULL) |
33 |
|
|
return NULL; |
34 |
|
|
|
35 |
|
|
black = BlackPixel(display, DefaultScreen(display)); |
36 |
|
|
window = XCreateSimpleWindow(display, DefaultRootWindow(display), |
37 |
|
|
0, 0, width, height, 0, black, black); |
38 |
|
|
|
39 |
|
|
XMapWindow(display, window); |
40 |
|
|
XSync(display, True); |
41 |
|
|
|
42 |
|
|
gc = XCreateGC(display, window, 0, NULL); |
43 |
|
|
|
44 |
|
|
wnd = xmalloc(sizeof(struct window)); |
45 |
|
|
wnd->display = display; |
46 |
|
|
wnd->wnd = window; |
47 |
|
|
wnd->gc = gc; |
48 |
|
|
return wnd; |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
void ui_destroy_window(HWINDOW wnd) |
52 |
|
|
{ |
53 |
|
|
XFreeGC(wnd->display, wnd->gc); |
54 |
|
|
XDestroyWindow(wnd->display, wnd->wnd); |
55 |
|
|
XCloseDisplay(wnd->display); |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
HBITMAP ui_create_bitmap(HWINDOW wnd, int width, int height, uint8 *data) |
59 |
|
|
{ |
60 |
|
|
XImage *image; |
61 |
|
|
Visual *visual; |
62 |
|
|
|
63 |
|
|
visual = DefaultVisual(wnd->display, DefaultScreen(wnd->display)); |
64 |
|
|
image = XCreateImage(wnd->display, visual, 8, ZPixmap, 0, |
65 |
|
|
data, width, height, 32, width); |
66 |
|
|
|
67 |
|
|
return (HBITMAP)image; |
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
void ui_destroy_bitmap(HBITMAP bmp) |
71 |
|
|
{ |
72 |
|
|
XDestroyImage((XImage *)bmp); |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
void ui_paint_bitmap(HWINDOW wnd, HBITMAP bmp, int x, int y) |
76 |
|
|
{ |
77 |
|
|
XImage *image = (XImage *)bmp; |
78 |
|
|
|
79 |
|
|
XPutImage(wnd->display, wnd->wnd, wnd->gc, image, |
80 |
|
|
0, 0, x, y, image->width, image->height); |
81 |
|
|
|
82 |
|
|
XSync(wnd->display, True); |
83 |
|
|
} |