@@ -145,14 +145,22 @@ void handle_mouse_move(
145145
146146 utki::assert (self->window , SL);
147147
148- // TODO: for optimization, check if rect has changed
149- // set the GL viewport
150- self->window ->gui .set_viewport (ruis::rect{
151- { ruis::real (rect.origin .x ), ruis::real (rect.origin .y )},
152- {ruis::real (rect.size .width ), ruis::real (rect.size .height )}
153- } // TODO: remove?
154- // self->window->ruis_native_window.get().get_content_rect()
155- );
148+ auto & natwin = self->window ->ruis_native_window .get ();
149+
150+ // TODO: get correct content rect
151+ auto content_rect = natwin.get_content_rect ();
152+ // ruis::rect content_rect{
153+ // {ruis::real(rect.origin.x), ruis::real(rect.origin.y)},
154+ // {ruis::real(rect.size.width), ruis::real(rect.size.height)} //
155+ // };
156+
157+ // utki::log_debug([&](auto&o){
158+ // o << "content_rect = " << content_rect << std::endl;
159+ // });
160+
161+ // TODO: for optimization, check if rect has changed
162+ // set the GL viewport
163+ self->window ->gui .set_viewport (content_rect);
156164
157165 auto & glue = get_glue ();
158166 glue.render ();
@@ -165,7 +173,6 @@ void handle_mouse_move(
165173 for (UITouch* touch in touches) {
166174 CGPoint p = [touch locationInView:self.view ];
167175
168- // TRACE(<< "touch began = " << ruis::Vec2r(p.x * scale, p.y * scale).rounded() << std::endl)
169176 using std::round;
170177 handle_mouse_button (
171178 true , // is_down
@@ -183,7 +190,6 @@ void handle_mouse_move(
183190 for (UITouch* touch in touches) {
184191 CGPoint p = [touch locationInView:self.view ];
185192
186- // TRACE(<< "touch moved = " << ruis::Vec2r(p.x * scale, p.y * scale).rounded() << std::endl)
187193 using std::round;
188194 handle_mouse_move (
189195 round (ruis::vector2 (p.x * scale, p.y * scale)), // pos
@@ -199,7 +205,6 @@ void handle_mouse_move(
199205 for (UITouch* touch in touches) {
200206 CGPoint p = [touch locationInView:self.view ];
201207
202- // TRACE(<< "touch ended = " << ruis::Vec2r(p.x * scale, p.y * scale).rounded() << std::endl)
203208 using std::round;
204209 handle_mouse_button (
205210 false , // is_down
@@ -329,6 +334,55 @@ void native_window::bind_rendering_context()
329334 [EAGLContext setCurrentContext:this ->ios_egl_context .context ];
330335}
331336
337+ void native_window::set_fullscreen_internal (bool enable)
338+ {
339+ float scale = [[UIScreen mainScreen] scale];
340+
341+ using std::round;
342+
343+ if (enable){
344+ if ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 7 .0f ) {
345+ CGRect rect = this ->ios_window .window .frame ;
346+ this ->ios_window .window .rootViewController .view .frame = rect;
347+ }
348+
349+ // TODO: this was setting the viewport, is something still needed here?
350+ // update_window_rect(
351+ // ruis::rect(
352+ // ruis::vector2(0),
353+ // ruis::vector2(
354+ // round(this->ios_window.window.frame.size.width * scale),
355+ // round(this->ios_window.window.frame.size.height * scale)
356+ // )
357+ // )
358+ // );
359+
360+ this ->ios_window .window .windowLevel = UIWindowLevelStatusBar;
361+ }else {
362+ CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size ;
363+
364+ if ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 7 .0f ) {
365+ CGRect rect = this ->ios_window .window .frame ;
366+ rect.origin .y += statusBarSize.height ;
367+ rect.size .height -= statusBarSize.height ;
368+ this ->ios_window .window .rootViewController .view .frame = rect;
369+ }
370+
371+ // TODO: this was setting the viewport, is something still needed here?
372+ // update_window_rect(
373+ // ruis::rect(
374+ // ruis::vector2(0),
375+ // ruis::vector2(
376+ // round(this->ios_window.window.frame.size.width * scale),
377+ // round((this->ios_window.window.frame.size.height - statusBarSize.height) * scale)
378+ // )
379+ // )
380+ // );
381+
382+ this ->ios_window .window .windowLevel = UIWindowLevelNormal;
383+ }
384+ }
385+
332386ruis::rect native_window::get_content_rect () const
333387{
334388 UIWindow* w = this ->ios_window .window ;
0 commit comments