Skip to content

Commit

Permalink
Drawing: Implement GraphicsExposures.
Browse files Browse the repository at this point in the history
Fixes scrolling in FLTK hanging forever.
  • Loading branch information
waddlesplash committed Aug 23, 2023
1 parent e5ff220 commit 39a6c0d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
48 changes: 39 additions & 9 deletions xlib/Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Drawing.h"

#include <interface/Bitmap.h>
#include <interface/Region.h>
#include <interface/Polygon.h>

#include "Color.h"
Expand Down Expand Up @@ -318,28 +319,57 @@ XCopyArea(Display* display, Drawable src, Drawable dest, GC gc,
const BRect src_rect = brect_from_xrect(make_xrect(src_x, src_y, width, height));
const BRect dest_rect = brect_from_xrect(make_xrect(dest_x, dest_y, width, height));

BRegion region(dest_rect);
if (src == dest) {
DrawStateManager srcMgr(src, gc);
if (!srcMgr.view())
return BadDrawable;
srcMgr.view()->CopyBits(src_rect, dest_rect);
return Success;
}

XPixmap* src_pxm = Drawables::get_pixmap(src);
if (src_pxm) {
srcMgr.view()->CopyBits(src_rect, dest_rect);
region.Exclude(srcMgr.view()->Bounds());
} else if (XPixmap* src_pxm = Drawables::get_pixmap(src)) {
src_pxm->sync();

DrawStateManager destMgr(dest, gc);
if (!destMgr.view())
return BadDrawable;

destMgr.view()->DrawBitmap(src_pxm->offscreen(), src_rect, dest_rect);
return Success;
region.Exclude(destMgr.view()->Bounds());
} else {
// TODO?
UNIMPLEMENTED();
return BadValue;
}

// TODO?
UNIMPLEMENTED();
return BadValue;
if (gc->values.graphics_exposures) {
if (region.CountRects() == 0) {
XEvent event;
event.type = NoExpose;
event.xany.window = dest;
event.xnoexpose.major_code = X_CopyArea;
event.xnoexpose.minor_code = 0;
_x_put_event(display, event);
} else {
for (int32 i = region.CountRects() - 1; i >= 0; i--) {
XRectangle rect = xrect_from_brect(region.RectAt(i));

XEvent event;
event.type = GraphicsExpose;
event.xany.window = dest;
event.xgraphicsexpose.x = rect.x;
event.xgraphicsexpose.y = rect.y;
event.xgraphicsexpose.width = rect.width;
event.xgraphicsexpose.height = rect.height;
event.xgraphicsexpose.count = i;
event.xgraphicsexpose.major_code = X_CopyArea;
event.xgraphicsexpose.minor_code = 0;
_x_put_event(display, event);
}
}
}

return Success;
}

extern "C" int
Expand Down
1 change: 1 addition & 0 deletions xlib/GC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ XCreateGC(Display* display, Window window,
gc->values.arc_mode = ArcChord;
gc->values.font = 0;
gc->values.subwindow_mode = ClipByChildren;
gc->values.graphics_exposures = True;
gc->values.clip_x_origin = gc->values.clip_y_origin = 0;
gc->values.clip_mask = None;
gc->dirty = 0;
Expand Down

0 comments on commit 39a6c0d

Please sign in to comment.