Home | History | Annotate | Download | only in win
      1 /*
      2  *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h"
     12 
     13 namespace webrtc {
     14 
     15 bool
     16 GetCroppedWindowRect(HWND window,
     17                      DesktopRect* cropped_rect,
     18                      DesktopRect* original_rect) {
     19   RECT rect;
     20   if (!GetWindowRect(window, &rect)) {
     21     return false;
     22   }
     23   WINDOWPLACEMENT window_placement;
     24   window_placement.length = sizeof(window_placement);
     25   if (!GetWindowPlacement(window, &window_placement)) {
     26     return false;
     27   }
     28 
     29   *original_rect = DesktopRect::MakeLTRB(
     30       rect.left, rect.top, rect.right, rect.bottom);
     31 
     32   if (window_placement.showCmd & SW_SHOWMAXIMIZED) {
     33     DesktopSize border = DesktopSize(GetSystemMetrics(SM_CXSIZEFRAME),
     34                                      GetSystemMetrics(SM_CYSIZEFRAME));
     35     *cropped_rect = DesktopRect::MakeLTRB(
     36         rect.left + border.width(),
     37         rect.top,
     38         rect.right - border.width(),
     39         rect.bottom - border.height());
     40   } else {
     41     *cropped_rect = *original_rect;
     42   }
     43   return true;
     44 }
     45 
     46 }  // namespace webrtc
     47