Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uwm.edu!lll-winken!sun-barr!newstop!sun!kimba!hvr From: hvr@kimba.Sun.COM (Heather Rose) Newsgroups: comp.windows.x Subject: Re: De-Transient'ing a transientShellWidget Keywords: transient,shell,popup Message-ID: <131190@sun.Eng.Sun.COM> Date: 3 Feb 90 22:45:01 GMT References: <597@igor.Rational.COM> Sender: news@sun.Eng.Sun.COM Reply-To: hvr@sun.UUCP (Heather Rose) Distribution: na Organization: Sun Microsystems, Mountain View Lines: 140 In article <597@igor.Rational.COM> geb@amber.Rational.COM (Gary Barnes) writes: > >What I want to do is to give the user the option of making the popup menu a >permanent window on his screen. I want to de-transient the transientShell. > >window. This is best illustrated by an open-look type window manager. >The window is decorated by a push-pin which means that the user just clicks on >the push-pin and the window goes away. The way the OpenLook XView toolkit deals with this is different for specific situations and implementations. If the application programmer has a static menu, then the code below is all the programmer needs to do to generate a pinnable menu. If you have a dynamic menu, then the process becomes a bit more involved. But for these purposes, a static menu case is sufficient. The method to generate the pinned menu would be all the application programmer would need to worry about in the case of the XView toolkit. The ability to pin a menu is supplied by the toolkit. Then it is the toolkit which implements the optimal solution for the current working environment. For example, I'll elaborate on how XView approaches the time versus space problem of pinnable menus. In the 1.0 and 1.0.1 implementation of XView, it will create the command frame for your pinned menu when the menu is created. This was done because the servers X11R3 and OpenWindows 1.0 were not quite fast enough to generate the popup frame on the fly. To save time, we chose to use space. In the 1.1 implementation of XView, it will create the command frame when the menu is pinned. This was done because the servers, X11R4 and OpenWindows 1.1 are fast enough to generate the popup frame on the fly. So here we chose to use time to save space since time is now cheaper. Since XView does not use an X11 window for each button created, this was a reasonable thing to do. However, if your toolkit creates each button as a window, the issue needs to be re-visited. In summary, you face a typical time versus space trade off. And the solution you choose has as much to do with your working environment outside the application as within it. Regards, Heather -------------------------- The XView toolkit is supplied with X11R4 in the contrib section. This example is taken from the O'Reilly XView Programmer's Manual. It can be found on line with the XView toolkit source in XView/clients/examples. /* * xv_menu.c - * Demonstrate the use of an XView menu in a canvas subwindow. * Menu is brought up with right mouse button and the selected * choice is displayed in the canvas. Allows menu to be pinned. */ #include #include Frame frame; main(argc,argv) int argc; char *argv[]; { Canvas canvas; Menu menu; void my_notify_proc(), my_event_proc(); extern void exit(); xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL); frame = (Frame)xv_create(NULL, FRAME, FRAME_LABEL, argv[0], NULL); canvas = (Canvas)xv_create(frame, CANVAS, XV_WIDTH, 300, XV_HEIGHT, 200, NULL); menu = (Menu)xv_create(NULL, MENU, MENU_TITLE_ITEM, "Junk", MENU_STRINGS, "Yes", "No", "Maybe", NULL, MENU_NOTIFY_PROC, my_notify_proc, MENU_ITEM, MENU_STRING, "Save", MENU_NOTIFY_PROC, my_notify_proc, MENU_PULLRIGHT, xv_create(canvas, MENU, MENU_GEN_PIN_WINDOW, frame, "Save", MENU_ITEM, MENU_STRING, "Update Changes", MENU_NOTIFY_PROC, my_notify_proc, NULL, NULL), NULL, MENU_ITEM, MENU_STRING, "Quit", MENU_NOTIFY_PROC, exit, NULL, NULL); xv_set(canvas_paint_window(canvas), WIN_CONSUME_EVENTS, WIN_MOUSE_BUTTONS, NULL, WIN_EVENT_PROC, my_event_proc, /* associate the menu to the canvas win so we can retrieve it easily */ WIN_CLIENT_DATA, menu, NULL); window_fit(frame); window_main_loop(frame); } /* * my_notify_proc - Display menu selection in frame header. */ void my_notify_proc(menu, menu_item) Menu menu; Menu_item menu_item; { xv_set(frame, FRAME_LABEL, xv_get(menu_item, MENU_STRING), NULL); } /* * my_event_proc - Call menu_show() to display menu on right mouse button push. */ void my_event_proc(window, event) Xv_Window window; Event *event; { if (event_action(event) == ACTION_MENU && event_is_down(event)) { Menu menu = (Menu)xv_get(window, WIN_CLIENT_DATA); menu_show(menu, window, event, NULL); } }