Skip to content

Commit 71c127e

Browse files
committed
cursor: Load style before initializing server. Fixes initialization of cursor styles and scaling on outputs.
1 parent 7357f61 commit 71c127e

File tree

11 files changed

+40
-36
lines changed

11 files changed

+40
-36
lines changed

doc/ROADMAP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ See the [Detailed Feature List](FEATURES.md) for details.
4444
* Fix: Handle `Terminal` flag and launch applications in a suitable terminal.
4545
* Support keypad (tap to click) and middle click alternatives.
4646
* Support configurable means (eg. Alt+) to emulate right-click on laptop.
47-
* Fix: On scaled output, pointer cursor is tiny.
4847
* Write log to logfile (vs. stderr).
4948
* Have a naive app to show battery status.
5049
* Wire up backlight control to window menu.
5150

5251
* Bug fixes
5352
* [done] Fix crash when changing to different terminal ([#438](https://github.com/phkaeser/wlmaker/issues/438)).
5453
* [done] wlmaker not showing window of wlroots clients ([#439](https://github.com/phkaeser/wlmaker/issues/439)).
54+
* [done] Cursor remains small (not scaled) on output with scale > 1.0 ([#444](https://github.com/phkaeser/wlmaker/issues/444)).
5555

5656
## [0.7](https://github.com/phkaeser/wlmaker/releases/tag/v0.7)
5757

src/action.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ void wlmaker_action_execute(wlmaker_server_t *server_ptr,
270270
workspace_ptr = wlmtk_workspace_create(
271271
server_ptr->wlr_output_layout_ptr,
272272
"New",
273-
&server_ptr->style.tile);
273+
&server_ptr->style_ptr->tile);
274274
if (NULL != workspace_ptr) {
275275
BS_ASSERT_NOTNULL(wlmaker_background_create(
276276
workspace_ptr,
277277
server_ptr->wlr_output_layout_ptr,
278-
server_ptr->style.background_color));
278+
server_ptr->style_ptr->background_color));
279279
wlmtk_root_add_workspace(server_ptr->root_ptr, workspace_ptr);
280280
}
281281
break;

src/cursor.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,21 @@ wlmaker_cursor_t *wlmaker_cursor_create(
8181
cursor_ptr->wlr_cursor_ptr, wlr_output_layout_ptr);
8282

8383
cursor_ptr->wlr_xcursor_manager_ptr = wlr_xcursor_manager_create(
84-
server_ptr->style.cursor.name_ptr,
85-
server_ptr->style.cursor.size);
84+
server_ptr->style_ptr->cursor.name_ptr,
85+
server_ptr->style_ptr->cursor.size);
8686
if (NULL == cursor_ptr->wlr_xcursor_manager_ptr) {
8787
bs_log(BS_ERROR, "Failed wlr_xcursor_manager_create(%s, %"PRIu64")",
88-
server_ptr->style.cursor.name_ptr,
89-
server_ptr->style.cursor.size);
88+
server_ptr->style_ptr->cursor.name_ptr,
89+
server_ptr->style_ptr->cursor.size);
9090
wlmaker_cursor_destroy(cursor_ptr);
9191
return NULL;
9292
}
9393
if (!wlr_xcursor_manager_load(cursor_ptr->wlr_xcursor_manager_ptr,
9494
config_output_scale)) {
9595

9696
bs_log(BS_ERROR, "Failed wlr_xcursor_manager_load() for %s, %"PRIu64,
97-
server_ptr->style.cursor.name_ptr,
98-
server_ptr->style.cursor.size);
97+
server_ptr->style_ptr->cursor.name_ptr,
98+
server_ptr->style_ptr->cursor.size);
9999
wlmaker_cursor_destroy(cursor_ptr);
100100
return NULL;
101101
}

src/icon_manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ wlmaker_toplevel_icon_t *wlmaker_toplevel_icon_create(
368368

369369
if (!wlmtk_tile_init(
370370
&toplevel_icon_ptr->super_tile,
371-
&icon_manager_ptr->server_ptr->style.tile)) {
371+
&icon_manager_ptr->server_ptr->style_ptr->tile)) {
372372
wlmaker_toplevel_icon_destroy(toplevel_icon_ptr);
373373
return NULL;
374374
}

src/server.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,14 @@ const uint32_t wlmaker_modifier_default_mask = (
116116
wlmaker_server_t *wlmaker_server_create(
117117
bspl_dict_t *config_dict_ptr,
118118
wlmaker_files_t *files_ptr,
119+
const wlmaker_config_style_t *style_ptr,
119120
const wlmaker_server_options_t *options_ptr)
120121
{
121122
wlmaker_server_t *server_ptr = logged_calloc(1, sizeof(wlmaker_server_t));
122123
if (NULL == server_ptr) return NULL;
123124
server_ptr->options_ptr = options_ptr;
124125
server_ptr->files_ptr = files_ptr;
126+
server_ptr->style_ptr = style_ptr;
125127

126128
server_ptr->config_dict_ptr = bspl_dict_ref(config_dict_ptr);
127129
if (NULL == server_ptr->config_dict_ptr) {

src/server.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ struct _wlmaker_server_t {
198198
struct wl_listener unclaimed_button_event_listener;
199199

200200
/** The current configuration style. */
201-
wlmaker_config_style_t style;
201+
const wlmaker_config_style_t *style_ptr;
202202
};
203203

204204
/** Specifies the key + modifier to bind. */
@@ -218,7 +218,8 @@ struct _wlmaker_key_combo_t {
218218
*
219219
* @param config_dict_ptr Configuration, as dictionary object. The server
220220
* will keep a reference on it until destroyed.
221-
* @param files_ptr
221+
* @param files_ptr Files handle. Must outlive the server.
222+
* @param style_ptr Style. Must outlive the server.
222223
* @param options_ptr Options for the server. The server expects the
223224
* pointed area to outlive the server.
224225
*
@@ -228,6 +229,7 @@ struct _wlmaker_key_combo_t {
228229
wlmaker_server_t *wlmaker_server_create(
229230
bspl_dict_t *config_dict_ptr,
230231
wlmaker_files_t *files_ptr,
232+
const wlmaker_config_style_t *style_ptr,
231233
const wlmaker_server_options_t *options_ptr);
232234

233235
/**

src/tl_menu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ wlmaker_tl_menu_t *wlmaker_tl_menu_create(
180180
wlmaker_action_item_t *ai_ptr = wlmaker_action_item_create_from_desc(
181181
desc_ptr,
182182
tl_menu_ptr,
183-
&server_ptr->style.menu.item,
183+
&server_ptr->style_ptr->menu.item,
184184
server_ptr);
185185
if (NULL == ai_ptr) {
186186
bs_log(BS_ERROR, "Failed wlmaker_action_item_create_from_desc()");
@@ -194,7 +194,7 @@ wlmaker_tl_menu_t *wlmaker_tl_menu_create(
194194
}
195195

196196
tl_menu_ptr->workspaces_submenu_ptr = wlmtk_menu_create(
197-
&server_ptr->style.menu);
197+
&server_ptr->style_ptr->menu);
198198
if (NULL == tl_menu_ptr->workspaces_submenu_ptr) {
199199
wlmaker_tl_menu_destroy(tl_menu_ptr);
200200
return NULL;
@@ -330,7 +330,7 @@ void _wlmaker_tl_menu_workspace_iterator_create_item(
330330
ws_item_ptr->window_ptr = tl_menu_ptr->window_ptr;
331331

332332
ws_item_ptr->menu_item_ptr = wlmtk_menu_item_create(
333-
&tl_menu_ptr->server_ptr->style.menu.item);
333+
&tl_menu_ptr->server_ptr->style_ptr->menu.item);
334334
if (NULL == ws_item_ptr->menu_item_ptr) {
335335
_destroy(ws_item_ptr);
336336
return;

src/toolkit/input.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,4 @@ void wlmtk_pointer_set_cursor(
8585
_wlmtk_pointer_cursor_names[cursor]);
8686
}
8787

88-
/* == Local (static) methods =============================================== */
89-
90-
/* == Unit Tests =========================================================== */
91-
9288
/* == End of input.c ======================================================= */

src/wlmaker.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,15 @@ bool create_workspaces(
280280
wlmtk_workspace_t *workspace_ptr = wlmtk_workspace_create(
281281
server_ptr->wlr_output_layout_ptr,
282282
s.name,
283-
&server_ptr->style.tile);
283+
&server_ptr->style_ptr->tile);
284284
if (NULL == workspace_ptr) {
285285
bs_log(BS_ERROR, "Failed wlmtk_workspace_create(\"%s\")", s.name);
286286
rv = false;
287287
break;
288288
}
289289

290290
if (s.color == 0) {
291-
s.color = server_ptr->style.background_color;
291+
s.color = server_ptr->style_ptr->background_color;
292292
}
293293
wlmaker_background_t *background_ptr = wlmaker_background_create(
294294
workspace_ptr,
@@ -383,13 +383,10 @@ int main(__UNUSED__ int argc, __UNUSED__ const char **argv)
383383
return EXIT_FAILURE;
384384
}
385385

386-
wlmaker_server_t *server_ptr = wlmaker_server_create(
387-
config_dict_ptr, files_ptr, &wlmaker_server_options);
388-
if (NULL == server_ptr) return EXIT_FAILURE;
389-
386+
wlmaker_config_style_t style = {};
390387
bspl_dict_t *style_dict_ptr = bspl_dict_from_object(
391388
wlmaker_config_object_load(
392-
server_ptr->files_ptr,
389+
files_ptr,
393390
"style",
394391
wlmaker_arg_theme_file_ptr,
395392
"Themes/Default.plist",
@@ -399,15 +396,19 @@ int main(__UNUSED__ int argc, __UNUSED__ const char **argv)
399396
if (!bspl_decode_dict(
400397
style_dict_ptr,
401398
wlmaker_config_style_desc,
402-
&server_ptr->style)) return EXIT_FAILURE;
399+
&style)) return EXIT_FAILURE;
403400
bspl_dict_unref(style_dict_ptr);
404401

402+
wlmaker_server_t *server_ptr = wlmaker_server_create(
403+
config_dict_ptr, files_ptr, &style, &wlmaker_server_options);
404+
if (NULL == server_ptr) return EXIT_FAILURE;
405+
405406
// TODO(kaeser@gubbe.ch): Uh, that's ugly...
406407
server_ptr->root_menu_ptr = wlmaker_root_menu_create(
407408
server_ptr,
408409
wlmaker_arg_root_menu_file_ptr,
409-
&server_ptr->style.window,
410-
&server_ptr->style.menu);
410+
&server_ptr->style_ptr->window,
411+
&server_ptr->style_ptr->menu);
411412
if (NULL == server_ptr->root_menu_ptr) {
412413
return EXIT_FAILURE;
413414
}
@@ -452,11 +453,11 @@ int main(__UNUSED__ int argc, __UNUSED__ const char **argv)
452453
}
453454

454455
dock_ptr = wlmaker_dock_create(
455-
server_ptr, state_dict_ptr, &server_ptr->style);
456+
server_ptr, state_dict_ptr, &style);
456457
clip_ptr = wlmaker_clip_create(
457-
server_ptr, state_dict_ptr, &server_ptr->style);
458+
server_ptr, state_dict_ptr, &style);
458459
task_list_ptr = wlmaker_task_list_create(
459-
server_ptr, &server_ptr->style);
460+
server_ptr, &style);
460461
if (NULL == dock_ptr || NULL == clip_ptr || NULL == task_list_ptr) {
461462
bs_log(BS_ERROR, "Failed to create dock, clip or task list.");
462463
} else {

src/xdg_toplevel.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <wlr/version.h>
3838
#undef WLR_USE_UNSTABLE
3939

40+
#include "config.h"
4041
#include "server.h"
4142
#include "tl_menu.h"
4243
#include "toolkit/toolkit.h"
@@ -346,8 +347,8 @@ struct wlmaker_xdg_toplevel *_wlmaker_xdg_toplevel_create_injected(
346347

347348
wlmaker_xdg_toplevel_ptr->window_ptr = wlmtk_window_create(
348349
wlmtk_base_element(&wlmaker_xdg_toplevel_ptr->base),
349-
&wlmaker_xdg_toplevel_ptr->server_ptr->style.window,
350-
&wlmaker_xdg_toplevel_ptr->server_ptr->style.menu);
350+
&wlmaker_xdg_toplevel_ptr->server_ptr->style_ptr->window,
351+
&wlmaker_xdg_toplevel_ptr->server_ptr->style_ptr->menu);
351352
if (NULL == wlmaker_xdg_toplevel_ptr->window_ptr) goto error;
352353
wlmtk_window_set_properties(
353354
wlmaker_xdg_toplevel_ptr->window_ptr,
@@ -923,6 +924,7 @@ struct _xdg_toplevel_test_data {
923924
struct wlr_xdg_toplevel wlr_xdg_toplevel;
924925

925926
struct _wlmaker_test_layout test_layout;
927+
wlmaker_config_style_t style;
926928
wlmaker_server_t server;
927929

928930
int32_t set_size_width;
@@ -1050,6 +1052,7 @@ void *_wlmaker_xdg_toplevel_test_setup(void)
10501052
td_ptr->test_layout.wlr_output_layout_ptr,
10511053
&td_ptr->test_layout.wlr_output);
10521054

1055+
td_ptr->server.style_ptr = &td_ptr->style;
10531056
td_ptr->server.wlr_scene_ptr = wlr_scene_create();
10541057
if (NULL == td_ptr->server.wlr_scene_ptr) goto error;
10551058

0 commit comments

Comments
 (0)