Skip to content

Commit

Permalink
Merge pull request #12 from fltk/master
Browse files Browse the repository at this point in the history
PR merge from fltk/fltk main
  • Loading branch information
rageworx committed Mar 6, 2023
2 parents 53ec840 + a528115 commit 9487eb1
Show file tree
Hide file tree
Showing 22 changed files with 217 additions and 216 deletions.
12 changes: 6 additions & 6 deletions CMake/variables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,35 +82,35 @@ endif ()
set (IMAGELIBS)
set (STATICIMAGELIBS)

if (FLTK_BUILTIN_JPEG_FOUND)
if (FLTK_USE_BUILTIN_JPEG)
list (APPEND IMAGELIBS -lfltk_jpeg)
list (APPEND STATICIMAGELIBS \$libdir/libfltk_jpeg.a)
else ()
if (LIB_jpeg)
list (APPEND IMAGELIBS -ljpeg)
list (APPEND STATICIMAGELIBS -ljpeg)
endif (LIB_jpeg)
endif (FLTK_BUILTIN_JPEG_FOUND)
endif (FLTK_USE_BUILTIN_JPEG)

if (FLTK_BUILTIN_PNG_FOUND)
if (FLTK_USE_BUILTIN_PNG)
list (APPEND IMAGELIBS -lfltk_png)
list (APPEND STATICIMAGELIBS \$libdir/libfltk_png.a)
else ()
if (LIB_png)
list (APPEND IMAGELIBS -lpng)
list (APPEND STATICIMAGELIBS -lpng)
endif (LIB_png)
endif (FLTK_BUILTIN_PNG_FOUND)
endif (FLTK_USE_BUILTIN_PNG)

if (FLTK_BUILTIN_ZLIB_FOUND)
if (FLTK_USE_BUILTIN_ZLIB)
list (APPEND IMAGELIBS -lfltk_z)
list (APPEND STATICIMAGELIBS \$libdir/libfltk_z.a)
else ()
if (LIB_zlib)
list (APPEND IMAGELIBS -lz)
list (APPEND STATICIMAGELIBS -lz)
endif (LIB_zlib)
endif (FLTK_BUILTIN_ZLIB_FOUND)
endif (FLTK_USE_BUILTIN_ZLIB)

string (REPLACE ";" " " IMAGELIBS "${IMAGELIBS}")
string (REPLACE ";" " " STATICIMAGELIBS "${STATICIMAGELIBS}")
Expand Down
2 changes: 1 addition & 1 deletion FL/Fl_Scheme_Choice.H
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <FL/Fl_Scheme.H>
#include <FL/Fl_Choice.H>

class Fl_Scheme_Choice : public Fl_Choice {
class FL_EXPORT Fl_Scheme_Choice : public Fl_Choice {

protected:
static void scheme_cb_(Fl_Widget *w, void *);
Expand Down
2 changes: 1 addition & 1 deletion FL/Fl_Shortcut_Button.H
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <FL/Fl_Button.H>

class Fl_Shortcut_Button : public Fl_Button {
class FL_EXPORT Fl_Shortcut_Button : public Fl_Button {
private:
bool hot_, pre_hot_;
Fl_Shortcut pre_esc_;
Expand Down
4 changes: 3 additions & 1 deletion FL/Fl_String.H
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
Basic Fl_String class for FLTK.
*/

#include "Fl_Export.H"

// See: https://en.cppreference.com/w/cpp/string/basic_string/basic_string

/**
Expand Down Expand Up @@ -49,7 +51,7 @@
\since 1.4.0
*/
class Fl_String {
class FL_EXPORT Fl_String {

private:
/*
Expand Down
2 changes: 1 addition & 1 deletion documentation/src/events.dox
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ application on the desktop to an FLTK widget. Text is transferred
using UTF-8 encoding. Files are received as a list of full path
and file names, separated by newline.

On some X11 platforms, files are received as a URL-encoded UTF-8 string,
On some X11 platforms and with Wayland, files are received as a URL-encoded UTF-8 string,
that is, non-ASCII bytes (and a few others such as space and %) are
replaced by the 3 bytes "%XY" where XY are the byte's hexadecimal value.
The \ref fl_decode_uri() function can be used to transform in-place
Expand Down
49 changes: 28 additions & 21 deletions documentation/src/wayland.dox
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ The rest of this chapter describes what happens when the Wayland leg has been ch

Establishing a Wayland connection requires environment variable \c XDG_RUNTIME_DIR to be
defined and to point to a directory containing a socket connected to a Wayland
compositor. This is usually done by the login procedure of Wayland-friendly desktops.
compositor. This variable is usually set by the login procedure of Wayland-friendly desktops.
The name of the Wayland socket is determined as follows:
- the client may call Fl::display(const char *display_name) before \c fl_open_display() runs
or use the \c -display command line argument and transmit there the socket name;
- the client may call <tt>Fl::display(const char *display_name)</tt> before
\c fl_open_display() runs or use the \c -display command line argument and transmit there the
socket name;
- environment variable \c WAYLAND_DISPLAY can be defined to the socket name;
- otherwise, \c "wayland-0" is used.

Expand Down Expand Up @@ -346,7 +347,8 @@ mapped on the display. This 3-step mechanism works as follows:
obtain a <tt>struct wl_callback</tt> object and stores it as member \c cb of the surface's
\ref fl_wld_buffer.
- Then it calls \c wl_callback_add_listener() to associate this object to the FLTK-defined,
callback function \c surface_frame_done() that Wayland calls at the end of the mapping operation.
callback function \c surface_frame_done() that Wayland calls when it's ready for another
mapping operation.
- Finally \c surface_frame_done() destroys the \c wl_callback object by function
\c wl_callback_destroy() and sets member \c cb to NULL.

Expand Down Expand Up @@ -380,7 +382,7 @@ computing and drawing in memory but not on display more lines of the desired Man

\section wayland-buffer-factory Buffer factories

Wayland calls <em>buffer factory</em> a software procedure that constructs objects of type
Wayland names <em>buffer factory</em> a software procedure that constructs objects of type
<tt>struct wl_buffer</tt> for use by a client application.
FLTK creates a \c wl_buffer object each time an Fl_Window is mapped on a display or resized.
That's done by member function \c Fl_Wayland_Graphics_Driver::create_shm_buffer()
Expand All @@ -402,7 +404,7 @@ beginning at offset \c chunk_offset in it. This function returns a pointer to th
beginning of the mmap'ed memory section encapsulated by this \c wl_buffer.
Variable \c chunk_offset is then increased by the length of this section.

A window's \c wl_buffer is re-used each time the window's content changes, and is destroyed by function
A window's \c wl_buffer is re-used each time the window gets redrawn, and is destroyed by function
\c Fl_Wayland_Graphics_Driver::buffer_release() which calls \c wl_buffer_destroy() when
\c Fl_Window::hide() runs or the window is resized.

Expand Down Expand Up @@ -449,11 +451,11 @@ This function also associates a 'listener' to each display
by calling function \c wl_output_add_listener(). This 'listener' is an array of callback function
pointers among which one (\c output_mode) runs when the display is resized and another
(\c output_scale) when the Wayland scale factor (see below) is changed.
FLTK defines type <tt>struct output</tt> (see \ref output) inside class
\c Fl_Wayland_Screen_Driver to store display size and scaling information.
FLTK defines type <tt>struct Fl_Wayland_Screen_Driver::output</tt> (see \ref output)
to store display size and scaling information.
One such record is created for each display. FLTK uses 2 distinct scaling parameters under Wayland:
- <tt>int wld_scale;</tt>. This member variable of <tt>struct output</tt> typically equals 1
for standard, and 2 for
- <tt>int wld_scale;</tt>. This member variable of
<tt>struct Fl_Wayland_Screen_Driver::output</tt> typically equals 1 for standard, and 2 for
HighDPI displays. Its value is set by the Wayland compositor for each display with the effect
that 1 Wayland graphics unit represents a block of \c nxn pixels when the value is \c n.
Another effect is that a drawing buffer for a surface of size WxH units contains
Expand All @@ -469,7 +471,8 @@ member variable of display # \c n. This variable is used by function
\c Fl_Wayland_Window_Driver::make_current() when it calls \c Fl_Wayland_Graphics_Driver::set_buffer()
that scales the graphics driver by this factor with \c cairo_scale().

The display size information of <tt>struct output</tt> accounts for the value of its \c wld_scale member
The display size information of <tt>struct Fl_Wayland_Screen_Driver::output</tt> accounts for
the value of its \c wld_scale member
variable: \c width and \c height are set to the number of pixels of the display / \c wld_scale.

Overall, an FLTK object, say an Fl_Window, of size \c WxH FLTK units occupies
Expand Down Expand Up @@ -758,9 +761,10 @@ operations:

FLTK can copy or paste plain UTF-8 text or image data to/from the clipboard. Images are copied to the
clipboard as \c image/bmp mime type. Images in \c image/bmp or \c image/png mime types from the
clipboard can be pasted to FLTK apps. Files dropped are received as a string with '\\n' between
successive filenames.
clipboard can be pasted to FLTK apps.

Files dropped are received one per line with URL-encoded UTF-8 names prepended by
<tt>file://</tt> (see \ref events_dnd).


\section wayland-egl EGL as support for OpenGL
Expand Down Expand Up @@ -793,7 +797,7 @@ Function \c fl_wl_xid(Fl_Window*) returns a pointer to the <tt>struct wld_window
<pre>
struct wld_window {
Fl_Window *fl_win;
struct wl_list outputs; // linked list of outputs where this surface is mapped
struct Fl_Wayland_Screen_Driver::output *output; // the display where win is mapped (see \ref output)
struct wl_surface *wl_surface; // the window's surface
struct fl_wld_buffer *buffer; // see \ref fl_wld_buffer
struct xdg_surface *xdg_surface;
Expand All @@ -809,7 +813,6 @@ struct wld_window {
int configured_height;
int floating_width; // helps restoring size after un-maximizing
int floating_height;
int scale; // the Wayland scale factor for HighDPI displays (1 or 2, possibly 3)
int state; // indicates whether window is fullscreen, maximized. Used otherwise for POPUPs
}
</pre>
Expand Down Expand Up @@ -837,8 +840,8 @@ struct fl_wld_buffer {
</pre>

\anchor output
<h3>struct output</h3>
Defined inside class \c Fl_Wayland_Screen_Driver. One such record is
<h3>struct Fl_Wayland_Screen_Driver::output</h3>
One such record is
created for each display of the system by function \c registry_handle_global() when it receives a
\c "wl_output" interface. These records are kept in a linked list of them all, and
an identifier of this linked list is stored in member \c outputs of the unique
Expand All @@ -849,17 +852,21 @@ an identifier of this linked list is stored in member \c outputs of the unique
\endcode
gives access, the Wayland way, to the linked list of displays in the system.
<pre>
struct output { // one record for each display
struct Fl_Wayland_Screen_Driver::output { // one record for each display
uint32_t id; // an identifier of the display
short width; // = nber of horizontal pixels / wld_scale
short height; // = nber of vertical pixels / wld_scale
short width; // nber of horizontal pixels / wld_scale
short height; // nber of vertical pixels / wld_scale
float dpi; // at this point, always 96.
struct wl_output *wl_output;
struct wl_output *wl_output; // the Wayland object for this display
int wld_scale; // Wayland scale factor
float gui_scale; // FLTK scale factor
struct wl_list link; // links these records together
};
</pre>
It's possible to get the FLTK-defined record associated to a display from the
Wayland-associated object for the same display, say <tt>struct wl_output *wl_output</tt>,
by this call:
<tt>(struct Fl_Wayland_Screen_Driver::output *)wl_output_get_user_data(wl_output)</tt>.

\anchor seat
<h3>struct seat</h3>
Expand Down
6 changes: 3 additions & 3 deletions fluid/alignment_panel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ Fl_Double_Window* make_shell_window() {
shell_command_input->textsize(12);
Fl_Group::current()->resizable(shell_command_input);
} // Fl_Input* shell_command_input
{ shell_savefl_button = new Fl_Check_Button(82, 39, 136, 19, "save .fl design file");
shell_savefl_button->tooltip("save the design to the .fl file before running the command");
{ shell_savefl_button = new Fl_Check_Button(82, 39, 136, 19, "save .fl project file");
shell_savefl_button->tooltip("save the project to the .fl file before running the command");
shell_savefl_button->down_box(FL_DOWN_BOX);
shell_savefl_button->labelsize(12);
} // Fl_Check_Button* shell_savefl_button
Expand All @@ -435,7 +435,7 @@ Fl_Double_Window* make_shell_window() {
shell_writemsgs_button->down_box(FL_DOWN_BOX);
shell_writemsgs_button->labelsize(12);
} // Fl_Check_Button* shell_writemsgs_button
{ shell_use_fl_button = new Fl_Check_Button(82, 110, 180, 19, "use settings in .fl design files");
{ shell_use_fl_button = new Fl_Check_Button(82, 110, 180, 19, "use settings in .fl project files");
shell_use_fl_button->tooltip("check to read and write shell command from and to .fl files");
shell_use_fl_button->down_box(FL_DOWN_BOX);
shell_use_fl_button->labelsize(12);
Expand Down
27 changes: 14 additions & 13 deletions fluid/alignment_panel.fl
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ decl {void init_scheme(void);} {
decl {extern struct Fl_Menu_Item *dbmanager_item;} {public local
}

Function {make_project_window()} {} {
Function {make_project_window()} {open
} {
Fl_Window project_window {
label {Project Settings}
xywh {472 246 399 298} type Double hide
xywh {472 246 399 298} type Double
code0 {\#include <FL/Fl_Preferences.H>}
code1 {\#include <FL/Fl_Tooltip.H>} modal
code1 {\#include <FL/Fl_Tooltip.H>} modal visible
} {
Fl_Button {} {
label Close
Expand Down Expand Up @@ -181,8 +182,8 @@ Function {make_settings_window()} {open
} {
Fl_Window settings_window {
label {GUI Settings} open
xywh {701 666 360 355} type Double hide resizable
code0 {o->size_range(o->w(), o->h());} non_modal
xywh {701 666 360 355} type Double resizable
code0 {o->size_range(o->w(), o->h());} non_modal visible
} {
Fl_Choice scheme_choice {
label {Scheme: }
Expand Down Expand Up @@ -291,8 +292,8 @@ Examples:
Function {make_shell_window()} {open
} {
Fl_Window shell_window {
label {Shell Command} open selected
xywh {844 473 375 208} type Double resizable modal size_range {375 208 1024 208} visible
label {Shell Command} open
xywh {502 196 375 208} type Double resizable modal size_range {375 208 1024 208} visible
} {
Fl_Group {} {open
xywh {0 0 375 165} resizable
Expand All @@ -302,8 +303,8 @@ Function {make_shell_window()} {open
tooltip {external shell command} xywh {82 14 277 20} labelfont 1 labelsize 12 textfont 4 textsize 12 resizable
}
Fl_Check_Button shell_savefl_button {
label {save .fl design file}
tooltip {save the design to the .fl file before running the command} xywh {82 39 136 19} down_box DOWN_BOX labelsize 12
label {save .fl project file}
tooltip {save the project to the .fl file before running the command} xywh {82 39 136 19} down_box DOWN_BOX labelsize 12
}
Fl_Check_Button shell_writecode_button {
label {save source code}
Expand All @@ -314,15 +315,15 @@ Function {make_shell_window()} {open
tooltip {save the internationalisation string before running the command} xywh {82 79 126 19} down_box DOWN_BOX labelsize 12
}
Fl_Check_Button shell_use_fl_button {
label {use settings in .fl design files}
label {use settings in .fl project files}
callback {g_shell_use_fl_settings = shell_use_fl_button->value();
fluid_prefs.set("shell_use_fl", g_shell_use_fl_settings);
if (g_shell_use_fl_settings) {
shell_settings_read();
} else {
shell_prefs_get();
}
update_shell_window();}
update_shell_window();} selected
tooltip {check to read and write shell command from and to .fl files} xywh {82 110 180 19} down_box DOWN_BOX labelsize 12
}
Fl_Box {} {
Expand Down Expand Up @@ -364,7 +365,7 @@ shell_window->hide();}
}
Fl_Window shell_run_window {
label {Shell Command Output}
xywh {887 409 555 430} type Double resizable visible
xywh {455 590 555 430} type Double resizable visible
} {
Fl_Simple_Terminal shell_run_terminal {
xywh {10 10 535 375} resizable
Expand Down Expand Up @@ -393,7 +394,7 @@ Function {make_layout_window()} {open
} {
Fl_Window grid_window {
label {Layout Settings}
xywh {745 303 310 245} type Double hide non_modal
xywh {745 303 310 245} type Double non_modal visible
} {
Fl_Input horizontal_input {
label x
Expand Down
3 changes: 2 additions & 1 deletion fluid/widget_panel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@ sized to fit the container.");
o->callback((Fl_Callback*)tooltip_cb);
} // Fl_Input* o
{ Fl_Box* o = new Fl_Box(95, 305, 300, 5);
o->labelsize(11);
o->hide();
Fl_Group::current()->resizable(o);
} // Fl_Box* o
o->end();
Fl_Group::current()->resizable(o);
Expand Down
6 changes: 3 additions & 3 deletions fluid/widget_panel.fl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Function {make_widget_panel()} {
} {
Fl_Group {} {
label GUI
callback propagate_load open
callback propagate_load open selected
xywh {10 30 400 330} labelsize 11 when 0 resizable
} {
Fl_Group {} {
Expand All @@ -66,7 +66,7 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 15 t
xywh {95 65 309 20} labelfont 1 labelsize 11 align 4
} {
Fl_Input {} {
callback image_cb selected
callback image_cb
tooltip {The active image for the widget.} xywh {95 65 200 20} labelfont 1 labelsize 11 textsize 11 resizable
}
Fl_Button {} {
Expand Down Expand Up @@ -539,7 +539,7 @@ Use 'Backspace' key to clear.} xywh {95 210 310 20} box DOWN_BOX color 7 selecti
Use Ctrl-J for newlines.} xywh {95 285 310 20} labelfont 1 labelsize 11 textsize 11
}
Fl_Box {} {
xywh {95 305 300 5} labelsize 11
xywh {95 305 300 5} hide resizable
}
}
Fl_Group {} {
Expand Down
2 changes: 1 addition & 1 deletion src/Fl_Preferences.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ char Fl_Preferences::set( const char *key, const void *data, int dsize ) {
was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preference file.
\param[in] key name of entry
\param[in] entry name of entry
\param[in] value set this entry to value (stops at the first nul character).
\return 0 if setting the value failed
*/
Expand Down

0 comments on commit 9487eb1

Please sign in to comment.