~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to win_utils.c

  • Committer: Matthew Fuller
  • Date: 2018-08-06 00:49:17 UTC
  • mto: This revision was merged to the branch mainline in revision 616.
  • Revision ID: fullermd@over-yonder.net-20180806004917-j3awg5rhv647i8ou
Split out setting ->name from doing the stuff that we do after
changing it.  AddWindow() only needs to do the setting part.

Show diffs side-by-side

added added

removed removed

Lines of Context:
939
939
 
940
940
 
941
941
/*
942
 
 * [Re]set a window's name.  This is called after we've received a new
943
 
 * WM_NAME (or other name-setting) property, to update our titlebars,
944
 
 * icon managers, etc.
 
942
 * [Re]set a window's name.  This should rarely be called directly;
 
943
 * apply_window_name() should be used instead.  It's split out because we
 
944
 * need to do this step individually in AddWindow().
945
945
 *
946
946
 * Note that we never need to worry about freeing win->name; it always
947
947
 * points to one of the win->names.something's (which are free'd by the
948
948
 * event handler when they change) or NoName (which is static).  So we
949
949
 * can just casually flip it around at will.
950
950
 */
951
 
void
952
 
apply_window_name(TwmWindow *win)
 
951
bool
 
952
set_window_name(TwmWindow *win)
953
953
{
954
 
        /* Figure what the name should be, and change if necessary */
955
 
        {
956
 
                char *newname = NULL;
 
954
        char *newname = NULL;
957
955
#define TRY(fld) { \
958
956
                if(newname == NULL && win->names.fld != NULL) { \
959
957
                        newname = win->names.fld; \
960
958
                } \
961
959
        }
962
960
#ifdef EWMH
963
 
                TRY(net_wm_name)
 
961
        TRY(net_wm_name)
964
962
#endif
965
 
                TRY(wm_name)
 
963
        TRY(wm_name)
966
964
#undef TRY
967
965
 
968
 
                if(newname == NULL) {
969
 
                        newname = NoName;
970
 
                }
971
 
                if(win->name == newname) {
972
 
                        return; // Nothing to do
973
 
                }
974
 
 
975
 
                win->name = newname;
976
 
                win->nameChanged = true;
977
 
        }
 
966
        if(newname == NULL) {
 
967
                newname = NoName;
 
968
        }
 
969
        if(win->name == newname) {
 
970
                return false; // Nothing to do
 
971
        }
 
972
 
 
973
        win->name = newname;
 
974
        return true;
 
975
}
 
976
 
 
977
 
 
978
/*
 
979
 * [Re]set and apply changes to a window's name.  This is called after
 
980
 * we've received a new WM_NAME (or other name-setting) property, to
 
981
 * update our titlebars, icon managers, etc.
 
982
 */
 
983
void
 
984
apply_window_name(TwmWindow *win)
 
985
{
 
986
        /* [Re]set ->name */
 
987
        if(set_window_name(win) == false) {
 
988
                // No change
 
989
                return;
 
990
        }
 
991
        win->nameChanged = true;
 
992
 
978
993
 
979
994
        /* Update the active name */
980
995
        {