"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/cpp/iedriver/CommandHandlers/MaximizeWindowCommandHandler.cpp" (17 Feb 2023, 2086 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "MaximizeWindowCommandHandler.cpp" see the Fossies "Dox" file reference documentation.

    1 // Licensed to the Software Freedom Conservancy (SFC) under one
    2 // or more contributor license agreements. See the NOTICE file
    3 // distributed with this work for additional information
    4 // regarding copyright ownership. The SFC licenses this file
    5 // to you under the Apache License, Version 2.0 (the "License");
    6 // you may not use this file except in compliance with the License.
    7 // You may obtain a copy of the License at
    8 //
    9 //     http://www.apache.org/licenses/LICENSE-2.0
   10 //
   11 // Unless required by applicable law or agreed to in writing, software
   12 // distributed under the License is distributed on an "AS IS" BASIS,
   13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14 // See the License for the specific language governing permissions and
   15 // limitations under the License.
   16 
   17 #include "MaximizeWindowCommandHandler.h"
   18 #include "errorcodes.h"
   19 #include "../Browser.h"
   20 #include "../IECommandExecutor.h"
   21 
   22 namespace webdriver {
   23 
   24 MaximizeWindowCommandHandler::MaximizeWindowCommandHandler(void) {
   25 }
   26 
   27 MaximizeWindowCommandHandler::~MaximizeWindowCommandHandler(void) {
   28 }
   29 
   30 void MaximizeWindowCommandHandler::ExecuteInternal(
   31     const IECommandExecutor& executor,
   32     const ParametersMap& command_parameters,
   33     Response* response) {
   34   int status_code = WD_SUCCESS;
   35 
   36   BrowserHandle browser_wrapper;
   37   status_code = executor.GetCurrentBrowser(&browser_wrapper);
   38   if (status_code != WD_SUCCESS) {
   39     response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Error retrieving window");
   40     return;
   41   }
   42 
   43   HWND window_handle = browser_wrapper->GetTopLevelWindowHandle();
   44   if (!::IsZoomed(window_handle)) {
   45     browser_wrapper->Restore();
   46     ::ShowWindow(window_handle, SW_MAXIMIZE);
   47   }
   48   RECT window_rect;
   49   ::GetWindowRect(window_handle, &window_rect);
   50   Json::Value response_value;
   51   response_value["width"] = window_rect.right - window_rect.left;
   52   response_value["height"] = window_rect.bottom - window_rect.top;
   53   response_value["x"] = window_rect.left;
   54   response_value["y"] = window_rect.top;
   55   response->SetSuccessResponse(response_value);
   56 }
   57 
   58 } // namespace webdriver