@@ -51,7 +51,7 @@ static void layout(const SP<IWindow>& window) {
5151
5252 auto rect4 = CRectangleBuilder::begin () //
5353 ->color ([] { return CHyprColor{0 .4F , 0 .2F , 0 .4F }; })
54- ->rounding (10 )
54+ ->rounding (0 )
5555 ->size ({CDynamicSize::HT_SIZE_ABSOLUTE, CDynamicSize::HT_SIZE_ABSOLUTE, {50 , 50 }})
5656 ->commence ();
5757
@@ -62,12 +62,12 @@ static void layout(const SP<IWindow>& window) {
6262 ->size ({CDynamicSize::HT_SIZE_ABSOLUTE, CDynamicSize::HT_SIZE_ABSOLUTE, {447 , 447 }})
6363 ->commence ();
6464
65- auto text = CTextBuilder::begin ()->text (" world is a fuck " )->color ([] { return CHyprColor{0 .4F , 0 .4F , 0 .4F }; })->commence ();
65+ auto text = CTextBuilder::begin ()->text (" never give up " )->color ([] { return CHyprColor{0 .4F , 0 .4F , 0 .4F }; })->commence ();
6666
6767 auto button = CButtonBuilder::begin ()
68- ->label (" Click me bitch " )
69- ->onMainClick ([](SP<CButtonElement> el) { el->rebuild ()->label (std::format (" Clicked {} times bitch " , buttonClicks++))->commence (); })
70- ->onRightClick ([](SP<CButtonElement> el) { el->rebuild ()->label (" Reset bitch " )->commence (); })
68+ ->label (" Click me kind person " )
69+ ->onMainClick ([](SP<CButtonElement> el) { el->rebuild ()->label (std::format (" Clicked {} times" , buttonClicks++))->commence (); })
70+ ->onRightClick ([](SP<CButtonElement> el) { el->rebuild ()->label (" Reset" )->commence (); })
7171 ->size ({CDynamicSize::HT_SIZE_AUTO, CDynamicSize::HT_SIZE_AUTO, {1 , 1 }})
7272 ->commence ();
7373
@@ -100,6 +100,15 @@ static void onWindowClose(WP<IWindow> window) {
100100 }
101101}
102102
103+ static void createLockSurface (SP<IOutput> output) {
104+ windows.emplace_back (CWindowBuilder::begin ()->type (HT_WINDOW_LOCK_SURFACE)->prefferedOutput (output)->commence ());
105+ std::println (" New surface {}!" , (uintptr_t )windows.back ().get ());
106+ WP<IWindow> weakWindow = windows.back ();
107+ weakWindow->m_events .closeRequest .listenStatic ([weakWindow]() { onWindowClose (weakWindow); });
108+
109+ layout (weakWindow.lock ());
110+ }
111+
103112int main (int argc, char ** argv, char ** envp) {
104113 int unlockSecs = 1 ;
105114 if (argc == 2 )
@@ -111,18 +120,10 @@ int main(int argc, char** argv, char** envp) {
111120 return -1 ;
112121 }
113122
114- backend->m_events .outputAdded .listenStatic ([](SP<IOutput> output) {
115- windows.emplace_back (CWindowBuilder::begin ()->type (HT_WINDOW_LOCK_SURFACE)->prefferedOutput (output)->commence ());
116- std::println (" New surface {}!" , (uintptr_t )windows.back ().get ());
117- WP<IWindow> window = windows.back ();
118- window->m_events .closeRequest .listenStatic ([window]() { onWindowClose (window); });
119-
120- layout (window.lock ());
121- });
123+ backend->m_events .outputAdded .listenStatic (createLockSurface);
122124
123- if (!backend->attempt ()) {
124- std::println (" Backend attempt failed!" );
125- return -1 ;
125+ for (const auto & o: backend->getOutputs ()) {
126+ createLockSurface (o);
126127 }
127128
128129 backend->addTimer (std::chrono::seconds (unlockSecs), [](auto , auto ) { backend->unlockSession (); }, nullptr );
0 commit comments