diff --git a/uppsrc/CtrlCore/GtkCreate.cpp b/uppsrc/CtrlCore/GtkCreate.cpp index e386a52f4..a935da7e3 100644 --- a/uppsrc/CtrlCore/GtkCreate.cpp +++ b/uppsrc/CtrlCore/GtkCreate.cpp @@ -87,9 +87,10 @@ void Ctrl::Create(Ctrl *owner, bool popup) bool custom_bar = tw && tw->custom_bar; static bool need_csd = IsWayland() && GetEnv("XDG_SESSION_DESKTOP") != "KDE"; top->csd = !popup && (need_csd || custom_bar); -#ifdef flagFORCE_CSD // Force using client side decorations even when server side is available - top->csd = !popup; +#ifndef flagFORCE_CSD // Force using client side decorations even when server side is available + if(tw && tw->force_csd) #endif + top->csd = !popup; if(top->csd) { ONCELOCK { UpdateWindowDecorationsGeometry(); diff --git a/uppsrc/CtrlCore/GtkTop.cpp b/uppsrc/CtrlCore/GtkTop.cpp index 8edef3c90..a8626df7b 100644 --- a/uppsrc/CtrlCore/GtkTop.cpp +++ b/uppsrc/CtrlCore/GtkTop.cpp @@ -21,7 +21,9 @@ void TopWindow::SyncSizeHints() if(top->csd) { mcx += csd_border.left + csd_border.right; mcy += csd_border.top + csd_border.bottom; - if(!custom_bar) + if(custom_bar_frame) + mcy += GetCustomTitleBarMetrics().height; + else mcy += csd_std_header_cy; } diff --git a/uppsrc/CtrlCore/GtkTop.h b/uppsrc/CtrlCore/GtkTop.h index 85274a8e7..6a18da19e 100644 --- a/uppsrc/CtrlCore/GtkTop.h +++ b/uppsrc/CtrlCore/GtkTop.h @@ -24,7 +24,12 @@ CustomBarIcon minicon, maxicon, closeicon; Color custom_titlebar_bk = SColorFace(); int custom_titlebar_cy = -1; - + bool force_csd = false; + +public: + void Force_csd_() { force_csd = true; } // this is for testing... + +private: enum { FULLSCREEN = 99 }; void CenterRect(Ctrl *owner); diff --git a/uppsrc/CtrlCore/GtkWnd.cpp b/uppsrc/CtrlCore/GtkWnd.cpp index b88d9e6db..9e399a37c 100644 --- a/uppsrc/CtrlCore/GtkWnd.cpp +++ b/uppsrc/CtrlCore/GtkWnd.cpp @@ -219,18 +219,6 @@ void Ctrl::WndRectsSync() const width = gtk_widget_get_allocated_width(w); height = gtk_widget_get_allocated_height(w); - /* TODO: Remove? - if(IsWayland()) { - if(top && utop->csd) { - gdk_window_get_origin(gtk_widget_get_window(w), &x, &y); - width = gtk_widget_get_allocated_width(w); - height = gtk_widget_get_allocated_height(w); - } - else - gdk_window_get_geometry(gdk(), &x, &y, &width, &height); - } - else - */ if(top && utop->csd) { gdk_window_get_root_origin(gdk(), &x, &y); int x1, y1; @@ -584,10 +572,15 @@ void Ctrl::WndSetPos(const Rect& rect) TopWindow *tw = dynamic_cast(this); if(tw) tw->SyncSizeHints(); + if(top && utop->csd) { int top = csd_border.top; - if(!tw || !tw->custom_bar) - top += csd_std_header_cy; + if(tw) { + if(tw->custom_bar_frame) + top += tw->GetCustomTitleBarMetrics().height; + else + top += csd_std_header_cy; + } gdk_window_move_resize(gdk(), LSC(rect.left - csd_border.left), LSC(rect.top - top), LSCH(rect.GetWidth() + csd_border.left + csd_border.right), LSCH(rect.GetHeight() + top + csd_border.bottom)); @@ -596,6 +589,7 @@ void Ctrl::WndSetPos(const Rect& rect) Rect m(0, 0, 0, 0); if(tw) m = frameMargins; + gdk_window_move_resize(gdk(), LSC(rect.left - m.left), LSC(rect.top - m.top), LSCH(rect.GetWidth()), LSCH(rect.GetHeight())); } diff --git a/upptst/MinMaxSize/main.cpp b/upptst/MinMaxSize/main.cpp index 38fb444c5..33337f46a 100644 --- a/upptst/MinMaxSize/main.cpp +++ b/upptst/MinMaxSize/main.cpp @@ -12,9 +12,10 @@ struct App : public TopWindow DrawFrame(w, 0, 0, 500, 500, Black()); DrawFrame(w, 0, 0, 400, 400, Black()); DrawFrame(w, 0, 0, 600, 600, Black()); - w.DrawText(10, 10, AsString(GetScreenRect())); - w.DrawText(10, 50, AsString(GetRect())); - w.DrawText(10, 90, AsString(GetMousePos())); + w.DrawText(10, 10, AsString(GetScreenView())); + w.DrawText(10, 50, AsString(GetScreenRect())); + w.DrawText(10, 90, AsString(GetRect())); + w.DrawText(10, 130, AsString(GetMousePos())); } void MouseMove(Point p, dword keyflags) override { @@ -37,7 +38,7 @@ struct App : public TopWindow App() { - SetRect(10, 100, 500, 500); + SetRect(100, 200, 500, 500); Sizeable().Zoomable(); Add(dl.LeftPos(10, 101).BottomPos(0)); @@ -57,7 +58,7 @@ struct App2 : App { Label title; App2() { - SetRect(500, 100, 500, 500); + SetRect(700, 200, 500, 500); Ctrl *tb = CustomTitleBar(SYellow(), GetStdFontCy() + DPI(4)); if(tb) *tb << title.SizePos(); @@ -69,10 +70,18 @@ struct App2 : App { GUI_APP_MAIN { - App app; + App app, app_csd; App2 app2; + + app.Title("SSD"); + + app_csd.Title("CSD"); + app_csd.Force_csd_(); + app_csd.SetRect(1300, 200, 500, 500); + app.OpenMain(); + app_csd.OpenMain(); app2.OpenMain(); - Ctrl::EventLoop(); + app.Run(); }