[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 |
474.0. "Multiple clients with a shared property???" by GSPMO::DIX (I guess I do windows now...) Fri Mar 24 1989 15:52
I'm having a problem using properties (probably something incredibly
stupid I've forgotten to do), but I'd appreciate ANY and ALL help to determine
what I'm doing wrong. This note has also been placed in the DECWindows
programming conference......
What I'm trying to do is have client "A" register with the server an
interest in all property notify events, have client "B" change the property
(causing a property notify event) and have client "A" take some action when the
property notify event is triggered. What's happening is that client "A" never
receives the events from client "B". At one time I had client "A" register an
interest in button events as well, and again the client never received any of
the button events raised by client "B".
The code follows and is in Ada......
========================= Client "B" ========================================
with x;
with system;
with text_io;
procedure get_property is
--
-- The get_property procedure registers an interest in property_notify,
-- button_press, and button_release events with the server then loops
-- until a property_notify event occurs for the specified atom. This
-- procedure will eventually get the data from the property, but there
-- appears to be a problem with the get_property call in the Ada
-- interface right now.
--
display : x.display_type;
name_of_display : constant string := "DECW$DISPLAY";
screen : system.unsigned_longword;
depth : integer;
visual : x.visual_type := x.visual_type_init;
attribute_mask : x.window_masks_type := x.window_masks_type_init;
window_attributes : x.set_win_attributes_type :=
x.set_win_attributes_type_init;
window_height : constant system.unsigned_longword := 280;
window_width : constant system.unsigned_longword := 360;
window_x : constant integer := 25;
window_y : constant integer := 100;
root_window : x.window_id_type;
main_window : x.window_id_type;
done : boolean;
event : x.event_type;
begin
--
-- Open up a display and get the default values for:
-- the screen
-- depth of the screen
-- visual
-- root window
--
x.open_display( result => display,
display_name => name_of_display );
x.default_screen_of_display( result => screen,
display => display );
x.default_depth_of_screen( result => depth,
screen_id => screen );
x.default_visual_of_screen( screen_id => screen,
visual_return => visual );
x.root_window_of_screen( result => root_window,
screen_id => screen );
--
-- set the attribute mask to true for events and set up the event
-- mask for property_change, button_press, and button_release
--
attribute_mask.cw_event_mask := true;
window_attributes.swda_event_mask := x.m_property_change +
x.m_button_press +
x.m_button_release;
--
-- Create the window now
--
x.create_window( result => main_window,
display => display,
parent_id => root_window,
x_coord => window_x,
y_coord => window_y,
width => window_width,
height => window_height,
border_width => 3,
depth => depth,
class => x.c_copy_from_parent,
visual_struc => visual,
attributes_mask => attribute_mask,
attributes => window_attributes );
x.map_window( display => display,
window_id => main_window );
--
-- while a property notify event has not occured for the specified
-- atom, loop around and receive events off the queue.
--
while not done loop
x.next_event( display => display,
event_return => event );
text_io.put_line("Received and event = "
& integer'image(event.evnt_type) );
if event.evnt_type = x.c_property_notify then
text_io.put_line("Event is a property notify");
if system."=" (event.ppev_atom, x.c_xa_atom) then
text_io.put_line("Correct property was changed");
done := true;
end if;
end if;
end loop;
end get_property;
========================= Client "A" ========================================
with x;
with system;
with text_io;
procedure write_property is
--
-- the write_property procedure waits for a button_press event at
-- which time it attempts to write some data to a property for a
-- specified atom.
--
display : x.display_type;
name_of_display : constant string := "DECW$DISPLAY";
screen : system.unsigned_longword;
depth : integer;
visual : x.visual_type := x.visual_type_init;
attribute_mask : x.window_masks_type := x.window_masks_type_init;
window_attributes : x.set_win_attributes_type :=
x.set_win_attributes_type_init;
window_height : constant system.unsigned_longword := 280;
window_width : constant system.unsigned_longword := 360;
window_x : constant integer := 25;
window_y : constant integer := 100;
root_window : x.window_id_type;
main_window : x.window_id_type;
done : boolean;
event : x.event_type;
begin
--
-- Open up a display and get the default values for:
-- the screen
-- depth of the screen
-- visual
-- root window
--
x.open_display( result => display,
display_name => name_of_display );
x.default_screen_of_display( result => screen,
display => display );
x.default_depth_of_screen( result => depth,
screen_id => screen );
x.default_visual_of_screen( screen_id => screen,
visual_return => visual );
x.root_window_of_screen( result => root_window,
screen_id => screen );
--
-- set the attribute mask to true for events and set up the event
-- mask for button_press events
--
attribute_mask.cw_event_mask := true;
window_attributes.swda_event_mask := x.m_button_press;
--
-- Create the window now
--
x.create_window( result => main_window,
display => display,
parent_id => root_window,
x_coord => window_x,
y_coord => window_y,
width => window_width,
height => window_height,
border_width => 3,
depth => depth,
class => x.c_copy_from_parent,
visual_struc => visual,
attributes_mask => attribute_mask,
attributes => window_attributes );
x.map_window( display => display,
window_id => main_window );
--
-- while the property has not been changed (instigated via a button_press
-- event), loop around and check the event queue for a button_press
--
while not done loop
x.next_event( display => display,
event_return => event );
text_io.put_line("Received and event = "
& integer'image(event.evnt_type) );
if event.evnt_type = x.c_button_press then
x.change_property( display => display,
window_id => main_window,
property_id => x.c_xa_atom,
type_id => x.c_xa_string,
format => 16,
change_mode => x.c_prop_mode_replace,
prop_data => "This is neat stuff",
num_elements => 18 );
done := true;
end if;
end loop;
end write_property;
T.R | Title | User | Personal Name | Date | Lines |
---|
474.1 | | AITG::DERAMO | Daniel V. {AITG,ZFC}:: D'Eramo | Fri Mar 24 1989 19:17 | 12 |
| Client A has to change the property of the window on which
client B is receiving property notify events. Since you have
each of A and B creating their own windows, client B does not
see the change to client A's window.
You could have client B select for property notify events on the
root window of the display, and have client A change the property
of the root window. Or one client can create a window and somehow
communicate its window id to the second client.
Dan
|
474.2 | I tried, No success... | GSPMO::DIX | I guess I do windows now... | Mon Mar 27 1989 11:16 | 29 |
|
Thanks for the tips Dan, I tried but with still no success......
I added in the select_input call to client B (an oversight on the
first writing) and set the window id to the root window. I also
changed client A to change the property on the root window. This
had the following results:
1) Client B recognized button events on the root window
2) Client A changed the property (I assume)
3) Client B never recognized the property change that client A made,
or the button event in client A that kicked off the property
change
After the lack of success I printed out the value of the root window
being returned by the call to "root_window_of_screen" to be sure I
was getting the same value in both clients, no problem there - they
were both the same.
Before using the root window for the communication I tried using a
common window between the clients (having client A pass the value
of its window to client B), but I had the same results as mentioned
above.
Any other suggestions?
Thanks,
Sandy
|