This commit is contained in:
Mirek Fidler 2025-02-14 13:47:59 +01:00
commit 7aa8e82eb5
23 changed files with 130 additions and 43 deletions

View file

@ -5,7 +5,7 @@ AskContinue()
{
read -p "Continue (Y/n)?" answer
if [ "$answer" != "${answer//[nN]/x}" ]; then
exit;
exit;
fi
}
@ -13,13 +13,13 @@ uname=`uname`
if [[ "$uname" == 'Darwin' ]]; then
DEP=""
if which brew; then
echo "Homebrew is already installed"
else
echo "Installing Homebrew package management system (to obtain openssl libraries required for U++)"
AskContinue
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if ! which brew; then
echo "Homebrew is not installed"
echo "We use Homebrew to obtain OpenSSL libraries and clang-format required for U++"
echo "Follow the instructions at https://brew.sh/ to install Homebrew"
exit
fi
echo "Homebrew is installed"
brew install openssl clang-format
if clang++ --version; then
echo "Commandline Development Tools already installed"

View file

@ -38,9 +38,6 @@
#ifndef flagGTK
#define flagGTK
#endif
#ifdef flagWAYLAND
#define GUI_GTK_WAYLAND
#endif
#define GUIPLATFORM_INCLUDE "Gtk.h"
#endif
#endif

View file

@ -90,15 +90,24 @@ void Ctrl::ThemeChanged(void *)
PostReSkin();
}
static bool sUseWayland;
void Ctrl::UseWayland()
{
sUseWayland = true;
}
bool InitGtkApp(int argc, char **argv, const char **envptr)
{
LLOG(rmsecs() << " InitGtkApp");
#if GTK_CHECK_VERSION(3, 10, 0)
String backends = "x11,wayland";
#ifdef GUI_GTK_WAYLAND
#ifdef flagWAYLAND
backends = "wayland,x11";
#endif
if(FileExists(ConfigFile("USE_WAYLAND")) || sUseWayland)
backends = "wayland,x11";
gdk_set_allowed_backends(backends);
#endif

View file

@ -48,16 +48,14 @@ void Ctrl::Create(Ctrl *owner, bool popup)
top->csd.Create(type_hint);
if(top->csd.IsEnabled()) {
if (findarg(type_hint, GDK_WINDOW_TYPE_HINT_POPUP_MENU) >= 0) {
top->header = gtk_drawing_area_new();
top->header = gtk_header_bar_new();
if (findarg(type_hint, GDK_WINDOW_TYPE_HINT_POPUP_MENU) >= 0)
gtk_widget_set_size_request(top->header, 1, 1);
gtk_window_set_titlebar(gtk(), top->header);
}
else {
top->header = gtk_header_bar_new();
else
gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(top->header), TRUE);
gtk_window_set_titlebar(gtk(), top->header);
}
gtk_window_set_titlebar(gtk(), top->header);
gtk_header_bar_set_has_subtitle(GTK_HEADER_BAR(top->header), false);
top->drawing_area = gtk_drawing_area_new();
gtk_widget_set_can_focus(top->drawing_area, TRUE);

View file

@ -210,6 +210,8 @@ public:
static bool IsRunningOnWayland();
static bool IsXWayland() { return IsX11() && IsRunningOnWayland(); }
static void UseWayland();
static Point CurrentMousePos;
static guint CurrentState;
static guint32 CurrentTime;

View file

@ -166,8 +166,8 @@ gboolean Ctrl::GtkEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data)
AddEvent(user_data, EVENT_FOCUS_CHANGE, value, event);
}
return false;
case GDK_MOTION_NOTIFY:
case GDK_LEAVE_NOTIFY:
case GDK_MOTION_NOTIFY:
break;
case GDK_BUTTON_PRESS:
p->CancelPreedit();
@ -325,6 +325,10 @@ void Ctrl::AddEvent(gpointer user_data, int type, const Value& value, GdkEvent *
GdkEventMotion *mevent = (GdkEventMotion *)event;
e.mousepos = s_mousepos = Point(SCL(mevent->x_root), SCL(mevent->y_root));
}
if(event && event->type == GDK_LEAVE_NOTIFY){
GdkEventCrossing *mevent = (GdkEventCrossing *)event;
e.mousepos = s_mousepos = Point(SCL(mevent->x_root), SCL(mevent->y_root));
}
e.state = (mod & ~(GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK)) | MouseState;
e.count = 1;
e.event = NULL;

View file

@ -435,6 +435,9 @@ void Ctrl::WndInvalidateRect(const Rect& r)
rr.right = (r.right + 1) / 2;
rr.bottom = (r.bottom + 1) / 2;
}
if(IsWayland())
rr.Inflate(2, 2); // TODO: This is temporary fix
// as gtk3 dropped thread locking, we need to push invalid rectangles onto main loop
for(Win& win : wins) {

View file

@ -459,7 +459,6 @@ void FixButton(Image& button)
Over(m, button);
int g1 = Grayscale(SColorFace());
int n = 0;
int r = GetRoundness(button);
for(RGBA c : m) {
if(abs(Grayscale(c) - g1) > 30)
n++;

View file

@ -127,7 +127,7 @@ void ChHostSkin()
CtrlImg::Reset();
CtrlsImg::Reset();
ChReset();
GUI_GlobalStyle_Write(GUISTYLE_XP);
GUI_PopUpEffect_Write(GUIEFFECT_NONE);
@ -143,6 +143,8 @@ void ChHostSkin()
ChBaseSkin();
RoundStyleArrows();
SOImages(CtrlsImg::I_S0, COCO_RADIOBUTTON, 0);
SOImages(CtrlsImg::I_S1, COCO_RADIOBUTTON, 1);
FinishSOImages();

View file

@ -57,6 +57,7 @@ void Coco_PaintCh(void *cgcontext, int type, int value, int state)
scroller.floatValue = 0;
scroller.knobProportion = 1;
scroller.knobStyle = NSScrollerKnobStyleDefault;
// scroller.knobStyle = Upp::IsDarkTheme() ? NSScrollerKnobStyleDark : NSScrollerKnobStyleLight;
scroller.scrollerStyle = NSScrollerStyleLegacy;
scroller.frame = cr;
if(type == COCO_SCROLLTHUMB)

View file

@ -377,7 +377,7 @@ void ChHostSkin()
auto& s = ToolButton::StyleDefault().Write();
s.look[CTRL_NORMAL] = Image();
s.look[CTRL_HOT] = button[CTRL_HOT];
s.look[CTRL_PRESSED] = button[CTRL_PRESSED];
s.look[CTRL_PRESSED] = button[CTRL_PRESSED];
s.look[CTRL_DISABLED] = Image();
s.look[CTRL_CHECKED] = button[CTRL_PRESSED];
s.look[CTRL_HOTCHECKED] = button[CTRL_HOT];
@ -421,7 +421,7 @@ void ChHostSkin()
Gtk_New("scrollbar.horizontal.bottom contents trough slider");
GtkSize(sz);
s.barsize = s.thumbwidth = DPI(sz.cy);
s.barsize = s.thumbwidth = Ctrl::SCL(sz.cy);
s.thumbmin = max(minslider, 2 * s.barsize);
sz.cx = 4 * sz.cy;

View file

@ -436,7 +436,6 @@ Vector<String> MakeBuild::GetAllUses(const Workspace& wspc, int f,
{ // Gathers all uses, including subpackages, to support SO builds
String package = wspc[f];
Index<String> all_uses;
bool warn = true;
int n = 0;
while(f >= 0) {
const Package& p = wspc.package[f];
@ -445,10 +444,6 @@ Vector<String> MakeBuild::GetAllUses(const Workspace& wspc, int f,
if(MatchWhen(p.uses[fu].when, config.GetKeys())) {
if(p.uses[fu].text != package)
all_uses.FindAdd(p.uses[fu].text);
else if(warn) {
PutConsole(Format("%s: circular 'uses' chain", package));
warn = false;
}
}
}
f = -1;

View file

@ -324,6 +324,10 @@ One<Debugger> PdbCreate(Host& host, const String& exefile, const String& cmdline
void Ide::BuildAndDebug(bool runto)
{
#ifdef PLATFORM_COCOA
BuildAndExtDebug();
return;
#endif
VectorMap<String, String> bm = GetMethodVars(method);
String builder = bm.Get("BUILDER", "");

View file

@ -374,6 +374,15 @@ void Ide::SetupFormat() {
.Add(20, "C++ 20")
.Add(23, "C++ 23")
;
ide.wayland.Hide();
#ifdef GUI_GTK
String use_wayland_path = ConfigFile("USE_WAYLAND");
if(IsWayland() || IsXWayland()) {
ide.wayland.Show();
ide.wayland <<= FileExists(use_wayland_path);
}
#endif
rtvr
(hlt.hilite_scope, hs)
@ -575,6 +584,17 @@ void Ide::SetupFormat() {
CurrentFileDeleteCache();
editor.SyncCurrentFile();
}
#ifdef GUI_GTK
if(IsWayland() || IsXWayland()) {
if(FileExists(use_wayland_path) != ide.wayland) {
if(ide.wayland)
Upp::SaveFile(use_wayland_path, Null);
else
DeleteFile(use_wayland_path);
}
}
#endif
}
void Ide::FinishConfig()

View file

@ -33,9 +33,8 @@ void Ide::UpgradeTheIDE()
#endif
release.createmap = false;
release.version.Clear();
release.def.blitz = false;
release.def.debug = false;
release.package.Clear();
release.def.blitz = MapFlag(GetMethodVars(method), "RELEASE_BLITZ");
targetmode = 1;

View file

@ -22,19 +22,25 @@ bool LoadLibClang0(const char *path)
bool LoadLibClang(const String& dir)
{
#ifdef PLATFORM_MACOS // it does not seem to work for some reason, block it for now
#ifdef PLATFORM_MACOS
if(LoadLibClang0(dir + "/libclang.dylib"))
return true;
#endif
if(LoadLibClang0(dir + "/libclang.so"))
return true;
Vector<String> ps;
for(FindFile ff(dir + "/libclang.so*"); ff; ff.Next())
ps << ff.GetPath();
Sort(ps, StdGreater<String>());
for(String p : ps)
if(LoadLibClang0(p))
return true;
for(int i = 0; i < 50; i++) {
String p = dir + "/libclang";
if(i)
p << "-" << AsString(i + 10);
p << ".so*";
for(FindFile ff(p); ff; ff.Next())
ps << ff.GetPath();
Sort(ps, StdGreater<String>());
for(String p : ps)
if(LoadLibClang0(p))
return true;
}
return false;
}

View file

@ -33,7 +33,8 @@ void ClangConfigSetDefaults()
IndexerThreads = max(min(CPU_Cores() - 2, (mem_mb - 4000) / 1000), 1);
AutoIndexer = CPU_Cores() >= 8 && mem_mb > 8000;
// AutoIndexer = CPU_Cores() >= 8 && mem_mb > 8000;
AutoIndexer = true;
LibClangCppVersion = 17;
}

View file

@ -1300,6 +1300,8 @@ String GetGitBranchRaw(const String& dir);
Index<String> GetAllNests(bool sleep = false);
bool MapFlag(const VectorMap<class String, class String>& map, const char *key);
#include "urepo.h"
#endif

View file

@ -623,7 +623,7 @@ LAYOUT(SetupAssistLayout, 544, 368)
ITEM(Upp::DropList, std_cpp, LeftPosZ(116, 80).TopPosZ(288, 19))
END_LAYOUT
LAYOUT(SetupIdeLayout, 512, 352)
LAYOUT(SetupIdeLayout, 512, 376)
ITEM(Upp::Option, mute_sounds, SetLabel(t_("Mute sounds")).LeftPosZ(4, 160).TopPosZ(4, 16))
ITEM(Upp::Label, dv___1, SetLabel(t_("HYDRA threads")).LeftPosZ(212, 80).TopPosZ(4, 19))
ITEM(Upp::EditIntSpin, hydra1_threads, Min(1).Max(64).LeftPosZ(344, 48).TopPosZ(4, 19))
@ -659,6 +659,7 @@ LAYOUT(SetupIdeLayout, 512, 352)
ITEM(Upp::Label, dv___32, SetLabel(t_("Default UppHub folder")).LeftPosZ(4, 192).TopPosZ(328, 20))
ITEM(Upp::EditString, upphub, HSizePosZ(172, 28).TopPosZ(328, 19))
ITEM(Upp::Button, upphub_sel, RightPosZ(4, 20).TopPosZ(328, 19))
ITEM(Upp::Option, wayland, SetLabel(t_("Use Wayland (experimental, needs restart)")).LeftPosZ(4, 408).TopPosZ(352, 16))
END_LAYOUT
LAYOUT(SetupWebSearchEngineLayout, 564, 84)

View file

@ -134,7 +134,6 @@ mainconfig
"" = "GUI PEAKMEM",
"" = "GUI HEAPLOG",
"" = "GUI X11",
"" = "GUI GTK WAYLAND",
"" = "GUI DEBUGCODE";
custom() "",

View file

@ -134,7 +134,7 @@ bool TryLoadLibClang()
// in Mint 21.1, clang installed is 14 but llvm defaults to 15
for(String s : Split(Sys("clang --version"), [](int c)->int { return !IsDigit(c); })) {
int n = Atoi(s);
if(n >= 5 && n < 30) { // update in 10 years...
if(n >= 5 && n < 5000) {
if(LoadLibClang("/usr/lib/llvm-" + AsString(n) + "/lib"))
return true;
break;
@ -171,6 +171,7 @@ void OnCrash()
INITBLOCK { // libclang does not work in Linux unless this is set
SetEnv("LC_CTYPE", "en_US.UTF-8");
SetConfigName("theide");
}
#ifdef flagMAIN
@ -179,7 +180,6 @@ GUI_APP_MAIN
void AppMain___()
#endif
{
SetConfigName("theide");
#ifdef DYNAMIC_LIBCLANG
if(FindIndex(CommandLine(), "--noclang") < 0) {
String wfile = ConfigFile(".nolibclang");

View file

@ -0,0 +1,9 @@
uses
CtrlLib;
file
main.cpp;
mainconfig
"" = "GUI";

View file

@ -0,0 +1,36 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
INITBLOCK {
Ctrl::UseWayland();
}
struct MyApp : TopWindow {
TimeCallback tm;
virtual void Paint(Draw& w) {
Size sz = GetSize();
w.DrawRect(GetSize(), SWhite());
int y = 0;
String txt;
#define DMP(x) txt << #x << " " << x << "\n";
DMP(Ctrl::IsWayland());
DMP(GetScreenRect());
DMP(GetVirtualScreenArea());
DMP(GetVirtualWorkArea());
DMP(GetWorkArea());
DMP(GetMousePos());
DrawSmartText(w, 0, 0, sz.cx, txt);
}
MyApp() {
Sizeable().Zoomable();
tm.Set(-200, [=] { Refresh(); });
}
};
GUI_APP_MAIN
{
MyApp().Run();
}