XHelper() : wmInf_(), acquireCount_(0) { acquire(); // Intern some atoms; const char* atoms[] = { "CLIPBOARD", "TEXT", "COMPOUND_TEXT", "UTF8_STRING", "WESNOTH_PASTE", "TARGETS" }; XInternAtoms(dpy(), const_cast<char**>(reinterpret_cast<const char**>(atoms)), 6, false, atomTable_); release(); }
StoredPosition storePosition(wxWindow * window) { WINDOWPLACEMENT wp; wp.length = sizeof(wp); GetWindowPlacement(window->GetHWND(), &wp); StoredPosition result; result.maximized = wp.showCmd == SW_MAXIMIZE; result.left = wp.rcNormalPosition.left; result.top = wp.rcNormalPosition.top; result.width = wp.rcNormalPosition.right - wp.rcNormalPosition.left; result.height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; if(!window->HasFlag(wxFRAME_TOOL_WINDOW)) { int n = wxDisplay::GetFromWindow(window); wxDisplay dpy(n == wxNOT_FOUND ? 0 : n); const wxPoint offset = dpy.GetClientArea().GetPosition() - dpy.GetGeometry().GetPosition(); result.left += offset.x; result.top += offset.y; } return result; }
void wxTopLevelWindowMSW::DoGetPosition(int *x, int *y) const { if ( IsIconized() ) { WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); if ( ::GetWindowPlacement(GetHwnd(), &wp) ) { RECT& rc = wp.rcNormalPosition; // the position returned by GetWindowPlacement() is in workspace // coordinates except for windows with WS_EX_TOOLWINDOW style if ( !HasFlag(wxFRAME_TOOL_WINDOW) ) { // we must use the correct display for the translation as the // task bar might be shown on one display but not the other one int n = wxDisplay::GetFromWindow(this); wxDisplay dpy(n == wxNOT_FOUND ? 0 : n); const wxPoint ptOfs = dpy.GetClientArea().GetPosition() - dpy.GetGeometry().GetPosition(); rc.left += ptOfs.x; rc.top += ptOfs.y; } if ( x ) *x = rc.left; if ( y ) *y = rc.top; return; } wxLogLastError(wxT("GetWindowPlacement")); } //else: normal case wxTopLevelWindowBase::DoGetPosition(x, y); }
status_t LayerBuffer::BufferSource::initTempBuffer() const { // figure out the size we need now const ISurface::BufferHeap& buffers(mBufferHeap); uint32_t w = mLayer.mTransformedBounds.width(); uint32_t h = mLayer.mTransformedBounds.height(); if (mLayer.getOrientation() & (Transform::ROT_90 | Transform::ROT_270)) { int t = w; w = h; h = t; } // we're in the copybit case, so make sure we can handle this blit // we don't have to keep the aspect ratio here copybit_device_t* copybit = mLayer.mBlitEngine; const int down = copybit->get(copybit, COPYBIT_MINIFICATION_LIMIT); const int up = copybit->get(copybit, COPYBIT_MAGNIFICATION_LIMIT); if (buffers.w > w*down) w = buffers.w / down; else if (w > buffers.w*up) w = buffers.w*up; if (buffers.h > h*down) h = buffers.h / down; else if (h > buffers.h*up) h = buffers.h*up; if (mTexture.image != EGL_NO_IMAGE_KHR) { // we have an EGLImage, make sure the needed size didn't change if (w!=mTexture.width || h!= mTexture.height) { // delete the EGLImage and texture clearTempBufferImage(); } else { // we're good, we have an EGLImageKHR and it's (still) the // right size return NO_ERROR; } } // figure out if we need linear filtering if (buffers.w * h == buffers.h * w) { // same pixel area, don't use filtering mLayer.mNeedsFiltering = false; } // Allocate a temporary buffer and create the corresponding EGLImageKHR // once the EGLImage has been created we don't need the // graphic buffer reference anymore. sp<GraphicBuffer> buffer = new GraphicBuffer( w, h, HAL_PIXEL_FORMAT_RGB_565, GraphicBuffer::USAGE_HW_TEXTURE | GraphicBuffer::USAGE_HW_2D); status_t err = buffer->initCheck(); if (err == NO_ERROR) { NativeBuffer& dst(mTempBuffer); dst.img.w = buffer->getStride(); dst.img.h = h; dst.img.format = buffer->getPixelFormat(); dst.img.handle = (native_handle_t *)buffer->handle; dst.img.base = 0; dst.crop.l = 0; dst.crop.t = 0; dst.crop.r = w; dst.crop.b = h; EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); err = mTextureManager.initEglImage(&mTexture, dpy, buffer); } return err; }
void wxTopLevelWindowBase::DoCentre(int dir) { // on some platforms centering top level windows is impossible // because they are always maximized by guidelines or limitations // // and centering a maximized window doesn't make sense as its position // can't change if ( IsAlwaysMaximized() || IsMaximized() ) return; // we need the display rect anyhow so store it first: notice that we should // be centered on the same display as our parent window, the display of // this window itself is not really defined yet int nDisplay = wxDisplay::GetFromWindow(GetParent() ? GetParent() : this); wxDisplay dpy(nDisplay == wxNOT_FOUND ? 0 : nDisplay); const wxRect rectDisplay(dpy.GetClientArea()); // what should we centre this window on? wxRect rectParent; if ( !(dir & wxCENTRE_ON_SCREEN) && GetParent() ) { // centre on parent window: notice that we need screen coordinates for // positioning this TLW rectParent = GetParent()->GetScreenRect(); // if the parent is entirely off screen (happens at least with MDI // parent frame under Mac but could happen elsewhere too if the frame // was hidden/moved away for some reason), don't use it as otherwise // this window wouldn't be visible at all if ( !rectParent.Intersects(rectDisplay) ) { // just centre on screen then rectParent = rectDisplay; } } else { // we were explicitly asked to centre this window on the entire screen // or if we have no parent anyhow and so can't centre on it rectParent = rectDisplay; } if ( !(dir & wxBOTH) ) dir |= wxBOTH; // if neither is specified, center in both directions // the new window rect candidate wxRect rect = GetRect().CentreIn(rectParent, dir & ~wxCENTRE_ON_SCREEN); // we don't want to place the window off screen if Centre() is called as // this is (almost?) never wanted and it would be very difficult to prevent // it from happening from the user code if we didn't check for it here if ( !rectDisplay.Contains(rect.GetTopLeft()) ) { // move the window just enough to make the corner visible int dx = rectDisplay.GetLeft() - rect.GetLeft(); int dy = rectDisplay.GetTop() - rect.GetTop(); rect.Offset(dx > 0 ? dx : 0, dy > 0 ? dy : 0); } if ( !rectDisplay.Contains(rect.GetBottomRight()) ) { // do the same for this corner too int dx = rectDisplay.GetRight() - rect.GetRight(); int dy = rectDisplay.GetBottom() - rect.GetBottom(); rect.Offset(dx < 0 ? dx : 0, dy < 0 ? dy : 0); } // the window top left and bottom right corner are both visible now and // although the window might still be not entirely on screen (with 2 // staggered displays for example) we wouldn't be able to improve the // layout much in such case, so we stop here // -1 could be valid coordinate here if there are several displays SetSize(rect, wxSIZE_ALLOW_MINUS_ONE); }
void MyFrame::OnResetMode(wxCommandEvent& WXUNUSED(event)) { wxDisplay dpy(m_book->GetSelection()); dpy.ResetMode(); }