OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
6 | 6 |
7 #include <X11/extensions/shape.h> | 7 #include <X11/extensions/shape.h> |
8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
10 #include <X11/Xregion.h> | 10 #include <X11/Xregion.h> |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 window_title_ = title; | 567 window_title_ = title; |
568 std::string utf8str = base::UTF16ToUTF8(title); | 568 std::string utf8str = base::UTF16ToUTF8(title); |
569 XChangeProperty(xdisplay_, | 569 XChangeProperty(xdisplay_, |
570 xwindow_, | 570 xwindow_, |
571 atom_cache_.GetAtom("_NET_WM_NAME"), | 571 atom_cache_.GetAtom("_NET_WM_NAME"), |
572 atom_cache_.GetAtom("UTF8_STRING"), | 572 atom_cache_.GetAtom("UTF8_STRING"), |
573 8, | 573 8, |
574 PropModeReplace, | 574 PropModeReplace, |
575 reinterpret_cast<const unsigned char*>(utf8str.c_str()), | 575 reinterpret_cast<const unsigned char*>(utf8str.c_str()), |
576 utf8str.size()); | 576 utf8str.size()); |
577 // TODO(erg): This is technically wrong. So XStoreName and friends expect | 577 XTextProperty xtp; |
578 // this in Host Portable Character Encoding instead of UTF-8, which I believe | 578 char *c_utf8_str = const_cast<char *>(utf8str.c_str()); |
579 // is Compound Text. This shouldn't matter 90% of the time since this is the | 579 const int err = |
580 // fallback to the UTF8 property above. | 580 Xutf8TextListToTextProperty(xdisplay_, &c_utf8_str, 1, |
581 XStoreName(xdisplay_, xwindow_, utf8str.c_str()); | 581 XCompoundTextStyle, &xtp); |
| 582 if (err != Success) { |
| 583 const std::string ascii_str = base::UTF16ToASCII(title); |
| 584 xtp.encoding = XA_STRING; |
| 585 xtp.format = 8; |
| 586 xtp.value = reinterpret_cast<unsigned char *> |
| 587 (const_cast<char *>(ascii_str.c_str())); |
| 588 xtp.nitems = ascii_str.size(); |
| 589 XSetWMName(xdisplay_, xwindow_, &xtp); |
| 590 } else { |
| 591 XSetWMName(xdisplay_, xwindow_, &xtp); |
| 592 } |
582 return true; | 593 return true; |
583 } | 594 } |
584 | 595 |
585 void DesktopWindowTreeHostX11::ClearNativeFocus() { | 596 void DesktopWindowTreeHostX11::ClearNativeFocus() { |
586 // This method is weird and misnamed. Instead of clearing the native focus, | 597 // This method is weird and misnamed. Instead of clearing the native focus, |
587 // it sets the focus to our |content_window_|, which will trigger a cascade | 598 // it sets the focus to our |content_window_|, which will trigger a cascade |
588 // of focus changes into views. | 599 // of focus changes into views. |
589 if (content_window_ && aura::client::GetFocusClient(content_window_) && | 600 if (content_window_ && aura::client::GetFocusClient(content_window_) && |
590 content_window_->Contains( | 601 content_window_->Contains( |
591 aura::client::GetFocusClient(content_window_)->GetFocusedWindow())) { | 602 aura::client::GetFocusClient(content_window_)->GetFocusedWindow())) { |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 if (linux_ui) { | 1728 if (linux_ui) { |
1718 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1729 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
1719 if (native_theme) | 1730 if (native_theme) |
1720 return native_theme; | 1731 return native_theme; |
1721 } | 1732 } |
1722 | 1733 |
1723 return ui::NativeTheme::instance(); | 1734 return ui::NativeTheme::instance(); |
1724 } | 1735 } |
1725 | 1736 |
1726 } // namespace views | 1737 } // namespace views |
OLD | NEW |