@@ -1176,6 +1176,7 @@ void NWindow::add_child_window(NWindow::ptr child)
11761176{
11771177 this ->child_windows_ .push_back (child);
11781178 child->parent_window_ = this ;
1179+ child->top_level_window_ = this ->top_level_window_ ;
11791180 child->is_unicode_locale_ = this ->is_unicode_locale_ ;
11801181 child->color_palette (this ->color_palette_ );
11811182
@@ -1192,6 +1193,7 @@ bool NWindow::remove_child_window(NWindow* child)
11921193 if (i->get () == child)
11931194 {
11941195 child->parent_window_ = nullptr ;
1196+ child->top_level_window_ = nullptr ;
11951197 child_windows_.erase (i);
11961198 return true ;
11971199 }
@@ -1201,21 +1203,11 @@ bool NWindow::remove_child_window(NWindow* child)
12011203
12021204NWindow* NWindow::top_level_window ()
12031205{
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_ ;
12101207}
12111208const NWindow* NWindow::top_level_window () const
12121209{
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_ ;
12191211}
12201212
12211213
@@ -1286,6 +1278,8 @@ void NWindow::init_root_window()
12861278 {
12871279 throw std::runtime_error (" A root window already exists. Create a child window instead, by supplying a parent window argument to NWindow::create." );
12881280 }
1281+ this ->top_level_window_ = this ;
1282+
12891283 std::string old_locale = ::setlocale (LC_ALL, " " );
12901284 std::string locale = ::setlocale (LC_ALL, nullptr );
12911285
@@ -4573,7 +4567,7 @@ static bool use_raspberry_pi_fallback() {
45734567 {
45744568 g_checked_raspberry_pi = true ;
45754569
4576- // Are we running in raspi lxterminal?
4570+ // Are we running in Raspberry Pi lxterminal?
45774571 // GIO_LAUNCHED_DESKTOP_FILE=/usr/share/raspi-ui-overrides/applications/lxterminal.desktop
45784572 const char * term = std::getenv (" GIO_LAUNCHED_DESKTOP_FILE" );
45794573 g_use_raspberry_pi_fallback = false ;
@@ -6313,8 +6307,33 @@ void NWindow::handle_is_active_changed(bool activated)
63136307}
63146308
63156309
6316-
63176310bool 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
63186337{
63196338 // Figure out whether wcwidth() works on Windows for emoji (and other extended unicode characters)
63206339 // or figure out an alternative.
0 commit comments