"Fossies" - the Fresh Open Source Software Archive

Member "xscreensaver-6.01/driver/atomswm.c" (20 May 2021, 3999 Bytes) of package /linux/misc/xscreensaver-6.01.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "atomswm.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.00_vs_6.01.

    1 /* xscreensaver-command, Copyright © 1991-2021 Jamie Zawinski <jwz@jwz.org>
    2  *
    3  * Permission to use, copy, modify, distribute, and sell this software and its
    4  * documentation for any purpose is hereby granted without fee, provided that
    5  * the above copyright notice appear in all copies and that both that
    6  * copyright notice and this permission notice appear in supporting
    7  * documentation.  No representations are made about the suitability of this
    8  * software for any purpose.  It is provided "as is" without express or 
    9  * implied warranty.
   10  */
   11 
   12 #ifdef HAVE_CONFIG_H
   13 # include "config.h"
   14 #endif
   15 
   16 #include <stdio.h>
   17 #include <ctype.h>
   18 #include <stdlib.h>
   19 #include <string.h>
   20 #include <X11/Xproto.h>     /* for CARD32 */
   21 #include <X11/Xlib.h>
   22 #include <X11/Xutil.h>
   23 #include <X11/Xatom.h>
   24 
   25 #include "atoms.h"
   26 
   27 #ifdef HAVE_UNAME
   28 # include <sys/utsname.h>   /* for uname() */
   29 #endif /* HAVE_UNAME */
   30 
   31 
   32 /* Set some properties to hopefully tell the window manager to leave us alone.
   33    This is used by xscreensaver-gfx and xscreensaver-auth but not xscreensaver.
   34  */
   35 void
   36 xscreensaver_set_wm_atoms (Display *dpy, Window window, int width, int height, 
   37                            Window for_window)
   38 {
   39   XClassHint class_hints;
   40   XSizeHints size_hints;
   41 # ifdef HAVE_UNAME
   42   struct utsname uts;
   43 # endif
   44   Atom va[10];
   45   long vl[10];
   46   int i;
   47   class_hints.res_name  = "xscreensaver";  /* not progname */
   48   class_hints.res_class = "XScreenSaver";
   49   size_hints.flags      = PMinSize | PMaxSize;
   50   size_hints.min_width  = size_hints.max_width  = width;  /* non-resizable */
   51   size_hints.min_height = size_hints.max_height = height;
   52   XStoreName (dpy, window, "XScreenSaver");
   53   XSetClassHint (dpy, window, &class_hints);
   54   XSetWMNormalHints (dpy, window, &size_hints);
   55 
   56   /* XA_WM_COMMAND and _NET_WM_PID are later updated by spawn_screenhack.  */
   57   XChangeProperty (dpy, window, XA_WM_COMMAND,
   58                    XA_STRING, 8, PropModeReplace,
   59                    (unsigned char *) class_hints.res_name,
   60                    strlen (class_hints.res_name));
   61 
   62 # ifdef HAVE_UNAME
   63   if (! uname (&uts))
   64     XChangeProperty (dpy, window,
   65                      XA_WM_CLIENT_MACHINE, XA_STRING, 8,
   66                      PropModeReplace, (unsigned char *) uts.nodename,
   67                      strlen (uts.nodename));
   68 # endif
   69 
   70   /* In the olden days, OverrideRedirect meant that the window manager did
   71      not see or touch our window, but these days, compositing WMs like to
   72      get up to all sorts of shenanigans.  I don't know whether setting these
   73      properties has any effect, but they *might* tell the WM to keep its
   74      grubby paws off of our windows.
   75    */
   76 
   77   i = 0;
   78   vl[i++] = 1;  /* _NET_WM_BYPASS_COMPOSITOR = 1 */
   79   XChangeProperty (dpy, window, XA_NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
   80                    PropModeReplace, (unsigned char *) vl, i);
   81 
   82   /* _NET_WM_STATE = [ _NET_WM_STATE_ABOVE, _NET_WM_STATE_FULLSCREEN ] */
   83   i = 0;
   84   va[i++] = XA_NET_WM_STATE_ABOVE;
   85   va[i++] = XA_NET_WM_STATE_FULLSCREEN;
   86   va[i++] = XA_NET_WM_STATE_STAYS_ON_TOP;  /* Does this do anything? */
   87   XChangeProperty (dpy, window, XA_NET_WM_STATE, XA_ATOM, 32,
   88                    PropModeReplace, (unsigned char *) va, i);
   89 
   90   /* As there is no _NET_WM_WINDOW_TYPE_SCREENSAVER, which property is
   91      most likely to effectively communicate "on top always" to the WM?
   92      _NET_WM_WINDOW_TYPE = NORMAL, SPLASH, DIALOG or NOTIFICATION? */
   93   i = 0;
   94   va[i++] = XA_NET_WM_WINDOW_TYPE_NOTIFICATION;
   95   va[i++] = XA_KDE_NET_WM_WINDOW_TYPE_OVERRIDE;  /* Does this do anything? */
   96   XChangeProperty (dpy, window, XA_NET_WM_WINDOW_TYPE, XA_ATOM, 32,
   97                    PropModeReplace, (unsigned char *) va, i);
   98 
   99   if (for_window)  /* This is the error dialog for a saver window */
  100     {
  101       va[0] = for_window;
  102       /* _WM_TRANSIENT_FOR = screensaver_window */
  103       XChangeProperty (dpy, window,
  104                        XA_WM_TRANSIENT_FOR, XA_WINDOW, 32,
  105                        PropModeReplace, (unsigned char *) va, 1);
  106     }
  107 }