int EWMH_WMName( FvwmWindow *fw, XEvent *ev, window_style *style, unsigned long any) { int size = 0; char *val; char *tmp_str; FlocaleCharset *fc = NULL; int what_changed; if (!FiconvSupport) return 0; val = ewmh_AtomGetByName( FW_W(fw), "_NET_WM_NAME", EWMH_ATOM_LIST_PROPERTY_NOTIFY, &size); if (val == NULL) { SET_HAS_EWMH_WM_NAME(fw,0); return 0; } if (IS_WINDOW_FONT_LOADED(fw) && fw->title_font != NULL) { fc = fw->title_font->str_fc; } tmp_str = (char *)FiconvUtf8ToCharset( dpy, fc, (const char *) val, size); free(val); if (tmp_str == NULL) { SET_HAS_EWMH_WM_NAME(fw,0); return 0; } if (strlen(tmp_str) > MAX_WINDOW_NAME_LEN) { tmp_str[MAX_WINDOW_NAME_LEN] = 0; } SET_HAS_EWMH_WM_NAME(fw, 1); if (fw->name.name && strcmp(tmp_str, fw->name.name) == 0) { /* migo: some apps update their names every second */ free(tmp_str); return 0; } if (ev != NULL) { /* client message */ free_window_names(fw, True, False); } fw->name.name = tmp_str; if (ev == NULL) { return 1; } SET_NAME_CHANGED(fw, 1); what_changed = 1; if (!WAS_ICON_NAME_PROVIDED(fw)) { fw->icon_name = fw->name; what_changed |= 2; } update_window_names(fw, what_changed); return 0; }
void HandlePropertyNotify() { XTextProperty text_prop; Boolean OnThisPage = False; DBUG("HandlePropertyNotify","Routine Entered"); if ((!Tmp_win)|| (XGetGeometry(dpy, Tmp_win->w, &JunkRoot, &JunkX, &JunkY, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0)) return; /* Make sure at least part of window is on this page before giving it focus... */ if ( (Tmp_win->Desk == Scr.CurrentDesk) && ( ((Tmp_win->frame_x + Tmp_win->frame_width) >= 0 && Tmp_win->frame_x < Scr.MyDisplayWidth) && ((Tmp_win->frame_y + Tmp_win->frame_height) >= 0 && Tmp_win->frame_y < Scr.MyDisplayHeight) ) ) { OnThisPage = True; } switch (Event.xproperty.atom) { case XA_WM_TRANSIENT_FOR: { if(XGetTransientForHint(dpy, Tmp_win->w, &Tmp_win->transientfor)) { Tmp_win->flags |= TRANSIENT; RaiseWindow(Tmp_win); } else { Tmp_win->flags &= ~TRANSIENT; } } break; case XA_WM_NAME: if (!XGetWMName(dpy, Tmp_win->w, &text_prop)) return; free_window_names (Tmp_win, True, False); Tmp_win->name = (char *)text_prop.value; if (Tmp_win->name && strlen(Tmp_win->name) > 200) /* limit to prevent hanging X server */ Tmp_win->name[200] = 0; if (Tmp_win->name == NULL) Tmp_win->name = NoName; BroadcastName(M_WINDOW_NAME,Tmp_win->w,Tmp_win->frame, (unsigned long)Tmp_win,Tmp_win->name); /* fix the name in the title bar */ if(!(Tmp_win->flags & ICONIFIED)) SetTitleBar(Tmp_win,(Scr.Hilite==Tmp_win),True); /* * if the icon name is NoName, set the name of the icon to be * the same as the window */ if (Tmp_win->icon_name == NoName) { Tmp_win->icon_name = Tmp_win->name; BroadcastName(M_ICON_NAME,Tmp_win->w,Tmp_win->frame, (unsigned long)Tmp_win,Tmp_win->icon_name); RedoIconName(Tmp_win); } break; case XA_WM_ICON_NAME: if (!XGetWMIconName (dpy, Tmp_win->w, &text_prop)) return; free_window_names (Tmp_win, False, True); Tmp_win->icon_name = (char *) text_prop.value; if (Tmp_win->icon_name && strlen(Tmp_win->icon_name) > 200) /* limit to prevent hanging X server */ Tmp_win->icon_name[200] = 0; if (Tmp_win->icon_name == NULL) Tmp_win->icon_name = NoName; BroadcastName(M_ICON_NAME,Tmp_win->w,Tmp_win->frame, (unsigned long)Tmp_win,Tmp_win->icon_name); RedoIconName(Tmp_win); break; case XA_WM_HINTS: if (Tmp_win->wmhints) XFree ((char *) Tmp_win->wmhints); Tmp_win->wmhints = XGetWMHints(dpy, Event.xany.window); if(Tmp_win->wmhints == NULL) return; if((Tmp_win->wmhints->flags & IconPixmapHint)|| (Tmp_win->wmhints->flags & IconWindowHint)) if(Tmp_win->icon_bitmap_file == Scr.DefaultIcon) Tmp_win->icon_bitmap_file = (char *)0; if((Tmp_win->wmhints->flags & IconPixmapHint)|| (Tmp_win->wmhints->flags & IconWindowHint)) { if (!(Tmp_win->flags & SUPPRESSICON)) { if (Tmp_win->icon_w) XDestroyWindow(dpy,Tmp_win->icon_w); XDeleteContext(dpy, Tmp_win->icon_w, FvwmContext); if(Tmp_win->flags & ICON_OURS) { if(Tmp_win->icon_pixmap_w != None) { XDestroyWindow(dpy,Tmp_win->icon_pixmap_w); XDeleteContext(dpy, Tmp_win->icon_pixmap_w, FvwmContext); } } else XUnmapWindow(dpy,Tmp_win->icon_pixmap_w); } Tmp_win->icon_w = None; Tmp_win->icon_pixmap_w = None; Tmp_win->iconPixmap = (Window)NULL; if(Tmp_win->flags & ICONIFIED) { Tmp_win->flags &= ~ICONIFIED; Tmp_win->flags &= ~ICON_UNMAPPED; CreateIconWindow(Tmp_win, Tmp_win->icon_x_loc,Tmp_win->icon_y_loc); BroadcastPacket(M_ICONIFY, 7, Tmp_win->w, Tmp_win->frame, (unsigned long)Tmp_win, Tmp_win->icon_x_loc, Tmp_win->icon_y_loc, Tmp_win->icon_w_width, Tmp_win->icon_w_height); BroadcastConfig(M_CONFIGURE_WINDOW, Tmp_win); if (!(Tmp_win->flags & SUPPRESSICON)) { LowerWindow(Tmp_win); AutoPlace(Tmp_win); if(Tmp_win->Desk == Scr.CurrentDesk) { if(Tmp_win->icon_w) XMapWindow(dpy, Tmp_win->icon_w); if(Tmp_win->icon_pixmap_w != None) XMapWindow(dpy, Tmp_win->icon_pixmap_w); } } Tmp_win->flags |= ICONIFIED; DrawIconWindow(Tmp_win); } } break; case XA_WM_NORMAL_HINTS: GetWindowSizeHints (Tmp_win); #if 0 /* ** ckh - not sure why this next stuff was here, but fvwm 1.xx ** didn't do this, and it seems to cause a bug when changing ** fonts in XTerm */ { int new_width, new_height; new_width = Tmp_win->frame_width; new_height = Tmp_win->frame_height; ConstrainSize(Tmp_win, &new_width, &new_height, False, 0, 0); if((new_width != Tmp_win->frame_width)|| (new_height != Tmp_win->frame_height)) SetupFrame(Tmp_win,Tmp_win->frame_x, Tmp_win->frame_y, new_width,new_height,False); } #endif /* 0 */ BroadcastConfig(M_CONFIGURE_WINDOW,Tmp_win); break; default: if(Event.xproperty.atom == _XA_WM_PROTOCOLS) FetchWmProtocols (Tmp_win); else if (Event.xproperty.atom == _XA_WM_COLORMAP_WINDOWS) { FetchWmColormapWindows (Tmp_win); /* frees old data */ ReInstallActiveColormap(); } else if(Event.xproperty.atom == _XA_WM_STATE) { if((Tmp_win != NULL)&&(Tmp_win->flags & ClickToFocus) &&(Tmp_win == Scr.Focus)) { if (OnThisPage) { Scr.Focus = NULL; SetFocus(Tmp_win->w,Tmp_win,0); } } } break; } }