Added missing properties.
[AROS.git] / arch / all-hosted / hidd / x11 / offbitmap.c
blob684cda03685bec703fe765490e93ac18114c2e13
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Offscreen bitmap class for X11 hidd.
6 Lang: English.
7 */
9 /****************************************************************************************/
11 #include "x11_debug.h"
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <X11/Xlib.h>
16 #include <X11/Xutil.h>
17 #include <X11/cursorfont.h>
18 #include <X11/keysym.h>
20 #include <string.h>
22 #include <proto/oop.h>
23 #include <proto/utility.h>
25 #include <exec/memory.h>
26 #include <exec/lists.h>
27 #include <graphics/rastport.h>
28 #include <graphics/gfx.h>
29 #include <oop/oop.h>
30 #include <hidd/graphics.h>
32 #include "x11gfx_intern.h"
33 #include "x11.h"
34 #include "bitmap.h"
36 /****************************************************************************************/
38 BOOL X11BM_InitPM(OOP_Class *cl, OOP_Object *o, struct TagItem *attrList)
40 OOP_Object *friend;
41 Drawable friend_drawable = 0;
42 IPTR depth;
43 struct bitmap_data *data = OOP_INST_DATA(cl, o);
45 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__));
47 /* Retrieve bitmap size from superclass */
48 OOP_GetAttr(o, aHidd_BitMap_Width , &data->width);
49 OOP_GetAttr(o, aHidd_BitMap_Height, &data->height);
50 OOP_GetAttr(o, aHidd_BitMap_Depth , &depth);
52 friend = (OOP_Object *)GetTagData(aHidd_BitMap_Friend, 0, attrList);
53 if (friend)
55 /* Get the X11 window from the friend bitmap */
56 OOP_GetAttr(friend, aHidd_X11BitMap_Drawable, &friend_drawable);
59 if (!friend_drawable)
61 /* If no friend, or friend is not X11 bitmap, use default friend drawable */
62 friend_drawable = XSD(cl)->dummy_window_for_creating_pixmaps;
65 /*
66 * We must only create depths that are supported by the friend drawable
67 * Currently we only support the default depth, and depth 1
69 if (depth != 1)
71 depth = DefaultDepth(data->display, data->screen);
73 else
75 /* Need this because of stipple bug in XFree86 :-( */
76 data->width += 32;
79 D(bug("[X11OffBm] %s: Creating X Pixmap, 0x%p, %ld, %ld, %ld\n", __PRETTY_FUNCTION__, friend_drawable, data->width, data->height, depth));
81 HostLib_Lock();
83 DRAWABLE(data) = XCALL(XCreatePixmap, data->display, friend_drawable, data->width, data->height, depth);
84 XCALL(XFlush, data->display);
86 HostLib_Unlock();
88 return DRAWABLE(data) ? TRUE : FALSE;
91 /****************************************************************************************/
93 VOID X11BM_DisposePM(struct bitmap_data *data)
95 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__));
97 if (DRAWABLE(data))
99 HostLib_Lock();
101 XCALL(XFreePixmap, GetSysDisplay(), DRAWABLE(data));
102 XCALL(XFlush, GetSysDisplay());
104 HostLib_Unlock();
108 /****************************************************************************************/
110 VOID X11BM_ClearPM(struct bitmap_data *data, HIDDT_Pixel bg)
112 D(bug("[X11OffBm] %s()\n", __PRETTY_FUNCTION__));
114 XCALL(XSetForeground, data->display, data->gc, bg);
115 XCALL(XFillRectangle, data->display, DRAWABLE(data), data->gc, 0, 0, data->width, data->height);