Skip to content

Commit 48fb703

Browse files
committed
wip
1 parent fd611d0 commit 48fb703

4 files changed

Lines changed: 70 additions & 15 deletions

File tree

src/ruisapp/application.hpp

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class application : public utki::intrusive_singleton<application>
5252
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
5353
static instance_type instance;
5454

55+
std::vector<window> windows_v;
56+
5557
public:
5658
const std::string name;
5759

@@ -64,6 +66,17 @@ class application : public utki::intrusive_singleton<application>
6466
void swap_frame_buffers();
6567

6668
public:
69+
/**
70+
* @brief Get application windows.
71+
* It is guaranteed that at least one window always exists,
72+
* so the returned span's size is guaranteed to be >= 1.
73+
* @return A span of application windows. Size of the span is always >= 1.
74+
*/
75+
utki::span<window> windows()
76+
{
77+
return this->windows_v;
78+
}
79+
6780
ruis::gui gui;
6881

6982
public:
@@ -183,16 +196,52 @@ class application : public utki::intrusive_singleton<application>
183196
unsigned pointer_id
184197
);
185198

199+
public:
200+
/**
201+
* @brief Application parameters.
202+
*/
203+
struct parameters {
204+
/**
205+
* @brief Application's name.
206+
* This name is not to be presented to the user, instead it is the name for
207+
* itentifying the application within the system.
208+
* For example, this name will be used to name application's config directories etc.
209+
* So, the name should be picked so that it does not collide with others.
210+
*/
211+
std::string name;
212+
213+
/**
214+
* @brief Graphics API version.
215+
* The version of the graphics API to initialize.
216+
* All windows will share the same graphics API.
217+
* A shared graphics API context will be created for each window.
218+
* Version value of 0.0 means to initialize minimal supported version of the graphics API.
219+
* Minimal supported versions of various graphics APIs:
220+
* - OpenGL 2.0
221+
* - OpenGL ES 2.0
222+
* - TODO: add more APIs
223+
*/
224+
// clang-format off
225+
utki::version_duplet graphics_api_version = {
226+
.major = 0,
227+
.minor = 0
228+
};
229+
// clang-format on
230+
231+
/**
232+
* @brief Application windows to create.
233+
* At least one window should be specified.
234+
*/
235+
std::vector<window_parameters> windows;
236+
};
237+
186238
protected:
187239
/**
188240
* @brief Application constructor.
189-
* @param name - name of the application.
190-
* @param window_params - requested window parameters.
241+
* @param params - application parameters.
242+
* @throw std::invalid_argument - in case list of windows to create is empty.
191243
*/
192-
application(
193-
std::string name, //
194-
const window_parameters& window_params
195-
);
244+
application(parameters params);
196245

197246
public:
198247
application(const application&) = delete;

src/ruisapp/glue/linux/glue_xorg.cxx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ struct window_wrapper : public utki::destructable {
217217

218218
std::atomic_bool quit_flag = false;
219219

220-
window_wrapper(const window_parameters& wp)
220+
window_wrapper(const application::parameters& app_params)
221221
{
222222
// set scale factor
223223
{
@@ -918,12 +918,9 @@ window_wrapper& get_impl(application& app)
918918

919919
} // namespace
920920

921-
application::application(
922-
std::string name, //
923-
const window_parameters& wp
924-
) :
925-
name(std::move(name)),
926-
window_pimpl(std::make_unique<window_wrapper>(wp)),
921+
application::application(application::parameters params) :
922+
name(std::move(params.name)),
923+
window_pimpl(std::make_unique<window_wrapper>(params)),
927924
gui(utki::make_shared<ruis::context>(
928925
utki::make_shared<ruis::style_provider>( //
929926
utki::make_shared<ruis::resource_loader>( //

src/ruisapp/glue/windows/glue.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,7 @@ window_wrapper::window_wrapper(const window_parameters& wp)
10251025
BYTE(0),
10261026
BYTE(0),
10271027
BYTE(0), // accumulation bits ignored
1028-
wp.buffers.get(ruisapp::buffer::depth) ? BYTE(utki::byte_bits * 2)
1029-
: BYTE(0), // 16 bit depth buffer
1028+
wp.buffers.get(ruisapp::buffer::depth) ? BYTE(utki::byte_bits * 2) : BYTE(0), // 16 bit depth buffer
10301029
wp.buffers.get(ruisapp::buffer::stencil) ? BYTE(utki::byte_bits) : BYTE(0),
10311030
BYTE(0), // no auxiliary buffer
10321031
BYTE(PFD_MAIN_PLANE), // main drawing layer

src/ruisapp/window.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ struct window_parameters {
7676
*/
7777
std::string title = "ruisapp";
7878

79+
/**
80+
* @brief Monitor index to place the window on.
81+
* Index of the monitor to initially place the window on.
82+
* The indexing starts from 1.
83+
* Value of 0 means to pick monitor automatically.
84+
* If the index exceeds the number of monitors the system actually has then
85+
* the window is placed to a monitor picked automatically as if the index was 0.
86+
*/
87+
unsigned monitor = 0;
88+
7989
/**
8090
* @brief Orientation policy.
8191
*/

0 commit comments

Comments
 (0)