program wm protocols in open look toolkit hi all i am studying the book unix desktop guide to open look there is an example winprop c that demonstrate how to program wm protocols property in chapter it can run but only show the static text messages no notice pop up what is the problem thanks in advance for help iop file winprop c shows how to set properties on a window include x xatom h for definition of xa atom include x intrinsic h include x stringdefs h include xol openlook h include xol statictext h include xol oblongbutt h include xol notice h this file defines the atoms with ol prefix id of the top level and noticeshell widget static widget top level notice shell static widget make notice static char message clients use properties to communicate with the window manager this example illustrates how an open look application requests notification from the window manager when certain events occur the communication is in the form of a clientmessage event that the application processes in an event handler atoms used for inter client communication atom atom wm protocols atom wm delete window atom wm save yourself static void handle wm messages static void save and exit static void save yourself static void pop notice static void do exit string to hold comand line for use in responding to the wm save yourself protocol message char saved cmdline void main argc argv int argc char argv widget w int i save the command line for use in responding to the wm save yourself protocol message sprintf saved cmdline s argv if argc for i i argc i strcat saved cmdline argv i strcat saved cmdline create and initialize the top level widget top level olinitialize argv ol main null argc argv create a statictext widget w xtvacreatemanagedwidget stext statictextwidgetclass top level xtnstring message xtnwidth null create a noticeshell widget for later use make notice top level intern the atoms atom wm protocols xinternatom xtdisplay w wm protocols false atom wm delete window xinternatom xtdisplay w wm delete window false atom wm save yourself xinternatom xtdisplay w wm save yourself false add an event handler to process clientmessage events sent by the window manager xtaddeventhandler top level noeventmask true handle wm messages null realize the widgets and start processing events xtrealizewidget top level append the properties wm delete window and wm save yourself to the definition of the wm protocols property this step requires the window id of the top level widget the window id is valid only after the widget is realized xchangeproperty xtdisplay top level xtwindow top level atom wm protocols xa atom propmodeappend atom wm delete window xchangeproperty xtdisplay top level xtwindow top level atom wm protocols xa atom propmodeappend atom wm save yourself xtmainloop static void handle wm messages w client data p event widget w xtpointer client data xevent p event if p event type clientmessage p event xclient message type atom wm protocols if p event xclient data l atom wm delete window save and exit if p event xclient data l atom wm save yourself save yourself static void save and exit display a notice giving the user a chance to respond pop notice top level notice shell static void save yourself set the wm command property to the saved command line xchangeproperty xtdisplay top level xtwindow top level xa wm command xa string propmodereplace saved cmdline strlen saved cmdline static widget make notice parent widget parent widget w n text n control n exit n cancel create a button and provide a callback to pop up a notice w xtvacreatemanagedwidget quitbutton oblongbuttonwidgetclass parent xtnlabel exit null xtaddcallback w xtnselect pop notice null create the noticeshell widget note that you have to use xtvacreatepopupshell instead of the usual xtvacreatemanagedwidget notice shell xtvacreatepopupshell quitnotice noticeshellwidgetclass w null get the id of the text and control area widgets of the noticeshell xtvagetvalues notice shell xtntextarea n text xtncontrolarea n control null place a message in the text area of the noticeshell xtvasetvalues n text xtnstring please confirm exit from program null add buttons to the control area of the noticeshell each button has an appropriate callback n exit xtvacreatemanagedwidget noticeexit oblongbuttonwidgetclass n control xtnlabel exit null xtaddcallback n exit xtnselect do exit null n cancel xtvacreatemanagedwidget noticecancel oblongbuttonwidgetclass n control xtnlabel cancel xtndefault true null return w static void pop notice w emanate w notice widget w emanate w notice xtvasetvalues w notice xtnemanatewidget w emanate null pop up the noticeshell widget the noticeshell widget makes sure that the aplication waits until the user selects from one of the buttons in the noticeshell s control area xtpopup w notice xtgrabexclusive static void do exit w call data client data widget w xtpointer call data client data xclosedisplay xtdisplay w exit
