mirror of https://github.com/fltk/fltk
Rewrite Fl::handle_(int e, Fl_Window* window) and Fl_Widget::damage() to remove their platform dependent parts
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11419 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
f432c17112
commit
2530120d7d
|
@ -257,6 +257,8 @@ public:
|
|||
virtual uchar **mask_bitmap() { return 0; }
|
||||
/** Support for pixmap drawing */
|
||||
virtual void mask_bitmap(uchar **) {}
|
||||
// each platform implements that its own way
|
||||
static void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h);
|
||||
protected:
|
||||
// --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx
|
||||
virtual void transformed_vertex0(COORD_T x, COORD_T y);
|
||||
|
|
53
src/Fl.cxx
53
src/Fl.cxx
|
@ -17,10 +17,6 @@
|
|||
//
|
||||
|
||||
|
||||
// warning: the Apple Quartz version still uses some Quickdraw calls,
|
||||
// mostly to get around the single active context in QD and
|
||||
// to implement clipping. This should be changed into pure
|
||||
// Quartz calls in the near future.
|
||||
#include "config_lib.h"
|
||||
|
||||
/* We require Windows 2000 features (e.g. VK definitions) */
|
||||
|
@ -1280,29 +1276,15 @@ int Fl::handle_(int e, Fl_Window* window)
|
|||
if (grab()) wi = grab();
|
||||
{ int ret;
|
||||
Fl_Widget* pbm = belowmouse();
|
||||
#ifdef __APPLE__ // bug fix
|
||||
if (fl_mac_os_version < 100500) {
|
||||
// before 10.5, mouse moved events aren't sent to borderless windows such as tooltips
|
||||
Fl_Window *tooltip = Fl_Tooltip::current_window();
|
||||
int inside = 0;
|
||||
if (tooltip && tooltip->shown() ) { // check if a tooltip window is currently opened
|
||||
// check if mouse is inside the tooltip
|
||||
inside = (Fl::event_x_root() >= tooltip->x() && Fl::event_x_root() < tooltip->x() + tooltip->w() &&
|
||||
Fl::event_y_root() >= tooltip->y() && Fl::event_y_root() < tooltip->y() + tooltip->h() );
|
||||
}
|
||||
// if inside, send event to tooltip window instead of background window
|
||||
if (inside) ret = send_event(e, tooltip, window);
|
||||
else ret = (wi && send_event(e, wi, window));
|
||||
} else
|
||||
#endif
|
||||
ret = (wi && send_event(e, wi, window));
|
||||
if (pbm != belowmouse()) {
|
||||
if (pbm != belowmouse()) {
|
||||
#ifdef DEBUG
|
||||
printf("Fl::handle(e=%d, window=%p);\n", e, window);
|
||||
printf("Fl::handle(e=%d, window=%p);\n", e, window);
|
||||
#endif // DEBUG
|
||||
Fl_Tooltip::enter(belowmouse());
|
||||
Fl_Tooltip::enter(belowmouse());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return ret;}
|
||||
|
||||
case FL_RELEASE: {
|
||||
// printf("FL_RELEASE: window=%p, pushed() = %p, grab() = %p, modal() = %p\n",
|
||||
|
@ -1582,29 +1564,7 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) {
|
|||
if (wi->damage()) {
|
||||
// if we already have damage we must merge with existing region:
|
||||
if (i->region) {
|
||||
#if defined(USE_X11)
|
||||
XRectangle R;
|
||||
R.x = X; R.y = Y; R.width = W; R.height = H;
|
||||
XUnionRectWithRegion(&R, i->region, i->region);
|
||||
#elif defined(WIN32)
|
||||
Fl_Region R = XRectangleRegion(X, Y, W, H);
|
||||
CombineRgn(i->region, i->region, R, RGN_OR);
|
||||
XDestroyRegion(R);
|
||||
#elif defined(__APPLE_QUARTZ__) // PORTME: Fl_Window_Driver - platform damage region
|
||||
CGRect arg = fl_cgrectmake_cocoa(X, Y, W, H);
|
||||
int j; // don't add a rectangle totally inside the Fl_Region
|
||||
for(j = 0; j < i->region->count; j++) {
|
||||
if(CGRectContainsRect(i->region->rects[j], arg)) break;
|
||||
}
|
||||
if( j >= i->region->count) {
|
||||
i->region->rects = (CGRect*)realloc(i->region->rects, (++(i->region->count)) * sizeof(CGRect));
|
||||
i->region->rects[i->region->count - 1] = arg;
|
||||
}
|
||||
#elif defined(FL_PORTING)
|
||||
# pragma message "FL_PORTING: code to merge damage regions"
|
||||
#else
|
||||
# error unsupported platform
|
||||
#endif
|
||||
Fl_Graphics_Driver::add_rectangle_to_region(i->region, X, Y, W, H);
|
||||
}
|
||||
wi->damage_ |= fl;
|
||||
} else {
|
||||
|
@ -1619,7 +1579,6 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) {
|
|||
|
||||
#ifdef WIN32
|
||||
# include "Fl_win32.cxx"
|
||||
//#elif defined(__APPLE__) // nothing here to see
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -1139,6 +1139,19 @@ static void cocoaMouseHandler(NSEvent *theEvent)
|
|||
}
|
||||
mods_to_e_state( mods );
|
||||
update_e_xy_and_e_xy_root([theEvent window]);
|
||||
if (fl_mac_os_version < 100500) {
|
||||
// before 10.5, mouse moved events aren't sent to borderless windows such as tooltips
|
||||
Fl_Window *tooltip = Fl_Tooltip::current_window();
|
||||
int inside = 0;
|
||||
if (tooltip && tooltip->shown() ) { // check if a tooltip window is currently opened
|
||||
// check if mouse is inside the tooltip
|
||||
inside = (Fl::event_x_root() >= tooltip->x() && Fl::event_x_root() < tooltip->x() + tooltip->w() &&
|
||||
Fl::event_y_root() >= tooltip->y() && Fl::event_y_root() < tooltip->y() + tooltip->h() );
|
||||
}
|
||||
// if inside, send event to tooltip window instead of background window
|
||||
if (inside)
|
||||
window = tooltip;
|
||||
}
|
||||
Fl::handle( sendEvent, window );
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -144,6 +144,12 @@ void Fl_Translated_GDI_Graphics_Driver::untranslate_all() {
|
|||
SetWindowOrgEx((HDC)gc(), origins[depth].x, origins[depth].y, NULL);
|
||||
}
|
||||
|
||||
void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int W, int H) {
|
||||
Fl_Region R = XRectangleRegion(X, Y, W, H);
|
||||
CombineRgn(r, r, R, RGN_OR);
|
||||
XDestroyRegion(R);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
|
||||
#include "../../config_lib.h"
|
||||
#include "Fl_Quartz_Graphics_Driver.h"
|
||||
#include "Fl_Quartz_Graphics_Driver.H"
|
||||
|
||||
/* Reference to the current CGContext
|
||||
For back-compatibility only. The preferred procedure to get this reference is
|
||||
|
@ -70,6 +70,18 @@ void Fl_Quartz_Graphics_Driver::copy_offscreen(int x,int y,int w,int h,Fl_Offscr
|
|||
CGDataProviderRelease(src_bytes);
|
||||
}
|
||||
|
||||
void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int W, int H) {
|
||||
CGRect arg = fl_cgrectmake_cocoa(X, Y, W, H);
|
||||
int j; // don't add a rectangle totally inside the Fl_Region
|
||||
for(j = 0; j < r->count; j++) {
|
||||
if(CGRectContainsRect(r->rects[j], arg)) break;
|
||||
}
|
||||
if( j >= r->count) {
|
||||
r->rects = (CGRect*)realloc(r->rects, (++(r->count)) * sizeof(CGRect));
|
||||
r->rects[r->count - 1] = arg;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
|
|
@ -580,7 +580,8 @@ if (fl_mac_os_version >= Fl_X::CoreText_threshold) {
|
|||
// activate the current GC
|
||||
iSize = sizeof(CGContextRef);
|
||||
iTag = kATSUCGContextTag;
|
||||
iValuePtr = &gc_;
|
||||
CGContextRef value = (CGContextRef)fl_graphics_driver->gc();
|
||||
iValuePtr = &value;
|
||||
ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr);
|
||||
// now measure the bounding box
|
||||
err = ATSUSetTextPointerLocation(layout, txt, kATSUFromTextBeginning, n, n);
|
||||
|
@ -657,7 +658,8 @@ else {
|
|||
// activate the current GC
|
||||
iSize = sizeof(CGContextRef);
|
||||
iTag = kATSUCGContextTag;
|
||||
iValuePtr = &gc_;
|
||||
CGContextRef value = (CGContextRef)gc();
|
||||
iValuePtr = &value;
|
||||
ATSUSetLayoutControls(layout, 1, &iTag, &iSize, &iValuePtr);
|
||||
// now measure the bounding box
|
||||
err = ATSUSetTextPointerLocation(layout, txt, kATSUFromTextBeginning, n, n);
|
||||
|
|
|
@ -98,6 +98,13 @@ void Fl_Xlib_Graphics_Driver::copy_offscreen_with_alpha(int x, int y, int w, int
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
void Fl_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int W, int H) {
|
||||
XRectangle R;
|
||||
R.x = X; R.y = Y; R.width = W; R.height = H;
|
||||
XUnionRectWithRegion(&R, r, r);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue