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

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, 7 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
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);
1301 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF), 1249 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF),
1302 kDragFrameWindowAlpha, LWA_ALPHA); 1250 kDragFrameWindowAlpha, LWA_ALPHA);
1303 } else { 1251 } else {
1304 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_); 1252 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_);
1305 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_); 1253 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_);
1306 } 1254 }
1307 } 1255 }
1308 1256
1309 NonClientFrameView* NativeWindowWin::CreateFrameViewForWindow() { 1257 NonClientFrameView* NativeWindowWin::CreateFrameViewForWindow() {
1310 return GetWindow()->ShouldUseNativeFrame() ? 1258 return GetWindow()->ShouldUseNativeFrame() ?
1311 new NativeFrameView(GetWindow()) : NULL; 1259 new NativeFrameView(GetWindow()) : NULL;
1312 } 1260 }
1313 1261
1314 void NativeWindowWin::UpdateFrameAfterFrameChange() { 1262 void NativeWindowWin::UpdateFrameAfterFrameChange() {
1315 // We've either gained or lost a custom window region, so reset it now. 1263 // We've either gained or lost a custom window region, so reset it now.
1316 ResetWindowRegion(true); 1264 ResetWindowRegion(true);
1317 } 1265 }
1318 1266
1319 gfx::NativeWindow NativeWindowWin::GetNativeWindow() const {
1320 return GetNativeView();
1321 }
1322
1323 bool NativeWindowWin::ShouldUseNativeFrame() const { 1267 bool NativeWindowWin::ShouldUseNativeFrame() const {
1324 return NativeWidgetWin::IsAeroGlassEnabled(); 1268 return NativeWidgetWin::IsAeroGlassEnabled();
1325 } 1269 }
1326 1270
1327 void NativeWindowWin::FrameTypeChanged() { 1271 void NativeWindowWin::FrameTypeChanged() {
1328 // Called when the frame type could possibly be changing (theme change or 1272 // Called when the frame type could possibly be changing (theme change or
1329 // DWM composition change). 1273 // DWM composition change).
1330 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { 1274 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
1331 // We need to toggle the rendering policy of the DWM/glass frame as we 1275 // We need to toggle the rendering policy of the DWM/glass frame as we
1332 // change from opaque to glass. "Non client rendering enabled" means that 1276 // change from opaque to glass. "Non client rendering enabled" means that
(...skipping 14 matching lines...) Expand all
1347 // type. 1291 // type.
1348 GetWindow()->non_client_view()->UpdateFrame(); 1292 GetWindow()->non_client_view()->UpdateFrame();
1349 1293
1350 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want 1294 // 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 1295 // to notify our children too, since we can have MDI child windows who need to
1352 // update their appearance. 1296 // update their appearance.
1353 EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL); 1297 EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL);
1354 } 1298 }
1355 1299
1356 //////////////////////////////////////////////////////////////////////////////// 1300 ////////////////////////////////////////////////////////////////////////////////
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 ////////////////////////////////////////////////////////////////////////////////
1357 // NativeWindowWin, private: 1310 // NativeWindowWin, private:
1358 1311
1359 void NativeWindowWin::RestoreEnabledIfNecessary() { 1312 void NativeWindowWin::RestoreEnabledIfNecessary() {
1360 if (delegate_->IsModal() && !restored_enabled_) { 1313 if (delegate_->IsModal() && !restored_enabled_) {
1361 restored_enabled_ = true; 1314 restored_enabled_ = true;
1362 // If we were run modally, we need to undo the disabled-ness we inflicted on 1315 // If we were run modally, we need to undo the disabled-ness we inflicted on
1363 // the owner's parent hierarchy. 1316 // the owner's parent hierarchy.
1364 HWND start = GetOwner(GetNativeView()); 1317 HWND start = GetOwner(GetNativeView());
1365 while (start) { 1318 while (start) {
1366 ::EnableWindow(start, TRUE); 1319 ::EnableWindow(start, TRUE);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 } 1402 }
1450 1403
1451 LRESULT NativeWindowWin::CallDefaultNCActivateHandler(BOOL active) { 1404 LRESULT NativeWindowWin::CallDefaultNCActivateHandler(BOOL active) {
1452 // The DefWindowProc handling for WM_NCACTIVATE renders the classic-look 1405 // 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 1406 // window title bar directly, so we need to use a redraw lock here to prevent
1454 // it from doing so. 1407 // it from doing so.
1455 ScopedRedrawLock lock(this); 1408 ScopedRedrawLock lock(this);
1456 return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0); 1409 return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0);
1457 } 1410 }
1458 1411
1459 void NativeWindowWin::ExecuteSystemMenuCommand(int command) {
1460 if (command)
1461 SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0);
1462 }
1463
1464 //////////////////////////////////////////////////////////////////////////////// 1412 ////////////////////////////////////////////////////////////////////////////////
1465 // NativeWindow, public: 1413 // NativeWindow, public:
1466 1414
1467 // static 1415 // static
1468 NativeWindow* NativeWindow::CreateNativeWindow( 1416 NativeWindow* NativeWindow::CreateNativeWindow(
1469 internal::NativeWindowDelegate* delegate) { 1417 internal::NativeWindowDelegate* delegate) {
1470 return new NativeWindowWin(delegate); 1418 return new NativeWindowWin(delegate);
1471 } 1419 }
1472 1420
1473 } // namespace views 1421 } // 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