This update includes the 0.20.3pre3 code
[wmaker-crm.git] / src / winspector.c
blob3fef6573100774420badebb8b17cb1d21c4112bf
1 /* winspector.c - window attribute inspector
2 *
3 * Window Maker window manager
4 *
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
23 #include "wconfig.h"
25 #include <X11/Xlib.h>
26 #include <X11/Xutil.h>
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <string.h>
31 #include "WindowMaker.h"
32 #include "screen.h"
33 #include "wcore.h"
34 #include "framewin.h"
35 #include "window.h"
36 #include "workspace.h"
37 #include "funcs.h"
38 #include "defaults.h"
39 #include "dialog.h"
40 #include "icon.h"
41 #include "stacking.h"
42 #include "application.h"
43 #include "appicon.h"
44 #include "actions.h"
45 #include "winspector.h"
46 #include "dock.h"
48 #include <proplist.h>
50 extern WDDomain *WDWindowAttributes;
52 static InspectorPanel *panelList=NULL;
54 extern WPreferences wPreferences;
56 static proplist_t ANoTitlebar = NULL;
57 static proplist_t ANoResizebar;
58 static proplist_t ANoMiniaturizeButton;
59 static proplist_t ANoCloseButton;
60 static proplist_t ANoHideOthers;
61 static proplist_t ANoMouseBindings;
62 static proplist_t ANoKeyBindings;
63 static proplist_t ANoAppIcon;
64 static proplist_t AKeepOnTop;
65 static proplist_t AKeepOnBottom;
66 static proplist_t AOmnipresent;
67 static proplist_t ASkipWindowList;
68 static proplist_t AKeepInsideScreen;
69 static proplist_t AUnfocusable;
70 static proplist_t AAlwaysUserIcon;
71 static proplist_t AStartMiniaturized;
72 static proplist_t ADontSaveSession;
73 static proplist_t AEmulateAppIcon;
75 static proplist_t AStartWorkspace;
77 static proplist_t AIcon;
79 /* application wide options */
80 static proplist_t AStartHidden;
83 static proplist_t AnyWindow;
84 static proplist_t EmptyString;
85 static proplist_t Yes, No;
88 #define PWIDTH 270
89 #define PHEIGHT 350
92 static void applySettings(WMButton *button, InspectorPanel *panel);
94 static void
95 make_keys()
97 if (ANoTitlebar!=NULL)
98 return;
100 AIcon = PLMakeString("Icon");
101 ANoTitlebar = PLMakeString("NoTitlebar");
102 ANoResizebar = PLMakeString("NoResizebar");
103 ANoMiniaturizeButton = PLMakeString("NoMiniaturizeButton");
104 ANoCloseButton = PLMakeString("NoCloseButton");
105 ANoHideOthers = PLMakeString("NoHideOthers");
106 ANoMouseBindings = PLMakeString("NoMouseBindings");
107 ANoKeyBindings = PLMakeString("NoKeyBindings");
108 ANoAppIcon = PLMakeString("NoAppIcon");
109 AKeepOnTop = PLMakeString("KeepOnTop");
110 AKeepOnBottom = PLMakeString("KeepOnBottom");
111 AOmnipresent = PLMakeString("Omnipresent");
112 ASkipWindowList = PLMakeString("SkipWindowList");
113 AKeepInsideScreen = PLMakeString("KeepInsideScreen");
114 AUnfocusable = PLMakeString("Unfocusable");
115 AAlwaysUserIcon = PLMakeString("AlwaysUserIcon");
116 AStartMiniaturized = PLMakeString("StartMiniaturized");
117 AStartHidden = PLMakeString("StartHidden");
118 ADontSaveSession = PLMakeString("DontSaveSession");
119 AEmulateAppIcon = PLMakeString("EmulateAppIcon");
121 AStartWorkspace = PLMakeString("StartWorkspace");
123 AnyWindow = PLMakeString("*");
124 EmptyString = PLMakeString("");
125 Yes = PLMakeString("Yes");
126 No = PLMakeString("No");
131 static void
132 freeInspector(InspectorPanel *panel)
134 panel->destroyed = 1;
135 if (panel->choosingIcon)
136 return;
138 WMDestroyWidget(panel->win);
140 XDestroyWindow(dpy, panel->parent);
142 free(panel);
146 static void
147 destroyInspector(WCoreWindow *foo, void *data, XEvent *event)
149 InspectorPanel *panel;
150 InspectorPanel *tmp;
152 panel = panelList;
153 while (panel->frame!=data)
154 panel = panel->nextPtr;
156 if (panelList == panel)
157 panelList = panel->nextPtr;
158 else {
159 tmp = panelList;
160 while (tmp->nextPtr!=panel) {
161 tmp = tmp->nextPtr;
163 tmp->nextPtr = panel->nextPtr;
165 panel->inspected->flags.inspector_open = 0;
166 panel->inspected->inspector = NULL;
168 WMRemoveNotificationObserver(panel);
170 XUnmapWindow(dpy, panel->parent);
171 XReparentWindow(dpy, panel->parent, panel->frame->screen_ptr->root_win,
172 0, 0);
173 wUnmanageWindow(panel->frame, False);
175 freeInspector(panel);
180 void
181 wDestroyInspectorPanels()
183 InspectorPanel *panel;
185 while (panelList != NULL) {
186 panel = panelList;
187 panelList = panelList->nextPtr;
188 WMDestroyWidget(panel->win);
189 wUnmanageWindow(panel->frame, False);
191 panel->inspected->flags.inspector_open = 0;
192 panel->inspected->inspector = NULL;
194 free(panel);
199 static void
200 changePage(WMPopUpButton *bPtr, InspectorPanel *panel)
202 int page;
204 page = WMGetPopUpButtonSelectedItem(bPtr);
206 if (page == 0) {
207 WMMapWidget(panel->specFrm);
208 WMMapWidget(panel->specLbl);
209 } else if (page == 1) {
210 WMMapWidget(panel->attrFrm);
211 } else if (page == 2) {
212 WMMapWidget(panel->moreFrm);
213 } else if (page == 3) {
214 WMMapWidget(panel->iconFrm);
215 WMMapWidget(panel->wsFrm);
216 } else {
217 WMMapWidget(panel->appFrm);
220 if (page != 0) {
221 WMUnmapWidget(panel->specFrm);
222 WMUnmapWidget(panel->specLbl);
224 if (page != 1)
225 WMUnmapWidget(panel->attrFrm);
226 if (page != 2)
227 WMUnmapWidget(panel->moreFrm);
228 if (page != 3) {
229 WMUnmapWidget(panel->iconFrm);
230 WMUnmapWidget(panel->wsFrm);
232 if (page != 4 && panel->appFrm)
233 WMUnmapWidget(panel->appFrm);
237 #define USE_TEXT_FIELD 1
238 #define UPDATE_TEXT_FIELD 2
239 #define REVERT_TO_DEFAULT 4
242 static int
243 showIconFor(WMScreen *scrPtr, InspectorPanel *panel,
244 char *wm_instance, char *wm_class, int flags)
246 WMPixmap *pixmap = (WMPixmap*) NULL;
247 char *file=NULL, *path=NULL;
248 char *db_icon=NULL;
250 if ((flags & USE_TEXT_FIELD) != 0) {
251 file = WMGetTextFieldText(panel->fileText);
252 if (file && file[0] == 0) {
253 free(file);
254 file = NULL;
256 } else {
257 db_icon = wDefaultGetIconFile(panel->inspected->screen_ptr,
258 wm_instance, wm_class, False);
259 if(db_icon != NULL)
260 file = wstrdup(db_icon);
262 if (db_icon!=NULL && (flags & REVERT_TO_DEFAULT)!=0) {
263 if (file)
264 file = wstrdup(db_icon);
265 flags |= UPDATE_TEXT_FIELD;
268 if ((flags & UPDATE_TEXT_FIELD) != 0) {
269 WMSetTextFieldText(panel->fileText, file);
272 if (file) {
273 path = FindImage(wPreferences.icon_path, file);
275 if (!path) {
276 char *buf;
278 buf = wmalloc(strlen(file)+80);
279 sprintf(buf, _("Could not find icon \"%s\" specified for this window"),
280 file);
281 wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
282 _("OK"), NULL, NULL);
283 free(buf);
284 free(file);
285 return -1;
288 pixmap = WMCreatePixmapFromFile(scrPtr, path);
289 free(path);
291 if (!pixmap) {
292 char *buf;
294 buf = wmalloc(strlen(file)+80);
295 sprintf(buf, _("Could not open specified icon \"%s\":%s"),
296 file, RMessageForError(RErrorCode));
297 wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
298 _("OK"), NULL, NULL);
299 free(buf);
300 free(file);
301 return -1;
303 free(file);
306 WMSetLabelImage(panel->iconLbl, pixmap);
307 if (pixmap)
308 WMReleasePixmap(pixmap);
310 return 0;
313 #if 0
314 static void
315 updateIcon(WMButton *button, InspectorPanel *panel)
317 showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
319 #endif
321 static int
322 getBool(proplist_t value)
324 char *val;
326 if (!PLIsString(value)) {
327 return 0;
329 if (!(val = PLGetString(value))) {
330 return 0;
333 if ((val[1]=='\0' && (val[0]=='y' || val[0]=='Y' || val[0]=='T'
334 || val[0]=='t' || val[0]=='1'))
335 || (strcasecmp(val, "YES")==0 || strcasecmp(val, "TRUE")==0)) {
337 return 1;
338 } else if ((val[1]=='\0'
339 && (val[0]=='n' || val[0]=='N' || val[0]=='F'
340 || val[0]=='f' || val[0]=='0'))
341 || (strcasecmp(val, "NO")==0 || strcasecmp(val, "FALSE")==0)) {
343 return 0;
344 } else {
345 wwarning(_("can't convert \"%s\" to boolean"), val);
346 return 0;
351 #define UPDATE_DEFAULTS 1
352 #define IS_BOOLEAN 2
356 * Will insert the attribute = value; pair in window's list,
357 * if it's different from the defaults.
358 * Defaults means either defaults database, or attributes saved
359 * for the default window "*". This is to let one revert options that are
360 * global because they were saved for all windows ("*").
365 static void
366 insertAttribute(proplist_t dict, proplist_t window, proplist_t attr,
367 proplist_t value, int *modified, int flags)
369 proplist_t def_win, def_value=NULL;
370 int update = 0;
372 if (!(flags & UPDATE_DEFAULTS) && dict) {
373 if ((def_win = PLGetDictionaryEntry(dict, AnyWindow)) != NULL) {
374 def_value = PLGetDictionaryEntry(def_win, attr);
378 /* If we could not find defaults in database, fall to hardcoded values.
379 * Also this is true if we save defaults for all windows
381 if (!def_value)
382 def_value = ((flags & IS_BOOLEAN) != 0) ? No : EmptyString;
384 if ((flags & IS_BOOLEAN))
385 update = (getBool(value) != getBool(def_value));
386 else {
387 update = !PLIsEqual(value, def_value);
390 if (update) {
391 PLInsertDictionaryEntry(window, attr, value);
392 *modified = 1;
397 static void
398 saveSettings(WMButton *button, InspectorPanel *panel)
400 WWindow *wwin = panel->inspected;
401 WDDomain *db = WDWindowAttributes;
402 proplist_t dict = db->dictionary;
403 proplist_t winDic, value, key;
404 char buffer[256], *icon_file;
405 int flags = 0;
406 int different = 0;
408 /* Save will apply the changes and save them */
409 applySettings(panel->applyBtn, panel);
411 if (WMGetButtonSelected(panel->instRb) != 0)
412 key = PLMakeString(wwin->wm_instance);
413 else if (WMGetButtonSelected(panel->clsRb) != 0)
414 key = PLMakeString(wwin->wm_class);
415 else if (WMGetButtonSelected(panel->bothRb) != 0) {
416 strcat(strcat(strcpy(buffer, wwin->wm_instance), "."), wwin->wm_class);
417 key = PLMakeString(buffer);
419 else if (WMGetButtonSelected(panel->defaultRb) != 0) {
420 key = PLRetain(AnyWindow);
421 flags = UPDATE_DEFAULTS;
423 else
424 key = NULL;
426 if (!key)
427 return;
429 if (!dict) {
430 dict = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
431 if (dict) {
432 db->dictionary = dict;
433 value = PLMakeString(db->path);
434 PLSetFilename(dict, value);
435 PLRelease(value);
437 else {
438 PLRelease(key);
439 return;
443 if (showIconFor(WMWidgetScreen(button), panel, NULL, NULL,
444 USE_TEXT_FIELD) < 0)
445 return;
447 PLSetStringCmpHook(NULL);
449 winDic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
451 /* Update icon for window */
452 icon_file = WMGetTextFieldText(panel->fileText);
453 if (icon_file) {
454 if (icon_file[0] != 0) {
455 value = PLMakeString(icon_file);
456 insertAttribute(dict, winDic, AIcon, value, &different, flags);
457 PLRelease(value);
459 free(icon_file);
462 if (WMGetButtonSelected(panel->curRb) != 0) {
463 value = PLMakeString("");
464 insertAttribute(dict, winDic, AStartWorkspace, value, &different, flags);
465 PLRelease(value);
466 } else if (WMGetButtonSelected(panel->setRb) != 0) {
467 char *ws_name = WMGetTextFieldText(panel->wsText);
468 if (ws_name) {
469 if (ws_name[0] != 0) {
470 value = PLMakeString(ws_name);
471 insertAttribute(dict, winDic, AStartWorkspace, value, &different, flags);
472 PLRelease(value);
474 free(ws_name);
478 flags |= IS_BOOLEAN;
480 value = (WMGetButtonSelected(panel->alwChk)!=0) ? Yes : No;
481 insertAttribute(dict, winDic, AAlwaysUserIcon, value, &different, flags);
483 value = (WMGetButtonSelected(panel->attrChk[0])!=0) ? Yes : No;
484 insertAttribute(dict, winDic, ANoTitlebar, value, &different, flags);
486 value = (WMGetButtonSelected(panel->attrChk[1])!=0) ? Yes : No;
487 insertAttribute(dict, winDic, ANoResizebar, value, &different, flags);
489 value = (WMGetButtonSelected(panel->attrChk[2])!=0) ? Yes : No;
490 insertAttribute(dict, winDic, ANoCloseButton, value, &different, flags);
492 value = (WMGetButtonSelected(panel->attrChk[3])!=0) ? Yes : No;
493 insertAttribute(dict, winDic, ANoMiniaturizeButton, value, &different, flags);
495 value = (WMGetButtonSelected(panel->attrChk[4])!=0) ? Yes : No;
496 insertAttribute(dict, winDic, AKeepOnTop, value, &different, flags);
498 value = (WMGetButtonSelected(panel->attrChk[5])!=0) ? Yes : No;
499 insertAttribute(dict, winDic, AKeepOnBottom, value, &different, flags);
501 value = (WMGetButtonSelected(panel->attrChk[6])!=0) ? Yes : No;
502 insertAttribute(dict, winDic, AOmnipresent, value, &different, flags);
504 value = (WMGetButtonSelected(panel->attrChk[7])!=0) ? Yes : No;
505 insertAttribute(dict, winDic, AStartMiniaturized, value, &different, flags);
507 value = (WMGetButtonSelected(panel->attrChk[8])!=0) ? Yes : No;
508 insertAttribute(dict, winDic, ASkipWindowList, value, &different, flags);
511 value = (WMGetButtonSelected(panel->moreChk[0])!=0) ? Yes : No;
512 insertAttribute(dict, winDic, ANoHideOthers, value, &different, flags);
514 value = (WMGetButtonSelected(panel->moreChk[1])!=0) ? Yes : No;
515 insertAttribute(dict, winDic, ANoKeyBindings, value, &different, flags);
517 value = (WMGetButtonSelected(panel->moreChk[2])!=0) ? Yes : No;
518 insertAttribute(dict, winDic, ANoMouseBindings, value, &different, flags);
520 value = (WMGetButtonSelected(panel->moreChk[3])!=0) ? Yes : No;
521 insertAttribute(dict, winDic, AKeepInsideScreen, value, &different, flags);
523 value = (WMGetButtonSelected(panel->moreChk[4])!=0) ? Yes : No;
524 insertAttribute(dict, winDic, AUnfocusable, value, &different, flags);
526 value = (WMGetButtonSelected(panel->moreChk[5])!=0) ? Yes : No;
527 insertAttribute(dict, winDic, ADontSaveSession, value, &different, flags);
529 value = (WMGetButtonSelected(panel->moreChk[6])!=0) ? Yes : No;
530 insertAttribute(dict, winDic, AEmulateAppIcon, value, &different, flags);
532 /* application wide settings for when */
533 /* the window is the leader, save the attribute with the others */
534 if (panel->inspected->main_window == panel->inspected->client_win) {
536 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
537 insertAttribute(dict, winDic, AStartHidden, value, &different, flags);
539 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
540 insertAttribute(dict, winDic, ANoAppIcon, value, &different, flags);
543 PLRemoveDictionaryEntry(dict, key);
544 if (different) {
545 PLInsertDictionaryEntry(dict, key, winDic);
547 PLRelease(key);
548 PLRelease(winDic);
550 different = 0;
552 /* application wide settings */
553 if (panel->inspected->main_window != panel->inspected->client_win
554 && !(flags & UPDATE_DEFAULTS)) {
555 WApplication *wapp;
556 proplist_t appDic;
558 wapp = wApplicationOf(panel->inspected->main_window);
559 if (wapp) {
560 char *iconFile;
562 appDic = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
564 assert(wapp->main_window_desc->wm_instance!=NULL);
565 assert(wapp->main_window_desc->wm_class!=NULL);
567 strcat(strcpy(buffer, wapp->main_window_desc->wm_instance), ".");
568 strcat(buffer, wwin->wm_class);
569 key = PLMakeString(buffer);
571 iconFile = wDefaultGetIconFile(wwin->screen_ptr,
572 wapp->main_window_desc->wm_instance,
573 wapp->main_window_desc->wm_class,
574 False);
576 if (iconFile && iconFile[0]!=0) {
577 value = PLMakeString(iconFile);
578 insertAttribute(dict, appDic, AIcon, value, &different,
579 flags&~IS_BOOLEAN);
580 PLRelease(value);
583 value = (WMGetButtonSelected(panel->appChk[0])!=0) ? Yes : No;
584 insertAttribute(dict, appDic, AStartHidden, value, &different, flags);
586 value = (WMGetButtonSelected(panel->appChk[1])!=0) ? Yes : No;
587 insertAttribute(dict, appDic, ANoAppIcon, value, &different, flags);
589 PLRemoveDictionaryEntry(dict, key);
590 if (different) {
591 PLInsertDictionaryEntry(dict, key, appDic);
593 PLRelease(key);
594 PLRelease(appDic);
598 PLSave(dict, YES);
600 /* clean up */
601 PLSetStringCmpHook(StringCompareHook);
605 static void
606 makeAppIconFor(WApplication *wapp)
608 WScreen *scr = wapp->main_window_desc->screen_ptr;
610 if (wapp->app_icon)
611 return;
613 if (!wapp->main_window_desc->window_flags.no_appicon)
614 wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
615 else
616 wapp->app_icon = NULL;
618 if (wapp->app_icon) {
619 WIcon *icon = wapp->app_icon->icon;
620 WDock *clip = scr->workspaces[scr->current_workspace]->clip;
621 int x=0, y=0;
623 wapp->app_icon->main_window = wapp->main_window;
625 if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {
626 wapp->app_icon->attracted = 1;
627 if (!clip->keep_attracted && !wapp->app_icon->icon->shadowed) {
628 wapp->app_icon->icon->shadowed = 1;
629 wapp->app_icon->icon->force_paint = 1;
631 wDockAttachIcon(clip, wapp->app_icon, x, y);
632 } else {
633 PlaceIcon(scr, &x, &y);
634 wAppIconMove(wapp->app_icon, x, y);
636 if (!clip || !wapp->app_icon->attracted || !clip->collapsed)
637 XMapWindow(dpy, icon->core->window);
639 if (wPreferences.auto_arrange_icons && !wapp->app_icon->attracted)
640 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
645 static void
646 removeAppIconFor(WApplication *wapp)
648 if (!wapp->app_icon)
649 return;
651 if (wapp->app_icon->docked &&
652 (!wapp->app_icon->attracted || wapp->app_icon->dock->keep_attracted)) {
653 wapp->app_icon->running = 0;
654 /* since we keep it, we don't care if it was attracted or not */
655 wapp->app_icon->attracted = 0;
656 wapp->app_icon->icon->shadowed = 0;
657 wapp->app_icon->main_window = None;
658 wapp->app_icon->pid = 0;
659 wapp->app_icon->icon->owner = NULL;
660 wapp->app_icon->icon->icon_win = None;
661 wapp->app_icon->icon->force_paint = 1;
662 wAppIconPaint(wapp->app_icon);
663 } else if (wapp->app_icon->docked) {
664 wapp->app_icon->running = 0;
665 wDockDetach(wapp->app_icon->dock, wapp->app_icon);
666 } else {
667 wAppIconDestroy(wapp->app_icon);
669 wapp->app_icon = NULL;
670 if (wPreferences.auto_arrange_icons)
671 wArrangeIcons(wapp->main_window_desc->screen_ptr, True);
675 static void
676 applySettings(WMButton *button, InspectorPanel *panel)
678 WWindow *wwin = panel->inspected;
679 WWindowAttributes *wflags = &wwin->window_flags;
680 WWindowAttributes oldFlags = *wflags;
681 WApplication *wapp = wApplicationOf(wwin->main_window);
682 int floating, sunken, skip_window_list;
684 showIconFor(WMWidgetScreen(button), panel, NULL, NULL, USE_TEXT_FIELD);
686 wflags->no_titlebar = WMGetButtonSelected(panel->attrChk[0]);
687 wflags->no_resizebar = WMGetButtonSelected(panel->attrChk[1]);
688 wflags->no_close_button = WMGetButtonSelected(panel->attrChk[2]);
689 wflags->no_miniaturize_button = WMGetButtonSelected(panel->attrChk[3]);
690 floating = WMGetButtonSelected(panel->attrChk[4]);
691 sunken = WMGetButtonSelected(panel->attrChk[5]);
692 wflags->omnipresent = WMGetButtonSelected(panel->attrChk[6]);
693 wflags->start_miniaturized = WMGetButtonSelected(panel->attrChk[7]);
694 skip_window_list = WMGetButtonSelected(panel->attrChk[8]);
696 wflags->no_hide_others = WMGetButtonSelected(panel->moreChk[0]);
697 wflags->no_bind_keys = WMGetButtonSelected(panel->moreChk[1]);
698 wflags->no_bind_mouse = WMGetButtonSelected(panel->moreChk[2]);
699 wflags->dont_move_off = WMGetButtonSelected(panel->moreChk[3]);
700 wflags->no_focusable = WMGetButtonSelected(panel->moreChk[4]);
701 wflags->dont_save_session = WMGetButtonSelected(panel->moreChk[5]);
702 wflags->emulate_appicon = WMGetButtonSelected(panel->moreChk[6]);
703 wflags->always_user_icon = WMGetButtonSelected(panel->alwChk);
705 if (wflags->no_titlebar && wwin->flags.shaded)
706 wUnshadeWindow(wwin);
707 wflags->no_shadeable = wflags->no_titlebar;
709 if (floating) {
710 if (!wflags->floating)
711 ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
712 } else if (sunken) {
713 if (!wflags->sunken)
714 ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
715 } else {
716 if (wflags->floating || wflags->sunken)
717 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
720 wflags->sunken = sunken;
721 wflags->floating = floating;
724 if (wflags->skip_window_list != skip_window_list) {
725 int action = ((wflags->skip_window_list = skip_window_list))
726 ? ACTION_REMOVE : ACTION_ADD;
727 UpdateSwitchMenu(wwin->screen_ptr, wwin, action);
730 if (wflags->no_bind_keys != oldFlags.no_bind_keys) {
731 if (!wflags->no_bind_keys) {
732 XUngrabKey(dpy, AnyKey, AnyModifier, wwin->frame->core->window);
733 } else {
734 wWindowSetKeyGrabs(wwin);
738 if (wflags->no_bind_mouse != oldFlags.no_bind_mouse) {
739 wWindowResetMouseGrabs(wwin);
742 wwin->frame->flags.need_texture_change = 1;
743 wWindowConfigureBorders(wwin);
744 wFrameWindowPaint(wwin->frame);
747 * Can't apply emulate_appicon because it will probably cause problems.
750 if (wapp) {
751 /* do application wide stuff */
752 wflags = &wapp->main_window_desc->window_flags;
754 wflags->start_hidden = WMGetButtonSelected(panel->appChk[0]);
755 wflags->no_appicon = WMGetButtonSelected(panel->appChk[1]);
757 if (wflags->no_appicon)
758 removeAppIconFor(wapp);
759 else
760 makeAppIconFor(wapp);
762 if (wapp->app_icon && wapp->main_window == wwin->client_win) {
763 char *file = WMGetTextFieldText(panel->fileText);
765 if (file[0] == 0) {
766 free(file);
767 file = NULL;
769 wIconChangeImageFile(wapp->app_icon->icon, file);
770 if (file)
771 free(file);
772 wAppIconPaint(wapp->app_icon);
778 static void
779 revertSettings(WMButton *button, InspectorPanel *panel)
781 WWindow *wwin = panel->inspected;
782 WApplication *wapp = wApplicationOf(wwin->main_window);
783 int i, n, floating, sunken, skip_window_list;
784 char *wm_instance = NULL;
785 char *wm_class = NULL;
787 if (WMGetButtonSelected(panel->instRb) != 0)
788 wm_instance = wwin->wm_instance;
789 else if (WMGetButtonSelected(panel->clsRb) != 0)
790 wm_class = wwin->wm_class;
791 else if (WMGetButtonSelected(panel->bothRb) != 0) {
792 wm_instance = wwin->wm_instance;
793 wm_class = wwin->wm_class;
795 memset(&wwin->window_flags, 0, sizeof(WWindowAttributes));
796 wDefaultFillAttributes(wwin->screen_ptr, wm_instance, wm_class,
797 &wwin->window_flags, True);
799 wWindowCheckAttributeSanity(wwin, &wwin->window_flags);
801 wwin->window_flags.kill_close = (wwin->protocols.DELETE_WINDOW) ? 0 : 1;
802 /* transients can't be iconified or maximized */
803 if (wwin->window_flags.no_miniaturizable) {
804 wwin->window_flags.no_miniaturize_button = 1;
806 /* if the window can't be resized, remove the resizebar */
807 if (wwin->window_flags.no_resizable) {
808 wwin->window_flags.no_resizebar = 1;
811 wwin->window_flags.no_shadeable = wwin->window_flags.no_titlebar;
813 for (i=0; i < 9; i++) {
814 int flag = 0;
816 switch (i) {
817 case 0:
818 flag = wwin->window_flags.no_titlebar;
819 break;
820 case 1:
821 flag = wwin->window_flags.no_resizebar;
822 break;
823 case 2:
824 flag = wwin->window_flags.no_close_button;
825 break;
826 case 3:
827 flag = wwin->window_flags.no_miniaturize_button;
828 break;
829 case 4:
830 flag = wwin->window_flags.floating;
831 break;
832 case 5:
833 flag = wwin->window_flags.sunken;
834 break;
835 case 6:
836 flag = wwin->window_flags.omnipresent;
837 break;
838 case 7:
839 flag = wwin->window_flags.no_focusable;
840 break;
841 case 8:
842 flag = wwin->window_flags.skip_window_list;
843 break;
845 WMSetButtonSelected(panel->attrChk[i], flag);
847 for (i=0; i < 7; i++) {
848 int flag = 0;
850 switch (i) {
851 case 0:
852 flag = wwin->window_flags.no_hide_others;
853 break;
854 case 1:
855 flag = wwin->window_flags.no_bind_keys;
856 break;
857 case 2:
858 flag = wwin->window_flags.no_bind_mouse;
859 break;
860 case 3:
861 flag = wwin->window_flags.dont_move_off;
862 break;
863 case 4:
864 flag = wwin->window_flags.start_miniaturized;
865 break;
866 case 5:
867 flag = wwin->window_flags.dont_save_session;
868 break;
869 case 6:
870 flag = wwin->window_flags.emulate_appicon;
871 break;
873 WMSetButtonSelected(panel->moreChk[i], flag);
875 if (panel->appFrm && wapp) {
876 for (i=0; i < 2; i++) {
877 int flag = 0;
879 switch (i) {
880 case 0:
881 flag = wapp->main_window_desc->window_flags.start_hidden;
882 break;
883 case 1:
884 flag = wapp->main_window_desc->window_flags.no_appicon;
885 break;
887 WMSetButtonSelected(panel->appChk[i], flag);
890 WMSetButtonSelected(panel->alwChk, wwin->window_flags.always_user_icon);
892 showIconFor(WMWidgetScreen(panel->alwChk), panel, wm_instance, wm_class,
893 REVERT_TO_DEFAULT);
895 n = wDefaultGetStartWorkspace(wwin->screen_ptr, wm_instance, wm_class);
897 if (n >= 0 && n <= wwin->screen_ptr->workspace_count) {
898 WMPerformButtonClick(panel->setRb);
899 WMSetTextFieldText(panel->wsText, wwin->screen_ptr->workspaces[n]->name);
900 } else {
901 WMPerformButtonClick(panel->curRb);
906 static void
907 chooseIconCallback(WMWidget *self, void *clientData)
909 char *file;
910 InspectorPanel *panel = (InspectorPanel*)clientData;
911 int result;
913 panel->choosingIcon = 1;
915 WMSetButtonEnabled(panel->browseIconBtn, False);
917 result = wIconChooserDialog(panel->frame->screen_ptr, &file);
919 panel->choosingIcon = 0;
921 if (!panel->destroyed) { /* kluge */
922 if (result) {
923 WMSetTextFieldText(panel->fileText, file);
924 showIconFor(WMWidgetScreen(self), panel, NULL, NULL,
925 USE_TEXT_FIELD);
926 free(file);
928 WMSetButtonEnabled(panel->browseIconBtn, True);
929 } else {
930 freeInspector(panel);
935 static void
936 textEditedObserver(void *observerData, WMNotification *notification)
938 InspectorPanel *panel = (InspectorPanel*)observerData;
940 if ((int)WMGetNotificationClientData(notification) != WMReturnTextMovement)
941 return;
943 if (observerData == panel->fileText) {
944 showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL,
945 USE_TEXT_FIELD);
947 WMPerformButtonClick(panel->updateIconBtn);
949 } else
950 WMPerformButtonClick(panel->setRb);
953 static InspectorPanel*
954 createInspectorForWindow(WWindow *wwin)
956 WScreen *scr = wwin->screen_ptr;
957 InspectorPanel *panel;
958 Window parent;
959 char charbuf[128];
960 int i;
961 int x, y;
962 int btn_width, frame_width;
963 #ifdef wrong_behaviour
964 WMPixmap *pixmap;
965 #endif
966 panel = wmalloc(sizeof(InspectorPanel));
968 panel->destroyed = 0;
971 panel->inspected = wwin;
973 panel->nextPtr = panelList;
974 panelList = panel;
977 sprintf(charbuf, "Inspecting %s.%s",
978 wwin->wm_instance ? wwin->wm_instance : "?",
979 wwin->wm_class ? wwin->wm_class : "?");
981 panel->win = WMCreateWindow(scr->wmscreen, "windowInspector");
982 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
985 /**** create common stuff ****/
987 /* command buttons */
988 /* (PWIDTH - (left and right margin) - (btn interval)) / 3 */
989 btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3;
990 panel->saveBtn = WMCreateCommandButton(panel->win);
991 WMSetButtonAction(panel->saveBtn, (WMAction*)saveSettings, panel);
992 WMMoveWidget(panel->saveBtn, 15, 310);
993 WMSetButtonText(panel->saveBtn, _("Save"));
994 WMResizeWidget(panel->saveBtn, btn_width, 28);
995 if (wPreferences.flags.noupdates)
996 WMSetButtonEnabled(panel->saveBtn, False);
998 panel->applyBtn = WMCreateCommandButton(panel->win);
999 WMSetButtonAction(panel->applyBtn, (WMAction*)applySettings, panel);
1000 WMMoveWidget(panel->applyBtn, btn_width + 10 + 15, 310);
1001 WMSetButtonText(panel->applyBtn, _("Apply"));
1002 WMResizeWidget(panel->applyBtn, btn_width, 28);
1004 panel->revertBtn = WMCreateCommandButton(panel->win);
1005 WMSetButtonAction(panel->revertBtn, (WMAction*)revertSettings, panel);
1006 WMMoveWidget(panel->revertBtn, (2 * (btn_width + 10)) + 15, 310);
1007 WMSetButtonText(panel->revertBtn, _("Revert"));
1008 WMResizeWidget(panel->revertBtn, btn_width, 28);
1010 /* page selection popup button */
1011 panel->pagePopUp = WMCreatePopUpButton(panel->win);
1012 WMSetPopUpButtonAction(panel->pagePopUp, (WMAction*)changePage, panel);
1013 WMMoveWidget(panel->pagePopUp, 25, 15);
1014 WMResizeWidget(panel->pagePopUp, PWIDTH - 50, 20);
1016 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Specification"));
1017 WMAddPopUpButtonItem(panel->pagePopUp, _("Window Attributes"));
1018 WMAddPopUpButtonItem(panel->pagePopUp, _("Advanced Options"));
1019 WMAddPopUpButtonItem(panel->pagePopUp, _("Icon and Initial Workspace"));
1020 WMAddPopUpButtonItem(panel->pagePopUp, _("Application Specific"));
1022 /**** window spec ****/
1023 frame_width = PWIDTH - (2 * 15);
1025 panel->specFrm = WMCreateFrame(panel->win);
1026 WMSetFrameTitle(panel->specFrm, _("Window Specification"));
1027 WMMoveWidget(panel->specFrm, 15, 65);
1028 WMResizeWidget(panel->specFrm, frame_width, 105);
1031 panel->defaultRb = WMCreateRadioButton(panel->specFrm);
1032 WMMoveWidget(panel->defaultRb, 10, 78);
1033 WMResizeWidget(panel->defaultRb, frame_width - (2 * 10), 20);
1034 WMSetButtonText(panel->defaultRb, _("Defaults for all windows"));
1035 WMSetButtonSelected(panel->defaultRb, False);
1038 if (wwin->wm_class && wwin->wm_instance) {
1039 sprintf(charbuf, "%s.%s", wwin->wm_instance, wwin->wm_class);
1040 panel->bothRb = WMCreateRadioButton(panel->specFrm);
1041 WMMoveWidget(panel->bothRb, 10, 18);
1042 WMResizeWidget(panel->bothRb, frame_width - (2 * 10), 20);
1043 WMSetButtonText(panel->bothRb, charbuf);
1044 WMSetButtonSelected(panel->bothRb, True);
1045 WMGroupButtons(panel->defaultRb, panel->bothRb);
1048 if (wwin->wm_instance) {
1049 panel->instRb = WMCreateRadioButton(panel->specFrm);
1050 WMMoveWidget(panel->instRb, 10, 38);
1051 WMResizeWidget(panel->instRb, frame_width - (2 * 10), 20);
1052 WMSetButtonText(panel->instRb, wwin->wm_instance);
1053 WMSetButtonSelected(panel->instRb, False);
1054 WMGroupButtons(panel->defaultRb, panel->instRb);
1057 if (wwin->wm_class) {
1058 panel->clsRb = WMCreateRadioButton(panel->specFrm);
1059 WMMoveWidget(panel->clsRb, 10, 58);
1060 WMResizeWidget(panel->clsRb, frame_width - (2 * 10), 20);
1061 WMSetButtonText(panel->clsRb, wwin->wm_class);
1062 WMSetButtonSelected(panel->clsRb, False);
1063 WMGroupButtons(panel->defaultRb, panel->clsRb);
1066 panel->specLbl = WMCreateLabel(panel->win);
1067 WMMoveWidget(panel->specLbl, 15, 170);
1068 WMResizeWidget(panel->specLbl, frame_width, 100);
1069 WMSetLabelText(panel->specLbl,
1070 _("The configuration will apply to all\n"
1071 "windows that have their WM_CLASS property"
1072 " set to the above selected\nname, when saved."));
1073 WMSetLabelTextAlignment(panel->specLbl, WACenter);
1075 /**** attributes ****/
1076 panel->attrFrm = WMCreateFrame(panel->win);
1077 WMSetFrameTitle(panel->attrFrm, _("Attributes"));
1078 WMMoveWidget(panel->attrFrm, 15, 50);
1079 WMResizeWidget(panel->attrFrm, frame_width, 240);
1081 for (i=0; i < 9; i++) {
1082 char *caption = NULL;
1083 int flag = 0;
1085 switch (i) {
1086 case 0:
1087 caption = _("Disable titlebar");
1088 flag = wwin->window_flags.no_titlebar;
1089 break;
1090 case 1:
1091 caption = _("Disable resizebar");
1092 flag = wwin->window_flags.no_resizebar;
1093 break;
1094 case 2:
1095 caption = _("Disable close button");
1096 flag = wwin->window_flags.no_close_button;
1097 break;
1098 case 3:
1099 caption = _("Disable miniaturize button");
1100 flag = wwin->window_flags.no_miniaturize_button;
1101 break;
1102 case 4:
1103 caption = _("Keep on top / floating");
1104 flag = wwin->window_flags.floating;
1105 break;
1106 case 5:
1107 caption = _("Keep on bottom / sunken");
1108 flag = wwin->window_flags.sunken;
1109 break;
1110 case 6:
1111 caption = _("Omnipresent");
1112 flag = wwin->window_flags.omnipresent;
1113 break;
1114 case 7:
1115 caption = _("Start Miniaturized");
1116 flag = wwin->window_flags.start_miniaturized;
1117 break;
1118 case 8:
1119 caption = _("Skip window list");
1120 flag = wwin->window_flags.skip_window_list;
1121 break;
1123 panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm);
1124 WMMoveWidget(panel->attrChk[i], 10, 20*(i+1));
1125 WMResizeWidget(panel->attrChk[i], frame_width-15, 20);
1126 WMSetButtonSelected(panel->attrChk[i], flag);
1127 WMSetButtonText(panel->attrChk[i], caption);
1131 /**** more attributes ****/
1132 panel->moreFrm = WMCreateFrame(panel->win);
1133 WMSetFrameTitle(panel->moreFrm, _("Advanced"));
1134 WMMoveWidget(panel->moreFrm, 15, 50);
1135 WMResizeWidget(panel->moreFrm, frame_width, 240);
1137 for (i=0; i < 7; i++) {
1138 char *caption = NULL;
1139 int flag = 0;
1141 switch (i) {
1142 case 0:
1143 caption = _("Ignore HideOthers");
1144 flag = wwin->window_flags.no_hide_others;
1145 break;
1146 case 1:
1147 caption = _("Don't bind keyboard shortcuts");
1148 flag = wwin->window_flags.no_bind_keys;
1149 break;
1150 case 2:
1151 caption = _("Don't bind mouse clicks");
1152 flag = wwin->window_flags.no_bind_mouse;
1153 break;
1154 case 3:
1155 caption = _("Keep inside screen");
1156 flag = wwin->window_flags.dont_move_off;
1157 break;
1158 case 4:
1159 caption = _("Don't let it take focus");
1160 flag = wwin->window_flags.no_focusable;
1161 break;
1162 case 5:
1163 caption = _("Don't Save Session");
1164 flag = wwin->window_flags.dont_save_session;
1165 break;
1166 case 6:
1167 caption = _("Emulate Application Icon");
1168 flag = wwin->window_flags.emulate_appicon;
1169 break;
1171 panel->moreChk[i] = WMCreateSwitchButton(panel->moreFrm);
1172 WMMoveWidget(panel->moreChk[i], 10, 20*(i+1));
1173 WMResizeWidget(panel->moreChk[i], frame_width-15, 20);
1174 WMSetButtonSelected(panel->moreChk[i], flag);
1175 WMSetButtonText(panel->moreChk[i], caption);
1178 panel->moreLbl = WMCreateLabel(panel->moreFrm);
1179 WMResizeWidget(panel->moreLbl, frame_width - (2 * 5), 60);
1180 WMMoveWidget(panel->moreLbl, 5, 160);
1181 WMSetLabelText(panel->moreLbl,
1182 _("Enable the \"Don't bind...\" options to allow the "
1183 "application to receive all mouse or keyboard events."));
1185 /* miniwindow/workspace */
1186 panel->iconFrm = WMCreateFrame(panel->win);
1187 WMMoveWidget(panel->iconFrm, 15, 50);
1188 WMResizeWidget(panel->iconFrm, PWIDTH - (2 * 15), 170);
1189 WMSetFrameTitle(panel->iconFrm, _("Miniwindow Image"));
1191 panel->iconLbl = WMCreateLabel(panel->iconFrm);
1192 WMMoveWidget(panel->iconLbl, PWIDTH - (2 * 15) - 22 - 64, 30);
1193 WMResizeWidget(panel->iconLbl, 64, 64);
1194 WMSetLabelRelief(panel->iconLbl, WRRaised);
1195 WMSetLabelImagePosition(panel->iconLbl, WIPImageOnly);
1197 panel->browseIconBtn = WMCreateCommandButton(panel->iconFrm);
1198 WMSetButtonAction(panel->browseIconBtn, chooseIconCallback, panel);
1199 WMMoveWidget(panel->browseIconBtn, 22, 30);
1200 WMResizeWidget(panel->browseIconBtn, 100, 26);
1201 WMSetButtonText(panel->browseIconBtn, _("Browse..."));
1203 #if 0
1204 panel->updateIconBtn = WMCreateCommandButton(panel->iconFrm);
1205 WMSetButtonAction(panel->updateIconBtn, (WMAction*)updateIcon, panel);
1206 WMMoveWidget(panel->updateIconBtn, 22, 65);
1207 WMResizeWidget(panel->updateIconBtn, 100, 26);
1208 WMSetButtonText(panel->updateIconBtn, _("Update"));
1209 #endif
1210 #ifdef wrong_behaviour
1211 WMSetButtonImagePosition(panel->updateIconBtn, WIPRight);
1212 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIReturnArrow);
1213 WMSetButtonImage(panel->updateIconBtn, pixmap);
1214 WMReleasePixmap(pixmap);
1215 pixmap = WMGetSystemPixmap(scr->wmscreen, WSIHighlightedReturnArrow);
1216 WMSetButtonAltImage(panel->updateIconBtn, pixmap);
1217 WMReleasePixmap(pixmap);
1218 #endif
1220 panel->fileLbl = WMCreateLabel(panel->iconFrm);
1221 WMMoveWidget(panel->fileLbl, 20, 95);
1222 WMResizeWidget(panel->fileLbl, PWIDTH - (2 * 15) - (2 * 20), 14);
1223 WMSetLabelText(panel->fileLbl, _("Icon file name:"));
1225 panel->fileText = WMCreateTextField(panel->iconFrm);
1226 WMMoveWidget(panel->fileText, 20, 115);
1227 WMResizeWidget(panel->fileText, PWIDTH - (2 * 15) - (2 * 15), 20);
1228 WMSetTextFieldText(panel->fileText, NULL);
1229 WMAddNotificationObserver(textEditedObserver, panel,
1230 WMTextDidEndEditingNotification,
1231 panel->fileText);
1232 panel->alwChk = WMCreateSwitchButton(panel->iconFrm);
1233 WMMoveWidget(panel->alwChk, 20, 140);
1234 WMResizeWidget(panel->alwChk, PWIDTH - (2 * 15) - (2 * 15), 20);
1235 WMSetButtonText(panel->alwChk, _("Ignore client supplied icon"));
1236 WMSetButtonSelected(panel->alwChk, wwin->window_flags.always_user_icon);
1239 panel->wsFrm = WMCreateFrame(panel->win);
1240 WMMoveWidget(panel->wsFrm, 15, 225);
1241 WMResizeWidget(panel->wsFrm, PWIDTH - (2 * 15), 70);
1242 WMSetFrameTitle(panel->wsFrm, _("Initial Workspace"));
1244 panel->curRb = WMCreateRadioButton(panel->wsFrm);
1245 WMMoveWidget(panel->curRb, 10, 15);
1246 WMResizeWidget(panel->curRb, frame_width - (2 * 10), 20);
1247 WMSetButtonText(panel->curRb, _("Nowhere in particular"));
1250 panel->setRb = WMCreateRadioButton(panel->wsFrm);
1251 WMMoveWidget(panel->setRb, 10, 40);
1252 WMResizeWidget(panel->setRb, 25, 20);
1253 WMGroupButtons(panel->curRb, panel->setRb);
1254 WMSetButtonText(panel->setRb, NULL);
1256 panel->wsText = WMCreateTextField(panel->wsFrm);
1257 WMMoveWidget(panel->wsText, 30, 40);
1258 WMResizeWidget(panel->wsText, PWIDTH - (2 * 15) - 25 - 10 - (2 * 5), 20);
1259 WMAddNotificationObserver(textEditedObserver, panel,
1260 WMTextDidEndEditingNotification,
1261 panel->wsText);
1264 i = wDefaultGetStartWorkspace(wwin->screen_ptr, wwin->wm_instance,
1265 wwin->wm_class);
1266 if (i >= 0 && i <= wwin->screen_ptr->workspace_count) {
1267 WMSetButtonSelected(panel->curRb, False);
1268 WMSetButtonSelected(panel->setRb, True);
1269 WMSetTextFieldText(panel->wsText,
1270 wwin->screen_ptr->workspaces[i]->name);
1271 } else {
1272 WMSetButtonSelected(panel->curRb, True);
1273 WMSetButtonSelected(panel->setRb, False);
1276 /* application wide attributes */
1277 if (wwin->main_window != None) {
1278 WApplication *wapp = wApplicationOf(wwin->main_window);
1280 panel->appFrm = WMCreateFrame(panel->win);
1281 WMSetFrameTitle(panel->appFrm, _("Application Wide"));
1282 WMMoveWidget(panel->appFrm, 15, 50);
1283 WMResizeWidget(panel->appFrm, frame_width, 240);
1285 for (i=0; i < 2; i++) {
1286 char *caption = NULL;
1287 int flag = 0;
1289 switch (i) {
1290 case 0:
1291 caption = _("Start Hidden");
1292 flag = wapp->main_window_desc->window_flags.start_hidden;
1293 break;
1294 case 1:
1295 caption = _("No application icon");
1296 flag = wapp->main_window_desc->window_flags.no_appicon;
1297 break;
1299 panel->appChk[i] = WMCreateSwitchButton(panel->appFrm);
1300 WMMoveWidget(panel->appChk[i], 10, 20*(i+1));
1301 WMResizeWidget(panel->appChk[i], 205, 20);
1302 WMSetButtonSelected(panel->appChk[i], flag);
1303 WMSetButtonText(panel->appChk[i], caption);
1306 if (wwin->window_flags.emulate_appicon) {
1307 WMSetButtonEnabled(panel->appChk[1], False);
1308 WMSetButtonEnabled(panel->moreChk[6], True);
1309 } else {
1310 WMSetButtonEnabled(panel->appChk[1], True);
1311 WMSetButtonEnabled(panel->moreChk[6], False);
1313 } else {
1314 int tmp;
1316 if (wwin->transient_for!=None
1317 && wwin->transient_for!=scr->root_win)
1318 tmp = False;
1319 else
1320 tmp = True;
1321 WMSetButtonEnabled(panel->moreChk[6], tmp);
1323 WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False);
1324 panel->appFrm = NULL;
1327 WMRealizeWidget(panel->win);
1329 WMMapSubwidgets(panel->win);
1330 WMMapSubwidgets(panel->specFrm);
1331 WMMapSubwidgets(panel->attrFrm);
1332 WMMapSubwidgets(panel->moreFrm);
1333 WMMapSubwidgets(panel->iconFrm);
1334 WMMapSubwidgets(panel->wsFrm);
1335 if (panel->appFrm)
1336 WMMapSubwidgets(panel->appFrm);
1338 WMSetPopUpButtonSelectedItem(panel->pagePopUp, 0);
1339 changePage(panel->pagePopUp, panel);
1342 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT,
1343 0, 0, 0);
1344 XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
1345 panel->parent = parent;
1346 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1348 WMMapWidget(panel->win);
1350 XSetTransientForHint(dpy, parent, wwin->client_win);
1352 x = wwin->frame_x+wwin->frame->core->width/2;
1353 y = wwin->frame_y+wwin->frame->top_width*2;
1354 if (y + PHEIGHT > scr->scr_height)
1355 y = scr->scr_height - PHEIGHT - 30;
1356 panel->frame = wManageInternalWindow(scr, parent, wwin->client_win,
1357 charbuf, x, y, PWIDTH, PHEIGHT);
1359 /* kluge to know who should get the key events */
1360 panel->frame->client_leader = WMWidgetXID(panel->win);
1362 panel->frame->window_flags.no_closable = 0;
1363 panel->frame->window_flags.no_close_button = 0;
1364 wWindowUpdateButtonImages(panel->frame);
1365 wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON);
1366 panel->frame->frame->on_click_right = destroyInspector;
1368 wWindowMap(panel->frame);
1370 showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance,
1371 wwin->wm_class, UPDATE_TEXT_FIELD);
1372 return panel;
1376 void
1377 wShowInspectorForWindow(WWindow *wwin)
1379 if (wwin->flags.inspector_open)
1380 return;
1382 make_keys();
1383 wwin->flags.inspector_open = 1;
1384 wwin->inspector = createInspectorForWindow(wwin);;