From 8601b2e15bf924d4be6b7843064028e514a71ec8 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 1 Apr 2002 14:09:44 +0000 Subject: [PATCH] Modifications to get wxNanoX compiling again git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14884 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/x11/app.h | 4 +- src/univ/menu.cpp | 2 +- src/unix/utilsx11.cpp | 2 + src/x11/app.cpp | 8 +++- src/x11/bitmap.cpp | 4 +- src/x11/colour.cpp | 5 ++- src/x11/popupwin.cpp | 56 +++++++++++++++++++++++----- src/x11/window.cpp | 85 ++++++++++++++++++++++++++++--------------- 8 files changed, 120 insertions(+), 46 deletions(-) diff --git a/include/wx/x11/app.h b/include/wx/x11/app.h index 4eab1ecb67..0a689ed00f 100644 --- a/include/wx/x11/app.h +++ b/include/wx/x11/app.h @@ -107,7 +107,8 @@ public: static long sm_lastMessageTime; bool m_showIconic; wxSize m_initialSize; - + +#if !wxUSE_NANOX // Someone find a better place for these int m_visualType; // TrueColor, DirectColor etc. int m_visualDepth; @@ -125,6 +126,7 @@ public: int m_visualBluePrec; unsigned char *m_colorCube; +#endif protected: bool m_keepGoing; diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index 6a64d031b9..1a70ef1eb4 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -2242,7 +2242,7 @@ void wxMenuBar::PopupCurrentMenu(bool selectFirst) wxCHECK_RET( m_current != -1, _T("no menu to popup") ); // forgot to call DismissMenu()? - wxASSERT_MSG( !m_menuShown, _T("shouldn't show two menu at once!") ); + wxASSERT_MSG( !m_menuShown, _T("shouldn't show two menus at once!") ); // in any case, we should show it - even if we won't m_shouldShowMenu = TRUE; diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp index d09ae24992..360d59df7e 100644 --- a/src/unix/utilsx11.cpp +++ b/src/unix/utilsx11.cpp @@ -28,6 +28,7 @@ void wxSetIconsX11( WXDisplay* display, WXWindow window, const wxIconBundle& ib ) { +#if !wxUSE_NANOX size_t size = 0; size_t i, max = ib.m_icons.GetCount(); @@ -91,6 +92,7 @@ void wxSetIconsX11( WXDisplay* display, WXWindow window, (Window)window, net_wm_icon ); } +#endif } #endif diff --git a/src/x11/app.cpp b/src/x11/app.cpp index e923a61920..3408003de4 100644 --- a/src/x11/app.cpp +++ b/src/x11/app.cpp @@ -399,17 +399,21 @@ wxApp::wxApp() m_showIconic = FALSE; m_initialSize = wxDefaultSize; +#if !wxUSE_NANOX m_visualColormap = NULL; m_colorCube = NULL; +#endif } wxApp::~wxApp() { +#if !wxUSE_NANOX if (m_colorCube) free( m_colorCube ); if (m_visualColormap) delete [] (XColor*)m_visualColormap; +#endif } bool wxApp::Initialized() @@ -505,7 +509,7 @@ bool wxApp::ProcessXEvent(WXEvent* _event) { case Expose: { -#if wxUSE_TWO_WINDOWS +#if wxUSE_TWO_WINDOWS && !wxUSE_NANOX if (event->xexpose.window != (Window)win->GetClientWindow()) { XEvent tmp_event; @@ -989,6 +993,7 @@ 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 @@ -1082,6 +1087,7 @@ bool wxApp::OnInitGui() } } } +#endif return TRUE; } diff --git a/src/x11/bitmap.cpp b/src/x11/bitmap.cpp index a365ddf028..9659dc351c 100644 --- a/src/x11/bitmap.cpp +++ b/src/x11/bitmap.cpp @@ -733,14 +733,14 @@ wxImage wxBitmap::ConvertToImage() const Display *xdisplay = (Display*) M_BMPDATA->m_display; wxASSERT_MSG( xdisplay, wxT("No display") ); - - int bpp = wxTheApp->m_visualDepth; #if wxUSE_NANOX + //int bpp = DefaultDepth(xdisplay, xscreen); wxGetImageFromDrawable((Pixmap) GetPixmap(), 0, 0, GetWidth(), GetHeight(), image); return image; #else // !wxUSE_NANOX + int bpp = wxTheApp->m_visualDepth; XImage *x_image = NULL; if (GetPixmap()) { diff --git a/src/x11/colour.cpp b/src/x11/colour.cpp index 058c00d84d..e10c2f486b 100644 --- a/src/x11/colour.cpp +++ b/src/x11/colour.cpp @@ -92,7 +92,7 @@ void wxColourRefData::FreeColour() { if (!m_colormap) return; - +#if !wxUSE_NANOX if ((wxTheApp->m_visualType == GrayScale) || (wxTheApp->m_visualType == PseudoColor)) { @@ -105,6 +105,7 @@ void wxColourRefData::FreeColour() XFreeColors( wxGlobalDisplay(), (Colormap) m_colormap, &pixel, 1, 0 ); } } +#endif } void wxColourRefData::AllocColour( WXColormap cmap ) @@ -114,6 +115,7 @@ void wxColourRefData::AllocColour( WXColormap cmap ) FreeColour(); +#if !wxUSE_NANOX if ((wxTheApp->m_visualType == GrayScale) || (wxTheApp->m_visualType == PseudoColor)) { @@ -122,6 +124,7 @@ void wxColourRefData::AllocColour( WXColormap cmap ) colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] + 1; } else +#endif { m_hasPixel = XAllocColor( wxGlobalDisplay(), (Colormap) cmap, &m_color ); } diff --git a/src/x11/popupwin.cpp b/src/x11/popupwin.cpp index e27499f171..2fbf352a72 100644 --- a/src/x11/popupwin.cpp +++ b/src/x11/popupwin.cpp @@ -56,8 +56,6 @@ bool wxPopupWindow::Create( wxWindow *parent, int style ) Visual *xvisual = DefaultVisual( xdisplay, xscreen ); Window xparent = RootWindow( xdisplay, xscreen ); -#if !wxUSE_NANOX - #if wxUSE_TWO_WINDOWS bool need_two_windows = ((( wxSUNKEN_BORDER | wxRAISED_BORDER | wxSIMPLE_BORDER | wxHSCROLL | wxVSCROLL ) & m_windowStyle) != 0); @@ -65,6 +63,10 @@ bool wxPopupWindow::Create( wxWindow *parent, int style ) bool need_two_windows = FALSE; #endif +#if wxUSE_NANOX + long xattributes_mask = 0; +#else + XSetWindowAttributes xattributes; long xattributes_mask = 0; @@ -79,28 +81,42 @@ bool wxPopupWindow::Create( wxWindow *parent, int style ) xattributes.save_under = True; xattributes_mask |= CWEventMask; +#endif if (need_two_windows) { +#if !wxUSE_NANOX xattributes.event_mask = ExposureMask | StructureNotifyMask | ColormapChangeMask; - +#endif + Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y, 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); + +#if wxUSE_NANOX + XSelectInput( xdisplay, xwindow, + ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | + KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | + PropertyChangeMask ); +#endif + // Set background to None which will prevent X11 from clearing the + // background comletely. XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); m_mainWindow = (WXWindow) xwindow; wxAddWindowToTable( xwindow, (wxWindow*) this ); // XMapWindow( xdisplay, xwindow ); - +#if !wxUSE_NANOX xattributes.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | PropertyChangeMask | VisibilityChangeMask ; - +#endif + if (HasFlag( wxSUNKEN_BORDER) || HasFlag( wxRAISED_BORDER)) { pos2.x = 2; @@ -123,8 +139,18 @@ bool wxPopupWindow::Create( wxWindow *parent, int style ) xwindow = XCreateWindow( xdisplay, xwindow, pos2.x, pos2.y, size2.x, size2.y, 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); + // Set background to None which will prevent X11 from clearing the + // background comletely. XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); +#if wxUSE_NANOX + XSelectInput( xdisplay, xwindow, + ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | + KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | + PropertyChangeMask ); +#endif + m_clientWindow = (WXWindow) xwindow; wxAddClientWindowToTable( xwindow, (wxWindow*) this ); @@ -133,15 +159,28 @@ bool wxPopupWindow::Create( wxWindow *parent, int style ) } else { + // One window +#if !wxUSE_NANOX xattributes.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | PropertyChangeMask | VisibilityChangeMask ; - +#endif + Window xwindow = XCreateWindow( xdisplay, xparent, pos.x, pos.y, size.x, size.y, 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); - + +#if wxUSE_NANOX + XSelectInput( xdisplay, xwindow, + ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | + KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | + PropertyChangeMask ); +#endif + + // Set background to None which will prevent X11 from clearing the + // background comletely. XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); m_mainWindow = (WXWindow) xwindow; @@ -151,9 +190,6 @@ bool wxPopupWindow::Create( wxWindow *parent, int style ) m_isShown = FALSE; // XMapWindow( xdisplay, xwindow ); } -#else - fixme -#endif XSetTransientForHint( xdisplay, (Window) m_mainWindow, xparent ); diff --git a/src/x11/window.cpp b/src/x11/window.cpp index ce08b9fd81..493e7d51c3 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -168,8 +168,6 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, if (pos2.y == -1) pos2.y = 0; -#if !wxUSE_NANOX - #if wxUSE_TWO_WINDOWS bool need_two_windows = ((( wxSUNKEN_BORDER | wxRAISED_BORDER | wxSIMPLE_BORDER | wxHSCROLL | wxVSCROLL ) & m_windowStyle) != 0); @@ -177,6 +175,9 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, bool need_two_windows = FALSE; #endif +#if wxUSE_NANOX + long xattributes = 0; +#else XSetWindowAttributes xattributes; long xattributes_mask = 0; @@ -187,22 +188,41 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, xattributes.border_pixel = BlackPixel( xdisplay, xscreen ); xattributes_mask |= CWEventMask; +#endif if (need_two_windows) { +#if wxUSE_NANOX + long backColor, foreColor; + backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()); + foreColor = GR_RGB(m_foregroundColour.Red(), m_foregroundColour.Green(), m_foregroundColour.Blue()); + + Window xwindow = XCreateWindowWithColor( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, + 0, 0, InputOutput, xvisual, backColor, foreColor); + XSelectInput( xdisplay, xwindow, + GR_EVENT_MASK_CLOSE_REQ | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | + KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | + PropertyChangeMask ); + +#else + // Normal X11 xattributes.event_mask = ExposureMask | StructureNotifyMask | ColormapChangeMask; Window xwindow = XCreateWindow( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); - + +#endif + XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); m_mainWindow = (WXWindow) xwindow; wxAddWindowToTable( xwindow, (wxWindow*) this ); XMapWindow( xdisplay, xwindow ); - + +#if !wxUSE_NANOX xattributes.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | @@ -214,7 +234,8 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, xattributes_mask |= CWBitGravity; xattributes.bit_gravity = StaticGravity; } - +#endif + if (HasFlag( wxSUNKEN_BORDER) || HasFlag( wxRAISED_BORDER)) { pos2.x = 2; @@ -233,10 +254,23 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, pos2.x = 0; pos2.y = 0; } +#if wxUSE_NANOX + backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()); + foreColor = GR_RGB(m_foregroundColour.Red(), m_foregroundColour.Green(), m_foregroundColour.Blue()); + + xwindow = XCreateWindowWithColor( xdisplay, xwindow, pos2.x, pos2.y, size2.x, size2.y, + 0, 0, InputOutput, xvisual, backColor, foreColor); + XSelectInput( xdisplay, xwindow, + GR_EVENT_MASK_CLOSE_REQ | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | + KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | + PropertyChangeMask ); +#else xwindow = XCreateWindow( xdisplay, xwindow, pos2.x, pos2.y, size2.x, size2.y, 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); - +#endif + XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); m_clientWindow = (WXWindow) xwindow; @@ -247,7 +281,20 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, else { // wxLogDebug( "No two windows needed %s", GetName().c_str() ); +#if wxUSE_NANOX + long backColor, foreColor; + backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()); + foreColor = GR_RGB(m_foregroundColour.Red(), m_foregroundColour.Green(), m_foregroundColour.Blue()); + Window xwindow = XCreateWindowWithColor( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, + 0, 0, InputOutput, xvisual, backColor, foreColor); + XSelectInput( xdisplay, xwindow, + GR_EVENT_MASK_CLOSE_REQ | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | + ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | + KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | + PropertyChangeMask ); + +#else xattributes.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | @@ -262,7 +309,8 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, Window xwindow = XCreateWindow( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, 0, DefaultDepth(xdisplay,xscreen), InputOutput, xvisual, xattributes_mask, &xattributes ); - +#endif + XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); m_mainWindow = (WXWindow) xwindow; @@ -271,29 +319,6 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id, XMapWindow( xdisplay, xwindow ); } -#else - - int extraFlags = GR_EVENT_MASK_CLOSE_REQ; - - long backColor, foreColor; - backColor = GR_RGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()); - foreColor = GR_RGB(m_foregroundColour.Red(), m_foregroundColour.Green(), m_foregroundColour.Blue()); - - Window xwindow = XCreateWindowWithColor( xdisplay, xparent, pos2.x, pos2.y, size2.x, size2.y, - 0, 0, InputOutput, xvisual, backColor, foreColor); - XSelectInput( xdisplay, xwindow, - extraFlags | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | - KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | - PropertyChangeMask ); - - XSetWindowBackgroundPixmap( xdisplay, xwindow, None ); - - m_mainWindow = (WXWindow) xwindow; - wxAddWindowToTable( xwindow, (wxWindow*) this ); - - XMapWindow( xdisplay, xwindow ); -#endif // Is a subwindow, so map immediately m_isShown = TRUE; -- 2.45.2