#include "wx/defs.h"
#include "X11/Xlib.h"
-class wxMouseEvent;
-class wxKeyEvent;
+#include "wx/x11/privx.h"
// Put any private declarations here: native Motif types may be used because
// this header is included after Xm/Xm.h
extern char * wxFindAccelerator (const char *s);
extern XmString wxFindAcceleratorText (const char *s);
-extern int wxCharCodeXToWX(KeySym keySym);
-extern KeySym wxCharCodeWXToX(int id);
-
// ----------------------------------------------------------------------------
// TranslateXXXEvent() functions - translate Motif event to wxWindow one
// ----------------------------------------------------------------------------
extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent);
extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent);
-int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap);
-Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
-
-extern XColor g_itemColors[];
-extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore);
-
extern void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
extern void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
extern "C" XtAppContext wxGetAppContext();
-#define wxMAX_RGB 0xff
-#define wxMAX_SV 1000
-#define wxSIGN(x) ((x < 0) ? -x : x)
-#define wxH_WEIGHT 4
-#define wxS_WEIGHT 1
-#define wxV_WEIGHT 2
-
-typedef struct wx_hsv {
- int h,s,v;
- } wxHSV;
-
-#define wxMax3(x,y,z) ((x > y) ? ((x > z) ? x : z) : ((y > z) ? y : z))
-#define wxMin3(x,y,z) ((x < y) ? ((x < z) ? x : z) : ((y < z) ? y : z))
-
-void wxHSVToXColor(wxHSV *hsv,XColor *xcolor);
-void wxXColorToHSV(wxHSV *hsv,XColor *xcolor);
-void wxAllocNearestColor(Display *display,Colormap colormap,XColor *xcolor);
-void wxAllocColor(Display *display,Colormap colormap,XColor *xcolor);
-
#endif
// _WX_PRIVATE_H_
// For convenience
inline Display* wxGlobalDisplay() { return (Display*) wxGetDisplay(); }
-#define wxNO_COLORS 0x00
-#define wxBACK_COLORS 0x01
-#define wxFORE_COLORS 0x02
-
-extern XColor itemColors[5] ;
-
-#define wxBACK_INDEX 0
-#define wxFORE_INDEX 1
-#define wxSELE_INDEX 2
-#define wxTOPS_INDEX 3
-#define wxBOTS_INDEX 4
-
#define wxMAX_RGB 0xff
#define wxMAX_SV 1000
#define wxSIGN(x) ((x < 0) ? -x : x)
wxString wxGetXEventName(XEvent& event);
#endif
+// Is the window visible?
+bool wxWindowIsVisible(Window win);
+
#endif
// _WX_PRIVX_H_
virtual void DoGetClientSize( int *width, int *height ) const;
virtual void DoSetClientSize(int width, int height);
+ virtual void DoSetSize(int x, int y,
+ int width, int height,
+ int sizeFlags = wxSIZE_AUTO);
+ virtual void DoGetPosition( int *x, int *y ) const;
// is the frame currently iconized?
bool m_iconized;
protected:
WXWindow m_mainWidget;
-
wxRegion m_clearRegion;
bool m_clipPaintRegion;
-
bool m_winCaptured; // ????
+ bool m_needsInputFocus; // Input focus set in OnIdle
// implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const;
void wxControlRenderer::DrawLabel(const wxBitmap& bitmap,
wxCoord marginX, wxCoord marginY)
{
+ m_dc.SetBackgroundMode(wxTRANSPARENT);
m_dc.SetFont(m_window->GetFont());
m_dc.SetTextForeground(m_window->GetForegroundColour());
EVT_IDLE(wxApp::OnIdle)
END_EVENT_TABLE()
-static const wxCmdLineEntryDesc g_cmdLineDesc[] =
-{
- { wxCMD_LINE_SWITCH, "sync", "sync", "synchronize the display" },
- { wxCMD_LINE_OPTION, "display", "display", "use the given display", wxCMD_LINE_VAL_STRING },
-
- { wxCMD_LINE_NONE }
-};
-
#ifdef __WXDEBUG__
typedef int (*XErrorHandlerFunc)(Display *, XErrorEvent *);
/// TODO
#if 0
- // Parse the arguments. Is it OK to use the command line
- // parser before calling Initialize?
- wxCmdLineParser cmdLine(argv, argv);
+ // Parse the arguments.
#endif
Display* xdisplay = XOpenDisplay(NULL);
return;
}
case ClientMessage:
- {
+ {
+ if (win && !win->IsEnabled())
+ return;
+
Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True);;
Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True);;
void wxTopLevelWindowX11::DoSetClientSize(int width, int height)
{
wxWindowX11::DoSetClientSize(width, height);
+
#if 0
if (!GetMainWindow())
return;
valueMask, & windowChanges);
#endif
}
+
+void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
+{
+ wxString msg;
+ msg.Printf("Setting pos: %d, %d", x, y);
+ wxLogDebug(msg);
+ wxWindowX11::DoSetSize(x, y, width, height, sizeFlags);
+
+ wxPoint pt = GetPosition();
+ msg.Printf("After, pos: %d, %d", pt.x, pt.y);
+ wxLogDebug(msg);
+#if 0
+ XSync(wxGlobalDisplay(), False);
+ int w, h;
+ GetSize(& w, & h);
+ wxString msg;
+ msg.Printf("Before setting size: %d, %d", w, h);
+ wxLogDebug(msg);
+ if (!GetMainWindow())
+ return;
+
+ XWindowChanges windowChanges;
+ int valueMask = 0;
+
+ if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ int yy = 0;
+ AdjustForParentClientOrigin( x, yy, sizeFlags);
+ windowChanges.x = x;
+ valueMask |= CWX;
+ }
+ if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ int xx = 0;
+ AdjustForParentClientOrigin( xx, y, sizeFlags);
+ windowChanges.y = y;
+ valueMask |= CWY;
+ }
+ if (width != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ windowChanges.width = width /* - m_borderSize*2 */;
+ valueMask |= CWWidth;
+ }
+ if (height != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ windowChanges.height = height /* -m_borderSize*2*/;
+ valueMask |= CWHeight;
+ }
+
+ XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
+ valueMask, & windowChanges);
+ XSync(wxGlobalDisplay(), False);
+ GetSize(& w, & h);
+ msg.Printf("Tried to set to %d, %d. After setting size: %d, %d", width, height, w, h);
+ wxLogDebug(msg);
+#endif
+}
+
+void wxTopLevelWindowX11::DoGetPosition(int *x, int *y) const
+{
+ XSync(wxGlobalDisplay(), False);
+ Window window = (Window) m_mainWidget;
+ if (window)
+ {
+ int offsetX = 0;
+ int offsetY = 0;
+
+ wxLogDebug("Translating...");
+ Window childWindow;
+ XTranslateCoordinates(wxGlobalDisplay(), window, XDefaultRootWindow(wxGlobalDisplay()),
+ 0, 0, & offsetX, & offsetY, & childWindow);
+
+ wxString msg;
+ msg.Printf("Offset: %d, %d", offsetX, offsetY);
+ wxLogDebug(msg);
+
+ XWindowAttributes attr;
+ Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
+ wxASSERT(status);
+
+ if (status)
+ {
+ *x = attr.x + offsetX;
+ *y = attr.y + offsetY;
+ }
+ }
+}
#endif
// __WXMOTIF__
+
+bool wxWindowIsVisible(Window win)
+{
+ XWindowAttributes wa;
+ XGetWindowAttributes(wxGlobalDisplay(), win, &wa);
+
+ return (wa.map_state == IsViewable);
+}
// X11-specific
m_mainWidget = (WXWindow) 0;
-
m_winCaptured = FALSE;
-
+ m_needsInputFocus = FALSE;
m_isShown = TRUE;
m_isBeingDeleted = FALSE;
-
m_lastTS = 0;
m_lastButton = 0;
}
Window xwindow = (Window) GetMainWindow();
wxCHECK_RET( xwindow, wxT("invalid window") );
-
- XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
+
+ if (wxWindowIsVisible(xwindow))
+ {
+ XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
+ m_needsInputFocus = FALSE;
+ }
+ else
+ {
+ m_needsInputFocus = TRUE;
+ }
}
// Get the window with the focus
wxCHECK_RET( xwindow, wxT("invalid window") );
+ XSync(wxGlobalDisplay(), False);
XWindowAttributes attr;
Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr );
wxASSERT(status);
Window window = (Window) m_mainWidget;
if (window)
{
+ XSync(wxGlobalDisplay(), False);
XWindowAttributes attr;
Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
wxASSERT(status);
if (window)
{
+ XSync(wxGlobalDisplay(), False);
XWindowAttributes attr;
Status status = XGetWindowAttributes( wxGlobalDisplay(), window, &attr );
wxASSERT(status);
XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
valueMask, & windowChanges);
+ XSync(wxGlobalDisplay(), False);
}
void wxWindowX11::DoSetClientSize(int width, int height)
}
XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
valueMask, & windowChanges);
+ XSync(wxGlobalDisplay(), False);
}
// For implementation purposes - sometimes decorations make the client area
// This calls the UI-update mechanism (querying windows for
// menu/toolbar/control state information)
UpdateWindowUI();
+
+ // Set the input focus if couldn't do it before
+ if (m_needsInputFocus)
+ SetFocus();
}
// ----------------------------------------------------------------------------