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

Side by Side Diff: chrome/common/win_util.cc

Issue 13100: Fixes bug in window positioning that resulted in positioning... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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 | « no previous file | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/common/win_util.h" 5 #include "chrome/common/win_util.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlapp.h> 8 #include <atlapp.h>
9 #include <commdlg.h> 9 #include <commdlg.h>
10 #include <dwmapi.h> 10 #include <dwmapi.h>
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // the containing parent. 577 // the containing parent.
578 if (child_rect->width() > (parent_rect.width() + twice_padding)) 578 if (child_rect->width() > (parent_rect.width() + twice_padding))
579 child_rect->set_width(std::max(0, parent_rect.width() - twice_padding)); 579 child_rect->set_width(std::max(0, parent_rect.width() - twice_padding));
580 if (child_rect->height() > parent_rect.height() + twice_padding) 580 if (child_rect->height() > parent_rect.height() + twice_padding)
581 child_rect->set_height(std::max(0, parent_rect.height() - twice_padding)); 581 child_rect->set_height(std::max(0, parent_rect.height() - twice_padding));
582 582
583 // SECOND, clamp x,y position to padding,padding so we don't position child 583 // SECOND, clamp x,y position to padding,padding so we don't position child
584 // windows in hyperspace. 584 // windows in hyperspace.
585 // TODO(mpcomplete): I don't see what the second check in each 'if' does that 585 // TODO(mpcomplete): I don't see what the second check in each 'if' does that
586 // isn't handled by the LAST set of 'ifs'. Maybe we can remove it. 586 // isn't handled by the LAST set of 'ifs'. Maybe we can remove it.
587 if (child_rect->x() < 0 || child_rect->x() > parent_rect.right()) 587 if (child_rect->x() < parent_rect.x() ||
588 child_rect->set_x(padding); 588 child_rect->x() > parent_rect.right()) {
589 if (child_rect->y() < 0 || child_rect->y() > parent_rect.bottom()) 589 child_rect->set_x(parent_rect.x() + padding);
590 child_rect->set_y(padding); 590 }
591 if (child_rect->y() < parent_rect.y() ||
592 child_rect->y() > parent_rect.bottom()) {
593 child_rect->set_y(parent_rect.y() + padding);
594 }
591 595
592 // LAST, nudge the window back up into the client area if its x,y position is 596 // LAST, nudge the window back up into the client area if its x,y position is
593 // within the parent bounds but its width/height place it off-screen. 597 // within the parent bounds but its width/height place it off-screen.
594 if (child_rect->bottom() > parent_rect.bottom()) 598 if (child_rect->bottom() > parent_rect.bottom())
595 child_rect->set_y(parent_rect.bottom() - child_rect->height() - padding); 599 child_rect->set_y(parent_rect.bottom() - child_rect->height() - padding);
596 if (child_rect->right() > parent_rect.right()) 600 if (child_rect->right() > parent_rect.right())
597 child_rect->set_x(parent_rect.right() - child_rect->width() - padding); 601 child_rect->set_x(parent_rect.right() - child_rect->width() - padding);
598 } 602 }
599 603
600 void SetChildBounds(HWND child_window, HWND parent_window, 604 void SetChildBounds(HWND child_window, HWND parent_window,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 818
815 ChromeFont GetWindowTitleFont() { 819 ChromeFont GetWindowTitleFont() {
816 NONCLIENTMETRICS ncm; 820 NONCLIENTMETRICS ncm;
817 win_util::GetNonClientMetrics(&ncm); 821 win_util::GetNonClientMetrics(&ncm);
818 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); 822 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
819 return ChromeFont::CreateFont(caption_font); 823 return ChromeFont::CreateFont(caption_font);
820 } 824 }
821 825
822 } // namespace win_util 826 } // namespace win_util
823 827
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698