New WM decoration code. It fails to resize dialogs

sometimes just like the previous versions.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-03-17 15:29:57 +00:00
parent 90f3fe56ee
commit 5268c5a32b
2 changed files with 60 additions and 81 deletions

View File

@@ -70,9 +70,9 @@ bool wxControl::Create(wxWindow *parent,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
// we use wxNO_FULL_REPAINT_ON_RESIZE by default as it results in much // Ee use wxNO_FULL_REPAINT_ON_RESIZE by default as it results in much
// less flicker and none of the standard controls needs to be entirely // less flicker and none of the standard controls needs to be entirely
// repainted after resize anyhow // repainted after resize anyhow.
if ( !wxControlBase::Create(parent, id, pos, size, if ( !wxControlBase::Create(parent, id, pos, size,
style | wxNO_FULL_REPAINT_ON_RESIZE, style | wxNO_FULL_REPAINT_ON_RESIZE,
validator, name) ) validator, name) )

View File

@@ -129,13 +129,6 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent,
xattributes.bit_gravity = StaticGravity; xattributes.bit_gravity = StaticGravity;
} }
// TODO: if we want no border, caption etc.,
// I think we set this to True to remove decorations
// No. RR.
// Yes :-) JACS (because some WMs don't respect
// the hints)
// xattributes.override_redirect = (style & wxNO_BORDER) ? True : False;
xattributes_mask |= CWEventMask; xattributes_mask |= CWEventMask;
xattributes.event_mask = xattributes.event_mask =
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
@@ -433,11 +426,11 @@ wxString wxTopLevelWindowX11::GetTitle() const
} }
#ifndef MWM_DECOR_BORDER #ifndef MWM_DECOR_BORDER
/* bit definitions for MwmHints.flags */
#define MWM_HINTS_FUNCTIONS (1L << 0) #define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1) #define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_HINTS_INPUT_MODE (1L << 2) #define MWM_HINTS_INPUT_MODE (1L << 2)
#define MWM_HINTS_STATUS (1L << 3) #define MWM_HINTS_STATUS (1L << 3)
#define MWM_DECOR_ALL (1L << 0) #define MWM_DECOR_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1) #define MWM_DECOR_BORDER (1L << 1)
@@ -446,6 +439,22 @@ wxString wxTopLevelWindowX11::GetTitle() const
#define MWM_DECOR_MENU (1L << 4) #define MWM_DECOR_MENU (1L << 4)
#define MWM_DECOR_MINIMIZE (1L << 5) #define MWM_DECOR_MINIMIZE (1L << 5)
#define MWM_DECOR_MAXIMIZE (1L << 6) #define MWM_DECOR_MAXIMIZE (1L << 6)
#define MWM_FUNC_ALL (1L << 0)
#define MWM_FUNC_RESIZE (1L << 1)
#define MWM_FUNC_MOVE (1L << 2)
#define MWM_FUNC_MINIMIZE (1L << 3)
#define MWM_FUNC_MAXIMIZE (1L << 4)
#define MWM_FUNC_CLOSE (1L << 5)
#define MWM_INPUT_MODELESS 0
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
#define MWM_INPUT_SYSTEM_MODAL 2
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
#define MWM_TEAROFF_WINDOW (1L<<0)
#endif #endif
struct MwmHints { struct MwmHints {
@@ -524,56 +533,51 @@ bool wxSetWMDecorations(Window w, long style)
GrSetWMProperties(w, & wmProp); GrSetWMProperties(w, & wmProp);
#else #else
if (!wxMWMIsRunning(w))
return FALSE;
Atom mwm_wm_hints = XInternAtom(wxGlobalDisplay(),"_MOTIF_WM_HINTS", False); Atom mwm_wm_hints = XInternAtom(wxGlobalDisplay(),"_MOTIF_WM_HINTS", False);
if (mwm_wm_hints == 0)
return FALSE;
MwmHints hints; MwmHints hints;
hints.flags = 0; hints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS;
hints.decorations = 0; hints.decorations = 0;
hints.functions = 0;
if (style & wxRESIZE_BORDER) if ((style & wxSIMPLE_BORDER) || (style & wxNO_BORDER))
{ {
// wxLogDebug("MWM_DECOR_RESIZEH"); // leave zeros
hints.flags |= MWM_HINTS_DECORATIONS;
hints.decorations |= MWM_DECOR_RESIZEH;
} }
else
if (style & wxSYSTEM_MENU)
{ {
// wxLogDebug("MWM_DECOR_MENU"); hints.decorations = MWM_DECOR_BORDER;
hints.flags |= MWM_HINTS_DECORATIONS; hints.functions = MWM_FUNC_MOVE;
hints.decorations |= MWM_DECOR_MENU;
}
if ((style & wxCAPTION) || if ((style & wxCAPTION) != 0)
(style & wxTINY_CAPTION_HORIZ) || hints.decorations |= MWM_DECOR_TITLE;
(style & wxTINY_CAPTION_VERT))
{
// wxLogDebug("MWM_DECOR_TITLE");
hints.flags |= MWM_HINTS_DECORATIONS;
hints.decorations |= MWM_DECOR_TITLE;
}
if ((style & wxTHICK_FRAME) || (style & wxCAPTION)) if ((style & wxSYSTEM_MENU) != 0)
{ {
// wxLogDebug("MWM_DECOR_BORDER"); hints.functions |= MWM_FUNC_CLOSE;
hints.flags |= MWM_HINTS_DECORATIONS; hints.decorations |= MWM_DECOR_MENU;
hints.decorations |= MWM_DECOR_BORDER; }
}
if (style & wxMINIMIZE_BOX) if ((style & wxMINIMIZE_BOX) != 0)
{ {
// wxLogDebug("MWM_DECOR_MINIMIZE"); hints.functions |= MWM_FUNC_MINIMIZE;
hints.flags |= MWM_HINTS_DECORATIONS; hints.decorations |= MWM_DECOR_MINIMIZE;
hints.decorations |= MWM_DECOR_MINIMIZE; }
}
if (style & wxMAXIMIZE_BOX) if ((style & wxMAXIMIZE_BOX) != 0)
{ {
// wxLogDebug("MWM_DECOR_MAXIMIZE"); hints.functions |= MWM_FUNC_MAXIMIZE;
hints.flags |= MWM_HINTS_DECORATIONS; hints.decorations |= MWM_DECOR_MAXIMIZE;
hints.decorations |= MWM_DECOR_MAXIMIZE; }
if ((style & wxRESIZE_BORDER) != 0)
{
hints.functions |= MWM_FUNC_RESIZE;
hints.decorations |= MWM_DECOR_RESIZEH;
}
} }
XChangeProperty(wxGlobalDisplay(), XChangeProperty(wxGlobalDisplay(),
@@ -586,31 +590,6 @@ bool wxSetWMDecorations(Window w, long style)
return TRUE; return TRUE;
} }
bool wxMWMIsRunning(Window w)
{
#if wxUSE_NANOX
return FALSE;
#else
Display *dpy = (Display*)wxGetDisplay();
Atom motifWmInfo = XInternAtom(dpy, "_MOTIF_WM_INFO", False);
unsigned long length, bytesafter;
unsigned char value[20];
unsigned char *ptr = &value[0];
int ret, format;
Atom type;
type = format = length = 0;
value[0] = 0;
ret = XGetWindowProperty(wxGlobalDisplay(), w, motifWmInfo,
0L, 2, False, motifWmInfo,
&type, &format, &length, &bytesafter, &ptr);
return (ret == Success);
#endif
}
// For implementation purposes - sometimes decorations make the client area // For implementation purposes - sometimes decorations make the client area
// smaller // smaller
wxPoint wxTopLevelWindowX11::GetClientAreaOrigin() const wxPoint wxTopLevelWindowX11::GetClientAreaOrigin() const