[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
|
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
3565.0. "X$FLUSH in/out of DEBUG" by GLORY::MATERNA () Thu Nov 01 1990 12:53
I'm not too clear on how the X$FLUSH command works, but I thought that
it's used to take care of any output for a display in the output
buffer. I have a short program here which is supposed to create a
display with a window, and a sub-window which is over the lower half of
this window. A small bit of text is then written to the sub-window,
and the program waits for a click in the window to exit.
Now, the problem is when the program is run in debug, and I set the
program to break between the first and second X$FLUSH calls, the text
is displayed when the second X$FLUSH call is executed. However,
when the program is allowed to go past both X$FLUSH calls without a
break, whether within debug or without debug, the text is not
displayed.
I would appreciate any help.
Bill
-------------------
PROGRAM test
IMPLICIT NONE
INCLUDE 'SYS$LIBRARY:DECW$XLIBDEF'
RECORD /x$color/ color_rec(20), exact_color
RECORD /x$event/ event
RECORD /x$gc_values/ xgcv
RECORD /x$visual/ xvis
RECORD /x$set_win_attributes/ xswa
INTEGER*4 str$trim
INTEGER*4 status
INTEGER*4 display
INTEGER*4 root_id
INTEGER*4 gc_id(20)
INTEGER*4 window_2_id
INTEGER*4 window_1_id
INTEGER*4 black, white
INTEGER*4 x_coord
INTEGER*4 y_coord
INTEGER*4 width
INTEGER*4 height
INTEGER*4 depth, class, border
INTEGER*4 xgcv_mask,num_colors,cmap,new_xgcv_mask
INTEGER*4 defscreen
INTEGER*4 xswa_mask
INTEGER*4 local_event_mask
INTEGER*4 length
INTEGER*4 index1
INTEGER*4 the_font
CHARACTER*65 font(36)
CHARACTER*9 color(20)
*R* Initialization
font(1) = '-ADOBE-TIMES-MEDIUM-R-NORMAL--*-120-*-*-P-*'
color(1) = 'WHITE'
color(2) = 'BLACK'
color(3) = 'RED'
color(4) = 'GREEN'
color(5) = 'BLUE'
color(6) = 'CYAN'
color(7) = 'MAGENTA'
color(8) = 'YELLOW'
color(9) = 'WHITE'
color(10) = 'WHITE'
*R* Open display
display = x$open_display()
IF (display .EQ. 0) THEN
WRITE (6,*) 'Could not Open Display'
STOP
END IF
*R* Obtain id of root window
root_id = x$root_window(display,0)
IF (root_id .EQ. 0) THEN
WRITE (6,*) 'Could not get Root ID'
STOP
END IF
*R* Obtain default screen information
defscreen = x$default_screen_of_display ( display )
*R* Obtain pixel numbers for black and white
black = x$black_pixel_of_screen(defscreen)
white = x$white_pixel_of_screen(defscreen)
*R* Obtain default color map id
cmap = x$default_colormap_of_screen ( defscreen )
*R* Use visual of parent
xvis.x$l_visu_visualid = x$c_copy_from_parent
*R* Initialize window attributes for main window
xswa.x$l_swda_background_pixel = black
xswa.x$l_swda_border_pixel = white
xswa_mask = x$m_cw_back_pixel .OR. x$m_cw_border_pixel .or.
1 x$m_cw_back_pixel
xswa.x$l_swda_event_mask = x$m_button_press
*R* Create main window
x_coord = 20
y_coord = 20
width = 400
height = 400
border = 1
depth = 8
class = x$c_input_output
window_1_id = x$create_window (display, root_id,
1 x_coord, y_coord,
1 width, height,
1 border, depth,
1 class, xvis,
1 xswa_mask, xswa)
*R* Initialize window attributes for sub window
xswa.x$l_swda_background_pixel = white
xswa.x$l_swda_border_pixel = black
*R* Create sub window
x_coord = 0
y_coord = 200
width = 400
height = 200
border = 1
depth = 8
class = x$c_input_output
window_2_id = x$create_window (display, window_1_id,
1 x_coord, y_coord,
1 width, height,
1 border, depth,
1 class, xvis,
1 xswa_mask, xswa)
*R* Look up colors from default color map and allocate them
*R* Create graphics context for drawing
DO index1 = 1,10
status = str$trim(color(index1),color(index1),length)
status = x$alloc_named_color(display,cmap,
1 color(index1)(1:length),color_rec(index1))
xgcv.x$l_gcvl_foreground = color_rec(index1).x$l_colr_pixel
xgcv.x$l_gcvl_function = x$c_gx_copy
xgcv_mask = x$m_gc_foreground +
1 x$m_gc_function +
1 x$m_gc_join_style +
1 x$m_gc_cap_style
gc_id(index1) = x$create_gc (display, window_1_id, xgcv_mask, xgcv)
END DO
*R* Look up colors from default color map and allocate them
*R* Create graphics context for text
DO index1 = 1,10
xgcv.x$l_gcvl_foreground = color_rec(index1).x$l_colr_pixel
xgcv.x$l_gcvl_background = white
xgcv.x$l_gcvl_function = x$c_gx_copy
xgcv_mask = x$m_gc_foreground +
1 x$m_gc_background
gc_id(index1 + 10) = x$create_gc(display,window_2_id,xgcv_mask,xgcv)
END DO
status = str$trim(font(1),font(1),length)
the_font = x$load_font(display, font(1)(1:length))
CALL x$set_font(display, gc_id(15), the_font)
*R* Set event mask for mouse buttons
local_event_mask = x$m_button_press
*R* Pass event mask for selecting input
CALL x$select_input ( display, window_1_id,
1 local_event_mask )
*R* Map windows
call x$map_window( display, window_1_id)
call x$map_window( display, window_2_id)
*R* Flush output buffer
CALL x$flush ( display )
CALL x$clear_window(display,window_1_id)
CALL x$clear_window(display,window_2_id)
*R* Draw text to sub window
CALL x$draw_image_string(display,window_2_id,gc_id(15),10,50,
1 'Here''s some text.')
*R* Flush output buffer
CALL x$flush ( display )
*R* Wait for click in window to exit
DO WHILE (.TRUE.)
call x$next_event(display, event)
if (event.evnt_type .eq. x$c_button_press) then
call x$unmap_window(display, window_1_id)
call x$destroy_window(display, window_1_id)
call x$close_display(display)
STOP
END IF
END DO
1000 END
T.R | Title | User | Personal Name | Date | Lines |
---|
3565.1 | flush and sync are not the same... | IO::MCCARTNEY | James T. McCartney III - DTN 381-2244 ZK02-2/N24 | Mon Nov 26 1990 15:38 | 17 |
|
The problem here is a classic one... You must wait for the exposure events
for a window before you know that any drawing operation to the window will
actually affect the screen. When you run in DEBUG, you are doing things slowly
enough that the window will map before the draw operation occurs. When you run
at speed, the window is mapped, the flush sends the packet to the server (but
does not wait) and the drawing operation is sent immediately afterward (but the
window is not yet mapped) and the bits get dropped into the bitbucket.
There are many ways to fix this problem, but the best is to delay the writing
of text until the window is mapped (as indicated by receiving the expose events).
After all, you're program must be smart enough to process exposures, why
special case the initial exposure?
James
|