Added some XSyncs to help size calculations, but positioning

dialog remains a mystery


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14208 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2002-02-14 18:06:50 +00:00
parent 99ee04b97b
commit 3a0b23eb74
9 changed files with 131 additions and 61 deletions

View File

@@ -15,8 +15,7 @@
#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
@@ -49,21 +48,12 @@ extern char wxFindMnemonic(const char* s);
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);
@@ -117,24 +107,5 @@ private:
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_

View File

@@ -38,18 +38,6 @@ extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore)
// 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)
@@ -74,5 +62,8 @@ void wxAllocColor(Display *display,Colormap colormap,XColor *xcolor);
wxString wxGetXEventName(XEvent& event);
#endif
// Is the window visible?
bool wxWindowIsVisible(Window win);
#endif
// _WX_PRIVX_H_

View File

@@ -78,6 +78,10 @@ protected:
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;

View File

@@ -156,11 +156,10 @@ protected:
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;

View File

@@ -417,6 +417,7 @@ wxControlRenderer::wxControlRenderer(wxWindow *window,
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());

View File

@@ -66,14 +66,6 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
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 *);
@@ -179,9 +171,7 @@ int wxEntryStart( int& argc, char *argv[] )
/// 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);
@@ -414,6 +404,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
}
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);;

View File

@@ -457,6 +457,7 @@ void wxTopLevelWindowX11::DoGetClientSize( int *width, int *height ) const
void wxTopLevelWindowX11::DoSetClientSize(int width, int height)
{
wxWindowX11::DoSetClientSize(width, height);
#if 0
if (!GetMainWindow())
return;
@@ -478,3 +479,90 @@ void wxTopLevelWindowX11::DoSetClientSize(int width, int height)
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;
}
}
}

View File

@@ -1231,3 +1231,11 @@ void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, boo
#endif
// __WXMOTIF__
bool wxWindowIsVisible(Window win)
{
XWindowAttributes wa;
XGetWindowAttributes(wxGlobalDisplay(), win, &wa);
return (wa.map_state == IsViewable);
}

View File

@@ -93,12 +93,10 @@ void wxWindowX11::Init()
// X11-specific
m_mainWidget = (WXWindow) 0;
m_winCaptured = FALSE;
m_needsInputFocus = FALSE;
m_isShown = TRUE;
m_isBeingDeleted = FALSE;
m_lastTS = 0;
m_lastButton = 0;
}
@@ -210,7 +208,15 @@ void wxWindowX11::SetFocus()
wxCHECK_RET( xwindow, wxT("invalid window") );
if (wxWindowIsVisible(xwindow))
{
XSetInputFocus( wxGlobalDisplay(), xwindow, RevertToParent, CurrentTime );
m_needsInputFocus = FALSE;
}
else
{
m_needsInputFocus = TRUE;
}
}
// Get the window with the focus
@@ -651,6 +657,7 @@ void wxWindowX11::DoGetSize(int *x, int *y) const
wxCHECK_RET( xwindow, wxT("invalid window") );
XSync(wxGlobalDisplay(), False);
XWindowAttributes attr;
Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr );
wxASSERT(status);
@@ -667,6 +674,7 @@ void wxWindowX11::DoGetPosition(int *x, int *y) const
Window window = (Window) m_mainWidget;
if (window)
{
XSync(wxGlobalDisplay(), False);
XWindowAttributes attr;
Status status = XGetWindowAttributes(wxGlobalDisplay(), window, & attr);
wxASSERT(status);
@@ -720,6 +728,7 @@ void wxWindowX11::DoGetClientSize(int *x, int *y) const
if (window)
{
XSync(wxGlobalDisplay(), False);
XWindowAttributes attr;
Status status = XGetWindowAttributes( wxGlobalDisplay(), window, &attr );
wxASSERT(status);
@@ -767,6 +776,7 @@ void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
valueMask, & windowChanges);
XSync(wxGlobalDisplay(), False);
}
void wxWindowX11::DoSetClientSize(int width, int height)
@@ -789,6 +799,7 @@ 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
@@ -1040,6 +1051,10 @@ void wxWindowX11::OnInternalIdle()
// 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();
}
// ----------------------------------------------------------------------------