[Motiftools-xmt-cvs] CVS: xmt/Xmt PixelCvt.c,1.2,1.3 Visual.c,1.2,1.3
Brought to you by:
motiftools
|
From: Grant M. <grm...@us...> - 2003-10-27 21:33:56
|
Update of /cvsroot/motiftools/xmt/Xmt
In directory sc8-pr-cvs1:/tmp/cvs-serv23794/d
Modified Files:
PixelCvt.c Visual.c
Log Message:
Change XmtGetVisual/_XmtFetchVisual to handle case when called
with uninitialized widget. Also provide capability to handle non-standard widgets
with Visual resource
Index: PixelCvt.c
===================================================================
RCS file: /cvsroot/motiftools/xmt/Xmt/PixelCvt.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** PixelCvt.c 19 Sep 2001 02:57:18 -0000 1.2
--- PixelCvt.c 27 Oct 2003 21:29:04 -0000 1.3
***************
*** 10,13 ****
--- 10,18 ----
*
* $Log$
+ * Revision 1.3 2003/10/27 21:29:04 grmcdorman
+ * Change XmtGetVisual/_XmtFetchVisual to handle case when called
+ * with uninitialized widget. Also provide capability to handle non-standard widgets
+ * with Visual resource
+ *
* Revision 1.2 2001/09/19 02:57:18 grmcdorman
* This change makes the following modifications:
***************
*** 62,66 ****
Widget rootshell = *((Widget *)args[0].addr);
Colormap colormap = *((Colormap *)args[1].addr);
! Visual *visual = *((Visual **)args[2].addr);
int status;
Pixel pixel;
--- 67,72 ----
Widget rootshell = *((Widget *)args[0].addr);
Colormap colormap = *((Colormap *)args[1].addr);
! /* pointer to Visual is returned */
! Visual *visual = ((Visual *)args[2].addr);
int status;
Pixel pixel;
Index: Visual.c
===================================================================
RCS file: /cvsroot/motiftools/xmt/Xmt/Visual.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Visual.c 19 Sep 2001 02:57:18 -0000 1.2
--- Visual.c 27 Oct 2003 21:29:04 -0000 1.3
***************
*** 10,13 ****
--- 10,18 ----
*
* $Log$
+ * Revision 1.3 2003/10/27 21:29:04 grmcdorman
+ * Change XmtGetVisual/_XmtFetchVisual to handle case when called
+ * with uninitialized widget. Also provide capability to handle non-standard widgets
+ * with Visual resource
+ *
* Revision 1.2 2001/09/19 02:57:18 grmcdorman
* This change makes the following modifications:
***************
*** 46,54 ****
#endif
{
while(!XtIsShell(w)) w = XtParent(w);
! if (((ShellWidget)w)->shell.visual != (Visual *)CopyFromParent)
! return ((ShellWidget)w)->shell.visual;
! else
! return DefaultVisualOfScreen(XtScreen(w));
}
--- 51,75 ----
#endif
{
+ #define NOVISUAL ((Visual *)-1)
+ #define COPYVISUAL ((Visual *)CopyFromParent)
+
+ Visual *vis = NOVISUAL;
+ #ifdef SEARCHVISUAL
+ /* Don't assume only Shells have a Visual resource; search everything. */
+ /* DANGER: This may crash'n'burn if the supplied widget is not initialized. */
+ Arg args[1];
+ XtSetArg(args[0], XmNvisual, &vis);
+
+ XtGetValues(w, args, 1);
+ while (w != NULL && !XtIsShell(w) && vis == NOVISUAL) {
+ w = XtParent(w);
+ XtGetValues(w, args, 1);
+ }
+ if (vis == NOVISUAL) vis = COPYVISUAL;
+ #else
while(!XtIsShell(w)) w = XtParent(w);
! vis = ((ShellWidget)w)->shell.visual;
! #endif
! return vis == COPYVISUAL ? DefaultVisualOfScreen(w->core.screen) : vis;
}
***************
*** 66,75 ****
#endif
{
! while(!XtIsShell(w)) w = XtParent(w);
! value->size = sizeof(Visual *);
! if (((ShellWidget)w)->shell.visual != (Visual *)CopyFromParent)
! value->addr = (XPointer) &((ShellWidget)w)->shell.visual;
! else
! value->addr = (XPointer) &DefaultVisualOfScreen(XtScreen(w));
}
--- 87,138 ----
#endif
{
! /*
! * We have a bit of an odd situation when we start with a Shell.
! * It's possible for this function to be invoked by string-to-pixel
! * conversion for the Core part of the Shell widget; this means that
! * the Shell part is not initialized.
! *
! * As a result, the shell.visual field is garbage.
! *
! * The rest of the time, everything is OK.
! *
! * So, to fix this we need to either:
! * 1) detect when this function is called with an uninitialized
! * Shell widget
! * or 2) detect when this function is called to convert the Core
! * pixel fields for a Shell widget
! *
! * The trick is that the shell is not inserted in its parent's
! * popup list until it's fully initialized. Thus, we can detect
! * case (1). In this case, it should be OK to return the default
! * visual, as the only Pixel fields in the Shell widget are those
! * in Core: background and borderPixel. Since the shell is not
! * a visible object (at least normally), we can use the default
! * visual - and if the result is wrong, it won't really matter.
! *
! * Of course, this doesn't work for the top-level (application)
! * shell, but we probably won't get called for that (usually
! * the converter that uses this function is installed after that
! * shell is created).
! */
! int use_default = 0;
! if (XtIsShell(w) && !XtIsRealized(w) && w->core.parent != NULL) {
! Widget parent = w->core.parent;
! int i;
! use_default = 1;
! for (i = 0; i < parent->core.num_popups; i++) {
! if (parent->core.popup_list[i] == w) {
! use_default = 0;
! break;
! }
! }
! }
!
! value->size = sizeof(Visual);
! if (use_default) {
! value->addr = (XPointer) DefaultVisualOfScreen(w->core.screen);
! } else {
! value->addr = (XPointer) XmtGetVisual(XtIsShell(w) ? w : XtParent(w));
! }
}
|