@@ -1176,6 +1176,7 @@ void NWindow::add_child_window(NWindow::ptr child)
1176
1176
{
1177
1177
this ->child_windows_ .push_back (child);
1178
1178
child->parent_window_ = this ;
1179
+ child->top_level_window_ = this ->top_level_window_ ;
1179
1180
child->is_unicode_locale_ = this ->is_unicode_locale_ ;
1180
1181
child->color_palette (this ->color_palette_ );
1181
1182
@@ -1192,6 +1193,7 @@ bool NWindow::remove_child_window(NWindow* child)
1192
1193
if (i->get () == child)
1193
1194
{
1194
1195
child->parent_window_ = nullptr ;
1196
+ child->top_level_window_ = nullptr ;
1195
1197
child_windows_.erase (i);
1196
1198
return true ;
1197
1199
}
@@ -1201,21 +1203,11 @@ bool NWindow::remove_child_window(NWindow* child)
1201
1203
1202
1204
NWindow* NWindow::top_level_window ()
1203
1205
{
1204
- NWindow* window = this ;
1205
- while (window->parent_window_ != nullptr )
1206
- {
1207
- window = window->parent_window_ ;
1208
- }
1209
- return window;
1206
+ return this ->top_level_window_ ;
1210
1207
}
1211
1208
const NWindow* NWindow::top_level_window () const
1212
1209
{
1213
- const NWindow* window = this ;
1214
- while (window->parent_window_ != nullptr )
1215
- {
1216
- window = window->parent_window_ ;
1217
- }
1218
- return window;
1210
+ return this ->top_level_window_ ;
1219
1211
}
1220
1212
1221
1213
@@ -1286,6 +1278,8 @@ void NWindow::init_root_window()
1286
1278
{
1287
1279
throw std::runtime_error (" A root window already exists. Create a child window instead, by supplying a parent window argument to NWindow::create." );
1288
1280
}
1281
+ this ->top_level_window_ = this ;
1282
+
1289
1283
std::string old_locale = ::setlocale (LC_ALL, " " );
1290
1284
std::string locale = ::setlocale (LC_ALL, nullptr );
1291
1285
@@ -4573,7 +4567,7 @@ static bool use_raspberry_pi_fallback() {
4573
4567
{
4574
4568
g_checked_raspberry_pi = true ;
4575
4569
4576
- // Are we running in raspi lxterminal?
4570
+ // Are we running in Raspberry Pi lxterminal?
4577
4571
// GIO_LAUNCHED_DESKTOP_FILE=/usr/share/raspi-ui-overrides/applications/lxterminal.desktop
4578
4572
const char * term = std::getenv (" GIO_LAUNCHED_DESKTOP_FILE" );
4579
4573
g_use_raspberry_pi_fallback = false ;
@@ -6313,8 +6307,33 @@ void NWindow::handle_is_active_changed(bool activated)
6313
6307
}
6314
6308
6315
6309
6316
-
6317
6310
bool NWindow::can_display_character (char32_t c) const
6311
+ {
6312
+ if (this ->top_level_window () != this )
6313
+ {
6314
+ return this ->top_level_window ()->can_display_character (c);
6315
+ }
6316
+ // Simple cache implementation, assuming that the underlying call
6317
+ // requires a round-trip wire transit,
6318
+
6319
+ auto ff = can_display_character_cache_.find (c);
6320
+ if (ff != can_display_character_cache_.end ())
6321
+ {
6322
+ return ff->second ;
6323
+ }
6324
+ bool result = can_display_character_ (c);
6325
+
6326
+ // moral constness.
6327
+ const_cast <NWindow*>(this )->can_display_character_cache_ [c] = result;
6328
+
6329
+ return result;
6330
+ }
6331
+ // std::unordered_map<char32_t,bool> NWindow::can_display_character_cache_;
6332
+
6333
+
6334
+
6335
+
6336
+ bool NWindow::can_display_character_ (char32_t c) const
6318
6337
{
6319
6338
// Figure out whether wcwidth() works on Windows for emoji (and other extended unicode characters)
6320
6339
// or figure out an alternative.
0 commit comments