Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc

Issue 2598383002: Fix integer overflow. (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/widget/widget.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 } 1087 }
1088 1088
1089 bool DesktopWindowTreeHostX11::IsFullscreen() const { 1089 bool DesktopWindowTreeHostX11::IsFullscreen() const {
1090 return is_fullscreen_; 1090 return is_fullscreen_;
1091 } 1091 }
1092 1092
1093 void DesktopWindowTreeHostX11::SetOpacity(float opacity) { 1093 void DesktopWindowTreeHostX11::SetOpacity(float opacity) {
1094 // X server opacity is in terms of 32 bit unsigned int space, and counts from 1094 // X server opacity is in terms of 32 bit unsigned int space, and counts from
1095 // the opposite direction. 1095 // the opposite direction.
1096 // XChangeProperty() expects "cardinality" to be long. 1096 // XChangeProperty() expects "cardinality" to be long.
1097 unsigned long cardinality = static_cast<int>(opacity * 255) * 0x1010101; 1097
1098 // Scale opacity to [0 .. 255] range.
1099 unsigned long opacity_8bit =
1100 static_cast<unsigned long>(opacity * 255.0f) & 0xFF;
1101 // Use opacity value for all channels.
1102 const unsigned long channel_multiplier = 0x1010101;
1103 unsigned long cardinality = opacity_8bit * channel_multiplier;
1098 1104
1099 if (cardinality == 0xffffffff) { 1105 if (cardinality == 0xffffffff) {
1100 XDeleteProperty(xdisplay_, xwindow_, 1106 XDeleteProperty(xdisplay_, xwindow_,
1101 atom_cache_.GetAtom("_NET_WM_WINDOW_OPACITY")); 1107 atom_cache_.GetAtom("_NET_WM_WINDOW_OPACITY"));
1102 } else { 1108 } else {
1103 XChangeProperty(xdisplay_, xwindow_, 1109 XChangeProperty(xdisplay_, xwindow_,
1104 atom_cache_.GetAtom("_NET_WM_WINDOW_OPACITY"), 1110 atom_cache_.GetAtom("_NET_WM_WINDOW_OPACITY"),
1105 XA_CARDINAL, 32, 1111 XA_CARDINAL, 32,
1106 PropModeReplace, 1112 PropModeReplace,
1107 reinterpret_cast<unsigned char*>(&cardinality), 1); 1113 reinterpret_cast<unsigned char*>(&cardinality), 1);
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 2363
2358 // static 2364 // static
2359 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( 2365 DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
2360 internal::NativeWidgetDelegate* native_widget_delegate, 2366 internal::NativeWidgetDelegate* native_widget_delegate,
2361 DesktopNativeWidgetAura* desktop_native_widget_aura) { 2367 DesktopNativeWidgetAura* desktop_native_widget_aura) {
2362 return new DesktopWindowTreeHostX11(native_widget_delegate, 2368 return new DesktopWindowTreeHostX11(native_widget_delegate,
2363 desktop_native_widget_aura); 2369 desktop_native_widget_aura);
2364 } 2370 }
2365 2371
2366 } // namespace views 2372 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698