Skip to content

Commit

Permalink
set window title
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Dec 31, 2024
1 parent 6b451d1 commit c282c41
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
9 changes: 8 additions & 1 deletion src/ruisapp/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ struct window_params {
*/
r4::vector2<unsigned> dims;

// TODO: add window title string
/**
* @brief Window title.
*/
std::string title = "ruisapp";

/**
* @brief Graphics buffer kind.
* Color buffer is always present, so no enum entry for color buffer is needed.
*/
enum class buffer {
depth,
stencil,
Expand Down
10 changes: 7 additions & 3 deletions src/ruisapp/glue/linux/glue_wayland.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1958,14 +1958,18 @@ struct window_wrapper : public utki::destructable {
.close = &xdg_toplevel_close,
};

toplevel_wrapper(surface_wrapper& surface, xdg_surface_wrapper& xdg_surface) :
toplevel_wrapper(
const ruisapp::window_params& wp,
surface_wrapper& surface, //
xdg_surface_wrapper& xdg_surface
) :
toplev(xdg_surface_get_toplevel(xdg_surface.xdg_sur))
{
if (!this->toplev) {
throw std::runtime_error("could not get wayland xdg toplevel");
}

xdg_toplevel_set_title(this->toplev, "ruisapp wayland");
xdg_toplevel_set_title(this->toplev, wp.title.c_str());
xdg_toplevel_add_listener(this->toplev, &listener, nullptr);

surface.commit();
Expand Down Expand Up @@ -2186,7 +2190,7 @@ struct window_wrapper : public utki::destructable {
seat(this->registry, this->compositor, this->shm),
surface(this->compositor),
xdg_surface_wrp(this->surface, this->wm_base),
toplevel(this->surface, this->xdg_surface_wrp),
toplevel(wp, this->surface, this->xdg_surface_wrp),
egl_window(this->surface, wp.dims),
egl_context(this->display, this->egl_window, wp),
cur_window_dims(wp.dims)
Expand Down
3 changes: 3 additions & 0 deletions src/ruisapp/glue/linux/glue_xorg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ struct window_wrapper : public utki::destructable {

XFlush(this->display.display);

// set window title
XStoreName(this->display.display, this->window, wp.title.c_str());

//====================
// create GLX context

Expand Down
4 changes: 2 additions & 2 deletions src/ruisapp/glue/macosx/glue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ -(BOOL)windowShouldClose:(id)sender{
return NO;
}

-(BOOL)canBecomeKeyWindow{return YES;} //This is needed for window without title bar to be able to get key events
-(BOOL)canBecomeKeyWindow{return YES;} // This is needed for window without title bar to be able to get key events
-(BOOL)canBecomeMainWindow{return YES;}
-(BOOL)acceptsFirstResponder{return YES;}

Expand Down Expand Up @@ -641,7 +641,7 @@ -(CocoaView*)view{return self->v;}
[this->windowObjectId release];
});

[this->windowObjectId setTitle:[[NSProcessInfo processInfo] processName]];
[this->windowObjectId setTitle:wp.title.c_str()];

{
std::vector<NSOpenGLPixelFormatAttribute> attributes;
Expand Down
2 changes: 1 addition & 1 deletion src/ruisapp/glue/sdl/glue.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class window_wrapper : public utki::destructable
auto dims = wp.dims.to<ruis::real>() * get_display_scaling_factor();

SDL_Window* window = SDL_CreateWindow(
"TODO: window title",
wp.title.c_str(),
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
int(dims.x()),
Expand Down
2 changes: 1 addition & 1 deletion src/ruisapp/glue/windows/glue.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ window_wrapper::window_wrapper(const window_params& wp)
this->hwnd = CreateWindowEx(
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // extended style
window_class_name,
"ruis app",
wp.title.c_str(),
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0, // x
0, // y
Expand Down

0 comments on commit c282c41

Please sign in to comment.