From 26a78c49925bf0a4fe1a2a8024298cb7afde9db0 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 23 Mar 2022 07:57:05 +0100 Subject: Fix for issue #419: Wayland: scale/resize issue. --- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 1e3990559..b1ac7974e 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -1490,6 +1490,7 @@ void Fl_Wayland_Window_Driver::resize(int X, int Y, int W, int H) { fl_win->configured_width = W; fl_win->configured_height = H; if (!in_handle_configure && xdg_toplevel()) { + if (Fl_Window::is_a_rescale()) size_range(); struct libdecor_state *state = libdecor_state_new(int(W * f), int(H * f)); libdecor_frame_commit(fl_win->frame, state, NULL); // necessary only if resize is initiated by prog libdecor_state_free(state); -- cgit v1.2.3 From 2d71a95b5d3b6eddb6d193a0d22a618938798c4f Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 23 Mar 2022 11:37:15 +0100 Subject: Wayland: replace global fl_display by function struct wl_display *fl_wl_display(). --- .../Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 16 ++++----- src/drivers/Wayland/Fl_Wayland_Screen_Driver.H | 1 + src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 35 ++++++++---------- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 41 ++++++++-------------- src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx | 8 ++--- 5 files changed, 42 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index 505709e09..e28588369 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx @@ -62,8 +62,8 @@ Fl_Wayland_Gl_Window_Driver::Fl_Wayland_Gl_Window_Driver(Fl_Gl_Window *win) : Fl void Fl_Wayland_Gl_Window_Driver::init() { EGLint major, minor; - if (!fl_display) Fl::screen_driver()->open_display(); - egl_display = eglGetDisplay((EGLNativeDisplayType) fl_display); + if (!Fl_Wayland_Screen_Driver::wl_display) Fl::screen_driver()->open_display(); + egl_display = eglGetDisplay((EGLNativeDisplayType) Fl_Wayland_Screen_Driver::wl_display); if (egl_display == EGL_NO_DISPLAY) { Fl::fatal("Can't create egl display\n"); } @@ -77,7 +77,7 @@ void Fl_Wayland_Gl_Window_Driver::init() { //printf("EGL has %d configs\n", configs_count); eglBindAPI(EGL_OPENGL_API); - gl_event_queue = wl_display_create_queue(fl_display); + gl_event_queue = wl_display_create_queue(Fl_Wayland_Screen_Driver::wl_display); } @@ -246,7 +246,7 @@ void Fl_Wayland_Gl_Window_Driver::make_current_before() { struct wl_callback *callback = wl_surface_frame(surface); wl_surface_commit(surface); wl_callback_add_listener(callback, &gl_surface_frame_listener, &done); - while (!done) wl_display_dispatch(fl_display); + while (!done) wl_display_dispatch(Fl_Wayland_Screen_Driver::wl_display); } } } @@ -301,11 +301,11 @@ void Fl_Wayland_Gl_Window_Driver::swap_buffers() { if (egl_surface) { //eglSwapInterval(egl_display, 0); // doesn't seem to have any effect in this context if (!egl_resize_in_progress) { - while (wl_display_prepare_read(fl_display) != 0) { - wl_display_dispatch_pending(fl_display); + while (wl_display_prepare_read(Fl_Wayland_Screen_Driver::wl_display) != 0) { + wl_display_dispatch_pending(Fl_Wayland_Screen_Driver::wl_display); } - wl_display_read_events(fl_display); - wl_display_dispatch_queue_pending(fl_display, gl_event_queue); + wl_display_read_events(Fl_Wayland_Screen_Driver::wl_display); + wl_display_dispatch_queue_pending(Fl_Wayland_Screen_Driver::wl_display, gl_event_queue); } egl_resize_in_progress = false; eglSwapBuffers(Fl_Wayland_Gl_Window_Driver::egl_display, egl_surface); diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H index 0ce25734f..97395dbef 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.H @@ -63,6 +63,7 @@ class FL_EXPORT Fl_Wayland_Screen_Driver : public Fl_Screen_Driver static int insertion_point_height; static bool insertion_point_location_is_valid; public: + static struct wl_display *wl_display; static void insertion_point_location(int x, int y, int height); static bool insertion_point_location(int *px, int *py, int *pwidth, int *pheight); int get_mouse_unscaled(int &xx, int &yy); diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index 458435756..081edfb50 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -157,8 +157,6 @@ extern const char *fl_bg2; // end of extern additions workaround -FL_EXPORT struct wl_display *fl_display = NULL; - static bool has_xrgb = false; @@ -225,6 +223,9 @@ static inline void checkdouble() { } +struct wl_display *Fl_Wayland_Screen_Driver::wl_display = NULL; + + Fl_Window *Fl_Wayland_Screen_Driver::surface_to_window(struct wl_surface *surface) { Fl_X *xp = Fl_X::first; while (xp) { @@ -749,7 +750,7 @@ void text_input_enter(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, zwp_text_input_v3_set_cursor_rectangle(zwp_text_input_v3, x, y, width, height); } zwp_text_input_v3_commit(zwp_text_input_v3); - wl_display_roundtrip(fl_display); + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); } void text_input_leave(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, @@ -1059,7 +1060,6 @@ Fl_Wayland_Screen_Driver::Fl_Wayland_Screen_Driver() : Fl_Screen_Driver() { } void Fl_Wayland_Screen_Driver::open_display_platform() { - struct wl_display *wl_display; struct wl_registry *wl_registry; static bool beenHereDoneThat = false; @@ -1071,7 +1071,6 @@ void Fl_Wayland_Screen_Driver::open_display_platform() { if (!wl_display) { Fl::fatal("No Wayland connection\n"); } - fl_display = wl_display; wl_list_init(&seats); wl_list_init(&outputs); @@ -1090,8 +1089,9 @@ void Fl_Wayland_Screen_Driver::open_display_platform() { } void Fl_Wayland_Screen_Driver::close_display() { - Fl::remove_fd(wl_display_get_fd(fl_display)); - wl_display_disconnect(fl_display); + Fl::remove_fd(wl_display_get_fd(Fl_Wayland_Screen_Driver::wl_display)); + wl_display_disconnect(Fl_Wayland_Screen_Driver::wl_display); + Fl_Wayland_Screen_Driver::wl_display = NULL; } @@ -1112,7 +1112,7 @@ void Fl_Wayland_Screen_Driver::init_workarea() int Fl_Wayland_Screen_Driver::x() { - if (!fl_display) open_display(); + if (!Fl_Wayland_Screen_Driver::wl_display) open_display(); Fl_Wayland_Screen_Driver::output *output; wl_list_for_each(output, &outputs, link) { break; @@ -1121,7 +1121,7 @@ int Fl_Wayland_Screen_Driver::x() { } int Fl_Wayland_Screen_Driver::y() { - if (!fl_display) open_display(); + if (!Fl_Wayland_Screen_Driver::wl_display) open_display(); Fl_Wayland_Screen_Driver::output *output; wl_list_for_each(output, &outputs, link) { break; @@ -1130,7 +1130,7 @@ int Fl_Wayland_Screen_Driver::y() { } int Fl_Wayland_Screen_Driver::w() { - if (!fl_display) open_display(); + if (!Fl_Wayland_Screen_Driver::wl_display) open_display(); Fl_Wayland_Screen_Driver::output *output; wl_list_for_each(output, &outputs, link) { break; @@ -1139,7 +1139,7 @@ int Fl_Wayland_Screen_Driver::w() { } int Fl_Wayland_Screen_Driver::h() { - if (!fl_display) open_display(); + if (!Fl_Wayland_Screen_Driver::wl_display) open_display(); Fl_Wayland_Screen_Driver::output *output; wl_list_for_each(output, &outputs, link) { break; @@ -1149,7 +1149,7 @@ int Fl_Wayland_Screen_Driver::h() { void Fl_Wayland_Screen_Driver::init() { - if (!fl_display) open_display(); + if (!Fl_Wayland_Screen_Driver::wl_display) open_display(); } @@ -1219,8 +1219,8 @@ void Fl_Wayland_Screen_Driver::beep(int type) void Fl_Wayland_Screen_Driver::flush() { - if (fl_display) { - wl_display_flush(fl_display); + if (Fl_Wayland_Screen_Driver::wl_display) { + wl_display_flush(Fl_Wayland_Screen_Driver::wl_display); } } @@ -1245,13 +1245,6 @@ void Fl_Wayland_Screen_Driver::grab(Fl_Window* win) } else { if (Fl::grab()) { // We must keep the grab in the non-EWMH fullscreen case - if (!fullscreen_win ) { - //XUngrabKeyboard(fl_display, fl_event_time); - } - //XUngrabPointer(fl_display, fl_event_time); - // this flush is done in case the picked menu item goes into - // an infinite loop, so we don't leave the X server locked up: - //XFlush(fl_display); Fl::grab_ = 0; // FIXME: Fl::grab_ "should be private", but we need // a way to *set* the variable from the driver! fl_fix_focus(); diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index b1ac7974e..1cf6e084f 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -636,21 +636,6 @@ void Fl_Wayland_Window_Driver::show_with_args_begin() { if (Fl::first_window()) key = Fl::first_window()->xclass(); if (!key) key = "fltk"; - - /*const char *val = XGetDefault(fl_display, key, "dndTextOps"); - if (val) Fl::dnd_text_ops(strcasecmp(val, "true") == 0 || - strcasecmp(val, "on") == 0 || - strcasecmp(val, "yes") == 0); - - val = XGetDefault(fl_display, key, "tooltips"); - if (val) Fl_Tooltip::enable(strcasecmp(val, "true") == 0 || - strcasecmp(val, "on") == 0 || - strcasecmp(val, "yes") == 0); - - val = XGetDefault(fl_display, key, "visibleFocus"); - if (val) Fl::visible_focus(strcasecmp(val, "true") == 0 || - strcasecmp(val, "on") == 0 || - strcasecmp(val, "yes") == 0);*/ } @@ -662,8 +647,6 @@ void Fl_Wayland_Window_Driver::show_with_args_end(int argc, char **argv) { char *buffer = new char[n]; char *p = buffer; for (j=0; jkind == DECORATED) { while (!(xid->state & LIBDECOR_WINDOW_STATE_FULLSCREEN) || !(xid->state & LIBDECOR_WINDOW_STATE_ACTIVE)) { - wl_display_dispatch(fl_display); + wl_display_dispatch(Fl_Wayland_Screen_Driver::wl_display); } } else if (xid->kind == UNFRAMED) { - wl_display_roundtrip(fl_display); + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); } } } @@ -1114,7 +1097,7 @@ Fl_X *Fl_Wayland_Window_Driver::makeWindow() } else if ( pWindow->border() && !pWindow->parent() ) { // a decorated window new_window->kind = DECORATED; - if (!scr_driver->libdecor_context) scr_driver->libdecor_context = libdecor_new(fl_display, &libdecor_iface); + if (!scr_driver->libdecor_context) scr_driver->libdecor_context = libdecor_new(Fl_Wayland_Screen_Driver::wl_display, &libdecor_iface); new_window->frame = libdecor_decorate(scr_driver->libdecor_context, new_window->wl_surface, &libdecor_frame_iface, new_window); //fprintf(stderr, "makeWindow: libdecor_decorate=%p pos:%dx%d\n", new_window->frame, pWindow->x(), pWindow->y()); @@ -1378,8 +1361,8 @@ void Fl_Wayland_Window_Driver::fullscreen_on() { if (xdg_toplevel()) { xdg_toplevel_set_fullscreen(xdg_toplevel(), NULL); pWindow->_set_fullscreen(); - wl_display_roundtrip(fl_display); // OK, but try to find something more specific - wl_display_roundtrip(fl_display); + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); // OK, but try to find something more specific + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); Fl::handle(FL_FULLSCREEN, pWindow); } } @@ -1563,12 +1546,12 @@ void Fl_Wayland_Window_Driver::reposition_menu_window(int x, int y) { xdg_positioner_destroy(positioner); xdg_popup_add_listener(xid_menu->xdg_popup, &popup_listener, xid_menu); wl_surface_commit(xid_menu->wl_surface); - wl_display_roundtrip(fl_display); + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); // delete the previous popup xdg_popup_destroy(old_popup); xdg_surface_destroy(old_xdg); wl_surface_destroy(old_surface); - wl_display_roundtrip(fl_display); + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); this->y(true_y); } @@ -1585,10 +1568,16 @@ void Fl_Wayland_Window_Driver::menu_window_area(int &X, int &Y, int &W, int &H, } -FL_EXPORT struct wl_surface *fl_wl_surface(Window xid) { +struct wl_surface *fl_wl_surface(Window xid) { return xid->wl_surface; } -FL_EXPORT struct _cairo *fl_wl_cairo() { + +struct _cairo *fl_wl_cairo() { return ((Fl_Cairo_Graphics_Driver*)fl_graphics_driver)->cr(); } + + +struct wl_display *fl_wl_display() { + return Fl_Wayland_Screen_Driver::wl_display; +} diff --git a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx index 6cfeb092a..315df2919 100644 --- a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx +++ b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx @@ -338,7 +338,7 @@ static void get_clipboard_or_dragged_text(struct wl_data_offer *offer) { if (pipe(fds)) return; wl_data_offer_receive(offer, wld_plain_text_clipboard, fds[1]); close(fds[1]); - wl_display_flush(fl_display); + wl_display_flush(Fl_Wayland_Screen_Driver::wl_display); // read in fl_selection_buffer char *to = fl_selection_buffer[1]; ssize_t rest = fl_selection_buffer_length[1]; @@ -370,7 +370,7 @@ static void get_clipboard_or_dragged_text(struct wl_data_offer *offer) { if (pipe(fds)) return; wl_data_offer_receive(offer, wld_plain_text_clipboard, fds[1]); close(fds[1]); - wl_display_flush(fl_display); + wl_display_flush(Fl_Wayland_Screen_Driver::wl_display); if (rest+1 > fl_selection_buffer_length[1]) { delete[] fl_selection_buffer[1]; fl_selection_buffer[1] = new char[rest+1000+1]; @@ -431,7 +431,7 @@ static void data_device_handle_motion(void *data, struct wl_data_device *data_de uint32_t supported_actions = ret ? WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY : WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE; uint32_t preferred_action = supported_actions; wl_data_offer_set_actions(current_drag_offer, supported_actions, preferred_action); - wl_display_roundtrip(fl_display); + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); if (ret && current_drag_offer) wl_data_offer_accept(current_drag_offer, fl_dnd_serial, "text/plain"); } @@ -488,7 +488,7 @@ static int get_clipboard_image() { if (pipe(fds)) return 1; wl_data_offer_receive(fl_selection_offer, fl_selection_offer_type, fds[1]); close(fds[1]); - wl_display_roundtrip(fl_display); + wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display); if (strcmp(fl_selection_offer_type, "image/png") == 0) { char tmp_fname[21]; Fl_Shared_Image *shared = 0; -- cgit v1.2.3 From 54ecae9bda20ac0788525d793c8107c8de7dee40 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 23 Mar 2022 14:11:49 +0100 Subject: Create struct wld_window *Fl_Wayland_Window_Driver::wld_window to replace eventually fl_window. --- src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx | 2 +- src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 6 +++--- src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H | 2 +- src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx | 10 +++++----- src/drivers/Wayland/Fl_Wayland_Window_Driver.H | 1 + src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 3 ++- 6 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx index 2759c7d60..a7eb5471d 100644 --- a/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx @@ -24,7 +24,7 @@ Fl_Wayland_Copy_Surface_Driver::Fl_Wayland_Copy_Surface_Driver(int w, int h) : Fl_Copy_Surface_Driver(w, h) { - int os_scale = (fl_window ? fl_window->scale : 1); + int os_scale = (Fl_Wayland_Window_Driver::wld_window ? Fl_Wayland_Window_Driver::wld_window->scale : 1); img_surf = new Fl_Image_Surface(w * os_scale, h * os_scale); driver(img_surf->driver()); driver()->scale(os_scale); diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index e28588369..6f2e22895 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx @@ -84,10 +84,10 @@ void Fl_Wayland_Gl_Window_Driver::init() { char *Fl_Wayland_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs) { // write str to a bitmap just big enough - Window save_win = fl_window; - fl_window = NULL; + struct wld_window *save_win = Fl_Wayland_Window_Driver::wld_window; + fl_window = Fl_Wayland_Window_Driver::wld_window = NULL; Fl_Image_Surface *surf = new Fl_Image_Surface(w, h); - fl_window = save_win; + fl_window = Fl_Wayland_Window_Driver::wld_window = save_win; Fl_Font f=fl_font(); Fl_Surface_Device::push_current(surf); fl_color(FL_BLACK); diff --git a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H index b65d858b4..7959267f8 100644 --- a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H @@ -22,7 +22,7 @@ class Fl_Wayland_Image_Surface_Driver : public Fl_Image_Surface_Driver { virtual void end_current(); - Window pre_window; + struct wld_window *pre_window; public: Fl_Wayland_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off); ~Fl_Wayland_Image_Surface_Driver(); diff --git a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx index 3e25b7873..a5d97fdcd 100644 --- a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx @@ -25,8 +25,8 @@ Fl_Wayland_Image_Surface_Driver::Fl_Wayland_Image_Surface_Driver(int w, int h, i float d = 1; if (!off) { fl_open_display(); - if (fl_window) { - d = fl_window->scale; + if (Fl_Wayland_Window_Driver::wld_window) { + d = Fl_Wayland_Window_Driver::wld_window->scale; } d *= fl_graphics_driver->scale(); if (d != 1 && high_res) { @@ -56,14 +56,14 @@ Fl_Wayland_Image_Surface_Driver::~Fl_Wayland_Image_Surface_Driver() { void Fl_Wayland_Image_Surface_Driver::set_current() { Fl_Surface_Device::set_current(); ((Fl_Wayland_Graphics_Driver*)fl_graphics_driver)->activate(offscreen, driver()->scale()); - pre_window = fl_window; - fl_window = NULL; + pre_window = Fl_Wayland_Window_Driver::wld_window; + fl_window = Fl_Wayland_Window_Driver::wld_window = NULL; } void Fl_Wayland_Image_Surface_Driver::end_current() { cairo_surface_t *surf = cairo_get_target(offscreen->cairo_); cairo_surface_flush(surf); - fl_window = pre_window; + fl_window = Fl_Wayland_Window_Driver::wld_window = pre_window; } void Fl_Wayland_Image_Surface_Driver::translate(int x, int y) { diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.H b/src/drivers/Wayland/Fl_Wayland_Window_Driver.H index 99a67dbba..2ee8a4f35 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.H @@ -88,6 +88,7 @@ public: struct xdg_toplevel *xdg_toplevel(); Fl_Wayland_Window_Driver(Fl_Window*); virtual ~Fl_Wayland_Window_Driver(); + static struct wld_window *wld_window; static void redraw(struct wld_window *window); static inline Fl_Wayland_Window_Driver* driver(const Fl_Window *w) {return (Fl_Wayland_Window_Driver*)Fl_Window_Driver::driver(w);} diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 1cf6e084f..d2e3d9305 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -52,6 +52,7 @@ extern "C" { #define fl_max(a,b) ((a) > (b) ? (a) : (b)) Window fl_window; +struct wld_window *Fl_Wayland_Window_Driver::wld_window = NULL; void Fl_Wayland_Window_Driver::destroy_double_buffer() { @@ -405,7 +406,7 @@ void Fl_Wayland_Window_Driver::make_current() { } fl_graphics_driver->clip_region(0); - fl_window = window; + fl_window = Fl_Wayland_Window_Driver::wld_window = window; if (!window->buffer) { window->buffer = Fl_Wayland_Graphics_Driver::create_shm_buffer( pWindow->w() * scale, pWindow->h() * scale); -- cgit v1.2.3 From 29c6d6c679d873988581e878f395399a6c4bb369 Mon Sep 17 00:00:00 2001 From: "ian.macarthur" Date: Wed, 23 Mar 2022 11:19:24 +0000 Subject: Remove vsscanf_l() call from Win32 driver (it appears to be a BSD-ism and unsupported by the MS tools) and rename several clocale specific methods from "name" to "vname" since they take a va_list not a variable list of arguments. --- src/Fl_Preferences.cxx | 4 ++-- src/Fl_System_Driver.H | 6 +++--- src/Fl_System_Driver.cxx | 8 ++++---- src/drivers/Darwin/Fl_Darwin_System_Driver.H | 6 +++--- src/drivers/Darwin/Fl_Darwin_System_Driver.cxx | 6 +++--- src/drivers/PostScript/Fl_PostScript.cxx | 2 +- src/drivers/Unix/Fl_Unix_System_Driver.H | 6 +++--- src/drivers/Unix/Fl_Unix_System_Driver.cxx | 6 +++--- src/drivers/WinAPI/Fl_WinAPI_System_Driver.H | 6 +++--- src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 12 +++--------- 10 files changed, 28 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx index b3c3c9c9f..af24ad75e 100644 --- a/src/Fl_Preferences.cxx +++ b/src/Fl_Preferences.cxx @@ -38,7 +38,7 @@ static int clocale_snprintf(char *buffer, size_t buffer_size, const char *format { va_list args; va_start(args, format); - int retval = Fl::system_driver()->clocale_snprintf(buffer, buffer_size, format, args); + int retval = Fl::system_driver()->clocale_vsnprintf(buffer, buffer_size, format, args); va_end(args); return retval; } @@ -47,7 +47,7 @@ static int clocale_sscanf(const char *input, const char *format, ...) { va_list args; va_start(args, format); - int retval = Fl::system_driver()->clocale_sscanf(input, format, args); + int retval = Fl::system_driver()->clocale_vsscanf(input, format, args); va_end(args); return retval; } diff --git a/src/Fl_System_Driver.H b/src/Fl_System_Driver.H index 3075565c9..d008f6a26 100644 --- a/src/Fl_System_Driver.H +++ b/src/Fl_System_Driver.H @@ -127,9 +127,9 @@ public: virtual unsigned utf8to_mb(const char* src, unsigned srclen, char* dst, unsigned dstlen); virtual unsigned utf8from_mb(char* dst, unsigned dstlen, const char* src, unsigned srclen); // implement to shield fprintf() from locale changes in decimal point - virtual int clocale_printf(FILE *output, const char *format, va_list args); - virtual int clocale_snprintf(char *output, size_t output_size, const char *format, va_list args); - virtual int clocale_sscanf(const char *input, const char *format, va_list args); + virtual int clocale_vprintf(FILE *output, const char *format, va_list args); + virtual int clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args); + virtual int clocale_vsscanf(const char *input, const char *format, va_list args); // implement functions telling whether a key is pressed virtual int event_key(int) {return 0;} virtual int get_key(int) {return 0;} diff --git a/src/Fl_System_Driver.cxx b/src/Fl_System_Driver.cxx index 143585b72..42a8e18eb 100644 --- a/src/Fl_System_Driver.cxx +++ b/src/Fl_System_Driver.cxx @@ -401,15 +401,15 @@ unsigned Fl_System_Driver::utf8from_mb(char* dst, unsigned dstlen, const char* s return srclen; } -int Fl_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) { +int Fl_System_Driver::clocale_vprintf(FILE *output, const char *format, va_list args) { return vfprintf(output, format, args); } -int Fl_System_Driver::clocale_snprintf(char *output, size_t output_size, const char *format, va_list args) { +int Fl_System_Driver::clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args) { return 0; // overridden in platform drivers } -int Fl_System_Driver::clocale_sscanf(const char *input, const char *format, va_list args) { +int Fl_System_Driver::clocale_vsscanf(const char *input, const char *format, va_list args) { return 0; // overridden in platform drivers } @@ -509,7 +509,7 @@ void Fl_System_Driver::gettime(time_t *sec, int *usec) { Platform drivers \b MUST override this virtual method to do their own stuff and call this base class method to run the platform independent wait functions. - + Overriden methods will typically call this method early and perform platform-specific operations after that in order to work with the \p time_to_wait value possibly modified by this method. diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.H b/src/drivers/Darwin/Fl_Darwin_System_Driver.H index 19b4dab2d..262f782df 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.H +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.H @@ -44,9 +44,9 @@ public: Fl_Darwin_System_Driver(); virtual int single_arg(const char *arg); virtual int arg_and_value(const char *name, const char *value); - virtual int clocale_printf(FILE *output, const char *format, va_list args); - virtual int clocale_snprintf(char *output, size_t output_size, const char *format, va_list args); - virtual int clocale_sscanf(const char *input, const char *format, va_list args); + virtual int clocale_vprintf(FILE *output, const char *format, va_list args); + virtual int clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args); + virtual int clocale_vsscanf(const char *input, const char *format, va_list args); static void *get_carbon_function(const char *name); static int calc_mac_os_version(); // computes the fl_mac_os_version global variable static unsigned short *compute_macKeyLookUp(); diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx index 9f59d8cae..4ca3ea73f 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx @@ -110,7 +110,7 @@ int Fl_Darwin_System_Driver::arg_and_value(const char *name, const char *value) static locale_t postscript_locale = NULL; #endif -int Fl_Darwin_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) { +int Fl_Darwin_System_Driver::clocale_vprintf(FILE *output, const char *format, va_list args) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (fl_mac_os_version >= 100400) { if (!postscript_locale) @@ -125,7 +125,7 @@ int Fl_Darwin_System_Driver::clocale_printf(FILE *output, const char *format, va return retval; } -int Fl_Darwin_System_Driver::clocale_snprintf(char *output, size_t output_size, const char *format, va_list args) { +int Fl_Darwin_System_Driver::clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (fl_mac_os_version >= 100400) { if (!postscript_locale) @@ -140,7 +140,7 @@ int Fl_Darwin_System_Driver::clocale_snprintf(char *output, size_t output_size, return retval; } -int Fl_Darwin_System_Driver::clocale_sscanf(const char *input, const char *format, va_list args) { +int Fl_Darwin_System_Driver::clocale_vsscanf(const char *input, const char *format, va_list args) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 if (fl_mac_os_version >= 100400) { if (!postscript_locale) diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx index e930bbee7..8eccba1ad 100644 --- a/src/drivers/PostScript/Fl_PostScript.cxx +++ b/src/drivers/PostScript/Fl_PostScript.cxx @@ -261,7 +261,7 @@ int Fl_PostScript_Graphics_Driver::clocale_printf(const char *format, ...) { va_list args; va_start(args, format); - int retval = Fl::system_driver()->clocale_printf(output, format, args); + int retval = Fl::system_driver()->clocale_vprintf(output, format, args); va_end(args); return retval; } diff --git a/src/drivers/Unix/Fl_Unix_System_Driver.H b/src/drivers/Unix/Fl_Unix_System_Driver.H index 1d01ebffe..caf10e247 100644 --- a/src/drivers/Unix/Fl_Unix_System_Driver.H +++ b/src/drivers/Unix/Fl_Unix_System_Driver.H @@ -23,9 +23,9 @@ class Fl_RGB_Image; class FL_EXPORT Fl_Unix_System_Driver : public Fl_Posix_System_Driver { public: - virtual int clocale_snprintf(char *output, size_t output_size, const char *format, va_list args); - virtual int clocale_sscanf(const char *input, const char *format, va_list args); - virtual int clocale_printf(FILE *output, const char *format, va_list args); + virtual int clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args); + virtual int clocale_vsscanf(const char *input, const char *format, va_list args); + virtual int clocale_vprintf(FILE *output, const char *format, va_list args); virtual int filename_list(const char *d, dirent ***list, int (*sort)(struct dirent **, struct dirent **), char *errmsg=NULL, int errmsg_sz=0); diff --git a/src/drivers/Unix/Fl_Unix_System_Driver.cxx b/src/drivers/Unix/Fl_Unix_System_Driver.cxx index d956f04b1..176ad9a07 100644 --- a/src/drivers/Unix/Fl_Unix_System_Driver.cxx +++ b/src/drivers/Unix/Fl_Unix_System_Driver.cxx @@ -73,7 +73,7 @@ static locale_t c_locale = NULL; #endif -int Fl_Unix_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) { +int Fl_Unix_System_Driver::clocale_vprintf(FILE *output, const char *format, va_list args) { #if defined(__linux__) && defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700 if (!c_locale) c_locale = newlocale(LC_NUMERIC_MASK, "C", duplocale(LC_GLOBAL_LOCALE)); @@ -89,7 +89,7 @@ int Fl_Unix_System_Driver::clocale_printf(FILE *output, const char *format, va_l return retval; } -int Fl_Unix_System_Driver::clocale_snprintf(char *output, size_t output_size, const char *format, va_list args) { +int Fl_Unix_System_Driver::clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args) { #if defined(__linux__) && defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700 if (!c_locale) c_locale = newlocale(LC_NUMERIC_MASK, "C", duplocale(LC_GLOBAL_LOCALE)); @@ -105,7 +105,7 @@ int Fl_Unix_System_Driver::clocale_snprintf(char *output, size_t output_size, co return retval; } -int Fl_Unix_System_Driver::clocale_sscanf(const char *input, const char *format, va_list args) { +int Fl_Unix_System_Driver::clocale_vsscanf(const char *input, const char *format, va_list args) { #if defined(__linux__) && defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700 if (!c_locale) c_locale = newlocale(LC_NUMERIC_MASK, "C", duplocale(LC_GLOBAL_LOCALE)); diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H index 3e6a86648..27e2e5739 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H @@ -66,9 +66,9 @@ public: virtual int utf8locale(); virtual unsigned utf8to_mb(const char *src, unsigned srclen, char *dst, unsigned dstlen); virtual unsigned utf8from_mb(char *dst, unsigned dstlen, const char *src, unsigned srclen); - virtual int clocale_printf(FILE *output, const char *format, va_list args); - virtual int clocale_snprintf(char *output, size_t output_size, const char *format, va_list args); - virtual int clocale_sscanf(const char *input, const char *format, va_list args); + virtual int clocale_vprintf(FILE *output, const char *format, va_list args); + virtual int clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args); + virtual int clocale_vsscanf(const char *input, const char *format, va_list args); // these 2 are in Fl_get_key_win32.cxx virtual int event_key(int k); virtual int get_key(int k); diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx index 18f6b3e3e..b6a435d02 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx @@ -450,7 +450,7 @@ unsigned Fl_WinAPI_System_Driver::utf8from_mb(char *dst, unsigned dstlen, const static _locale_t c_locale = NULL; #endif -int Fl_WinAPI_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) { +int Fl_WinAPI_System_Driver::clocale_vprintf(FILE *output, const char *format, va_list args) { #if defined(_MSC_VER) && (_MSC_VER >= 1400 /*Visual Studio 2005*/) if (!c_locale) c_locale = _create_locale(LC_NUMERIC, "C"); @@ -464,7 +464,7 @@ int Fl_WinAPI_System_Driver::clocale_printf(FILE *output, const char *format, va return retval; } -int Fl_WinAPI_System_Driver::clocale_snprintf(char *output, size_t output_size, const char *format, va_list args) { +int Fl_WinAPI_System_Driver::clocale_vsnprintf(char *output, size_t output_size, const char *format, va_list args) { #if defined(_MSC_VER) && (_MSC_VER >= 1400 /*Visual Studio 2005*/) if (!c_locale) c_locale = _create_locale(LC_NUMERIC, "C"); @@ -478,17 +478,11 @@ int Fl_WinAPI_System_Driver::clocale_snprintf(char *output, size_t output_size, return retval; } -int Fl_WinAPI_System_Driver::clocale_sscanf(const char *input, const char *format, va_list args) { -#if defined(_MSC_VER) && (_MSC_VER >= 1400 /*Visual Studio 2005*/) - if (!c_locale) - c_locale = _create_locale(LC_NUMERIC, "C"); - int retval = _vsscanf_l(input, format, c_locale, args); -#else +int Fl_WinAPI_System_Driver::clocale_vsscanf(const char *input, const char *format, va_list args) { char *saved_locale = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); int retval = vsscanf(input, format, args); setlocale(LC_NUMERIC, saved_locale); -#endif return retval; } -- cgit v1.2.3