Skip to content

Commit 4c406da

Browse files
committed
fix and improve Pixmap
1 parent bc71a0f commit 4c406da

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

examples/pizarra.winxed

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class ToolSelector : ChildWindow, BoxedSelector
151151
self.BoxedSelector(pizarra.display, 2, 2);
152152
self.pizarra = pizarra;
153153
self.ChildWindow(pizarra, x, y, self.width, self.height);
154+
self.OnDestroy += evhandler(self, "ondestroy");
154155
self.OnExpose += evhandler(self, "onexpose");
155156
self.OnButtonPress += evhandler(self, "onbuttonpress");
156157
self.Map();
@@ -181,6 +182,14 @@ static char *test[] = {
181182
:>>
182183
);
183184
}
185+
function ondestroy(event)
186+
{
187+
var pixmap = self.pixmap;
188+
if (pixmap != null) {
189+
pixmap.Free();
190+
self.pixmap = null;
191+
}
192+
}
184193
function onexpose(event)
185194
{
186195
int width = self.width;

src/Guitor.winxed

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,11 +1051,10 @@ class Drawable
10511051
function CreatePixmapFromBuffer(string buffer)
10521052
{
10531053
var display = self.display;
1054-
int pixmap = display._CreatePixmapFromBuffer(self.xdrawable, buffer);
1055-
if (pixmap != None) {
1056-
var result = new Drawable;
1057-
result.display = display;
1058-
result.xdrawable = pixmap;
1054+
int xpixmap = display._CreatePixmapFromBuffer(self.xdrawable, buffer);
1055+
if (xpixmap != None) {
1056+
var result = new Pixmap;
1057+
result._set(display, xpixmap);
10591058
return result;
10601059
}
10611060
else
@@ -1086,11 +1085,28 @@ class Drawable
10861085

10871086
class Pixmap : Drawable
10881087
{
1088+
function Pixmap(from, int width, int height, int depth[optional], int has_depth[opt_flag])
1089+
{
1090+
self.display = from.display;
1091+
if (! has_depth)
1092+
depth = display.DefaultDepth(display.DefaultScreen());
1093+
int xpixmap = getfun("XCreatePixmap")
1094+
(from.display, from.xdrawable, width, height, depth);
1095+
self.xdrawable = xpixmap;
1096+
}
10891097
// Internal only - construct from a X Pixmap
10901098
function _set(display, int xpixmap)
10911099
{
10921100
self.display = display;
1093-
self.drawable = xpixmap;
1101+
self.xdrawable = xpixmap;
1102+
}
1103+
function Free()
1104+
{
1105+
int xdrawable = self.xdrawable;
1106+
if (xdrawable != None) {
1107+
getfun("XFreePixmap")(self.display.xdisplay, self.xdrawable);
1108+
self.xdrawable =: None;
1109+
}
10941110
}
10951111
}
10961112

src/GuitorNci.winxed

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,12 @@ function create_function(string funcname)
546546
case "XSetBackground":
547547
sig = "vppi";
548548
break;
549+
case "XCreatePixmap":
550+
sig = "ipiiii";
551+
break;
552+
case "XFreePixmap":
553+
sig = "vpi";
554+
break;
549555
case "XMapWindow":
550556
case "XUnmapWindow":
551557
sig = "ipi";

0 commit comments

Comments
 (0)