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

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

Issue 7075019: 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
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
1225 void NativeWindowWin::SetFullscreen(bool fullscreen) { 1178 void NativeWindowWin::SetFullscreen(bool fullscreen) {
1226 if (fullscreen_ == fullscreen) 1179 if (fullscreen_ == fullscreen)
1227 return; // Nothing to do. 1180 return; // Nothing to do.
1228 1181
1229 // Reduce jankiness during the following position changes by hiding the window 1182 // Reduce jankiness during the following position changes by hiding the window
1230 // until it's in the final position. 1183 // until it's in the final position.
1231 PushForceHidden(); 1184 PushForceHidden();
1232 1185
1233 // Size/position/style window appropriately. 1186 // Size/position/style window appropriately.
1234 if (!fullscreen_) { 1187 if (!fullscreen_) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 } 1229 }
1277 1230
1278 // Undo our anti-jankiness hacks. 1231 // Undo our anti-jankiness hacks.
1279 PopForceHidden(); 1232 PopForceHidden();
1280 } 1233 }
1281 1234
1282 bool NativeWindowWin::IsFullscreen() const { 1235 bool NativeWindowWin::IsFullscreen() const {
1283 return fullscreen_; 1236 return fullscreen_;
1284 } 1237 }
1285 1238
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
1291 void NativeWindowWin::SetUseDragFrame(bool use_drag_frame) { 1239 void NativeWindowWin::SetUseDragFrame(bool use_drag_frame) {
1292 if (use_drag_frame) { 1240 if (use_drag_frame) {
1293 // Make the frame slightly transparent during the drag operation. 1241 // Make the frame slightly transparent during the drag operation.
1294 drag_frame_saved_window_style_ = GetWindowLong(GWL_STYLE); 1242 drag_frame_saved_window_style_ = GetWindowLong(GWL_STYLE);
1295 drag_frame_saved_window_ex_style_ = GetWindowLong(GWL_EXSTYLE); 1243 drag_frame_saved_window_ex_style_ = GetWindowLong(GWL_EXSTYLE);
1296 SetWindowLong(GWL_EXSTYLE, 1244 SetWindowLong(GWL_EXSTYLE,
1297 drag_frame_saved_window_ex_style_ | WS_EX_LAYERED); 1245 drag_frame_saved_window_ex_style_ | WS_EX_LAYERED);
1298 // Remove the captions tyle so the window doesn't have window controls for a 1246 // Remove the captions tyle so the window doesn't have window controls for a
1299 // more "transparent" look. 1247 // more "transparent" look.
1300 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION); 1248 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 // type. 1295 // type.
1348 GetWindow()->non_client_view()->UpdateFrame(); 1296 GetWindow()->non_client_view()->UpdateFrame();
1349 1297
1350 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want 1298 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
1351 // to notify our children too, since we can have MDI child windows who need to 1299 // to notify our children too, since we can have MDI child windows who need to
1352 // update their appearance. 1300 // update their appearance.
1353 EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL); 1301 EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL);
1354 } 1302 }
1355 1303
1356 //////////////////////////////////////////////////////////////////////////////// 1304 ////////////////////////////////////////////////////////////////////////////////
1305 // NativeWindowWin, NativeWidgetWin overrides:
1306
1307 bool NativeWindowWin::IsActive() const {
1308 // TODO(beng): evaluate whether or not this is needed. NativeWidgetWin checks
1309 // active-state with the OS using GetWindowInfo().
1310 return is_active_;
1311 }
1312
1313 ////////////////////////////////////////////////////////////////////////////////
1357 // NativeWindowWin, private: 1314 // NativeWindowWin, private:
1358 1315
1359 void NativeWindowWin::RestoreEnabledIfNecessary() { 1316 void NativeWindowWin::RestoreEnabledIfNecessary() {
1360 if (delegate_->IsModal() && !restored_enabled_) { 1317 if (delegate_->IsModal() && !restored_enabled_) {
1361 restored_enabled_ = true; 1318 restored_enabled_ = true;
1362 // If we were run modally, we need to undo the disabled-ness we inflicted on 1319 // If we were run modally, we need to undo the disabled-ness we inflicted on
1363 // the owner's parent hierarchy. 1320 // the owner's parent hierarchy.
1364 HWND start = GetOwner(GetNativeView()); 1321 HWND start = GetOwner(GetNativeView());
1365 while (start) { 1322 while (start) {
1366 ::EnableWindow(start, TRUE); 1323 ::EnableWindow(start, TRUE);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 } 1406 }
1450 1407
1451 LRESULT NativeWindowWin::CallDefaultNCActivateHandler(BOOL active) { 1408 LRESULT NativeWindowWin::CallDefaultNCActivateHandler(BOOL active) {
1452 // The DefWindowProc handling for WM_NCACTIVATE renders the classic-look 1409 // The DefWindowProc handling for WM_NCACTIVATE renders the classic-look
1453 // window title bar directly, so we need to use a redraw lock here to prevent 1410 // window title bar directly, so we need to use a redraw lock here to prevent
1454 // it from doing so. 1411 // it from doing so.
1455 ScopedRedrawLock lock(this); 1412 ScopedRedrawLock lock(this);
1456 return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0); 1413 return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0);
1457 } 1414 }
1458 1415
1459 void NativeWindowWin::ExecuteSystemMenuCommand(int command) {
1460 if (command)
1461 SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0);
1462 }
1463
1464 //////////////////////////////////////////////////////////////////////////////// 1416 ////////////////////////////////////////////////////////////////////////////////
1465 // NativeWindow, public: 1417 // NativeWindow, public:
1466 1418
1467 // static 1419 // static
1468 NativeWindow* NativeWindow::CreateNativeWindow( 1420 NativeWindow* NativeWindow::CreateNativeWindow(
1469 internal::NativeWindowDelegate* delegate) { 1421 internal::NativeWindowDelegate* delegate) {
1470 return new NativeWindowWin(delegate); 1422 return new NativeWindowWin(delegate);
1471 } 1423 }
1472 1424
1473 } // namespace views 1425 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698