summaryrefslogtreecommitdiff
path: root/fluid/app
diff options
context:
space:
mode:
authormaxim nikonov <maxim.nikonov@hqo.co>2026-02-05 22:05:41 +0500
committermaxim nikonov <maxim.nikonov@hqo.co>2026-02-05 22:05:41 +0500
commit57860e277f2298ad6c0830b1492087cfa124c862 (patch)
tree50e9a7082c4143483fe01afc83293fb4ecbb4c22 /fluid/app
parentdc39575fb3ef90e5a2689babe7fb335cd88f6727 (diff)
wip
Diffstat (limited to 'fluid/app')
-rw-r--r--fluid/app/Snap_Action.cxx38
-rw-r--r--fluid/app/shell_command.cxx25
2 files changed, 39 insertions, 24 deletions
diff --git a/fluid/app/Snap_Action.cxx b/fluid/app/Snap_Action.cxx
index 0de72919e..08e9bf1e5 100644
--- a/fluid/app/Snap_Action.cxx
+++ b/fluid/app/Snap_Action.cxx
@@ -30,9 +30,13 @@
#include <math.h>
#include <string.h>
#include <assert.h>
-#undef min
-#undef max
-#include <algorithm>
+
+#ifndef MIN
+#define MIN(a,b) ((a)<=(b) ? (a) : (b))
+#endif
+#ifndef MAX
+#define MAX(a,b) ((a)>=(b) ? (a) : (b))
+#endif
using namespace fld;
using namespace fld::app;
@@ -700,14 +704,15 @@ void Layout_List::write(Fl_Preferences &prefs, fld::Tool_Store storage) {
*/
void Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) {
Fl_Preferences prefs_list(prefs, "Layouts");
- std::string cs;
+ char *cs_ptr = 0;
int cp = 0;
- prefs_list.get("current_suite", cs, "");
+ prefs_list.get("current_suite", cs_ptr, "");
prefs_list.get("current_preset", cp, 0);
- for (int i = 0; i < prefs_list.groups(); ++i) {
+ int i;
+ for (i = 0; i < prefs_list.groups(); ++i) {
Fl_Preferences prefs_suite(prefs_list, Fl_Preferences::Name(i));
- char *new_name = nullptr;
- prefs_suite.get("name", new_name, nullptr);
+ char *new_name = 0;
+ prefs_suite.get("name", new_name, 0);
if (new_name) {
int n = add(new_name);
list_[n].read(prefs_suite);
@@ -715,7 +720,10 @@ void Layout_List::read(Fl_Preferences &prefs, fld::Tool_Store storage) {
::free(new_name);
}
}
- current_suite(cs);
+ if (cs_ptr) {
+ current_suite(std::string(cs_ptr));
+ ::free(cs_ptr);
+ }
current_preset(cp);
update_dialogs();
}
@@ -1117,8 +1125,8 @@ void Snap_Action::better_size(int &w, int &h) {
x_min = x_inc;
y_min = y_inc;
}
- int ww = std::max(w - x_min, 0); w = (w - ww + x_inc - 1) / x_inc; w = w * x_inc; w = w + ww;
- int hh = std::max(h - y_min, 0); h = (h - hh + y_inc - 1) / y_inc; h = h * y_inc; h = h + hh;
+ int ww = MAX(w - x_min, 0); w = (w - ww + x_inc - 1) / x_inc; w = w * x_inc; w = w + ww;
+ int hh = MAX(h - y_min, 0); h = (h - hh + y_inc - 1) / y_inc; h = h * y_inc; h = h + hh;
}
@@ -1511,7 +1519,7 @@ class Fd_Snap_Siblings_Left : public Fd_Snap_Sibling {
public:
Fd_Snap_Siblings_Left() { type = 1; mask = FD_LEFT|FD_DRAG; }
int sibling_check(Snap_Data &d, Fl_Widget *s) override {
- return std::min(check_x_(d, d.bx, s->x()+s->w()),
+ return MIN(check_x_(d, d.bx, s->x()+s->w()),
check_x_(d, d.bx, s->x()+s->w()+Fluid.proj.layout->widget_gap_x) );
}
void draw(Snap_Data &d) override {
@@ -1536,7 +1544,7 @@ class Fd_Snap_Siblings_Right : public Fd_Snap_Sibling {
public:
Fd_Snap_Siblings_Right() { type = 1; mask = FD_RIGHT|FD_DRAG; }
int sibling_check(Snap_Data &d, Fl_Widget *s) override {
- return std::min(check_x_(d, d.br, s->x()),
+ return MIN(check_x_(d, d.br, s->x()),
check_x_(d, d.br, s->x()-Fluid.proj.layout->widget_gap_x));
}
void draw(Snap_Data &d) override {
@@ -1561,7 +1569,7 @@ class Fd_Snap_Siblings_Top : public Fd_Snap_Sibling {
public:
Fd_Snap_Siblings_Top() { type = 2; mask = FD_TOP|FD_DRAG; }
int sibling_check(Snap_Data &d, Fl_Widget *s) override {
- return std::min(check_y_(d, d.by, s->y()+s->h()),
+ return MIN(check_y_(d, d.by, s->y()+s->h()),
check_y_(d, d.by, s->y()+s->h()+Fluid.proj.layout->widget_gap_y));
}
void draw(Snap_Data &d) override {
@@ -1586,7 +1594,7 @@ class Fd_Snap_Siblings_Bottom : public Fd_Snap_Sibling {
public:
Fd_Snap_Siblings_Bottom() { type = 2; mask = FD_BOTTOM|FD_DRAG; }
int sibling_check(Snap_Data &d, Fl_Widget *s) override {
- return std::min(check_y_(d, d.bt, s->y()),
+ return MIN(check_y_(d, d.bt, s->y()),
check_y_(d, d.bt, s->y()-Fluid.proj.layout->widget_gap_y));
}
void draw(Snap_Data &d) override {
diff --git a/fluid/app/shell_command.cxx b/fluid/app/shell_command.cxx
index bd53a28af..a4b664fda 100644
--- a/fluid/app/shell_command.cxx
+++ b/fluid/app/shell_command.cxx
@@ -564,26 +564,31 @@ bool Fd_Shell_Command::is_active() {
void Fd_Shell_Command::read(Fl_Preferences &prefs) {
int tmp;
- prefs.get("name", name, "<unnamed>");
- prefs.get("label", label, "<no label>");
+ char *str_ptr = 0;
+ prefs.get("name", str_ptr, "<unnamed>");
+ if (str_ptr) { name = str_ptr; free(str_ptr); str_ptr = 0; }
+ prefs.get("label", str_ptr, "<no label>");
+ if (str_ptr) { label = str_ptr; free(str_ptr); str_ptr = 0; }
prefs.get("shortcut", tmp, 0);
shortcut = (Fl_Shortcut)tmp;
prefs.get("storage", tmp, -1);
if (tmp != -1) storage = (fld::Tool_Store)tmp;
prefs.get("condition", condition, ALWAYS);
- prefs.get("condition_data", condition_data, "");
- prefs.get("command", command, "");
+ prefs.get("condition_data", str_ptr, "");
+ if (str_ptr) { condition_data = str_ptr; free(str_ptr); str_ptr = 0; }
+ prefs.get("command", str_ptr, "");
+ if (str_ptr) { command = str_ptr; free(str_ptr); str_ptr = 0; }
prefs.get("flags", flags, 0);
}
void Fd_Shell_Command::write(Fl_Preferences &prefs, bool save_location) {
- prefs.set("name", name);
- prefs.set("label", label);
+ prefs.set("name", name.c_str());
+ prefs.set("label", label.c_str());
if (shortcut != 0) prefs.set("shortcut", (int)shortcut);
if (save_location) prefs.set("storage", (int)storage);
if (condition != ALWAYS) prefs.set("condition", condition);
- if (!condition_data.empty()) prefs.set("condition_data", condition_data);
- if (!command.empty()) prefs.set("command", command);
+ if (!condition_data.empty()) prefs.set("condition_data", condition_data.c_str());
+ if (!command.empty()) prefs.set("command", command.c_str());
if (flags != 0) prefs.set("flags", flags);
}
@@ -695,7 +700,9 @@ void Fd_Shell_Command_List::read(Fl_Preferences &prefs, fld::Tool_Store storage)
cmd->name = "Sample Shell Command";
cmd->label = "Sample Shell Command";
cmd->shortcut = FL_ALT+'g';
- Fluid.preferences.get("shell_command", cmd->command, "echo \"Sample Shell Command\"");
+ char *cmd_str = 0;
+ Fluid.preferences.get("shell_command", cmd_str, "echo \"Sample Shell Command\"");
+ if (cmd_str) { cmd->command = cmd_str; free(cmd_str); }
Fluid.preferences.get("shell_savefl", save_fl, 1);
Fluid.preferences.get("shell_writecode", save_code, 1);
Fluid.preferences.get("shell_writemsgs", save_strings, 0);