bool wxTopLevelWindowMotif::Create( wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { SetName(name); m_windowStyle = style; if ( parent ) parent->AddChild(this); wxTopLevelWindows.Append(this); m_windowId = ( id > -1 ) ? id : NewControlId(); // MBN: More backward compatible, but uglier m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); m_inheritFont = true; bool retval = XmDoCreateTLW( parent, id, title, pos, size, style, name ); if( !retval ) return false; // Intercept CLOSE messages from the window manager Widget shell = (Widget)GetShellWidget(); Atom WM_DELETE_WINDOW = XmInternAtom( XtDisplay( shell ), "WM_DELETE_WINDOW", False ); // Remove and add WM_DELETE_WINDOW so ours is only handler // This only appears to be necessary for wxDialog, but does not hurt // for wxFrame XmRemoveWMProtocols( shell, &WM_DELETE_WINDOW, 1 ); XmAddWMProtocols( shell, &WM_DELETE_WINDOW, 1 ); XmActivateWMProtocol( shell, WM_DELETE_WINDOW ); // Modified Steve Hammes for Motif 2.0 #if (XmREVISION > 1 || XmVERSION > 1) XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW, (XtCallbackProc)wxCloseTLWCallback, (XtPointer)this ); #elif XmREVISION == 1 XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW, (XtCallbackProc)wxCloseTLWCallback, (caddr_t)this ); #else XmAddWMProtocolCallback( shell, WM_DELETE_WINDOW, (void (*)())wxCloseTLWCallback, (caddr_t)this ); #endif // This patch come from Torsten Liermann [email protected] if( XmIsMotifWMRunning( shell ) ) { int decor = 0 ; if( !(m_windowStyle & wxNO_BORDER) ) decor |= MWM_DECOR_BORDER; if( m_windowStyle & wxRESIZE_BORDER ) decor |= MWM_DECOR_RESIZEH; if( m_windowStyle & wxSYSTEM_MENU ) decor |= MWM_DECOR_MENU; if( ( m_windowStyle & wxCAPTION ) || ( m_windowStyle & wxTINY_CAPTION_HORIZ ) || ( m_windowStyle & wxTINY_CAPTION_VERT ) ) decor |= MWM_DECOR_TITLE; if( m_windowStyle & wxRESIZE_BORDER ) decor |= MWM_DECOR_BORDER; if( m_windowStyle & wxMINIMIZE_BOX ) decor |= MWM_DECOR_MINIMIZE; if( m_windowStyle & wxMAXIMIZE_BOX ) decor |= MWM_DECOR_MAXIMIZE; XtVaSetValues( shell, XmNmwmDecorations, decor, NULL ); } else { // This allows non-Motif window managers to support at least the // no-decorations case. if( ( m_windowStyle & wxCAPTION ) != wxCAPTION ) XtVaSetValues( shell, XmNoverrideRedirect, True, NULL ); } XtAddEventHandler( (Widget)GetClientWidget(), ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask, False, wxTLWEventHandler, (XtPointer)this ); return retval; }
void awt_util_reshape(Widget w, jint x, jint y, jint wd, jint ht) { Widget parent; Dimension ww, wh; Position wx, wy; Boolean move = False; Boolean resize = False; Boolean mapped_when_managed = False; Boolean need_to_unmanage = True; Widget saved_focus_widget = NULL; if (w == NULL) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNU_ThrowNullPointerException(env,"NullPointerException"); return; } parent = XtParent(w); /* Aim: hack to prevent direct children of scrollpane from * being unmanaged during a reshape operation (which results * in too many expose events). */ if (parent != NULL && XtParent(parent) != NULL && XtIsSubclass(XtParent(parent), xmScrolledWindowWidgetClass)) { need_to_unmanage = False; } XtVaGetValues(w, XmNwidth, &ww, XmNheight, &wh, XmNx, &wx, XmNy, &wy, NULL); if (x != wx || y != wy) { move = True; } if (wd != ww || ht != wh) { resize = True; } if (!move && !resize) { return; } if (need_to_unmanage) { if (!resize) { mapped_when_managed = w->core.mapped_when_managed; w->core.mapped_when_managed = False; } saved_focus_widget = get_shell_focused_widget(w); XtUnmanageChild(w); } /* GES: AVH's hack: * Motif ignores attempts to move a toplevel window to 0,0. * Instead we set the position to 1,1. The expected value is * returned by Frame.getBounds() since it uses the internally * held rectangle rather than querying the peer. * N.B. [pauly, 9/97] This is only required for wm shells * under the Motif Window Manager (MWM), not for any others. * Note. Utilizes C short-circuiting if w is not a wm shell. */ if ((x == 0) && (y == 0) && (XtIsSubclass(w, wmShellWidgetClass)) && (XmIsMotifWMRunning(w))) { XtVaSetValues(w, XmNx, 1, XmNy, 1, NULL); } if (move && !resize) { XtVaSetValues(w, XmNx, x, XmNy, y, NULL); } else if (resize && !move) { XtVaSetValues(w, XmNwidth, (wd > 0) ? wd : 1, XmNheight, (ht > 0) ? ht : 1, NULL); } else { XtVaSetValues(w, XmNx, x, XmNy, y, XmNwidth, (wd > 0) ? wd : 1, XmNheight, (ht > 0) ? ht : 1, NULL); } if (need_to_unmanage) { XtManageChild(w); if (!resize) { w->core.mapped_when_managed = mapped_when_managed; } if (saved_focus_widget != NULL) { Boolean result = XmProcessTraversal(saved_focus_widget, XmTRAVERSE_CURRENT); if (!result) { Widget shell = saved_focus_widget; while(shell != NULL && !XtIsShell(shell)) { shell = XtParent(shell); } XtSetKeyboardFocus(shell, saved_focus_widget); } } } }