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

Side by Side Diff: views/window/native_window_win.cc

Issue 6976040: Revert 86914 - Move a bunch of functions from Window onto Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « views/window/native_window_win.h ('k') | views/window/window.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/window/native_window_win.h" 5 #include "views/window/native_window_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 } 1168 }
1169 } 1169 }
1170 } 1170 }
1171 1171
1172 void NativeWindowWin::SetWindowBounds(const gfx::Rect& bounds, 1172 void NativeWindowWin::SetWindowBounds(const gfx::Rect& bounds,
1173 gfx::NativeWindow other_window) { 1173 gfx::NativeWindow other_window) {
1174 SetChildBounds(GetNativeView(), GetParent(), other_window, bounds, 1174 SetChildBounds(GetNativeView(), GetParent(), other_window, bounds,
1175 kMonitorEdgePadding, 0); 1175 kMonitorEdgePadding, 0);
1176 } 1176 }
1177 1177
1178 void NativeWindowWin::HideWindow() {
1179 // We can just call the function implemented by the widget.
1180 Hide();
1181 }
1182
1183 void NativeWindowWin::Activate() {
1184 if (IsMinimized())
1185 ::ShowWindow(GetNativeView(), SW_RESTORE);
1186 ::SetWindowPos(GetNativeView(), HWND_TOP, 0, 0, 0, 0,
1187 SWP_NOSIZE | SWP_NOMOVE);
1188 SetForegroundWindow(GetNativeView());
1189 }
1190
1191 void NativeWindowWin::Deactivate() {
1192 HWND hwnd = ::GetNextWindow(GetNativeView(), GW_HWNDNEXT);
1193 if (hwnd)
1194 ::SetForegroundWindow(hwnd);
1195 }
1196
1197 void NativeWindowWin::Maximize() {
1198 ExecuteSystemMenuCommand(SC_MAXIMIZE);
1199 }
1200
1201 void NativeWindowWin::Minimize() {
1202 ExecuteSystemMenuCommand(SC_MINIMIZE);
1203 }
1204
1205 void NativeWindowWin::Restore() {
1206 ExecuteSystemMenuCommand(SC_RESTORE);
1207 }
1208
1209 bool NativeWindowWin::IsActive() const {
1210 return is_active_;
1211 }
1212
1213 bool NativeWindowWin::IsVisible() const {
1214 return !!::IsWindowVisible(GetNativeView());
1215 }
1216
1217 bool NativeWindowWin::IsMaximized() const {
1218 return !!::IsZoomed(GetNativeView());
1219 }
1220
1221 bool NativeWindowWin::IsMinimized() const {
1222 return !!::IsIconic(GetNativeView());
1223 }
1224
1178 void NativeWindowWin::SetFullscreen(bool fullscreen) { 1225 void NativeWindowWin::SetFullscreen(bool fullscreen) {
1179 if (fullscreen_ == fullscreen) 1226 if (fullscreen_ == fullscreen)
1180 return; // Nothing to do. 1227 return; // Nothing to do.
1181 1228
1182 // Reduce jankiness during the following position changes by hiding the window 1229 // Reduce jankiness during the following position changes by hiding the window
1183 // until it's in the final position. 1230 // until it's in the final position.
1184 PushForceHidden(); 1231 PushForceHidden();
1185 1232
1186 // Size/position/style window appropriately. 1233 // Size/position/style window appropriately.
1187 if (!fullscreen_) { 1234 if (!fullscreen_) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 } 1276 }
1230 1277
1231 // Undo our anti-jankiness hacks. 1278 // Undo our anti-jankiness hacks.
1232 PopForceHidden(); 1279 PopForceHidden();
1233 } 1280 }
1234 1281
1235 bool NativeWindowWin::IsFullscreen() const { 1282 bool NativeWindowWin::IsFullscreen() const {
1236 return fullscreen_; 1283 return fullscreen_;
1237 } 1284 }
1238 1285
1286 void NativeWindowWin::SetAlwaysOnTop(bool always_on_top) {
1287 ::SetWindowPos(GetNativeView(), always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST,
1288 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
1289 }
1290
1239 void NativeWindowWin::SetUseDragFrame(bool use_drag_frame) { 1291 void NativeWindowWin::SetUseDragFrame(bool use_drag_frame) {
1240 if (use_drag_frame) { 1292 if (use_drag_frame) {
1241 // Make the frame slightly transparent during the drag operation. 1293 // Make the frame slightly transparent during the drag operation.
1242 drag_frame_saved_window_style_ = GetWindowLong(GWL_STYLE); 1294 drag_frame_saved_window_style_ = GetWindowLong(GWL_STYLE);
1243 drag_frame_saved_window_ex_style_ = GetWindowLong(GWL_EXSTYLE); 1295 drag_frame_saved_window_ex_style_ = GetWindowLong(GWL_EXSTYLE);
1244 SetWindowLong(GWL_EXSTYLE, 1296 SetWindowLong(GWL_EXSTYLE,
1245 drag_frame_saved_window_ex_style_ | WS_EX_LAYERED); 1297 drag_frame_saved_window_ex_style_ | WS_EX_LAYERED);
1246 // Remove the captions tyle so the window doesn't have window controls for a 1298 // Remove the captions tyle so the window doesn't have window controls for a
1247 // more "transparent" look. 1299 // more "transparent" look.
1248 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION); 1300 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION);
1249 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF), 1301 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF),
1250 kDragFrameWindowAlpha, LWA_ALPHA); 1302 kDragFrameWindowAlpha, LWA_ALPHA);
1251 } else { 1303 } else {
1252 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_); 1304 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_);
1253 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_); 1305 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_);
1254 } 1306 }
1255 } 1307 }
1256 1308
1257 NonClientFrameView* NativeWindowWin::CreateFrameViewForWindow() { 1309 NonClientFrameView* NativeWindowWin::CreateFrameViewForWindow() {
1258 return GetWindow()->ShouldUseNativeFrame() ? 1310 return GetWindow()->ShouldUseNativeFrame() ?
1259 new NativeFrameView(GetWindow()) : NULL; 1311 new NativeFrameView(GetWindow()) : NULL;
1260 } 1312 }
1261 1313
1262 void NativeWindowWin::UpdateFrameAfterFrameChange() { 1314 void NativeWindowWin::UpdateFrameAfterFrameChange() {
1263 // We've either gained or lost a custom window region, so reset it now. 1315 // We've either gained or lost a custom window region, so reset it now.
1264 ResetWindowRegion(true); 1316 ResetWindowRegion(true);
1265 } 1317 }
1266 1318
1319 gfx::NativeWindow NativeWindowWin::GetNativeWindow() const {
1320 return GetNativeView();
1321 }
1322
1267 bool NativeWindowWin::ShouldUseNativeFrame() const { 1323 bool NativeWindowWin::ShouldUseNativeFrame() const {
1268 return NativeWidgetWin::IsAeroGlassEnabled(); 1324 return NativeWidgetWin::IsAeroGlassEnabled();
1269 } 1325 }
1270 1326
1271 void NativeWindowWin::FrameTypeChanged() { 1327 void NativeWindowWin::FrameTypeChanged() {
1272 // Called when the frame type could possibly be changing (theme change or 1328 // Called when the frame type could possibly be changing (theme change or
1273 // DWM composition change). 1329 // DWM composition change).
1274 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { 1330 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
1275 // We need to toggle the rendering policy of the DWM/glass frame as we 1331 // We need to toggle the rendering policy of the DWM/glass frame as we
1276 // change from opaque to glass. "Non client rendering enabled" means that 1332 // change from opaque to glass. "Non client rendering enabled" means that
(...skipping 14 matching lines...) Expand all
1291 // type. 1347 // type.
1292 GetWindow()->non_client_view()->UpdateFrame(); 1348 GetWindow()->non_client_view()->UpdateFrame();
1293 1349
1294 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want 1350 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
1295 // to notify our children too, since we can have MDI child windows who need to 1351 // to notify our children too, since we can have MDI child windows who need to
1296 // update their appearance. 1352 // update their appearance.
1297 EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL); 1353 EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL);
1298 } 1354 }
1299 1355
1300 //////////////////////////////////////////////////////////////////////////////// 1356 ////////////////////////////////////////////////////////////////////////////////
1301 // NativeWindowWin, NativeWidgetWin overrides:
1302
1303 bool NativeWindowWin::IsActive() const {
1304 // TODO(beng): evaluate whether or not this is needed. NativeWidgetWin checks
1305 // active-state with the OS using GetWindowInfo().
1306 return is_active_;
1307 }
1308
1309 ////////////////////////////////////////////////////////////////////////////////
1310 // NativeWindowWin, private: 1357 // NativeWindowWin, private:
1311 1358
1312 void NativeWindowWin::RestoreEnabledIfNecessary() { 1359 void NativeWindowWin::RestoreEnabledIfNecessary() {
1313 if (delegate_->IsModal() && !restored_enabled_) { 1360 if (delegate_->IsModal() && !restored_enabled_) {
1314 restored_enabled_ = true; 1361 restored_enabled_ = true;
1315 // If we were run modally, we need to undo the disabled-ness we inflicted on 1362 // If we were run modally, we need to undo the disabled-ness we inflicted on
1316 // the owner's parent hierarchy. 1363 // the owner's parent hierarchy.
1317 HWND start = GetOwner(GetNativeView()); 1364 HWND start = GetOwner(GetNativeView());
1318 while (start) { 1365 while (start) {
1319 ::EnableWindow(start, TRUE); 1366 ::EnableWindow(start, TRUE);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 } 1449 }
1403 1450
1404 LRESULT NativeWindowWin::CallDefaultNCActivateHandler(BOOL active) { 1451 LRESULT NativeWindowWin::CallDefaultNCActivateHandler(BOOL active) {
1405 // The DefWindowProc handling for WM_NCACTIVATE renders the classic-look 1452 // The DefWindowProc handling for WM_NCACTIVATE renders the classic-look
1406 // window title bar directly, so we need to use a redraw lock here to prevent 1453 // window title bar directly, so we need to use a redraw lock here to prevent
1407 // it from doing so. 1454 // it from doing so.
1408 ScopedRedrawLock lock(this); 1455 ScopedRedrawLock lock(this);
1409 return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0); 1456 return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0);
1410 } 1457 }
1411 1458
1459 void NativeWindowWin::ExecuteSystemMenuCommand(int command) {
1460 if (command)
1461 SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0);
1462 }
1463
1412 //////////////////////////////////////////////////////////////////////////////// 1464 ////////////////////////////////////////////////////////////////////////////////
1413 // NativeWindow, public: 1465 // NativeWindow, public:
1414 1466
1415 // static 1467 // static
1416 NativeWindow* NativeWindow::CreateNativeWindow( 1468 NativeWindow* NativeWindow::CreateNativeWindow(
1417 internal::NativeWindowDelegate* delegate) { 1469 internal::NativeWindowDelegate* delegate) {
1418 return new NativeWindowWin(delegate); 1470 return new NativeWindowWin(delegate);
1419 } 1471 }
1420 1472
1421 } // namespace views 1473 } // namespace views
OLDNEW
« no previous file with comments | « views/window/native_window_win.h ('k') | views/window/window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698