STR#3444: Add MacOS support for application rescaling (not quite complete)
With this, most MacOS FLTK app can be scaled with command/+/-/0/ keystrokes. A scaling problem remains, visible in test/cube, where the "Test" string is not positioned correctly. GLUT apps can also be scaled (across platforms). SVG images are re-rasterized after app scaling for optimal drawing. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12594 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
31f16205cb
commit
3f9f4debbb
@ -77,6 +77,8 @@ struct Fl_Fontdesc;
|
||||
class FL_EXPORT Fl_Graphics_Driver {
|
||||
friend class Fl_Surface_Device;
|
||||
friend class Fl_Display_Device;
|
||||
friend class Fl_Screen_Driver;
|
||||
friend class Fl_Window_Driver;
|
||||
friend class Fl_Pixmap;
|
||||
friend class Fl_Bitmap;
|
||||
friend class Fl_RGB_Image;
|
||||
@ -93,6 +95,10 @@ class FL_EXPORT Fl_Graphics_Driver {
|
||||
private:
|
||||
// some platforms may need to reimplement this
|
||||
virtual void set_current_();
|
||||
protected:
|
||||
float scale_; // scale between user and graphical coordinates: graphical = user * scale_
|
||||
/** Sets the current value of the scaling factor */
|
||||
virtual void scale(float f) { scale_ = f; }
|
||||
public:
|
||||
// The following functions create the various graphics drivers that are required
|
||||
// for core operations. They must be implemented as members of Fl_Graphics_Driver,
|
||||
@ -218,6 +224,8 @@ public:
|
||||
Fl_Graphics_Driver();
|
||||
virtual ~Fl_Graphics_Driver() {} ///< Destructor
|
||||
static Fl_Graphics_Driver &default_driver();
|
||||
/** Current scale factor between FLTK and graphical coordinates: graphical = FLTK * scale() */
|
||||
float scale() { return scale_; }
|
||||
/** Return whether the graphics driver can do alpha blending */
|
||||
virtual char can_do_alpha_blending() { return 0; }
|
||||
// --- implementation is in src/fl_rect.cxx which includes src/drivers/xxx/Fl_xxx_Graphics_Driver_rect.cxx
|
||||
@ -370,10 +378,6 @@ public:
|
||||
virtual void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h);
|
||||
virtual Fl_Region XRectangleRegion(int x, int y, int w, int h);
|
||||
virtual void XDestroyRegion(Fl_Region r);
|
||||
/** Returns the current value of the scaling factor (usually > 1 on HiDPI displays) */
|
||||
virtual float scale() {return 1;}
|
||||
/** Sets the current value of the scaling factor */
|
||||
virtual void scale(float f) {}
|
||||
/** Support for Fl::get_font_name() */
|
||||
virtual const char* get_font_name(Fl_Font fnum, int* ap) {return NULL;}
|
||||
/** Support for Fl::get_font_sizes() */
|
||||
@ -411,9 +415,7 @@ public:
|
||||
class FL_EXPORT Fl_Scalable_Graphics_Driver : public Fl_Graphics_Driver {
|
||||
public:
|
||||
Fl_Scalable_Graphics_Driver();
|
||||
float scale() { return scale_; }
|
||||
protected:
|
||||
float scale_; // scale between user and graphical coordinates: graphical = user * scale_
|
||||
int line_width_;
|
||||
void cache_size(Fl_Image *img, int &width, int &height);
|
||||
virtual Fl_Region scale_clip(float f)=0;
|
||||
|
||||
@ -25,6 +25,7 @@ extern int fl_gl_load_plugin;
|
||||
#include <FL/Fl_Gl_Window.H>
|
||||
#include <FL/Fl_Gl_Window_Driver.H>
|
||||
#include <FL/Fl_Window_Driver.H>
|
||||
#include <FL/Fl_Graphics_Driver.H>
|
||||
#include <stdlib.h>
|
||||
#include <FL/fl_utf8.h>
|
||||
# if (HAVE_DLSYM && HAVE_DLFCN_H)
|
||||
@ -516,8 +517,9 @@ void Fl_Cocoa_Gl_Window_Driver::after_show(int need_redraw) {
|
||||
|
||||
float Fl_Cocoa_Gl_Window_Driver::pixels_per_unit()
|
||||
{
|
||||
return (fl_mac_os_version >= 100700 && Fl::use_high_res_GL() && Fl_X::i(pWindow) &&
|
||||
int retina = (fl_mac_os_version >= 100700 && Fl::use_high_res_GL() && Fl_X::i(pWindow) &&
|
||||
Fl_Cocoa_Window_Driver::driver(pWindow)->mapped_to_retina()) ? 2 : 1;
|
||||
return retina * Fl_Graphics_Driver::default_driver().scale();
|
||||
}
|
||||
|
||||
int Fl_Cocoa_Gl_Window_Driver::mode_(int m, const int *a) {
|
||||
|
||||
@ -41,6 +41,7 @@ Fl_Graphics_Driver::Fl_Graphics_Driver()
|
||||
m = m0;
|
||||
fl_matrix = &m;
|
||||
font_descriptor_ = NULL;
|
||||
scale_ = 1;
|
||||
};
|
||||
|
||||
/** Return the graphics driver used when drawing to the platform's display */
|
||||
|
||||
@ -193,6 +193,7 @@ void Fl_SVG_Image::rasterize_(int W, int H) {
|
||||
rasterized_ = true;
|
||||
raster_w_ = W;
|
||||
raster_h_ = H;
|
||||
//printf("rasterize to %dx%d\n",W, H);
|
||||
}
|
||||
|
||||
|
||||
@ -234,10 +235,14 @@ void Fl_SVG_Image::resize(int width, int height) {
|
||||
|
||||
|
||||
void Fl_SVG_Image::draw(int X, int Y, int W, int H, int cx, int cy) {
|
||||
static float f = Fl::screen_driver()->retina_factor();
|
||||
float f = 1;
|
||||
if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) {
|
||||
f = Fl::screen_driver()->retina_factor() * fl_graphics_driver->scale();
|
||||
}
|
||||
int w1 = w(), h1 = h();
|
||||
/* When f > 1, there may be several pixels per drawing unit in an area
|
||||
of size w() x h() of the display. This occurs, e.g., with Apple retina displays.
|
||||
of size w() x h() of the display. This occurs, e.g., with Apple retina displays
|
||||
and when the display is rescaled.
|
||||
The SVG is rasterized to the area dimension in pixels. The image is then drawn
|
||||
scaled to its size expressed in drawing units. With this procedure,
|
||||
the SVG image is drawn using the full resolution of the display.
|
||||
@ -269,9 +274,6 @@ void Fl_SVG_Image::color_average(Fl_Color c, float i) {
|
||||
|
||||
|
||||
int Fl_SVG_Image::draw_scaled(int X, int Y, int W, int H) {
|
||||
if (rasterized_ && raster_w_ >= W && raster_h_ >= H) {
|
||||
return fl_graphics_driver->draw_scaled(this, X, Y, W, H);
|
||||
}
|
||||
w(W);
|
||||
h(H);
|
||||
draw(X, Y, W, H, 0, 0);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
//
|
||||
// MacOS-Cocoa specific code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
||||
// Copyright 1998-2017 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -742,7 +742,10 @@ void Fl_Cocoa_Screen_Driver::remove_timeout(Fl_Timeout_Handler cb, void* data)
|
||||
by += parent->y();
|
||||
parent = parent->window();
|
||||
}
|
||||
NSRect rp = NSMakeRect(bx, main_screen_height - (by + w->h()), w->w(), w->h());
|
||||
float s = Fl::screen_driver()->scale(0);
|
||||
NSRect rp = NSMakeRect(int(s * bx + 0.5), main_screen_height - int(s * (by + w->h()) + 0.5),
|
||||
int(s * w->w() + 0.5), int(s * w->h() + 0.5));
|
||||
|
||||
if (!NSEqualRects(rp, [self frame])) {
|
||||
[self setFrame:rp display:YES];
|
||||
}
|
||||
@ -982,11 +985,12 @@ static void update_e_xy_and_e_xy_root(NSWindow *nsw)
|
||||
{
|
||||
NSPoint pt;
|
||||
pt = [nsw mouseLocationOutsideOfEventStream];
|
||||
Fl::e_x = int(pt.x);
|
||||
Fl::e_y = int([[nsw contentView] frame].size.height - pt.y);
|
||||
float s = Fl::screen_driver()->scale(0);
|
||||
Fl::e_x = int(pt.x / s);
|
||||
Fl::e_y = int(([[nsw contentView] frame].size.height - pt.y)/s);
|
||||
pt = [NSEvent mouseLocation];
|
||||
Fl::e_x_root = int(pt.x);
|
||||
Fl::e_y_root = int(main_screen_height - pt.y);
|
||||
Fl::e_x_root = int(pt.x/s);
|
||||
Fl::e_y_root = int((main_screen_height - pt.y)/s);
|
||||
}
|
||||
|
||||
|
||||
@ -1074,6 +1078,8 @@ static void cocoaMouseHandler(NSEvent *theEvent)
|
||||
Fl_Window *first = Fl::first_window();
|
||||
if (first != window && !(first->modal() || first->non_modal())) Fl::first_window(window);
|
||||
NSPoint pos = [theEvent locationInWindow];
|
||||
float s = Fl::screen_driver()->scale(0);
|
||||
pos.x /= s; pos.y /= s;
|
||||
pos.y = window->h() - pos.y;
|
||||
NSInteger btn = [theEvent buttonNumber] + 1;
|
||||
NSUInteger mods = [theEvent modifierFlags];
|
||||
@ -1311,6 +1317,9 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
||||
pt2 = [nsw convertBaseToScreen:NSMakePoint(0, [[nsw contentView] frame].size.height)];
|
||||
update_e_xy_and_e_xy_root(nsw);
|
||||
pt2.y = main_screen_height - pt2.y;
|
||||
float s = Fl::screen_driver()->scale(0);
|
||||
pt2.x = int(pt2.x / s + 0.5);
|
||||
pt2.y = int(pt2.y / s + 0.5);
|
||||
Fl_Window *parent = window->window();
|
||||
while (parent) {
|
||||
pt2.x -= parent->x();
|
||||
@ -1340,6 +1349,8 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
||||
r = [[nsw contentView] frame];
|
||||
pt2 = [nsw convertBaseToScreen:NSMakePoint(0, r.size.height)];
|
||||
pt2.y = main_screen_height - pt2.y;
|
||||
float s = Fl::screen_driver()->scale(window->driver()->screen_num());
|
||||
pt2.x = int(pt2.x/s + 0.5); pt2.y = int(pt2.y/s + 0.5);
|
||||
Fl_Window *parent = window->window();
|
||||
while (parent) {
|
||||
pt2.x -= parent->x();
|
||||
@ -1350,7 +1361,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
||||
Fl_Cocoa_Window_Driver *d = Fl_Cocoa_Window_Driver::driver(window);
|
||||
if (window->as_gl_window() && Fl_X::i(window)) d->in_windowDidResize(true);
|
||||
update_e_xy_and_e_xy_root(nsw);
|
||||
window->resize((int)pt2.x, (int)pt2.y, (int)r.size.width, (int)r.size.height);
|
||||
window->resize((int)(pt2.x), (int)(pt2.y), (int)(r.size.width/s +0.5), (int)(r.size.height/s +0.5));
|
||||
[nsw recursivelySendToSubwindows:@selector(setSubwindowFrame)];
|
||||
[nsw recursivelySendToSubwindows:@selector(checkSubwindowFrame)];
|
||||
if (window->as_gl_window() && Fl_X::i(window)) d->in_windowDidResize(false);
|
||||
@ -3009,10 +3020,11 @@ Fl_X* Fl_Cocoa_Window_Driver::makeWindow()
|
||||
winstyle = NSBorderlessWindowMask;
|
||||
winlevel = NSStatusWindowLevel;
|
||||
}
|
||||
crect.origin.x = w->x(); // correct origin set later for subwindows
|
||||
crect.origin.y = main_screen_height - (w->y() + w->h());
|
||||
crect.size.width=w->w();
|
||||
crect.size.height=w->h();
|
||||
float s = Fl::screen_driver()->scale(0);
|
||||
crect.origin.x = int(s * w->x()); // correct origin set later for subwindows
|
||||
crect.origin.y = main_screen_height - int(s * (w->y() + w->h()));
|
||||
crect.size.width = int(s * w->w());
|
||||
crect.size.height = int(s * w->h());
|
||||
FLWindow *cw = [[FLWindow alloc] initWithFl_W:w
|
||||
contentRect:crect
|
||||
styleMask:winstyle];
|
||||
@ -3056,8 +3068,8 @@ Fl_X* Fl_Cocoa_Window_Driver::makeWindow()
|
||||
delta = [cw cascadeTopLeftFromPoint:delta];
|
||||
}
|
||||
crect = [cw frame]; // synchronize FLTK's and the system's window coordinates
|
||||
this->x(int(crect.origin.x));
|
||||
this->y(int(main_screen_height - (crect.origin.y + w->h())));
|
||||
this->x(int(crect.origin.x/s));
|
||||
this->y( main_screen_height/s - (crect.origin.y/s + w->h()) );
|
||||
}
|
||||
if(w->menu_window()) { // make menu windows slightly transparent
|
||||
[cw setAlphaValue:0.97];
|
||||
@ -3196,7 +3208,7 @@ void Fl_Cocoa_Window_Driver::resize(int X,int Y,int W,int H) {
|
||||
Fl_Window *parent;
|
||||
if (W<=0) W = 1; // OS X does not like zero width windows
|
||||
if (H<=0) H = 1;
|
||||
int is_a_resize = (W != w() || H != h());
|
||||
int is_a_resize = (W != w() || H != h() || is_a_rescale());
|
||||
// printf("Fl_Window::resize(X=%d, Y=%d, W=%d, H=%d), is_a_resize=%d, resize_from_system=%p, this=%p\n",
|
||||
// X, Y, W, H, is_a_resize, resize_from_system, this);
|
||||
if (X != x() || Y != y()) force_position(1);
|
||||
@ -3226,7 +3238,8 @@ void Fl_Cocoa_Window_Driver::resize(int X,int Y,int W,int H) {
|
||||
by += parent->y();
|
||||
parent = parent->window();
|
||||
}
|
||||
NSRect r = NSMakeRect(bx, main_screen_height - (by + H), W, H + (border()?bt:0));
|
||||
float s = Fl::screen_driver()->scale(screen_num());
|
||||
NSRect r = NSMakeRect(int(bx*s+0.5), main_screen_height - int((by + H)*s +0.5), int(W*s+0.5), int(H*s+0.5) + (border()?bt:0));
|
||||
if (visible_r()) [fl_xid(pWindow) setFrame:r display:YES];
|
||||
} else {
|
||||
bx = X; by = Y;
|
||||
@ -3310,6 +3323,9 @@ void Fl_Cocoa_Window_Driver::make_current()
|
||||
// half pixel offset is necessary for clipping as done by fl_cgrectmake_cocoa()
|
||||
if (subRect()) CGContextClipToRect(gc, CGRectOffset(*(subRect()), -0.5, -0.5));
|
||||
|
||||
float s = Fl::screen_driver()->scale(0);
|
||||
CGContextScaleCTM(gc, s, s); // apply current scaling factor
|
||||
|
||||
// this is the context with origin at top left of (sub)window
|
||||
CGContextSaveGState(gc);
|
||||
#if defined(FLTK_USE_CAIRO)
|
||||
@ -4333,17 +4349,19 @@ void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top,
|
||||
int htop = pWindow->decorated_h() - h();
|
||||
CALayer *layer = get_titlebar_layer(pWindow);
|
||||
CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
|
||||
uchar *rgba = new uchar[4 * w() * htop * 4];
|
||||
CGContextRef auxgc = CGBitmapContextCreate(rgba, 2 * w(), 2 * htop, 8, 8 * w(), cspace, kCGImageAlphaPremultipliedLast);
|
||||
float s = Fl::screen_driver()->scale(screen_num());
|
||||
int scaled_w = int(w() * s);
|
||||
uchar *rgba = new uchar[4 * scaled_w * htop * 4];
|
||||
CGContextRef auxgc = CGBitmapContextCreate(rgba, 2 * scaled_w, 2 * htop, 8, 8 * scaled_w, cspace, kCGImageAlphaPremultipliedLast);
|
||||
CGColorSpaceRelease(cspace);
|
||||
CGContextClearRect(auxgc, CGRectMake(0,0,2*w(),2*htop));
|
||||
CGContextClearRect(auxgc, CGRectMake(0,0,2*scaled_w,2*htop));
|
||||
CGContextScaleCTM(auxgc, 2, 2);
|
||||
if (layer) {
|
||||
Fl_Cocoa_Window_Driver::draw_layer_to_context(layer, auxgc, w(), htop);
|
||||
Fl_Cocoa_Window_Driver::draw_layer_to_context(layer, auxgc, scaled_w, htop);
|
||||
if (fl_mac_os_version >= 101300) {
|
||||
// drawn layer is left transparent and alpha-premultiplied: demultiply it and set it opaque.
|
||||
uchar *p = rgba;
|
||||
uchar *last = rgba + 4 * w() * htop * 4;
|
||||
uchar *last = rgba + 4 * scaled_w * htop * 4;
|
||||
while (p < last) {
|
||||
uchar q = *(p+3);
|
||||
if (q) {
|
||||
@ -4356,14 +4374,14 @@ void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CGImageRef img = CGImage_from_window_rect(0, -htop, w(), htop);
|
||||
CGImageRef img = CGImage_from_window_rect(0, -htop, scaled_w, htop);
|
||||
CGContextSaveGState(auxgc);
|
||||
clip_to_rounded_corners(auxgc, w(), htop);
|
||||
CGContextDrawImage(auxgc, CGRectMake(0, 0, w(), htop), img);
|
||||
clip_to_rounded_corners(auxgc, scaled_w, htop);
|
||||
CGContextDrawImage(auxgc, CGRectMake(0, 0, scaled_w, htop), img);
|
||||
CGContextRestoreGState(auxgc);
|
||||
CFRelease(img);
|
||||
}
|
||||
Fl_RGB_Image *top_rgb = new Fl_RGB_Image(rgba, 2 * w(), 2 * htop, 4);
|
||||
Fl_RGB_Image *top_rgb = new Fl_RGB_Image(rgba, 2 * scaled_w, 2 * htop, 4);
|
||||
top_rgb->alloc_array = 1;
|
||||
top = Fl_Shared_Image::get(top_rgb);
|
||||
top->scale(w(),htop);
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include <FL/Fl_Printer.H>
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
#include <FL/Fl_Window_Driver.H>
|
||||
#include <FL/Fl_Screen_Driver.H>
|
||||
#include "../Quartz/Fl_Quartz_Graphics_Driver.H"
|
||||
#include "../Darwin/Fl_Darwin_System_Driver.H"
|
||||
#include "Fl_Cocoa_Window_Driver.H"
|
||||
@ -401,8 +402,9 @@ void Fl_Cocoa_Printer_Driver::draw_decorated_window(Fl_Window *win, int x_offset
|
||||
CGContextRef gc = (CGContextRef)driver()->gc();
|
||||
CGContextSaveGState(gc);
|
||||
CGContextTranslateCTM(gc, x_offset - 0.5, y_offset + bt - 0.5);
|
||||
CGContextScaleCTM(gc, 1, -1);
|
||||
Fl_Cocoa_Window_Driver::draw_layer_to_context(layer, gc, win->w(), bt);
|
||||
float s = Fl::screen_driver()->scale(win->driver()->screen_num());
|
||||
CGContextScaleCTM(gc, 1/s, -1/s);
|
||||
Fl_Cocoa_Window_Driver::draw_layer_to_context(layer, gc, win->w() * s, bt);
|
||||
CGContextRestoreGState(gc);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
// Definition of Apple Cocoa Screen interface
|
||||
// for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2010-2016 by Bill Spitzak and others.
|
||||
// Copyright 2010-2017 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -97,6 +97,12 @@ public:
|
||||
// --- compute dimensions of an Fl_Offscreen
|
||||
virtual void offscreen_size(Fl_Offscreen o, int &width, int &height);
|
||||
virtual float retina_factor() { return 2; }
|
||||
|
||||
virtual APP_SCALING_CAPABILITY rescalable() { return SYSTEMWIDE_APP_SCALING; }
|
||||
virtual float scale(int n) {return scale_;}
|
||||
virtual void scale(int n, float f) { scale_ = f;}
|
||||
private:
|
||||
float scale_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -99,10 +99,11 @@ void Fl_Cocoa_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int n)
|
||||
if ((n < 0) || (n >= num_screens))
|
||||
n = 0;
|
||||
|
||||
X = screens[n].x;
|
||||
Y = screens[n].y;
|
||||
W = screens[n].width;
|
||||
H = screens[n].height;
|
||||
float s = scale(0);
|
||||
X = screens[n].x/s;
|
||||
Y = screens[n].y/s;
|
||||
W = screens[n].width/s;
|
||||
H = screens[n].height/s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ Fl_GDI_Copy_Surface_Driver::Fl_GDI_Copy_Surface_Driver(int w, int h) : Fl_Copy_S
|
||||
// Global display scaling factor: 1, 1.25, 1.5, 1.75, etc...
|
||||
#ifdef FLTK_HIDPI_SUPPORT
|
||||
float scaling = Fl_Graphics_Driver::default_driver().scale();
|
||||
driver()->scale(scaling);
|
||||
((Fl_GDI_Graphics_Driver*)driver())->scale(scaling);
|
||||
#else
|
||||
float scaling = 1/((Fl_WinAPI_Screen_Driver*)Fl::screen_driver())->DWM_scaling_factor();
|
||||
#endif
|
||||
|
||||
@ -93,7 +93,6 @@ public:
|
||||
void untranslate_all(void);
|
||||
static HRGN scale_region(HRGN r, float f, Fl_GDI_Graphics_Driver *dr);
|
||||
virtual void scale(float f);
|
||||
virtual float scale();
|
||||
protected:
|
||||
void transformed_vertex0(float x, float y);
|
||||
void fixloop();
|
||||
|
||||
@ -236,10 +236,6 @@ void Fl_GDI_Graphics_Driver::scale(float f) {
|
||||
}
|
||||
}
|
||||
|
||||
float Fl_GDI_Graphics_Driver::scale() {
|
||||
return scale_;
|
||||
}
|
||||
|
||||
|
||||
/* Rescale region r with factor f and returns the scaled region.
|
||||
Region r is returned unchanged if r is null or f is 1.
|
||||
|
||||
@ -58,7 +58,7 @@ Fl_GDI_Image_Surface_Driver::Fl_GDI_Image_Surface_Driver(int w, int h, int high_
|
||||
offscreen = off ? off : CreateCompatibleBitmap( (gc ? gc : fl_GetDC(0) ) , w, h);
|
||||
if (!offscreen) offscreen = CreateCompatibleBitmap(fl_GetDC(0), w, h);
|
||||
driver(new Fl_GDI_Graphics_Driver);
|
||||
if (d != 1 && high_res) driver()->scale(d);
|
||||
if (d != 1 && high_res) ((Fl_GDI_Graphics_Driver*)driver())->scale(d);
|
||||
origin.x = origin.y = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include <FL/x.H>
|
||||
#include "Fl_WinAPI_Window_Driver.H"
|
||||
#include "Fl_WinAPI_Screen_Driver.H"
|
||||
#include "../GDI/Fl_GDI_Graphics_Driver.H"
|
||||
#include <windows.h>
|
||||
#include <math.h> // for ceil()
|
||||
|
||||
@ -415,7 +416,7 @@ void Fl_WinAPI_Window_Driver::make_current() {
|
||||
#endif // USE_COLORMAP
|
||||
|
||||
fl_graphics_driver->clip_region(0);
|
||||
fl_graphics_driver->scale(Fl::screen_driver()->scale(screen_num()));
|
||||
((Fl_GDI_Graphics_Driver*)fl_graphics_driver)->scale(Fl::screen_driver()->scale(screen_num()));
|
||||
}
|
||||
|
||||
void Fl_WinAPI_Window_Driver::label(const char *name,const char *iname) {
|
||||
|
||||
@ -105,7 +105,6 @@ public:
|
||||
void translate_all(int dx, int dy);
|
||||
void untranslate_all();
|
||||
virtual void scale(float f);
|
||||
virtual float scale();
|
||||
virtual int has_feature(driver_feature mask) { return mask & NATIVE; }
|
||||
virtual void *gc() { return gc_; }
|
||||
virtual void gc(void *value);
|
||||
|
||||
@ -100,11 +100,6 @@ void Fl_Xlib_Graphics_Driver::scale(float f) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
float Fl_Xlib_Graphics_Driver::scale() {
|
||||
return scale_;
|
||||
}
|
||||
|
||||
void Fl_Xlib_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
|
||||
XCopyArea(fl_display, pixmap, fl_window, gc_, srcx*scale_, srcy*scale_, w*scale_, h*scale_, (x+offset_x_)*scale_, (y+offset_y_)*scale_);
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "flstring.h"
|
||||
#if HAVE_GL
|
||||
# include <FL/Fl_Gl_Window_Driver.H>
|
||||
# include <FL/Fl_Screen_Driver.H>
|
||||
# include <FL/glut.H>
|
||||
# define MAXWINDOWS 32
|
||||
|
||||
@ -130,6 +131,9 @@ int Fl_Glut_Window::handle(int event) {
|
||||
if (!keyboard && !special) break;
|
||||
|
||||
case FL_KEYBOARD:
|
||||
// keyboard() does not distinguish between recognized and unrecognized keystrokes
|
||||
// so check for window scaling keystroke before normal keystroke processing
|
||||
if ( Fl::event_command() && Fl_Screen_Driver::scale_handler(FL_SHORTCUT) ) return 1;
|
||||
if (Fl::event_text()[0]) {
|
||||
if (keyboard) {keyboard(Fl::event_text()[0],ex,ey); return 1;}
|
||||
break;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user