ewmh.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
  3. * For license, see COPYING.
  4. */
  5. #include <X11/Xatom.h>
  6. #include <X11/Xutil.h>
  7. #include "ewmh.h"
  8. #include "util.h"
  9. void
  10. ewmh_init(void)
  11. {
  12. int b = 1;
  13. W->net_atom = xcalloc(net_last, sizeof(Atom));
  14. /* EWMH hints */
  15. W->net_atom[wm_state] = ATOM("WM_STATE");
  16. W->net_atom[net_supported] = ATOM("_NET_SUPPORTED");
  17. W->net_atom[net_client_list] = ATOM("_NET_CLIENT_LIST");
  18. W->net_atom[net_frame_extents] = ATOM("_NET_FRAME_EXTENTS");
  19. W->net_atom[net_number_of_desktops] = ATOM("_NET_NUMBER_OF_DESKTOPS");
  20. W->net_atom[net_current_desktop] = ATOM("_NET_CURRENT_DESKTOP");
  21. W->net_atom[net_desktop_names] = ATOM("_NET_DESKTOP_NAMES");
  22. W->net_atom[net_desktop_geometry] = ATOM("_NET_DESKTOP_GEOMETRY");
  23. W->net_atom[net_active_window] = ATOM("_NET_ACTIVE_WINDOW");
  24. W->net_atom[net_close_window] = ATOM("_NET_CLOSE_WINDOW");
  25. W->net_atom[net_wm_name] = ATOM("_NET_WM_NAME");
  26. W->net_atom[net_wm_pid] = ATOM("_NET_WM_PID");
  27. W->net_atom[net_wm_desktop] = ATOM("_NET_WM_DESKTOP");
  28. W->net_atom[net_showing_desktop] = ATOM("_NET_SHOWING_DESKTOP");
  29. W->net_atom[net_wm_icon_name] = ATOM("_NET_WM_ICON_NAME");
  30. W->net_atom[net_wm_window_type] = ATOM("_NET_WM_WINDOW_TYPE");
  31. W->net_atom[net_supporting_wm_check] = ATOM("_NET_SUPPORTING_WM_CHECK");
  32. W->net_atom[net_wm_window_opacity] = ATOM("_NET_WM_WINDOW_OPACITY");
  33. W->net_atom[net_wm_window_type_normal] = ATOM("_NET_WM_WINDOW_TYPE_NORMAL");
  34. W->net_atom[net_wm_window_type_dock] = ATOM("_NET_WM_WINDOW_TYPE_DOCK");
  35. W->net_atom[net_wm_window_type_splash] = ATOM("_NET_WM_WINDOW_TYPE_SPLASH");
  36. W->net_atom[net_wm_window_type_dialog] = ATOM("_NET_WM_WINDOW_TYPE_DIALOG");
  37. W->net_atom[net_wm_icon] = ATOM("_NET_WM_ICON");
  38. W->net_atom[net_wm_state] = ATOM("_NET_WM_STATE");
  39. W->net_atom[net_wm_state_fullscreen] = ATOM("_NET_WM_STATE_FULLSCREEN");
  40. W->net_atom[net_wm_state_sticky] = ATOM("_NET_WM_STATE_STICKY");
  41. W->net_atom[net_wm_state_demands_attention] = ATOM("_NET_WM_STATE_DEMANDS_ATTENTION");
  42. W->net_atom[net_wm_system_tray_opcode] = ATOM("_NET_SYSTEM_TRAY_OPCODE");
  43. W->net_atom[net_system_tray_message_data] = ATOM("_NET_SYSTEM_TRAY_MESSAGE_DATA");
  44. W->net_atom[net_system_tray_visual] = ATOM("_NET_SYSTEM_TRAY_VISUAL");
  45. W->net_atom[net_system_tray_orientation] = ATOM("_NET_SYSTEM_TRAY_ORIENTATION");
  46. W->net_atom[xembed] = ATOM("_XEMBED");
  47. W->net_atom[xembedinfo] = ATOM("_XEMBED_INFO");
  48. W->net_atom[manager] = ATOM("MANAGER");
  49. W->net_atom[utf8_string] = ATOM("UTF8_STRING");
  50. /* WMFS hints */
  51. W->net_atom[wmfs_running] = ATOM("_WMFS_RUNNING");
  52. W->net_atom[wmfs_update_hints] = ATOM("_WMFS_UPDATE_HINTS");
  53. W->net_atom[wmfs_set_screen] = ATOM("_WMFS_SET_SCREEN");
  54. W->net_atom[wmfs_screen_count] = ATOM("_WMFS_SCREEN_COUNT");
  55. W->net_atom[wmfs_current_tag] = ATOM("_WMFS_CURRENT_TAG");
  56. W->net_atom[wmfs_tag_list] = ATOM("_WMFS_TAG_LIST");
  57. W->net_atom[wmfs_current_screen] = ATOM("_WMFS_CURRENT_SCREEN");
  58. W->net_atom[wmfs_current_layout] = ATOM("_WMFS_CURRENT_LAYOUT");
  59. W->net_atom[wmfs_mwfact] = ATOM("_WMFS_MWFACT");
  60. W->net_atom[wmfs_nmaster] = ATOM("_WMFS_NMASTER");
  61. W->net_atom[wmfs_function] = ATOM("_WMFS_FUNCTION");
  62. W->net_atom[wmfs_cmd] = ATOM("_WMFS_CMD");
  63. W->net_atom[wmfs_font] = ATOM("_WMFS_FONT");
  64. XChangeProperty(W->dpy, W->root, W->net_atom[net_supported], XA_ATOM, 32,
  65. PropModeReplace, (unsigned char*)W->net_atom, net_last);
  66. XChangeProperty(W->dpy, W->root, W->net_atom[wmfs_running], XA_CARDINAL, 32,
  67. PropModeReplace, (unsigned char*)&b, 1);
  68. /* Set _NET_SUPPORTING_WM_CHECK */
  69. XChangeProperty(W->dpy, W->root, W->net_atom[net_supporting_wm_check], XA_WINDOW, 32,
  70. PropModeReplace, (unsigned char*)&W->root, 1);
  71. /*
  72. XChangeProperty(W->dpy, W->root, W->net_atom[net_wm_name], W->net_atom[utf8_string], 8,
  73. PropModeReplace, (unsigned char*)&rootn, strlen(rootn));
  74. XChangeProperty(W->dpy, W->root, ATOM("WM_CLASS"), XA_STRING, 8,
  75. PropModeReplace, (unsigned char*)&class, strlen(class));
  76. * Set _NET_WM_PID
  77. XChangeProperty(W->dpy, W->root, W->net_atom[net_wm_pid], XA_CARDINAL, 32,
  78. PropModeReplace, (unsigned char*)&pid, 1);
  79. * Set _NET_SHOWING_DESKTOP
  80. XChangeProperty(W->dpy, W->root, W->net_atom[net_showing_desktop], XA_CARDINAL, 32,
  81. PropModeReplace, (unsigned char*)&showing_desk, 1);
  82. */
  83. }
  84. void
  85. ewmh_set_wm_state(Window w, int state)
  86. {
  87. unsigned char d[] = { state, None };
  88. XChangeProperty(W->dpy, w, W->net_atom[wm_state],
  89. W->net_atom[wm_state], 32, PropModeReplace, d, 2);
  90. }