X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/09a1dffa32ae09ea47789eb071a1fdac0d154dda..44f5b995740b69ba222e92a5f7da87080afe4367:/src/x11/app.cpp?ds=sidebyside diff --git a/src/x11/app.cpp b/src/x11/app.cpp index baf2b44241..bd29c3eac5 100644 --- a/src/x11/app.cpp +++ b/src/x11/app.cpp @@ -32,16 +32,10 @@ #include "wx/univ/theme.h" #include "wx/univ/renderer.h" -#define ABS(a) (((a) < 0) ? -(a) : (a)) - #if wxUSE_THREADS #include "wx/thread.h" #endif -#if wxUSE_WX_RESOURCES - #include "wx/resource.h" -#endif - #include "wx/x11/private.h" #include @@ -121,10 +115,6 @@ bool wxApp::Initialize() wxInitializeStockLists(); wxInitializeStockObjects(); -#if wxUSE_WX_RESOURCES - wxInitializeResourceSystem(); -#endif - wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER); wxClientWidgetHashTable = new wxHashTable(wxKEY_INTEGER); @@ -143,10 +133,6 @@ void wxApp::CleanUp() wxModule::CleanUpModules(); -#if wxUSE_WX_RESOURCES - wxCleanUpResourceSystem(); -#endif - delete wxTheColourDatabase; wxTheColourDatabase = NULL; @@ -239,7 +225,7 @@ int wxEntryStart( int& argc, char *argv[] ) } - // X11 display stuff + // X11 display stuff Display* xdisplay = XOpenDisplay( displayName ); if (!xdisplay) { @@ -251,7 +237,7 @@ int wxEntryStart( int& argc, char *argv[] ) XSynchronize(xdisplay, True); wxApp::ms_display = (WXDisplay*) xdisplay; - + XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask); // Misc. @@ -260,7 +246,7 @@ int wxEntryStart( int& argc, char *argv[] ) #if wxUSE_UNICODE // Glib's type system required by Pango g_type_init(); -#endif +#endif if (!wxApp::Initialize()) return -1; @@ -392,19 +378,14 @@ wxApp::wxApp() m_initialSize = wxDefaultSize; #if !wxUSE_NANOX - m_visualColormap = NULL; - m_colorCube = NULL; + m_visualInfo = NULL; #endif } wxApp::~wxApp() { #if !wxUSE_NANOX - if (m_colorCube) - free( m_colorCube ); - - if (m_visualColormap) - delete [] (XColor*)m_visualColormap; + delete m_visualInfo; #endif } @@ -976,24 +957,6 @@ void wxApp::DeletePendingObjects() } } -static void wxCalcPrecAndShift( unsigned long mask, int *shift, int *prec ) -{ - *shift = 0; - *prec = 0; - - while (!(mask & 0x1)) - { - (*shift)++; - mask >>= 1; - } - - while (mask & 0x1) - { - (*prec)++; - mask >>= 1; - } -} - // Create display, and other initialization bool wxApp::OnInitGui() { @@ -1010,99 +973,8 @@ bool wxApp::OnInitGui() m_maxRequestSize = XMaxRequestSize( (Display*) wxApp::GetDisplay() ); #if !wxUSE_NANOX - // Get info about the current visual. It is enough - // to do this once here unless we support different - // visuals, displays and screens. Given that wxX11 - // mostly for embedded things, that is no real - // limitation. - Display *xdisplay = (Display*) wxApp::GetDisplay(); - int xscreen = DefaultScreen(xdisplay); - Visual* xvisual = DefaultVisual(xdisplay,xscreen); - int xdepth = DefaultDepth(xdisplay, xscreen); - - XVisualInfo vinfo_template; - vinfo_template.visual = xvisual; - vinfo_template.visualid = XVisualIDFromVisual( xvisual ); - vinfo_template.depth = xdepth; - - int nitem = 0; - XVisualInfo *vi = XGetVisualInfo( xdisplay, VisualIDMask|VisualDepthMask, &vinfo_template, &nitem ); - wxASSERT_MSG( vi, wxT("No visual info") ); - - m_visualType = vi->visual->c_class; - m_visualScreen = vi->screen; - - m_visualRedMask = vi->red_mask; - m_visualGreenMask = vi->green_mask; - m_visualBlueMask = vi->blue_mask; - - if (m_visualType != GrayScale && m_visualType != PseudoColor) - { - wxCalcPrecAndShift( m_visualRedMask, &m_visualRedShift, &m_visualRedPrec ); - wxCalcPrecAndShift( m_visualGreenMask, &m_visualGreenShift, &m_visualGreenPrec ); - wxCalcPrecAndShift( m_visualBlueMask, &m_visualBlueShift, &m_visualBluePrec ); - } - - m_visualDepth = xdepth; - if (xdepth == 16) - xdepth = m_visualRedPrec + m_visualGreenPrec + m_visualBluePrec; - - m_visualColormapSize = vi->colormap_size; - - XFree( vi ); - - if (m_visualDepth > 8) - return TRUE; - - m_visualColormap = new XColor[m_visualColormapSize]; - XColor* colors = (XColor*) m_visualColormap; - - for (int i = 0; i < m_visualColormapSize; i++) - colors[i].pixel = i; - - XQueryColors( xdisplay, DefaultColormap(xdisplay,xscreen), colors, m_visualColormapSize ); - - m_colorCube = (unsigned char*)malloc(32 * 32 * 32); - - for (int r = 0; r < 32; r++) - { - for (int g = 0; g < 32; g++) - { - for (int b = 0; b < 32; b++) - { - int rr = (r << 3) | (r >> 2); - int gg = (g << 3) | (g >> 2); - int bb = (b << 3) | (b >> 2); - - int index = -1; - - if (colors) - { - int max = 3 * 65536; - - for (int i = 0; i < m_visualColormapSize; i++) - { - int rdiff = ((rr << 8) - colors[i].red); - int gdiff = ((gg << 8) - colors[i].green); - int bdiff = ((bb << 8) - colors[i].blue); - int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff); - if (sum < max) - { - index = i; max = sum; - } - } - } - else - { - // assume 8-bit true or static colors. this really exists - index = (r >> (5 - m_visualRedPrec)) << m_visualRedShift; - index |= (g >> (5 - m_visualGreenPrec)) << m_visualGreenShift; - index |= (b >> (5 - m_visualBluePrec)) << m_visualBlueShift; - } - m_colorCube[ (r*1024) + (g*32) + b ] = index; - } - } - } + m_visualInfo = new wxXVisualInfo; + wxFillXVisualInfo( m_visualInfo, (Display*) wxApp::GetDisplay() ); #endif return TRUE; @@ -1119,9 +991,9 @@ PangoContext* wxApp::GetPangoContext() static PangoContext *ret = NULL; if (ret) return ret; - + Display *xdisplay = (Display*) wxApp::GetDisplay(); - + #if 1 int xscreen = DefaultScreen(xdisplay); static int use_xft = -1; @@ -1130,16 +1002,16 @@ PangoContext* wxApp::GetPangoContext() wxString val = wxGetenv( L"GDK_USE_XFT" ); use_xft = (val == L"1"); } - + if (use_xft) ret = pango_xft_get_context( xdisplay, xscreen ); else #endif ret = pango_x_get_context( xdisplay ); - + if (!PANGO_IS_CONTEXT(ret)) wxLogError( wxT("No pango context.") ); - + return ret; } #endif @@ -1240,7 +1112,7 @@ bool wxApp::Yield(bool onlyIfNeeded) // Call dispatch at least once so that sockets // can be tested wxTheApp->Dispatch(); - + while (wxTheApp && wxTheApp->Pending()) wxTheApp->Dispatch();