bool
ScreenManagerParent::RecvScreenRefresh(const uint32_t& aId,
                                       ScreenDetails* aRetVal,
                                       bool* aSuccess)
{
  *aSuccess = false;

  nsCOMPtr<nsIScreen> screen;
  nsresult rv = mScreenMgr->ScreenForId(aId, getter_AddRefs(screen));
  if (NS_FAILED(rv)) {
    return true;
  }

  ScreenDetails details;
  unused << ExtractScreenDetails(screen, details);

  *aRetVal = details;
  *aSuccess = true;
  return true;
}
bool
ScreenManagerParent::RecvGetPrimaryScreen(ScreenDetails* aRetVal,
                                          bool* aSuccess)
{
  *aSuccess = false;

  nsCOMPtr<nsIScreen> screen;
  nsresult rv = mScreenMgr->GetPrimaryScreen(getter_AddRefs(screen));

  NS_ENSURE_SUCCESS(rv, true);

  ScreenDetails details;
  if (!ExtractScreenDetails(screen, details)) {
    return true;
  }

  *aRetVal = details;
  *aSuccess = true;
  return true;
}
bool
ScreenManagerParent::RecvScreenForBrowser(PBrowserParent* aBrowser,
                                          ScreenDetails* aRetVal,
                                          bool* aSuccess)
{
  *aSuccess = false;
#ifdef MOZ_VALGRIND
  // Zero this so that Valgrind doesn't complain when we send it to another
  // process.
  memset(aRetVal, 0, sizeof(ScreenDetails));
#endif

  // Find the mWidget associated with the tabparent, and then return
  // the nsIScreen it's on.
  TabParent* tabParent = static_cast<TabParent*>(aBrowser);
  nsCOMPtr<nsIWidget> widget = tabParent->GetWidget();

  nsCOMPtr<nsIScreen> screen;
  if (widget) {
    if (widget->GetNativeData(NS_NATIVE_WINDOW)) {
      mScreenMgr->ScreenForNativeWidget(widget->GetNativeData(NS_NATIVE_WINDOW),
                                        getter_AddRefs(screen));
    }
  } else {
    nsresult rv = mScreenMgr->GetPrimaryScreen(getter_AddRefs(screen));
    if (NS_WARN_IF(NS_FAILED(rv))) {
      return true;
    }
  }

  NS_ENSURE_TRUE(screen, true);

  ScreenDetails details;
  if (!ExtractScreenDetails(screen, details)) {
    return true;
  }

  *aRetVal = details;
  *aSuccess = true;
  return true;
}
bool
ScreenManagerParent::RecvScreenForRect(const int32_t& aLeft,
                                       const int32_t& aTop,
                                       const int32_t& aWidth,
                                       const int32_t& aHeight,
                                       ScreenDetails* aRetVal,
                                       bool* aSuccess)
{
  *aSuccess = false;

  nsCOMPtr<nsIScreen> screen;
  nsresult rv = mScreenMgr->ScreenForRect(aLeft, aTop, aWidth, aHeight, getter_AddRefs(screen));

  NS_ENSURE_SUCCESS(rv, true);

  ScreenDetails details;
  if (!ExtractScreenDetails(screen, details)) {
    return true;
  }

  *aRetVal = details;
  *aSuccess = true;
  return true;
}