Make draw to image and draw to clipboard behave equally in X11 and Wayland
This commit is contained in:
parent
ca786597f7
commit
c0c2cf7d40
@ -48,8 +48,13 @@ void Fl_X11_Cairo_Graphics_Driver::scale(float f) {
|
||||
}
|
||||
|
||||
|
||||
void Fl_X11_Cairo_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)Fl_Graphics_Driver::default_driver().gc(), int(srcx*scale()), int(srcy*scale()), int(w*scale()), int(h*scale()), int(x*scale()), int(y*scale()));
|
||||
void Fl_X11_Cairo_Graphics_Driver::copy_offscreen(int x, int y, int w, int h,
|
||||
Fl_Offscreen pixmap, int srcx, int srcy) {
|
||||
cairo_matrix_t mat;
|
||||
if (cairo_) cairo_get_matrix(cairo_, &mat);
|
||||
else cairo_matrix_init_identity(&mat);
|
||||
XCopyArea(fl_display, pixmap, fl_window, (GC)Fl_Graphics_Driver::default_driver().gc(), int(srcx*scale()), int(srcy*scale()), int(w*scale()), int(h*scale()),
|
||||
int(x*scale()) + mat.x0, int(y*scale()) + mat.y0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,15 +22,14 @@
|
||||
|
||||
|
||||
Fl_Wayland_Copy_Surface_Driver::Fl_Wayland_Copy_Surface_Driver(int w, int h) : Fl_Copy_Surface_Driver(w, h) {
|
||||
struct Fl_Wayland_Window_Driver::surface_output *s_output = NULL;
|
||||
if (Fl_Wayland_Window_Driver::wld_window &&
|
||||
!wl_list_empty(&Fl_Wayland_Window_Driver::wld_window->outputs)) {
|
||||
s_output = wl_container_of(Fl_Wayland_Window_Driver::wld_window->outputs.next, s_output, link);
|
||||
float os_scale = Fl_Graphics_Driver::default_driver().scale();
|
||||
int d = 1;
|
||||
if (Fl::first_window()) {
|
||||
d = Fl_Wayland_Window_Driver::driver(Fl::first_window())->wld_scale();
|
||||
}
|
||||
int os_scale = (s_output ? s_output->output->wld_scale : 1);
|
||||
img_surf = new Fl_Image_Surface(w * os_scale, h * os_scale);
|
||||
img_surf = new Fl_Image_Surface(int(w * os_scale) * d, int(h * os_scale) * d);
|
||||
driver(img_surf->driver());
|
||||
driver()->scale(os_scale);
|
||||
driver()->scale(d * os_scale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,12 +27,10 @@ Fl_Wayland_Image_Surface_Driver::Fl_Wayland_Image_Surface_Driver(int w, int h,
|
||||
int d = 1;
|
||||
if (!off) {
|
||||
fl_open_display();
|
||||
if (Fl_Wayland_Window_Driver::wld_window) {
|
||||
d = Fl_Wayland_Window_Driver::driver(
|
||||
Fl_Wayland_Window_Driver::wld_window->fl_win
|
||||
)->wld_scale();
|
||||
if (Fl::first_window()) {
|
||||
d = Fl_Wayland_Window_Driver::driver(Fl::first_window())->wld_scale();
|
||||
}
|
||||
s = fl_graphics_driver->scale();
|
||||
s = Fl_Graphics_Driver::default_driver().scale();
|
||||
if (d*s != 1 && high_res) {
|
||||
w = int(w * s) * d;
|
||||
h = int(h * s) * d;
|
||||
|
||||
@ -45,7 +45,6 @@ Fl_Xlib_Copy_Surface_Driver::Fl_Xlib_Copy_Surface_Driver(int w, int h) : Fl_Copy
|
||||
cairo_surface_t *surf = cairo_xlib_surface_create(fl_display, xid->offscreen(), fl_visual->visual, w * s, h * s);
|
||||
cairo_ = cairo_create(surf);
|
||||
cairo_surface_destroy(surf);
|
||||
cairo_scale(cairo_, 1/s, 1/s);
|
||||
cairo_save(cairo_);
|
||||
((Fl_X11_Cairo_Graphics_Driver*)driver())->set_cairo(cairo_);
|
||||
#endif
|
||||
@ -62,8 +61,10 @@ Fl_Xlib_Copy_Surface_Driver::~Fl_Xlib_Copy_Surface_Driver() {
|
||||
Fl_RGB_Image *rgb = Fl::screen_driver()->read_win_rectangle(0, 0, width, height, 0);
|
||||
fl_window = old_win;
|
||||
if (is_current()) end_current();
|
||||
Fl_X11_Screen_Driver::copy_image(rgb->array, rgb->w(), rgb->h(), 1);
|
||||
delete rgb;
|
||||
if (rgb) {
|
||||
Fl_X11_Screen_Driver::copy_image(rgb->array, rgb->w(), rgb->h(), 1);
|
||||
delete rgb;
|
||||
}
|
||||
delete xid;
|
||||
#if FLTK_USE_CAIRO
|
||||
cairo_destroy(cairo_);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user