wxGLContext::~wxGLContext() { if (!m_glContext) return; if (m_glContext == glXGetCurrentContext()) { glXMakeCurrent( (Display*) wxGetDisplay(), None, NULL); } glXDestroyContext( (Display*) wxGetDisplay(), m_glContext ); }
// Create a DC representing the whole screen wxScreenDCImpl::wxScreenDCImpl(wxScreenDC *owner) : wxWindowDCImpl(owner) { m_display = wxGetDisplay(); Display* display = (Display*) m_display; if (sm_overlayWindow) { m_pixmap = sm_overlayWindow; m_deviceOriginX = - sm_overlayWindowX; m_deviceOriginY = - sm_overlayWindowY; } else m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display)); XGCValues gcvalues; gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); gcvalues.background = WhitePixel (display, DefaultScreen (display)); gcvalues.graphics_exposures = False; gcvalues.subwindow_mode = IncludeInferiors; gcvalues.line_width = 1; m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)), GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, &gcvalues); m_backgroundPixel = gcvalues.background; m_ok = true; }
void wxGLContext::SetColour(const wxChar *colour) { wxColour the_colour = wxTheColourDatabase->Find(colour); if(the_colour.Ok()) { GLboolean b; glGetBooleanv(GL_RGBA_MODE, &b); if(b) { glColor3ub(the_colour.Red(), the_colour.Green(), the_colour.Blue()); } else { #ifdef __WXMOTIF__ the_colour.AllocColour(m_window->GetXDisplay()); #else the_colour.CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay())); #endif GLint pix = (GLint)the_colour.GetPixel(); if(pix == -1) { wxLogError(wxT("wxGLCanvas: cannot allocate color\n")); return; } glIndexi(pix); } } }
wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC* dc) : wxWindowDCImpl(owner) { m_ok = true; if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC))) m_display = ((wxWindowDCImpl *)dc->GetImpl())->GetDisplay(); else m_display = wxGetDisplay(); Display* display = (Display*) m_display; XGCValues gcvalues; gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); gcvalues.background = WhitePixel (display, DefaultScreen (display)); gcvalues.graphics_exposures = False; gcvalues.subwindow_mode = IncludeInferiors; gcvalues.line_width = 1; m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, &gcvalues); m_backgroundPixel = gcvalues.background; SetBrush (* wxWHITE_BRUSH); SetPen (* wxBLACK_PEN); }
void WXAppBar::UnSetDockedModeStep2() { Display *dd= (Display *) wxGetDisplay(); // Window X11 handle GtkWidget *gtkWidget= (GtkWidget *) this->GetHandle(); Window w= GDK_WINDOW_XWINDOW (gtkWidget->window); Refresh(); Update(); // // Set window style back to normal again // Atom atomTmp= XInternAtom (dd, "_NET_WM_WINDOW_TYPE", False); Atom atom_NET_WM_WINDOW_TYPE_NORMAL= XInternAtom (dd, "_NET_WM_WINDOW_TYPE_NORMAL", False); unsigned long propInfo= atom_NET_WM_WINDOW_TYPE_NORMAL; XChangeProperty (dd, w, atomTmp, XA_ATOM, 32, PropModeReplace, (unsigned char *) &propInfo, 1); XSync(dd, False); // The code above disables the sticky property, so we enable it again SetSticky(true); // Restore decorations when needed SetBorderDecorations(m_dialogHadBorderDecorations); // Restore original size wxSize proposedSize= DoGetBestSize(); //SetSize (0, 0, proposedSize.GetWidth(), proposedSize.GetHeight()); SetSize (proposedSize.GetWidth(), proposedSize.GetHeight()); }
Window wxGetWindowParent(Window window) { wxASSERT_MSG( window, wxT("invalid window") ); return (Window) 0; #ifndef __VMS // VMS chokes on unreacheable code Window parent, root = 0; #if wxUSE_NANOX int noChildren = 0; #else unsigned int noChildren = 0; #endif Window* children = NULL; // #define XQueryTree(d,w,r,p,c,nc) GrQueryTree(w,p,c,nc) int res = 1; #if !wxUSE_NANOX res = #endif XQueryTree((Display*) wxGetDisplay(), window, & root, & parent, & children, & noChildren); if (children) XFree(children); if (res) return parent; else return (Window) 0; #endif }
bool wxPalette::TransferBitmap(void *data, int depth, int size) { switch(depth) { case 8: { unsigned char *uptr = (unsigned char *)data; int pix_array_n; unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while(size-- > 0) { if((int)*uptr < pix_array_n) *uptr = (unsigned char)pix_array[*uptr]; uptr++; } return true; } default: return false; } }
void wxDataFormat::SetId( const wxString& id ) { #if !wxUSE_NANOX PrepareFormats(); m_type = wxDF_PRIVATE; m_format = XInternAtom( (Display*) wxGetDisplay(), id.ToAscii(), FALSE ); #endif }
wxString wxDataFormat::GetId() const { char *t = XGetAtomName ((Display*) wxGetDisplay(), m_format); wxString ret( t ); // this will convert from ascii to Unicode if (t) XFree( t ); return ret; }
void wxGLContext::SwapBuffers() { if (m_glContext) { Display* display = (Display*) wxGetDisplay(); glXSwapBuffers(display, (Window) wxGetClientAreaWindow(m_window)); } }
MO_DISPLAY moGLCanvas::GetDisplay() { #ifdef MO_WIN32 return NULL; #else return (MO_DISPLAY)wxGetDisplay(); //default display; #endif }
// Find an existing, or create a new, XFontStruct // based on this wxFont and the given scale. Append the // font to list in the private data for future reference. wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const { if ( !IsOk() ) return NULL; long intScale = long(scale * 100.0 + 0.5); // key for wxXFont int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100; // search existing fonts first wxList::compatibility_iterator node = M_FONTDATA->m_fonts.GetFirst(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while (node) { wxXFont* f = (wxXFont*) node->GetData(); if ((!display || (f->m_display == display)) && (f->m_scale == intScale)) return f; node = node->GetNext(); } wxString xFontName = M_FONTDATA->m_nativeFontInfo.GetXFontName(); if (xFontName == "-*-*-*-*-*--*-*-*-*-*-*-*-*") // wxFont constructor not called with native font info parameter => take M_FONTDATA values xFontName.Clear(); // not found, create a new one XFontStruct *font = (XFontStruct *) wxLoadQueryNearestFont(pointSize, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined, wxT(""), M_FONTDATA->m_encoding, & xFontName); if ( !font ) { wxFAIL_MSG( wxT("Could not allocate even a default font -- something is wrong.") ); return NULL; } wxXFont* f = new wxXFont; f->m_fontStruct = (WXFontStructPtr)font; f->m_display = ( display ? display : wxGetDisplay() ); f->m_scale = intScale; M_FONTDATA->m_fonts.Append(f); return f; }
void wxGLContext::SetCurrent() { if (m_glContext) { Display* display = (Display*) wxGetDisplay(); glXMakeCurrent(display, (Window) wxGetClientAreaWindow(m_window), m_glContext );; } }
void wxDisplaySizeMM(int *width, int *height) { Display *dpy = (Display*) wxGetDisplay(); if ( width ) *width = DisplayWidthMM(dpy, DefaultScreen (dpy)); if ( height ) *height = DisplayHeightMM(dpy, DefaultScreen (dpy)); }
// Consume all events until no more left void wxFlushEvents() { Display *display = (Display*) wxGetDisplay(); XSync (display, FALSE); // TODO for X11 // ?? }
void wxGetMousePosition( int* x, int* y ) { #if wxUSE_NANOX // TODO *x = 0; *y = 0; #else XMotionEvent xev; Window root, child; XQueryPointer((Display*) wxGetDisplay(), DefaultRootWindow((Display*) wxGetDisplay()), &root, &child, &(xev.x_root), &(xev.y_root), &(xev.x), &(xev.y), &(xev.state)); *x = xev.x_root; *y = xev.y_root; #endif };
bool wxScreenDCImpl::EndDrawingOnTop() { if (sm_overlayWindow) { XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow); sm_overlayWindow = 0; return true; } else return false; }
void WXAppBar::OnTimer(wxTimerEvent& event) { #if defined(__WXGTK__) long x, y; m_pMouseControl->GetPointerLocation (x, y); wxRect barRect = GetRect(); if (m_autohide && m_currentDockingMode != NON_DOCKED && m_isAutohideWindowShown && !barRect.Contains(x,y)) { // Get X11 display Display* dd= (Display *) wxGetDisplay(); assert (dd); // Get desktop working area dimensions int xDesktop, yDesktop, widthDesktop, heightDesktop, screenWidth, screenHeight; GetDesktopDimensions (dd, xDesktop, yDesktop, widthDesktop, heightDesktop, screenWidth, screenHeight); // Get original dimensions of the bar wxSize proposedSize= GetBestSize(); // Compute bar position and size depending on docking mode m_Width= proposedSize.GetWidth(); m_Height= proposedSize.GetHeight(); switch (m_currentDockingMode) { case TOP_DOCKED: m_X= (screenWidth - proposedSize.GetWidth())/2; m_Y= 0 - proposedSize.GetHeight() + AUTOHIDE_FLANGE; break; case BOTTOM_DOCKED: m_X= (screenWidth - proposedSize.GetWidth())/2; m_Y= screenHeight - AUTOHIDE_FLANGE; break; case LEFT_DOCKED: m_X= 0 - proposedSize.GetWidth() + AUTOHIDE_FLANGE; m_Y= (screenHeight - proposedSize.GetHeight())/2; break; case RIGHT_DOCKED: m_X= screenWidth - AUTOHIDE_FLANGE; m_Y= (screenHeight - proposedSize.GetHeight())/2; break; case NON_DOCKED: default: assert (false); } // Set desired location and dimensions SetSize(m_X, m_Y, m_Width, m_Height); m_isAutohideWindowShown= false; } #endif event.Skip(false); }
int wxGLCanvas::GetColourIndex(const wxColour& col_) { wxColour& col = const_cast<wxColour&>(col_); #ifdef __WXMOTIF__ col.AllocColour(GetXDisplay()); #else col.CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay())); #endif return col.GetPixel(); }
wxString wxDataFormat::GetId() const { #if wxUSE_NANOX return wxEmptyString; #else char *t = XGetAtomName ((Display*) wxGetDisplay(), m_format); wxString ret = wxString::FromAscii( t ); if (t) XFree( t ); return ret; #endif }
wxClipboard::wxClipboard() { m_open = false; m_ownsClipboard = false; m_ownsPrimarySelection = false; m_data = NULL; m_receivedData = NULL; /* we use m_targetsWidget to query what formats are available */ /* we use m_clipboardWidget to get and to offer data */ #if !wxUSE_NANOX if (!g_clipboardAtom) g_clipboardAtom = XInternAtom( (Display*) wxGetDisplay(), "CLIPBOARD", False ); if (!g_targetsAtom) g_targetsAtom = XInternAtom( (Display*) wxGetDisplay(), "TARGETS", False ); #endif m_formatSupported = false; m_targetRequested = 0; }
bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz, void *dest, unsigned int bpp) { int pix_array_n; unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n); switch(bpp) { case 8: { unsigned char *dptr = (unsigned char *)dest; while(sz-- > 0) { if((int)*data < pix_array_n) *dptr = (unsigned char)pix_array[*data]; data++; dptr++; } break; } case 16: { unsigned short *dptr = (unsigned short *)dest; while(sz-- > 0) { if((int)*data < pix_array_n) *dptr = (unsigned short)pix_array[*data]; data++; dptr++; } break; } case 24: { struct rgb24 { unsigned char r, g, b; } *dptr = (struct rgb24 *)dest; while(sz-- > 0) { if((int)*data < pix_array_n) { dptr->r = pix_array[*data] & 0xFF; dptr->g = (pix_array[*data] >> 8) & 0xFF; dptr->b = (pix_array[*data] >> 16) & 0xFF; } data++; dptr++; } break; } case 32: { unsigned long *dptr = (unsigned long *)dest; while(sz-- > 0) { if((int)*data < pix_array_n) *dptr = pix_array[*data]; data++; dptr++; } break; } default: return false; }
WXWidget wxApp::GetTopLevelRealizedWidget() { WXDisplay* display = wxGetDisplay(); wxPerDisplayDataMap::iterator it = m_perDisplayData->find( display ); if( it != m_perDisplayData->end() && it->second->m_topLevelRealizedWidget ) return (WXWidget)it->second->m_topLevelRealizedWidget; WXWidget rTlw = wxCreateTopLevelRealizedWidget( display ); SetTopLevelRealizedWidget( display, rTlw ); return rTlw; }
WXWidget wxApp::GetTopLevelWidget() { WXDisplay* display = wxGetDisplay(); wxPerDisplayData& data = GetOrCreatePerDisplayData( *m_perDisplayData, display ); if( data.m_topLevelWidget ) return (WXWidget)data.m_topLevelWidget; WXWidget tlw = wxCreateTopLevelWidget( display ); SetTopLevelWidget( display, tlw ); return tlw; }
wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, const wxPalette& WXUNUSED(palette), const wxGLContext *other /* for sharing display lists */ ) { m_window = win; // m_widget = win->m_wxwindow; wxGLCanvas *gc = (wxGLCanvas*) win; XVisualInfo *vi = (XVisualInfo *) gc->m_vi; wxCHECK_RET( vi, wxT("invalid visual for OpenGL") ); if( other != 0 ) m_glContext = glXCreateContext( (Display *)wxGetDisplay(), vi, other->m_glContext, GL_TRUE ); else m_glContext = glXCreateContext( (Display *)wxGetDisplay(), vi, None, GL_TRUE ); wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGL context") ); }
void WXAppBar::OnEnterWindow( wxMouseEvent& event ) { #if defined(__WXGTK__) if (m_autohide && m_currentDockingMode != NON_DOCKED && !m_isAutohideWindowShown) { // Get X11 display Display* dd= (Display *) wxGetDisplay(); assert (dd); // Get desktop working area dimensions int xDesktop, yDesktop, widthDesktop, heightDesktop, screenWidth, screenHeight; GetDesktopDimensions (dd, xDesktop, yDesktop, widthDesktop, heightDesktop, screenWidth, screenHeight); // Get original dimensions of the bar wxSize proposedSize= GetBestSize(); // Compute bar position and size depending on docking mode m_Width= proposedSize.GetWidth(); m_Height= proposedSize.GetHeight(); switch (m_currentDockingMode) { case TOP_DOCKED: m_X= (screenWidth - proposedSize.GetWidth())/2; m_Y= 0; break; case BOTTOM_DOCKED: m_X= (screenWidth - proposedSize.GetWidth())/2; m_Y= screenHeight - proposedSize.GetHeight(); break; case LEFT_DOCKED: m_X= 0; m_Y= (screenHeight - proposedSize.GetHeight())/2; break; case RIGHT_DOCKED: m_X= screenWidth - proposedSize.GetWidth(); m_Y= (screenHeight - proposedSize.GetHeight())/2; break; case NON_DOCKED: default: assert (false); } // Set desired location and dimensions SetSize(m_X, m_Y, m_Width, m_Height); m_isAutohideWindowShown= true; } #endif event.Skip(true); }
CPointerAction::CPointerAction() : m_enabled(false) { m_pClickSound= new wxSound (eviacam::GetDataDir() + _T("/click.wav")); m_pLeftUpClickSound= new wxSound (eviacam::GetDataDir() + _T("/click2.wav")); #if defined(__WXGTK__) m_pMouseControl= new CMouseControl ((void *) wxGetDisplay()); #else m_pMouseControl= new CMouseControl (); #endif m_pDwellClick= new CDwellClick (*m_pMouseControl); m_pGestureClick= new CGestureClick (*m_pMouseControl); InitDefaults (); }
bool wxGetKeyState(wxKeyCode key) { wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); Display *pDisplay = (Display*) wxGetDisplay(); int iKey = wxCharCodeWXToX(key); int iKeyMask = 0; Window wDummy1, wDummy2; int iDummy3, iDummy4, iDummy5, iDummy6; unsigned int iMask; KeyCode keyCode = XKeysymToKeycode(pDisplay,iKey); if (keyCode == NoSymbol) return false; if ( IsModifierKey(iKey) ) // If iKey is a modifier key, use a different method { XModifierKeymap *map = XGetModifierMapping(pDisplay); wxCHECK_MSG( map, false, wxT("failed to get X11 modifiers map") ); for (int i = 0; i < 8; ++i) { if ( map->modifiermap[map->max_keypermod * i] == keyCode) { iKeyMask = 1 << i; } } XQueryPointer(pDisplay, DefaultRootWindow(pDisplay), &wDummy1, &wDummy2, &iDummy3, &iDummy4, &iDummy5, &iDummy6, &iMask ); XFreeModifiermap(map); return (iMask & iKeyMask) != 0; } // From the XLib manual: // The XQueryKeymap() function returns a bit vector for the logical state of the keyboard, // where each bit set to 1 indicates that the corresponding key is currently pressed down. // The vector is represented as 32 bytes. Byte N (from 0) contains the bits for keys 8N to 8N + 7 // with the least-significant bit in the byte representing key 8N. char key_vector[32]; XQueryKeymap(pDisplay, key_vector); return key_vector[keyCode >> 3] & (1 << (keyCode & 7)); }
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) { UnRef(); if (!n) { return false; } m_refData = new wxPaletteRefData; XColor xcol; Display* display = (Display*) wxGetDisplay(); unsigned long *pix_array; Colormap cmap; int pix_array_n; cmap = (Colormap) wxTheApp->GetMainColormap(display); pix_array = new unsigned long[n]; if (!pix_array) return false; pix_array_n = n; xcol.flags = DoRed | DoGreen | DoBlue; for(int i = 0; i < n; i++) { xcol.red = (unsigned short)red[i] << 8; xcol.green = (unsigned short)green[i] << 8; xcol.blue = (unsigned short)blue[i] << 8; pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel; } wxXPalette *c = new wxXPalette; c->m_pix_array_n = pix_array_n; c->m_pix_array = pix_array; c->m_cmap = (WXColormap) cmap; c->m_display = (WXDisplay*) display; c->m_destroyable = false; M_PALETTEDATA->m_palettes.Append(c); return true; }
// Find an existing, or create a new, XFontStruct // based on this wxFont and the given scale. Append the // font to list in the private data for future reference. wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const { if ( !Ok() ) return (wxXFont *)NULL; long intScale = long(scale * 100.0 + 0.5); // key for wxXFont int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100; // search existing fonts first wxList::compatibility_iterator node = M_FONTDATA->m_fonts.GetFirst(); while (node) { wxXFont* f = (wxXFont*) node->GetData(); if ((!display || (f->m_display == display)) && (f->m_scale == intScale)) return f; node = node->GetNext(); } // not found, create a new one XFontStruct *font = (XFontStruct *) wxLoadQueryNearestFont(pointSize, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined, wxT(""), M_FONTDATA->m_encoding); if ( !font ) { wxFAIL_MSG( wxT("Could not allocate even a default font -- something is wrong.") ); return (wxXFont*) NULL; } wxXFont* f = new wxXFont; f->m_fontStruct = (WXFontStructPtr)font; f->m_display = ( display ? display : wxGetDisplay() ); f->m_scale = intScale; M_FONTDATA->m_fonts.Append(f); return f; }