Ejemplo n.º 1
0
void
FrameworkView::UpdateLogicalDPI()
{
    ComPtr<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> dispProps;
    HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(),
                                      dispProps.GetAddressOf());
    AssertHRESULT(hr);
    FLOAT value;
    AssertHRESULT(dispProps->get_LogicalDpi(&value));
    SetDpi(value);
}
Ejemplo n.º 2
0
void
FrameworkView::SetCursor(CoreCursorType aCursorType, DWORD aCustomId)
{
    if (mShuttingDown) {
        return;
    }
    NS_ASSERTION(mWindow, "SetWindow must be called before SetCursor!");
    ComPtr<ABI::Windows::UI::Core::ICoreCursorFactory> factory;
    AssertHRESULT(GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreCursor).Get(), factory.GetAddressOf()));
    ComPtr<ABI::Windows::UI::Core::ICoreCursor> cursor;
    AssertHRESULT(factory->CreateCursor(aCursorType, aCustomId, cursor.GetAddressOf()));
    mWindow->put_PointerCursor(cursor.Get());
}
Ejemplo n.º 3
0
void
FrameworkView::AddEventHandlers() {
  NS_ASSERTION(mWindow, "SetWindow must be called before AddEventHandlers!");
  NS_ASSERTION(mWidget, "SetWidget must be called before AddEventHAndlers!");

  mMetroInput = Make<MetroInput>(mWidget.Get(),
                                 mWindow.Get());

  mWindow->add_VisibilityChanged(Callback<__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CVisibilityChangedEventArgs>(
    this, &FrameworkView::OnWindowVisibilityChanged).Get(), &mWindowVisibilityChanged);
  mWindow->add_Activated(Callback<__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowActivatedEventArgs_t>(
    this, &FrameworkView::OnWindowActivated).Get(), &mWindowActivated);
  mWindow->add_Closed(Callback<__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CCoreWindowEventArgs_t>(
    this, &FrameworkView::OnWindowClosed).Get(), &mWindowClosed);
  mWindow->add_SizeChanged(Callback<__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowSizeChangedEventArgs_t>(
    this, &FrameworkView::OnWindowSizeChanged).Get(), &mWindowSizeChanged);

  mWindow->add_AutomationProviderRequested(Callback<__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CAutomationProviderRequestedEventArgs_t>(
    this, &FrameworkView::OnAutomationProviderRequested).Get(), &mAutomationProviderRequested);

  HRESULT hr;
  ComPtr<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> dispProps;
  if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), dispProps.GetAddressOf()))) {
    hr = dispProps->add_LogicalDpiChanged(Callback<ABI::Windows::Graphics::Display::IDisplayPropertiesEventHandler, FrameworkView>(
      this, &FrameworkView::OnLogicalDpiChanged).Get(), &mDisplayPropertiesChanged);
    LogHRESULT(hr);
  }

  ComPtr<ABI::Windows::UI::ViewManagement::IInputPaneStatics> inputStatic;
  if (SUCCEEDED(hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(), inputStatic.GetAddressOf()))) {
    ComPtr<ABI::Windows::UI::ViewManagement::IInputPane> inputPane;
    if (SUCCEEDED(inputStatic->GetForCurrentView(inputPane.GetAddressOf()))) {
      inputPane->add_Hiding(Callback<__FITypedEventHandler_2_Windows__CUI__CViewManagement__CInputPane_Windows__CUI__CViewManagement__CInputPaneVisibilityEventArgs_t>(
        this, &FrameworkView::OnSoftkeyboardHidden).Get(), &mSoftKeyboardHidden);
      inputPane->add_Showing(Callback<__FITypedEventHandler_2_Windows__CUI__CViewManagement__CInputPane_Windows__CUI__CViewManagement__CInputPaneVisibilityEventArgs_t>(
        this, &FrameworkView::OnSoftkeyboardShown).Get(), &mSoftKeyboardShown);
    }
  }
}
Ejemplo n.º 4
0
void
FrameworkView::AddSetting(ISettingsPaneCommandsRequestedEventArgs* aArgs,
                          uint32_t aId, HString& aSettingName)
{
  HRESULT hr;

  ComPtr<ABI::Windows::UI::ApplicationSettings::ISettingsPaneCommandsRequest> request;
  AssertHRESULT(aArgs->get_Request(request.GetAddressOf()));

  // ApplicationCommands - vector that holds SettingsCommand to be invoked
  ComPtr<IVector<ABI::Windows::UI::ApplicationSettings::SettingsCommand*>> list;
  AssertHRESULT(request->get_ApplicationCommands(list.GetAddressOf()));

  ComPtr<IUICommand> command;
  ComPtr<ISettingsCommandFactory> factory;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsCommand).Get(),
                            factory.GetAddressOf());
  AssertHRESULT(hr);

  // Create the IInspectable string property that identifies this command
  ComPtr<IInspectable> prop;
  ComPtr<IPropertyValueStatics> propStatics;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_PropertyValue).Get(),
                            propStatics.GetAddressOf());
  AssertHRESULT(hr);
  hr = propStatics->CreateUInt32(aId, prop.GetAddressOf());
  AssertHRESULT(hr);

  // Create the command
  hr = factory->CreateSettingsCommand(prop.Get(), aSettingName.Get(),
    Callback<ABI::Windows::UI::Popups::IUICommandInvokedHandler>(
      this, &FrameworkView::OnSettingsCommandInvoked).Get(), command.GetAddressOf());
  AssertHRESULT(hr);

  // Add it to the list
  hr = list->Append(command.Get());
  AssertHRESULT(hr);
}
Ejemplo n.º 5
0
static float GetLogicalDpi()
{
    ComPtr<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> displayProperties;

    if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), displayProperties.GetAddressOf())))
    {
        float dpi = 96.0f;
        if (SUCCEEDED(displayProperties->get_LogicalDpi(&dpi)))
        {
            return dpi;
        }
    }

    // Return 96 dpi as a default if display properties cannot be obtained.
    return 96.0f;
}
Ejemplo n.º 6
0
void Trim11::unregisterForRendererTrimRequest()
{
#if defined(ANGLE_ENABLE_WINDOWS_STORE)
    if (mApplicationSuspendedEventToken.value != 0)
    {
        ICoreApplication *coreApplication = nullptr;
        if (SUCCEEDED(GetActivationFactory(
                HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
                &coreApplication)))
        {
            coreApplication->remove_Suspending(mApplicationSuspendedEventToken);
        }
        mApplicationSuspendedEventToken.value = 0;
        SafeRelease(coreApplication);
    }
#endif
}
Ejemplo n.º 7
0
EZ_CORE_DLL ezResult ezUWPRun(ezApplication* pApp)
{
  ComPtr<ABI::Windows::ApplicationModel::Core::ICoreApplication> coreApplication;
  HRESULT result = ABI::Windows::Foundation::GetActivationFactory(
      HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), &coreApplication);
  if (FAILED(result))
  {
    printf("Failed to create core application: %i\n", result);
    return EZ_FAILURE;
  }

  {
    ComPtr<ezUwpApplication> application = Make<ezUwpApplication>(pApp);
    coreApplication->Run(application.Get());
    application.Detach(); // Was already deleted by uwp.
  }

  return EZ_SUCCESS;
}
Ejemplo n.º 8
0
bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet *propertySet)
{
    mOrientationChangedEventToken.value = 0;
    ComPtr<IPropertySet> props = propertySet;
    ComPtr<IInspectable> win = window;
    SIZE swapChainSize = {};
    bool swapChainSizeSpecified = false;
    HRESULT result = S_OK;

    // IPropertySet is an optional parameter and can be null.
    // If one is specified, cache as an IMap and read the properties
    // used for initial host initialization.
    if (propertySet)
    {
        result = props.As(&mPropertyMap);
        if (SUCCEEDED(result))
        {
            // The EGLRenderSurfaceSizeProperty is optional and may be missing.  The IPropertySet
            // was prevalidated to contain the EGLNativeWindowType before being passed to
            // this host.
            result = GetOptionalSizePropertyValue(mPropertyMap, EGLRenderSurfaceSizeProperty, &swapChainSize, &swapChainSizeSpecified);
        }
    }

    if (SUCCEEDED(result))
    {
        result = win.As(&mCoreWindow);
    }

    if (SUCCEEDED(result))
    {
        // If a swapchain size is specfied, then the automatic resize
        // behaviors implemented by the host should be disabled.  The swapchain
        // will be still be scaled when being rendered to fit the bounds
        // of the host.
        // Scaling of the swapchain output occurs automatically because if
        // the scaling mode setting DXGI_SCALING_STRETCH on the swapchain.
        if (swapChainSizeSpecified)
        {
            mClientRect = { 0, 0, swapChainSize.cx, swapChainSize.cy };
            mSupportsSwapChainResize = false;
        }
        else
        {
            result = GetCoreWindowSizeInPixels(mCoreWindow, &mClientRect);
        }
    }

    if (SUCCEEDED(result))
    {
        ComPtr<ABI::Windows::Graphics::Display::IDisplayInformationStatics> displayInformation;
        result = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(), &displayInformation);
        if (SUCCEEDED(result))
        {
            result = displayInformation->GetForCurrentView(&mDisplayInformation);
        }
    }

    if (SUCCEEDED(result))
    {
        mNewClientRect = mClientRect;
        mClientRectChanged = false;
        return registerForSizeChangeEvents();
    }

    return false;
}
 // Get the activation factory for the IThreadPoolStatics interface.
 ComPtr<IThreadPoolStatics> threadPool;
 HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_System_Threading_ThreadPool).Get(), &threadPool);
 if (FAILED(hr))
 {
     return PrintError(__LINE__, hr);
 }
Ejemplo n.º 10
0
bool IsEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Foundation::Collections::IPropertySet **propertySet, IInspectable **eglNativeWindow)
{
    if (!window)
    {
        return false;
    }

    ComPtr<IInspectable> props = window;
    ComPtr<IPropertySet> propSet;
    ComPtr<IInspectable> nativeWindow;
    ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable*>> propMap;
    boolean hasEglNativeWindowPropertyKey = false;

    HRESULT result = props.As(&propSet);
    if (SUCCEEDED(result))
    {
        result = propSet.As(&propMap);
    }

    // Look for the presence of the EGLNativeWindowType in the property set
    if (SUCCEEDED(result))
    {
        result = propMap->HasKey(HStringReference(EGLNativeWindowTypeProperty).Get(), &hasEglNativeWindowPropertyKey);
    }

    // If the IPropertySet does not contain the required EglNativeWindowType key, the property set is
    // considered invalid.
    if (SUCCEEDED(result) && !hasEglNativeWindowPropertyKey)
    {
        ERR() << "Could not find EGLNativeWindowTypeProperty in IPropertySet. Valid "
                 "EGLNativeWindowTypeProperty values include ICoreWindow";
        return false;
    }

    // The EglNativeWindowType property exists, so retreive the IInspectable that represents the EGLNativeWindowType
    if (SUCCEEDED(result) && hasEglNativeWindowPropertyKey)
    {
        result = propMap->Lookup(HStringReference(EGLNativeWindowTypeProperty).Get(), &nativeWindow);
    }

    if (SUCCEEDED(result))
    {
        if (propertySet != nullptr)
        {
            result = propSet.CopyTo(propertySet);
        }
    }

    if (SUCCEEDED(result))
    {
        if (eglNativeWindow != nullptr)
        {
            result = nativeWindow.CopyTo(eglNativeWindow);
        }
    }

    if (SUCCEEDED(result))
    {
        return true;
    }

    return false;
}
Ejemplo n.º 11
0
HRESULT
FrameworkView::OnDataShareRequested(IDataTransferManager* aDTM,
                                    IDataRequestedEventArgs* aArg)
{
  // Only share pages that contain a title and a URI
  nsCOMPtr<nsIMetroUIUtils> metroUIUtils = do_CreateInstance("@mozilla.org/metro-ui-utils;1");
  if (!metroUIUtils)
      return E_FAIL;

  nsString url, title;
  nsresult rv = metroUIUtils->GetCurrentPageURI(url);
  nsresult rv2 = metroUIUtils->GetCurrentPageTitle(title);
  if (NS_FAILED(rv) || NS_FAILED(rv2)) {
    return E_FAIL;
  }

  // Get the package to share
  HRESULT hr;
  ComPtr<IDataRequest> request;
  AssertRetHRESULT(hr = aArg->get_Request(request.GetAddressOf()), hr);
  ComPtr<IDataPackage> dataPackage;
  AssertRetHRESULT(hr = request->get_Data(dataPackage.GetAddressOf()), hr);
  ComPtr<IDataPackagePropertySet> props;
  AssertRetHRESULT(hr = dataPackage->get_Properties(props.GetAddressOf()), hr);

  // Only add a URI to the package when there is no selected content.
  // This is because most programs treat URIs as highest priority to generate
  // their own preview, but we only want the selected content to show up.
  bool hasSelectedContent = false;
  metroUIUtils->GetHasSelectedContent(&hasSelectedContent);
  if (!hasSelectedContent) {
    ComPtr<IUriRuntimeClass> uri;
    AssertRetHRESULT(hr = MetroUtils::CreateUri(HStringReference(url.BeginReading()).Get(), uri), hr);

    // If there is no selection, then we don't support sharing for sites that
    // are not HTTP, HTTPS, FTP, and FILE.
    HString schemeHString;
    uri->get_SchemeName(schemeHString.GetAddressOf());
    unsigned int length;
    LPCWSTR scheme = schemeHString.GetRawBuffer(&length);
    if (!scheme || wcscmp(scheme, L"http") && wcscmp(scheme, L"https") &&
        wcscmp(scheme, L"ftp") && wcscmp(scheme, L"file")) {
      return S_OK;
    }

    AssertRetHRESULT(hr = dataPackage->SetUri(uri.Get()), hr);
  }

  // Add whatever content metroUIUtils wants us to for the text sharing
  nsString shareText;
  if (NS_SUCCEEDED(metroUIUtils->GetShareText(shareText)) && shareText.Length()) {
    AssertRetHRESULT(hr = dataPackage->SetText(HStringReference(shareText.BeginReading()).Get()) ,hr);
  }

  // Add whatever content metroUIUtils wants us to for the HTML sharing
  nsString shareHTML;
  if (NS_SUCCEEDED(metroUIUtils->GetShareHTML(shareHTML)) && shareHTML.Length()) {
    // The sharing format needs some special headers, so pass it through Windows
    ComPtr<IHtmlFormatHelperStatics> htmlFormatHelper;
    hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_HtmlFormatHelper).Get(),
                              htmlFormatHelper.GetAddressOf());
    AssertRetHRESULT(hr, hr);
    HSTRING fixedHTML;
    htmlFormatHelper->CreateHtmlFormat(HStringReference(shareHTML.BeginReading()).Get(), &fixedHTML);

    // And now add the fixed HTML to the data package
    AssertRetHRESULT(hr = dataPackage->SetHtmlFormat(fixedHTML), hr);
  }

  // Obtain the brand name
  nsCOMPtr<nsIStringBundleService> bundleService = 
    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
  NS_ENSURE_TRUE(bundleService, E_FAIL);
  nsCOMPtr<nsIStringBundle> brandBundle;
  nsString brandName;
  bundleService->CreateBundle("chrome://branding/locale/brand.properties",
    getter_AddRefs(brandBundle));
  NS_ENSURE_TRUE(brandBundle, E_FAIL);
  if(brandBundle) {
    brandBundle->GetStringFromName(MOZ_UTF16("brandFullName"),
                                   getter_Copies(brandName));
  }

  // Set these properties at the end.  Otherwise users can get a
  // "There was a problem with the data package" error when there
  // is simply nothing to share.
  props->put_ApplicationName(HStringReference(brandName.BeginReading()).Get());
  if (title.Length()) {
    props->put_Title(HStringReference(title.BeginReading()).Get());
  } else {
    props->put_Title(HStringReference(brandName.BeginReading()).Get());
  }
  props->put_Description(HStringReference(url.BeginReading()).Get());

  return S_OK;
}