Skip to content

Commit 178dc6f

Browse files
author
Hidenori Matsubayashi
authored
Refactoring: remove the keywords of static and struct (sony#74)
1 parent a052911 commit 178dc6f

File tree

2 files changed

+84
-93
lines changed

2 files changed

+84
-93
lines changed

src/flutter/shell/platform/linux_embedded/window/linuxes_window_wayland.cc

Lines changed: 80 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@
1818
namespace flutter {
1919

2020
namespace {
21-
static constexpr char kWestonDesktopShell[] = "weston_desktop_shell";
22-
static constexpr char kZwpTextInputManagerV1[] = "zwp_text_input_manager_v1";
23-
24-
static constexpr char kWlCursorThemeBottomLeftCorner[] = "bottom_left_corner";
25-
static constexpr char kWlCursorThemeBottomRightCorner[] = "bottom_right_corner";
26-
static constexpr char kWlCursorThemeBottomSide[] = "bottom_side";
27-
static constexpr char kWlCursorThemeGrabbing[] = "grabbing";
28-
static constexpr char kWlCursorThemeLeftPtr[] = "left_ptr";
29-
static constexpr char kWlCursorThemeLeftSide[] = "left_side";
30-
static constexpr char kWlCursorThemeRightSide[] = "right_side";
31-
static constexpr char kWlCursorThemeTopLeftCorner[] = "top_left_corner";
32-
static constexpr char kWlCursorThemeTopRightCorner[] = "top_right_corner";
33-
static constexpr char kWlCursorThemeTopSide[] = "top_side";
34-
static constexpr char kWlCursorThemeXterm[] = "xterm";
35-
static constexpr char kWlCursorThemeHand1[] = "hand1";
36-
static constexpr char kWlCursorThemeWatch[] = "watch";
37-
static constexpr char kCursorNameNone[] = "none";
38-
39-
static constexpr char kClipboardMimeTypeText[] = "text/plain";
21+
constexpr char kWestonDesktopShell[] = "weston_desktop_shell";
22+
constexpr char kZwpTextInputManagerV1[] = "zwp_text_input_manager_v1";
23+
24+
constexpr char kWlCursorThemeBottomLeftCorner[] = "bottom_left_corner";
25+
constexpr char kWlCursorThemeBottomRightCorner[] = "bottom_right_corner";
26+
constexpr char kWlCursorThemeBottomSide[] = "bottom_side";
27+
constexpr char kWlCursorThemeGrabbing[] = "grabbing";
28+
constexpr char kWlCursorThemeLeftPtr[] = "left_ptr";
29+
constexpr char kWlCursorThemeLeftSide[] = "left_side";
30+
constexpr char kWlCursorThemeRightSide[] = "right_side";
31+
constexpr char kWlCursorThemeTopLeftCorner[] = "top_left_corner";
32+
constexpr char kWlCursorThemeTopRightCorner[] = "top_right_corner";
33+
constexpr char kWlCursorThemeTopSide[] = "top_side";
34+
constexpr char kWlCursorThemeXterm[] = "xterm";
35+
constexpr char kWlCursorThemeHand1[] = "hand1";
36+
constexpr char kWlCursorThemeWatch[] = "watch";
37+
constexpr char kCursorNameNone[] = "none";
38+
39+
constexpr char kClipboardMimeTypeText[] = "text/plain";
4040
} // namespace
4141

4242
const wl_registry_listener LinuxesWindowWayland::kWlRegistryListener = {
@@ -97,8 +97,8 @@ const wl_seat_listener LinuxesWindowWayland::kWlSeatListener = {
9797
};
9898

9999
const wl_pointer_listener LinuxesWindowWayland::kWlPointerListener = {
100-
.enter = [](void* data, struct wl_pointer* wl_pointer, uint32_t serial,
101-
struct wl_surface* surface, wl_fixed_t surface_x,
100+
.enter = [](void* data, wl_pointer* wl_pointer, uint32_t serial,
101+
wl_surface* surface, wl_fixed_t surface_x,
102102
wl_fixed_t surface_y) -> void {
103103
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
104104
self->serial_ = serial;
@@ -115,7 +115,7 @@ const wl_pointer_listener LinuxesWindowWayland::kWlPointerListener = {
115115
self->pointer_y_ = y;
116116
}
117117
},
118-
.leave = [](void* data, struct wl_pointer* pointer, uint32_t serial,
118+
.leave = [](void* data, wl_pointer* pointer, uint32_t serial,
119119
wl_surface* surface) -> void {
120120
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
121121
self->serial_ = serial;
@@ -125,7 +125,7 @@ const wl_pointer_listener LinuxesWindowWayland::kWlPointerListener = {
125125
self->pointer_y_ = -1;
126126
}
127127
},
128-
.motion = [](void* data, struct wl_pointer* pointer, uint32_t time,
128+
.motion = [](void* data, wl_pointer* pointer, uint32_t time,
129129
wl_fixed_t surface_x, wl_fixed_t surface_y) -> void {
130130
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
131131
if (self->binding_handler_delegate_) {
@@ -136,7 +136,7 @@ const wl_pointer_listener LinuxesWindowWayland::kWlPointerListener = {
136136
self->pointer_y_ = y;
137137
}
138138
},
139-
.button = [](void* data, struct wl_pointer* pointer, uint32_t serial,
139+
.button = [](void* data, wl_pointer* pointer, uint32_t serial,
140140
uint32_t time, uint32_t button, uint32_t status) -> void {
141141
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
142142
self->serial_ = serial;
@@ -172,8 +172,8 @@ const wl_pointer_listener LinuxesWindowWayland::kWlPointerListener = {
172172
}
173173
}
174174
},
175-
.axis = [](void* data, struct wl_pointer* wl_pointer, uint32_t time,
176-
uint32_t axis, wl_fixed_t value) -> void {
175+
.axis = [](void* data, wl_pointer* wl_pointer, uint32_t time, uint32_t axis,
176+
wl_fixed_t value) -> void {
177177
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
178178
if (self->binding_handler_delegate_) {
179179
double delta = wl_fixed_to_double(value);
@@ -188,9 +188,9 @@ const wl_pointer_listener LinuxesWindowWayland::kWlPointerListener = {
188188
}; // namespace flutter
189189

190190
const wl_touch_listener LinuxesWindowWayland::kWlTouchListener = {
191-
.down = [](void* data, struct wl_touch* wl_touch, uint32_t serial,
192-
uint32_t time, struct wl_surface* surface, int32_t id,
193-
wl_fixed_t surface_x, wl_fixed_t surface_y) -> void {
191+
.down = [](void* data, wl_touch* wl_touch, uint32_t serial, uint32_t time,
192+
wl_surface* surface, int32_t id, wl_fixed_t surface_x,
193+
wl_fixed_t surface_y) -> void {
194194
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
195195
self->serial_ = serial;
196196
if (self->binding_handler_delegate_) {
@@ -199,26 +199,25 @@ const wl_touch_listener LinuxesWindowWayland::kWlTouchListener = {
199199
self->binding_handler_delegate_->OnTouchDown(time, id, x, y);
200200
}
201201
},
202-
.up = [](void* data, struct wl_touch* wl_touch, uint32_t serial,
203-
uint32_t time, int32_t id) -> void {
202+
.up = [](void* data, wl_touch* wl_touch, uint32_t serial, uint32_t time,
203+
int32_t id) -> void {
204204
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
205205
self->serial_ = serial;
206206
if (self->binding_handler_delegate_) {
207207
self->binding_handler_delegate_->OnTouchUp(time, id);
208208
}
209209
},
210-
.motion = [](void* data, struct wl_touch* wl_touch, uint32_t time,
211-
int32_t id, wl_fixed_t surface_x,
212-
wl_fixed_t surface_y) -> void {
210+
.motion = [](void* data, wl_touch* wl_touch, uint32_t time, int32_t id,
211+
wl_fixed_t surface_x, wl_fixed_t surface_y) -> void {
213212
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
214213
if (self->binding_handler_delegate_) {
215214
double x = wl_fixed_to_double(surface_x);
216215
double y = wl_fixed_to_double(surface_y);
217216
self->binding_handler_delegate_->OnTouchMotion(time, id, x, y);
218217
}
219218
},
220-
.frame = [](void* data, struct wl_touch* wl_touch) -> void {},
221-
.cancel = [](void* data, struct wl_touch* wl_touch) -> void {
219+
.frame = [](void* data, wl_touch* wl_touch) -> void {},
220+
.cancel = [](void* data, wl_touch* wl_touch) -> void {
222221
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
223222
if (self->binding_handler_delegate_) {
224223
self->binding_handler_delegate_->OnTouchCancel();
@@ -270,12 +269,12 @@ const wl_keyboard_listener LinuxesWindowWayland::kWlKeyboardListener = {
270269
};
271270

272271
const wl_output_listener LinuxesWindowWayland::kWlOutputListener = {
273-
.geometry = [](void* data, struct wl_output* wl_output, int32_t x,
274-
int32_t y, int32_t physical_width, int32_t physical_height,
272+
.geometry = [](void* data, wl_output* wl_output, int32_t x, int32_t y,
273+
int32_t physical_width, int32_t physical_height,
275274
int32_t subpixel, const char* make, const char* model,
276275
int32_t output_transform) -> void {},
277-
.mode = [](void* data, struct wl_output* wl_output, uint32_t flags,
278-
int32_t width, int32_t height, int32_t refresh) -> void {
276+
.mode = [](void* data, wl_output* wl_output, uint32_t flags, int32_t width,
277+
int32_t height, int32_t refresh) -> void {
279278
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
280279
if (flags & WL_OUTPUT_MODE_CURRENT) {
281280
LINUXES_LOG(INFO) << "Display output resolution: " << width << "x"
@@ -289,9 +288,8 @@ const wl_output_listener LinuxesWindowWayland::kWlOutputListener = {
289288
}
290289
}
291290
},
292-
.done = [](void* data, struct wl_output* wl_output) -> void {},
293-
.scale = [](void* data, struct wl_output* wl_output,
294-
int32_t scale) -> void {
291+
.done = [](void* data, wl_output* wl_output) -> void {},
292+
.scale = [](void* data, wl_output* wl_output, int32_t scale) -> void {
295293
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
296294
LINUXES_LOG(INFO) << "Display output scale: " << scale;
297295
self->current_scale_ = scale;
@@ -300,8 +298,8 @@ const wl_output_listener LinuxesWindowWayland::kWlOutputListener = {
300298

301299
const zwp_text_input_v1_listener LinuxesWindowWayland::kZwpTextInputV1Listener =
302300
{
303-
.enter = [](void* data, struct zwp_text_input_v1* zwp_text_input_v1,
304-
struct wl_surface* surface) -> void {
301+
.enter = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
302+
wl_surface* surface) -> void {
305303
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
306304
// If there is no input data, the backspace key cannot be used,
307305
// so set dummy data.
@@ -310,22 +308,20 @@ const zwp_text_input_v1_listener LinuxesWindowWayland::kZwpTextInputV1Listener =
310308
" ", 1, 1);
311309
}
312310
},
313-
.leave = [](void* data,
314-
struct zwp_text_input_v1* zwp_text_input_v1) -> void {
311+
.leave = [](void* data, zwp_text_input_v1* zwp_text_input_v1) -> void {
315312
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
316313
if (self->zwp_text_input_v1_) {
317314
zwp_text_input_v1_hide_input_panel(self->zwp_text_input_v1_);
318315
}
319316
},
320-
.modifiers_map = [](void* data,
321-
struct zwp_text_input_v1* zwp_text_input_v1,
322-
struct wl_array* map) -> void {},
317+
.modifiers_map = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
318+
wl_array* map) -> void {},
323319
.input_panel_state = [](void* data,
324-
struct zwp_text_input_v1* zwp_text_input_v1,
320+
zwp_text_input_v1* zwp_text_input_v1,
325321
uint32_t state) -> void {},
326-
.preedit_string =
327-
[](void* data, struct zwp_text_input_v1* zwp_text_input_v1,
328-
uint32_t serial, const char* text, const char* commit) -> void {
322+
.preedit_string = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
323+
uint32_t serial, const char* text,
324+
const char* commit) -> void {
329325
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
330326
if (self->binding_handler_delegate_ && strlen(text)) {
331327
self->binding_handler_delegate_->OnVirtualKey(text[0]);
@@ -338,14 +334,12 @@ const zwp_text_input_v1_listener LinuxesWindowWayland::kZwpTextInputV1Listener =
338334
" ", 1, 1);
339335
}
340336
},
341-
.preedit_styling =
342-
[](void* data, struct zwp_text_input_v1* zwp_text_input_v1,
343-
uint32_t index, uint32_t length, uint32_t style) -> void {},
344-
.preedit_cursor = [](void* data,
345-
struct zwp_text_input_v1* zwp_text_input_v1,
337+
.preedit_styling = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
338+
uint32_t index, uint32_t length,
339+
uint32_t style) -> void {},
340+
.preedit_cursor = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
346341
int32_t index) -> void {},
347-
.commit_string = [](void* data,
348-
struct zwp_text_input_v1* zwp_text_input_v1,
342+
.commit_string = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
349343
uint32_t serial, const char* text) -> void {
350344
// commit_string is notified only when the space key is pressed.
351345
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
@@ -359,12 +353,11 @@ const zwp_text_input_v1_listener LinuxesWindowWayland::kZwpTextInputV1Listener =
359353
" ", 1, 1);
360354
}
361355
},
362-
.cursor_position = [](void* data,
363-
struct zwp_text_input_v1* zwp_text_input_v1,
356+
.cursor_position = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
364357
int32_t index, int32_t anchor) -> void {},
365-
.delete_surrounding_text =
366-
[](void* data, struct zwp_text_input_v1* zwp_text_input_v1,
367-
int32_t index, uint32_t length) -> void {
358+
.delete_surrounding_text = [](void* data,
359+
zwp_text_input_v1* zwp_text_input_v1,
360+
int32_t index, uint32_t length) -> void {
368361
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
369362
if (self->binding_handler_delegate_) {
370363
self->binding_handler_delegate_->OnVirtualSpecialKey(KEY_BACKSPACE);
@@ -376,7 +369,7 @@ const zwp_text_input_v1_listener LinuxesWindowWayland::kZwpTextInputV1Listener =
376369
" ", 1, 1);
377370
}
378371
},
379-
.keysym = [](void* data, struct zwp_text_input_v1* zwp_text_input_v1,
372+
.keysym = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
380373
uint32_t serial, uint32_t time, uint32_t sym,
381374
uint32_t state, uint32_t modifiers) -> void {
382375
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
@@ -406,25 +399,24 @@ const zwp_text_input_v1_listener LinuxesWindowWayland::kZwpTextInputV1Listener =
406399
}
407400
}
408401
},
409-
.language = [](void* data, struct zwp_text_input_v1* zwp_text_input_v1,
402+
.language = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
410403
uint32_t serial, const char* language) -> void {},
411-
.text_direction = [](void* data,
412-
struct zwp_text_input_v1* zwp_text_input_v1,
404+
.text_direction = [](void* data, zwp_text_input_v1* zwp_text_input_v1,
413405
uint32_t serial, uint32_t direction) -> void {},
414406
};
415407

416408
const wl_data_device_listener LinuxesWindowWayland::kWlDataDeviceListener = {
417-
.data_offer = [](void* data, struct wl_data_device* wl_data_device,
418-
struct wl_data_offer* offer) -> void {},
419-
.enter = [](void* data, struct wl_data_device* wl_data_device,
420-
uint32_t serial, struct wl_surface* surface, wl_fixed_t x,
421-
wl_fixed_t y, struct wl_data_offer* offer) -> void {},
422-
.leave = [](void* data, struct wl_data_device* wl_data_device) -> void {},
423-
.motion = [](void* data, struct wl_data_device* wl_data_device,
424-
uint32_t time, wl_fixed_t x, wl_fixed_t y) -> void {},
425-
.drop = [](void* data, struct wl_data_device* wl_data_device) -> void {},
426-
.selection = [](void* data, struct wl_data_device* wl_data_device,
427-
struct wl_data_offer* offer) -> void {
409+
.data_offer = [](void* data, wl_data_device* wl_data_device,
410+
wl_data_offer* offer) -> void {},
411+
.enter = [](void* data, wl_data_device* wl_data_device, uint32_t serial,
412+
wl_surface* surface, wl_fixed_t x, wl_fixed_t y,
413+
wl_data_offer* offer) -> void {},
414+
.leave = [](void* data, wl_data_device* wl_data_device) -> void {},
415+
.motion = [](void* data, wl_data_device* wl_data_device, uint32_t time,
416+
wl_fixed_t x, wl_fixed_t y) -> void {},
417+
.drop = [](void* data, wl_data_device* wl_data_device) -> void {},
418+
.selection = [](void* data, wl_data_device* wl_data_device,
419+
wl_data_offer* offer) -> void {
428420
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
429421
if (self->wl_data_offer_) {
430422
wl_data_offer_destroy(self->wl_data_offer_);
@@ -434,9 +426,9 @@ const wl_data_device_listener LinuxesWindowWayland::kWlDataDeviceListener = {
434426
};
435427

436428
const wl_data_source_listener LinuxesWindowWayland::kWlDataSourceListener = {
437-
.target = [](void* data, struct wl_data_source* wl_data_source,
429+
.target = [](void* data, wl_data_source* wl_data_source,
438430
const char* mime_type) -> void {},
439-
.send = [](void* data, struct wl_data_source* wl_data_source,
431+
.send = [](void* data, wl_data_source* wl_data_source,
440432
const char* mime_type, int32_t fd) -> void {
441433
if (strcmp(mime_type, kClipboardMimeTypeText)) {
442434
LINUXES_LOG(ERROR) << "Not expected mime_type: " << mime_type;
@@ -448,7 +440,7 @@ const wl_data_source_listener LinuxesWindowWayland::kWlDataSourceListener = {
448440
strlen(self->clipboard_data_.c_str()));
449441
close(fd);
450442
},
451-
.cancelled = [](void* data, struct wl_data_source* wl_data_source) -> void {
443+
.cancelled = [](void* data, wl_data_source* wl_data_source) -> void {
452444
auto self = reinterpret_cast<LinuxesWindowWayland*>(data);
453445
self->clipboard_data_ = "";
454446
if (self->wl_data_source_) {
@@ -457,17 +449,16 @@ const wl_data_source_listener LinuxesWindowWayland::kWlDataSourceListener = {
457449
}
458450
},
459451
.dnd_drop_performed = [](void* data,
460-
struct wl_data_source* wl_data_source) -> void {},
461-
.dnd_finished = [](void* data,
462-
struct wl_data_source* wl_data_source) -> void {},
463-
.action = [](void* data, struct wl_data_source* wl_data_source,
452+
wl_data_source* wl_data_source) -> void {},
453+
.dnd_finished = [](void* data, wl_data_source* wl_data_source) -> void {},
454+
.action = [](void* data, wl_data_source* wl_data_source,
464455
uint32_t dnd_action) -> void {},
465456
};
466457

467458
LinuxesWindowWayland::LinuxesWindowWayland(FlutterWindowMode window_mode,
468459
int32_t width, int32_t height,
469460
bool show_cursor)
470-
: cursor_info_({nullptr, 0, ""}),
461+
: cursor_info_({"", 0, nullptr}),
471462
display_valid_(false),
472463
wl_pointer_(nullptr),
473464
wl_touch_(nullptr),

src/flutter/shell/platform/linux_embedded/window/linuxes_window_wayland.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ class LinuxesWindowWayland : public LinuxesWindow, public WindowBindingHandler {
6868
void SetClipboardData(const std::string& data) override;
6969

7070
private:
71-
struct cursor_info {
72-
::wl_pointer* wl_pointer;
73-
uint32_t serial;
71+
struct CursorInfo {
7472
std::string cursor_name;
73+
uint32_t serial;
74+
wl_pointer* wl_pointer;
7575
};
7676

7777
void WlRegistryHandler(wl_registry* wl_registry, uint32_t name,
@@ -121,7 +121,7 @@ class LinuxesWindowWayland : public LinuxesWindow, public WindowBindingHandler {
121121
zwp_text_input_manager_v1* zwp_text_input_manager_v1_;
122122
zwp_text_input_v1* zwp_text_input_v1_;
123123

124-
cursor_info cursor_info_;
124+
CursorInfo cursor_info_;
125125

126126
// List of cursor name and wl_cursor supported by Wayland.
127127
std::unordered_map<std::string, wl_cursor*> supported_wl_cursor_list_;

0 commit comments

Comments
 (0)