- XFrame placement: layout raises+activates itself via EWMH (_NET_ACTIVE_WINDOW + XRaiseWindow + XSetInputFocus) on every new palette selection, and the designer forwards a canvas click to the layout via a place-request file (/tmp/lightgui-place.txt, $LIGHTGUI_PLACE) when an XFrame widget is selected, so placement works even when the click lands on the designer canvas. Verified under openbox (real WM): selection raises the layout, place file centres the widget on the click. - Resize handles: 16px drawn (was 12px), 32x32 grab target (8px hit pad around each handle centre). All 8 handles verified by real mouse drags under openbox: SE corner resizes both axes exactly, N edge height-only, W edge width-only; handles drawn last (foreground) so they are always on top. - Help -> About: GtkAboutDialog with the git commit hash baked in at build time (Makefile -DLIGHTGUI_GIT_HASH) and the build date. - Menu bar moved out of the main designer window into the LightGUI Code window (reparented from root_box at startup); the layout window is now just the layout manager. Ctrl+E on the main window toggles the Code window back in when it is hidden. - Tabbed multi-file editor in the Code window: GtkNotebook, one codeview per tab, File -> Open File in Code... opens a file in a new tab, per-tab dirty flag / Ctrl+S save / close button (asks before dropping unsaved edits), Variables pane + splitter and //region folding kept per tab. Debugger opens the stopped file in its own tab instead of overwriting the current one; refresh shows generated code in its own tab and never clobbers a hand-opened file. - tests/code_window_tests.sh: reopen check now uses Ctrl+E.
70 lines
1.9 KiB
C++
70 lines
1.9 KiB
C++
// common/ipc.h — how the palette and layout windows share state.
|
|
// Palette -> layout: the palette writes the selected widget name to the
|
|
// selection file on every selection; the layout polls the file's mtime.
|
|
// Layout -> tests: the layout writes its full placed-widget state to the
|
|
// state file after every mutation, so the driver can verify bounds
|
|
// without guessing from pixels.
|
|
#pragma once
|
|
|
|
#include <cstdio>
|
|
#include <string>
|
|
#include <sys/stat.h>
|
|
|
|
namespace lg {
|
|
|
|
inline std::string selection_path() {
|
|
const char* e = getenv("LIGHTGUI_SELECTION");
|
|
if (e && *e) return e;
|
|
return "/tmp/lightgui-selection.txt";
|
|
}
|
|
|
|
inline std::string place_path() {
|
|
const char* e = getenv("LIGHTGUI_PLACE");
|
|
if (e && *e) return e;
|
|
return "/tmp/lightgui-place.txt";
|
|
}
|
|
|
|
inline std::string layout_state_path() {
|
|
const char* e = getenv("LIGHTGUI_LAYOUT_STATE");
|
|
if (e && *e) return e;
|
|
return "/tmp/lightgui-layout-state.txt";
|
|
}
|
|
|
|
inline std::string icons_dir() {
|
|
const char* e = getenv("LIGHTGUI_ICONS");
|
|
if (e && *e) return e;
|
|
return "/opt/lightgui/widgets/icons";
|
|
}
|
|
|
|
inline bool write_selection(const std::string& name, int index) {
|
|
FILE* f = fopen(selection_path().c_str(), "w");
|
|
if (!f) return false;
|
|
fprintf(f, "%s\n%d\n", name.c_str(), index);
|
|
fclose(f);
|
|
return true;
|
|
}
|
|
|
|
inline bool read_selection(std::string& name, int& index) {
|
|
FILE* f = fopen(selection_path().c_str(), "r");
|
|
if (!f) return false;
|
|
char buf[256];
|
|
bool ok = false;
|
|
if (fgets(buf, sizeof(buf), f)) {
|
|
buf[strcspn(buf, "\r\n")] = 0;
|
|
name = buf;
|
|
ok = true;
|
|
}
|
|
index = -1;
|
|
if (fscanf(f, "%d", &index) != 1) index = -1;
|
|
fclose(f);
|
|
return ok;
|
|
}
|
|
|
|
inline long file_mtime(const std::string& path) {
|
|
struct stat st;
|
|
if (stat(path.c_str(), &st) != 0) return -1;
|
|
return (long)st.st_mtime * 1000000000L + (long)st.st_mtim.tv_nsec;
|
|
}
|
|
|
|
} // namespace lg
|