Window xparent = RootWindow( xdisplay, xscreen );
XSetWindowAttributes xattributes;
- XSizeHints size_hints;
- XWMHints wm_hints;
long xattributes_mask =
CWOverrideRedirect |
m_mainWidget = (WXWindow) xwindow;
wxAddWindowToTable( xwindow, (wxWindow*) this );
- // Probably shouldn't be here for an unmanaged window
- //XSetTransientForHint( xdisplay, xwindow, xparent );
-
- // TODO: Will these calls cause decoration??
+ XSetTransientForHint( xdisplay, xwindow, xparent );
- size_hints.flags = PSize;
- size_hints.width = size.x;
- size_hints.height = size.y;
- XSetWMNormalHints( xdisplay, xwindow, &size_hints);
-
+ XWMHints wm_hints;
wm_hints.flags = InputHint | StateHint /* | WindowGroupHint */;
wm_hints.input = True;
wm_hints.initial_state = NormalState;
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;
}
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
m_mainWidget = (WXWindow) window;
// Select event types wanted
- XSelectInput(wxGlobalDisplay(), window,
+ XSelectInput( wxGlobalDisplay(), window,
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
KeymapStateMask | FocusChangeMask | ColormapChangeMask | StructureNotifyMask |
void wxWindowX11::SetFocus()
{
- Window wMain = (Window) GetMainWindow();
- if (wMain)
- {
- // TODO: set a m_needInputFocus flag and do the
- // the setting in OnIdle or Show, because we can't
- // 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
- }
+ Window xwindow = (Window) GetMainWindow();
+
+ wxCHECK_RET( xwindow, wxT("invalid window") );
+
+ XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
}
// Get the window with the focus
wxWindow *wxWindowBase::FindFocus()
{
- Window wFocus = (Window) 0;
+ Window xfocus = (Window) 0;
int revert = 0;
- XGetInputFocus(wxGlobalDisplay(), & wFocus, & revert);
- if (wFocus)
+ XGetInputFocus( wxGlobalDisplay(), &xfocus, &revert);
+ if (xfocus)
{
- wxWindow *win = NULL;
- do
- {
- win = wxGetWindowFromTable(wFocus);
- wFocus = wxGetWindowParent(wFocus);
- } while (wFocus && !win);
+ wxWindow *win = wxGetWindowFromTable( xfocus );
return win;
}
Window xwindow = (Window) GetMainWindow();
+ wxCHECK_RET( xwindow, wxT("invalid window") );
+
g_captureWindow = (wxWindow*) this;
if (xwindow)
return FALSE;
}
- wxCursor* cursor2 = NULL;
+ Window xwindow = (Window) GetMainWindow();
+
+ wxCHECK_MSG( xwindow, FALSE, wxT("invalid window") );
+
+ wxCursor cursorToUse;
if (m_cursor.Ok())
- cursor2 = & m_cursor;
+ cursorToUse = m_cursor;
else
- cursor2 = wxSTANDARD_CURSOR;
+ cursorToUse = *wxSTANDARD_CURSOR;
- WXCursor x_cursor = cursor2->GetCursor();
+ Cursor xcursor = (Cursor) cursorToUse.GetCursor();
- Window win = (Window) GetMainWindow();
- XDefineCursor((Display*) wxGlobalDisplay(), win, (Cursor) x_cursor);
+ XDefineCursor( (Display*) wxGlobalDisplay(), xwindow, xcursor );
return TRUE;
}
// Coordinates relative to the window
void wxWindowX11::WarpPointer (int x, int y)
{
- if (m_mainWidget)
- XWarpPointer( wxGlobalDisplay(), None, (Window) m_mainWidget, 0, 0, 0, 0, x, y);
+ Window xwindow = (Window) GetMainWindow();
+
+ wxCHECK_RET( xwindow, wxT("invalid window") );
+
+ XWarpPointer( wxGlobalDisplay(), None, xwindow, 0, 0, 0, 0, x, y);
}
// Does a physical scroll
// Get total size
void wxWindowX11::DoGetSize(int *x, int *y) const
{
- Window window = (Window) m_mainWidget;
- if (window)
- {
- XWindowAttributes attr;
- Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
- wxASSERT(status);
+ Window xwindow = (Window) GetMainWindow();
+
+ wxCHECK_RET( xwindow, wxT("invalid window") );
+
+ XWindowAttributes attr;
+ Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr );
+ wxASSERT(status);
- if (status)
- {
- *x = attr.width /* + 2*m_borderSize */ ;
- *y = attr.height /* + 2*m_borderSize */ ;
- }
+ if (status)
+ {
+ *x = attr.width /* + 2*m_borderSize */ ;
+ *y = attr.height /* + 2*m_borderSize */ ;
}
}
// 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)
{
wxWindowBase::SetBackgroundColour(col);