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 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1185 native_window_frame_borders_ = gfx::Insets( | 1185 native_window_frame_borders_ = gfx::Insets( |
1186 insets[2], | 1186 insets[2], |
1187 insets[0], | 1187 insets[0], |
1188 insets[3], | 1188 insets[3], |
1189 insets[1]); | 1189 insets[1]); |
1190 } else { | 1190 } else { |
1191 native_window_frame_borders_ = gfx::Insets(); | 1191 native_window_frame_borders_ = gfx::Insets(); |
1192 } | 1192 } |
1193 } | 1193 } |
1194 | 1194 |
1195 void DesktopWindowTreeHostX11::UpdateWMUserTime( | |
1196 const ui::PlatformEvent& event) { | |
1197 if (!IsActive()) | |
1198 return; | |
1199 | |
1200 ui::EventType type = ui::EventTypeFromNative(event); | |
1201 if (type == ui::ET_MOUSE_PRESSED || | |
1202 type == ui::ET_KEY_PRESSED || | |
1203 type == ui::ET_TOUCH_PRESSED) { | |
Elliot Glaysher
2014/06/05 20:46:33
I'm pretty sure you want the released versions of
| |
1204 unsigned long wm_user_time_ms = static_cast<unsigned long>( | |
1205 ui::EventTimeFromNative(event).InMilliseconds()); | |
1206 XChangeProperty(xdisplay_, | |
1207 xwindow_, | |
1208 atom_cache_.GetAtom("_NET_WM_USER_TIME"), | |
1209 XA_CARDINAL, | |
1210 32, | |
1211 PropModeReplace, | |
1212 reinterpret_cast<const unsigned char *>(&wm_user_time_ms), | |
1213 1); | |
1214 X11DesktopHandler::get()->set_wm_user_time_ms(wm_user_time_ms); | |
1215 } | |
1216 } | |
1217 | |
1195 void DesktopWindowTreeHostX11::SetWMSpecState(bool enabled, | 1218 void DesktopWindowTreeHostX11::SetWMSpecState(bool enabled, |
1196 ::Atom state1, | 1219 ::Atom state1, |
1197 ::Atom state2) { | 1220 ::Atom state2) { |
1198 XEvent xclient; | 1221 XEvent xclient; |
1199 memset(&xclient, 0, sizeof(xclient)); | 1222 memset(&xclient, 0, sizeof(xclient)); |
1200 xclient.type = ClientMessage; | 1223 xclient.type = ClientMessage; |
1201 xclient.xclient.window = xwindow_; | 1224 xclient.xclient.window = xwindow_; |
1202 xclient.xclient.message_type = atom_cache_.GetAtom("_NET_WM_STATE"); | 1225 xclient.xclient.message_type = atom_cache_.GetAtom("_NET_WM_STATE"); |
1203 xclient.xclient.format = 32; | 1226 xclient.xclient.format = 32; |
1204 xclient.xclient.data.l[0] = | 1227 xclient.xclient.data.l[0] = |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1398 // will ignore toplevel XMoveWindow commands. | 1421 // will ignore toplevel XMoveWindow commands. |
1399 XSizeHints size_hints; | 1422 XSizeHints size_hints; |
1400 size_hints.flags = PPosition; | 1423 size_hints.flags = PPosition; |
1401 size_hints.x = bounds_.x(); | 1424 size_hints.x = bounds_.x(); |
1402 size_hints.y = bounds_.y(); | 1425 size_hints.y = bounds_.y(); |
1403 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); | 1426 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); |
1404 | 1427 |
1405 // If SHOW_STATE_INACTIVE, tell the window manager not to focus the window | 1428 // If SHOW_STATE_INACTIVE, tell the window manager not to focus the window |
1406 // when mapping. This is done by setting the _NET_WM_USER_TIME to 0. See e.g. | 1429 // when mapping. This is done by setting the _NET_WM_USER_TIME to 0. See e.g. |
1407 // http://standards.freedesktop.org/wm-spec/latest/ar01s05.html | 1430 // http://standards.freedesktop.org/wm-spec/latest/ar01s05.html |
1408 if (show_state == ui::SHOW_STATE_INACTIVE) { | 1431 unsigned long wm_user_time_ms = (show_state == ui::SHOW_STATE_INACTIVE) ? |
1409 unsigned long value = 0; | 1432 0 : X11DesktopHandler::get()->wm_user_time_ms(); |
1433 if (show_state == ui::SHOW_STATE_INACTIVE || wm_user_time_ms != 0) { | |
1410 XChangeProperty(xdisplay_, | 1434 XChangeProperty(xdisplay_, |
1411 xwindow_, | 1435 xwindow_, |
1412 atom_cache_.GetAtom("_NET_WM_USER_TIME"), | 1436 atom_cache_.GetAtom("_NET_WM_USER_TIME"), |
1413 XA_CARDINAL, | 1437 XA_CARDINAL, |
1414 32, | 1438 32, |
1415 PropModeReplace, | 1439 PropModeReplace, |
1416 reinterpret_cast<const unsigned char *>(&value), | 1440 reinterpret_cast<const unsigned char *>(&wm_user_time_ms), |
1417 1); | 1441 1); |
1418 } else { | |
1419 // TODO(piman): if this window was created in response to an X event, we | |
1420 // should set the time to the server time of the event that caused this. | |
1421 // https://crbug.com/355667 | |
1422 XDeleteProperty( | |
1423 xdisplay_, xwindow_, atom_cache_.GetAtom("_NET_WM_USER_TIME")); | |
1424 } | 1442 } |
1425 | 1443 |
1426 XMapWindow(xdisplay_, xwindow_); | 1444 XMapWindow(xdisplay_, xwindow_); |
1427 | 1445 |
1428 // We now block until our window is mapped. Some X11 APIs will crash and | 1446 // We now block until our window is mapped. Some X11 APIs will crash and |
1429 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is | 1447 // burn if passed |xwindow_| before the window is mapped, and XMapWindow is |
1430 // asynchronous. | 1448 // asynchronous. |
1431 if (ui::X11EventSource::GetInstance()) | 1449 if (ui::X11EventSource::GetInstance()) |
1432 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(xwindow_); | 1450 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(xwindow_); |
1433 window_mapped_ = true; | 1451 window_mapped_ = true; |
(...skipping 15 matching lines...) Expand all Loading... | |
1449 static_cast<XIDeviceEvent*>(event->xcookie.data)->event == xwindow_); | 1467 static_cast<XIDeviceEvent*>(event->xcookie.data)->event == xwindow_); |
1450 } | 1468 } |
1451 | 1469 |
1452 uint32_t DesktopWindowTreeHostX11::DispatchEvent( | 1470 uint32_t DesktopWindowTreeHostX11::DispatchEvent( |
1453 const ui::PlatformEvent& event) { | 1471 const ui::PlatformEvent& event) { |
1454 XEvent* xev = event; | 1472 XEvent* xev = event; |
1455 | 1473 |
1456 TRACE_EVENT1("views", "DesktopWindowTreeHostX11::Dispatch", | 1474 TRACE_EVENT1("views", "DesktopWindowTreeHostX11::Dispatch", |
1457 "event->type", event->type); | 1475 "event->type", event->type); |
1458 | 1476 |
1477 UpdateWMUserTime(event); | |
1478 | |
1459 // May want to factor CheckXEventForConsistency(xev); into a common location | 1479 // May want to factor CheckXEventForConsistency(xev); into a common location |
1460 // since it is called here. | 1480 // since it is called here. |
1461 switch (xev->type) { | 1481 switch (xev->type) { |
1462 case EnterNotify: | 1482 case EnterNotify: |
1463 case LeaveNotify: { | 1483 case LeaveNotify: { |
1464 ui::MouseEvent mouse_event(xev); | 1484 ui::MouseEvent mouse_event(xev); |
1465 DispatchMouseEvent(&mouse_event); | 1485 DispatchMouseEvent(&mouse_event); |
1466 break; | 1486 break; |
1467 } | 1487 } |
1468 case Expose: { | 1488 case Expose: { |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1718 if (linux_ui) { | 1738 if (linux_ui) { |
1719 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); | 1739 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(window); |
1720 if (native_theme) | 1740 if (native_theme) |
1721 return native_theme; | 1741 return native_theme; |
1722 } | 1742 } |
1723 | 1743 |
1724 return ui::NativeTheme::instance(); | 1744 return ui::NativeTheme::instance(); |
1725 } | 1745 } |
1726 | 1746 |
1727 } // namespace views | 1747 } // namespace views |
OLD | NEW |