Some clean-ups which don't really solve any problem yet.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14201 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-02-14 13:13:08 +00:00
parent 307be31a92
commit 86fd8bda38
3 changed files with 52 additions and 129 deletions

View File

@@ -703,6 +703,10 @@ WXColormap wxApp::GetMainColormap(WXDisplay* display)
Window wxGetWindowParent(Window window) Window wxGetWindowParent(Window window)
{ {
wxASSERT_MSG( window, "invalid window" );
return (Window) 0;
Window parent, root = 0; Window parent, root = 0;
unsigned int noChildren = 0; unsigned int noChildren = 0;
Window* children = NULL; Window* children = NULL;

View File

@@ -55,8 +55,6 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
Window xparent = RootWindow( xdisplay, xscreen ); Window xparent = RootWindow( xdisplay, xscreen );
XSetWindowAttributes xattributes; XSetWindowAttributes xattributes;
XSizeHints size_hints;
XWMHints wm_hints;
long xattributes_mask = long xattributes_mask =
CWOverrideRedirect | CWOverrideRedirect |
@@ -79,29 +77,14 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
m_mainWidget = (WXWindow) xwindow; m_mainWidget = (WXWindow) xwindow;
wxAddWindowToTable( xwindow, (wxWindow*) this ); wxAddWindowToTable( xwindow, (wxWindow*) this );
// Probably shouldn't be here for an unmanaged window XSetTransientForHint( xdisplay, xwindow, xparent );
//XSetTransientForHint( xdisplay, xwindow, xparent );
// TODO: Will these calls cause decoration?? XWMHints wm_hints;
size_hints.flags = PSize;
size_hints.width = size.x;
size_hints.height = size.y;
XSetWMNormalHints( xdisplay, xwindow, &size_hints);
wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */; wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */;
wm_hints.input = True; wm_hints.input = True;
wm_hints.initial_state = NormalState; wm_hints.initial_state = NormalState;
XSetWMHints( xdisplay, xwindow, &wm_hints); XSetWMHints( xdisplay, xwindow, &wm_hints);
// No decorations for this window
#if 0
Atom wm_delete_window = XInternAtom( xdisplay, "WM_DELETE_WINDOW", False);
XSetWMProtocols( xdisplay, xwindow, &wm_delete_window, 1);
wxSetWMDecorations((Window) GetMainWindow(), style);
#endif
return TRUE; return TRUE;
} }
@@ -117,7 +100,15 @@ void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlag
bool wxPopupWindow::Show( bool show ) bool wxPopupWindow::Show( bool show )
{ {
return wxWindowX11::Show( show ); bool ret = wxWindowX11::Show( show );
#if 0
int x,y;
GetSize( &x, &y );
printf( "popup size %d, %d\n", x, y );
#endif
return ret;
} }
#endif // wxUSE_POPUPWIN #endif // wxUSE_POPUPWIN

View File

@@ -148,7 +148,7 @@ bool wxWindowX11::Create(wxWindow *parent, wxWindowID id,
m_mainWidget = (WXWindow) window; m_mainWidget = (WXWindow) window;
// Select event types wanted // Select event types wanted
XSelectInput(wxGlobalDisplay(), window, XSelectInput( wxGlobalDisplay(), window,
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask | KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
@@ -206,40 +206,23 @@ wxWindowX11::~wxWindowX11()
void wxWindowX11::SetFocus() void wxWindowX11::SetFocus()
{ {
Window wMain = (Window) GetMainWindow(); Window xwindow = (Window) GetMainWindow();
if (wMain)
{ wxCHECK_RET( xwindow, wxT("invalid window") );
// TODO: set a m_needInputFocus flag and do the
// the setting in OnIdle or Show, because we can't XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
// set the focus for an unmapped window.
// We need to figure out how to find out if the window
// is mapped.
#if 0
XSetInputFocus(wxGlobalDisplay(), wMain, RevertToParent, CurrentTime);
XWMHints wmhints;
wmhints.flags = InputHint;
wmhints.input = True;
XSetWMHints(wxGlobalDisplay(), wMain, &wmhints);
#endif
}
} }
// Get the window with the focus // Get the window with the focus
wxWindow *wxWindowBase::FindFocus() wxWindow *wxWindowBase::FindFocus()
{ {
Window wFocus = (Window) 0; Window xfocus = (Window) 0;
int revert = 0; int revert = 0;
XGetInputFocus(wxGlobalDisplay(), & wFocus, & revert); XGetInputFocus( wxGlobalDisplay(), &xfocus, &revert);
if (wFocus) if (xfocus)
{ {
wxWindow *win = NULL; wxWindow *win = wxGetWindowFromTable( xfocus );
do
{
win = wxGetWindowFromTable(wFocus);
wFocus = wxGetWindowParent(wFocus);
} while (wFocus && !win);
return win; return win;
} }
@@ -313,6 +296,8 @@ void wxWindowX11::DoCaptureMouse()
Window xwindow = (Window) GetMainWindow(); Window xwindow = (Window) GetMainWindow();
wxCHECK_RET( xwindow, wxT("invalid window") );
g_captureWindow = (wxWindow*) this; g_captureWindow = (wxWindow*) this;
if (xwindow) if (xwindow)
@@ -422,16 +407,19 @@ bool wxWindowX11::SetCursor(const wxCursor& cursor)
return FALSE; return FALSE;
} }
wxCursor* cursor2 = NULL; Window xwindow = (Window) GetMainWindow();
wxCHECK_MSG( xwindow, FALSE, wxT("invalid window") );
wxCursor cursorToUse;
if (m_cursor.Ok()) if (m_cursor.Ok())
cursor2 = & m_cursor; cursorToUse = m_cursor;
else else
cursor2 = wxSTANDARD_CURSOR; cursorToUse = *wxSTANDARD_CURSOR;
WXCursor x_cursor = cursor2->GetCursor(); Cursor xcursor = (Cursor) cursorToUse.GetCursor();
Window win = (Window) GetMainWindow(); XDefineCursor( (Display*) wxGlobalDisplay(), xwindow, xcursor );
XDefineCursor((Display*) wxGlobalDisplay(), win, (Cursor) x_cursor);
return TRUE; return TRUE;
} }
@@ -439,8 +427,11 @@ bool wxWindowX11::SetCursor(const wxCursor& cursor)
// Coordinates relative to the window // Coordinates relative to the window
void wxWindowX11::WarpPointer (int x, int y) void wxWindowX11::WarpPointer (int x, int y)
{ {
if (m_mainWidget) Window xwindow = (Window) GetMainWindow();
XWarpPointer( wxGlobalDisplay(), None, (Window) m_mainWidget, 0, 0, 0, 0, x, y);
wxCHECK_RET( xwindow, wxT("invalid window") );
XWarpPointer( wxGlobalDisplay(), None, xwindow, 0, 0, 0, 0, x, y);
} }
// Does a physical scroll // Does a physical scroll
@@ -656,18 +647,18 @@ bool wxWindowX11::PreResize()
// Get total size // Get total size
void wxWindowX11::DoGetSize(int *x, int *y) const void wxWindowX11::DoGetSize(int *x, int *y) const
{ {
Window window = (Window) m_mainWidget; Window xwindow = (Window) GetMainWindow();
if (window)
{ wxCHECK_RET( xwindow, wxT("invalid window") );
XWindowAttributes attr;
Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr); XWindowAttributes attr;
wxASSERT(status); Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr );
wxASSERT(status);
if (status) if (status)
{ {
*x = attr.width /* + 2*m_borderSize */ ; *x = attr.width /* + 2*m_borderSize */ ;
*y = attr.height /* + 2*m_borderSize */ ; *y = attr.height /* + 2*m_borderSize */ ;
}
} }
} }
@@ -1281,69 +1272,6 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Window WXUNUSED(win
// Colour stuff // Colour stuff
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if 0
#define YAllocColor XAllocColor
XColor g_itemColors[5];
int wxComputeColours (Display *display, wxColour * back, wxColour * fore)
{
int result;
static XmColorProc colorProc;
result = wxNO_COLORS;
if (back)
{
g_itemColors[0].red = (((long) back->Red ()) << 8);
g_itemColors[0].green = (((long) back->Green ()) << 8);
g_itemColors[0].blue = (((long) back->Blue ()) << 8);
g_itemColors[0].flags = DoRed | DoGreen | DoBlue;
if (colorProc == (XmColorProc) NULL)
{
// Get a ptr to the actual function
colorProc = XmSetColorCalculation ((XmColorProc) NULL);
// And set it back to motif.
XmSetColorCalculation (colorProc);
}
(*colorProc) (&g_itemColors[wxBACK_INDEX],
&g_itemColors[wxFORE_INDEX],
&g_itemColors[wxSELE_INDEX],
&g_itemColors[wxTOPS_INDEX],
&g_itemColors[wxBOTS_INDEX]);
result = wxBACK_COLORS;
}
if (fore)
{
g_itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8);
g_itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8);
g_itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8);
g_itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue;
if (result == wxNO_COLORS)
result = wxFORE_COLORS;
}
Display *dpy = display;
Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy);
if (back)
{
/* 5 Colours to allocate */
for (int i = 0; i < 5; i++)
if (!YAllocColor (dpy, cmap, &g_itemColors[i]))
result = wxNO_COLORS;
}
else if (fore)
{
/* Only 1 colour to allocate */
if (!YAllocColor (dpy, cmap, &g_itemColors[wxFORE_INDEX]))
result = wxNO_COLORS;
}
return (result);
}
#endif
bool wxWindowX11::SetBackgroundColour(const wxColour& col) bool wxWindowX11::SetBackgroundColour(const wxColour& col)
{ {
wxWindowBase::SetBackgroundColour(col); wxWindowBase::SetBackgroundColour(col);