b=682625 move XVisualIDToInfo to X11Util r=cjones

--HG--
extra : transplant_source : %BA%AF%7F%B2%B3%12%F2%CBl%FAy%5C%F25lI%23%EC%92%28
This commit is contained in:
Karl Tomlinson 2012-01-10 23:54:38 +13:00
parent 25280e6ccf
commit 5d027f5e32
3 changed files with 39 additions and 31 deletions

View File

@ -963,37 +963,6 @@ PluginInstanceChild::RecvWindowPosChanged(const NPRemoteEvent& event)
#endif #endif
} }
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
static bool
XVisualIDToInfo(Display* aDisplay, VisualID aVisualID,
Visual** aVisual, unsigned int* aDepth)
{
if (aVisualID == None) {
*aVisual = NULL;
*aDepth = 0;
return true;
}
const Screen* screen = DefaultScreenOfDisplay(aDisplay);
for (int d = 0; d < screen->ndepths; d++) {
Depth *d_info = &screen->depths[d];
for (int v = 0; v < d_info->nvisuals; v++) {
Visual* visual = &d_info->visuals[v];
if (visual->visualid == aVisualID) {
*aVisual = visual;
*aDepth = d_info->depth;
return true;
}
}
}
NS_ERROR("VisualID not on Screen.");
return false;
}
#endif
bool bool
PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow) PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
{ {

View File

@ -41,6 +41,34 @@
namespace mozilla { namespace mozilla {
bool
XVisualIDToInfo(Display* aDisplay, VisualID aVisualID,
Visual** aVisual, unsigned int* aDepth)
{
if (aVisualID == None) {
*aVisual = NULL;
*aDepth = 0;
return true;
}
const Screen* screen = DefaultScreenOfDisplay(aDisplay);
for (int d = 0; d < screen->ndepths; d++) {
Depth *d_info = &screen->depths[d];
for (int v = 0; v < d_info->nvisuals; v++) {
Visual* visual = &d_info->visuals[v];
if (visual->visualid == aVisualID) {
*aVisual = visual;
*aDepth = d_info->depth;
return true;
}
}
}
NS_ERROR("VisualID not on Screen.");
return false;
}
ScopedXErrorHandler::ErrorEvent* ScopedXErrorHandler::sXErrorPtr; ScopedXErrorHandler::ErrorEvent* ScopedXErrorHandler::sXErrorPtr;
int int

View File

@ -72,6 +72,17 @@ DefaultXDisplay()
#endif #endif
} }
/**
* Sets *aVisual to point to aDisplay's Visual struct corresponding to
* aVisualID, and *aDepth to its depth. When aVisualID is None, these are set
* to NULL and 0 respectively. Both out-parameter pointers are assumed
* non-NULL. Returns true in both of these situations, but false if aVisualID
* is not None and not found on the Display.
*/
bool
XVisualIDToInfo(Display* aDisplay, VisualID aVisualID,
Visual** aVisual, unsigned int* aDepth);
/** /**
* Invoke XFree() on a pointer to memory allocated by Xlib (if the * Invoke XFree() on a pointer to memory allocated by Xlib (if the
* pointer is nonnull) when this class goes out of scope. * pointer is nonnull) when this class goes out of scope.