Alert::Alert(std::shared_ptr<DocumentHost> browser, HWND handle) { LOG(TRACE) << "Entering Alert::Alert"; this->browser_ = browser; this->alert_handle_ = handle; this->is_standard_alert_ = true; this->is_standard_control_alert_ = true; HWND direct_ui_child = this->GetDirectUIChild(); if (direct_ui_child) { this->is_standard_control_alert_ = false; DialogButtonInfo cancel_button_info = this->GetDialogButton(CANCEL); if (cancel_button_info.button_exists) { this->is_standard_alert_ = !IsLinkButton(cancel_button_info.button_handle); } else { this->is_standard_alert_ = false; } } std::vector<char> window_class(30); ::GetClassNameA(handle, &window_class[0], 30); if (strcmp(&window_class[0], SECURITY_DIALOG_WINDOW_CLASS) == 0) { this->is_standard_alert_ = false; this->is_standard_control_alert_ = false; this->is_security_alert_ = true; } else { std::vector<HWND> text_boxes; ::EnumChildWindows(this->alert_handle_, &Alert::FindTextBoxes, reinterpret_cast<LPARAM>(&text_boxes)); this->is_security_alert_ = text_boxes.size() > 1; } }
//____________________________________________________________________ Configuration Factory::configuration( const Client& client ) { QString window_title; QString class_name; for( ExceptionList::const_iterator iter = _exceptions.constBegin(); iter != _exceptions.constEnd(); ++iter ) { // discard disabled exceptions if( !iter->enabled() ) continue; /* decide which value is to be compared to the regular expression, based on exception type */ QString value; switch( iter->type() ) { case Exception::WindowTitle: { value = window_title.isEmpty() ? (window_title = client.caption()):window_title; break; } case Exception::WindowClassName: { if( class_name.isEmpty() ) { // retrieve class name KWindowInfo info( client.windowId(), 0, NET::WM2WindowClass ); QString window_class_name( info.windowClassName() ); QString window_class( info.windowClassClass() ); class_name = window_class_name + ' ' + window_class; } value = class_name; break; } default: assert( false ); } if( iter->regExp().indexIn( value ) < 0 ) continue; Configuration configuration( defaultConfiguration() ); configuration.readException( *iter ); configuration.setTransparencyEnabled( iter->transparencyEnabled() ); return configuration; } return defaultConfiguration(); }
//____________________________________________________________________ Factory::ConfigurationPtr Factory::configuration( const Client& client ) { QString windowTitle; QString className; foreach( const ConfigurationPtr& configuration, _exceptions ) { // discard disabled exceptions if( !configuration->enabled() ) continue; // discard exceptions with empty exception pattern if( configuration->exceptionPattern().isEmpty() ) continue; /* decide which value is to be compared to the regular expression, based on exception type */ QString value; switch( configuration->exceptionType() ) { case Configuration::ExceptionWindowTitle: { value = windowTitle.isEmpty() ? (windowTitle = client.caption()):windowTitle; break; } default: case Configuration::ExceptionWindowClassName: { if( className.isEmpty() ) { // retrieve class name KWindowInfo info( client.windowId(), 0, NET::WM2WindowClass ); QString window_className( QString::fromUtf8(info.windowClassName()) ); QString window_class( QString::fromUtf8(info.windowClassClass()) ); className = window_className + QStringLiteral(" ") + window_class; } value = className; break; } } // check matching if( QRegExp( configuration->exceptionPattern() ).indexIn( value ) >= 0 ) { return configuration; } } return _defaultConfiguration; }
BorderlessWindow::BorderlessWindow() : hwnd(CreateWindow(window_class().c_str(), L"Borderless Window", static_cast<DWORD>(Style::aero_borderless), 0, 0, 1280, 720, nullptr, nullptr, module_handle(), nullptr)) { if (!hwnd) throw std::runtime_error("failed to create window"); static_assert(sizeof(LONG_PTR) == sizeof(this), "sanity check on LONG_PTR size failed!"); // store pointer to this class instance in window's user data, so we may retrieve it in the Window Procedure SetWindowLongPtr(hwnd.get(), GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); set_borderless(borderless); set_borderless_shadow(borderless_shadow); show(); }