emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

EWMH package, please review.


From: Jan D.
Subject: EWMH package, please review.
Date: Sun, 12 Oct 2003 18:53:36 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

Hello.

I've made a small package to manipulate extended window manager hints. Since Elisp is not my biggest strength, I'd like some comments. I don't know if this is useful enough to be included in Emacs, so I'd like your views on that also.

Thanks,

        Jan D.
;;; x-ewmh.el --- support extended window manager hints under X. -*-coding: 
iso-2022-7bit;-*-

;; Copyright (C) 2003 Free Software Foundation

;; Author: Jan Dj,Ad(Brv <address@hidden>
;; Keywords: window manager, hints

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; Manipulate extended window manager hints (EWMH) under X.
;; The EWMH specification can be found at http://www.freedesktop.org/.

;; Extended window manager hints lets you manipulate the state
;; of Emacs frames, like fullscreen, shaded, maximized vertical
;; and/or horizontal.  If the window manager supports multiple desktops,
;; EWMH can set if a window is sticky (present in all desktops) or not.

;; NOTE:  EWMH only works on window managers that support EWMH.  If
;; there is no support, this package does nothing.  Also, not all
;; window managers implement all hints, and not with the same effect.

;;; Todo:

;; Retreive current EWMH state?.


;;; Code:

(defun x-ewmh-send (arg hint frame &optional hint2)
  "Send a client message to change an extended window manager hint.

FRAME may be nil to use the selected frame.
If ARG is poitive, add HINT.
If ARG is negative, remove HINT.
Otherwise toggle HINT."

  (let* ((eff-arg (if (null arg) 0 (prefix-numeric-value arg)))
         (action (cond ((= eff-arg 0) 2)        ;; Toggle
                       ((> eff-arg 0) 1)        ;; Add
                       (t 0))))                 ;; Remove
    (x-send-client-message nil 0 frame "_NET_WM_STATE" 32
                           (list action
                                 hint 
                                 (if hint2 hint2 0)
                                 0))))


(defun x-ewmh-fullscreen (&optional arg frame)
  "Toggle FRAME fullscreen hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is poitive, add fullscreen hint.
If ARG is negative, remove fullscreen hint.
Otherwise toggle fullscreen hint.

If fullscreen doesn't work with your window manager, try
`x-ewmh-horz-and-vert'.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_FULLSCREEN" frame))


(defun x-ewmh-shaded (&optional arg frame)
  "Toggle FRAME shaded hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add shaded hint.
If ARG is negative, remove shaded hint.
Otherwise toggle shaded hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_SHADED" frame))


(defun x-ewmh-sticky (&optional arg frame)
  "Toggle FRAME sticky hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add sticky hint.
If ARG is negative, remove sticky hint.
Otherwise toggle sticky hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_STICKY" frame))


(defun x-ewmh-maximized_vert (&optional arg frame)
  "Toggle FRAME maximized_vert hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add maximized_vert hint.
If ARG is negative, remove maximized_vert hint.
Otherwise toggle maximized_vert hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_MAXIMIZED_VERT" frame))


(defun x-ewmh-maximized_horz (&optional arg frame)
  "Toggle FRAME maximized_horz hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add maximized_horz hint.
If ARG is negative, remove maximized_horz hint.
Otherwise toggle maximized_horz hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_MAXIMIZED_HORZ" frame))


(defun x-ewmh-horz-and-vert (&optional arg frame)
  "Toggle FRAME maximized_horz/vert hints at the same time.

If FRAME is not given, the selected frame is used.
If ARG is positive, add both hints.
If ARG is negative, remove both hints.
Otherwise toggle both hints.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_MAXIMIZED_HORZ" frame
               "_NET_WM_STATE_MAXIMIZED_VERT"))


(defun x-ewmh-above (&optional arg frame)
  "Toggle FRAME above hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add above hint.
If ARG is negative, remove above hint.
Otherwise toggle above hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_ABOVE" frame))


(defun x-ewmh-below (&optional arg frame)
  "Toggle FRAME below hint using extended window manager hints (EWMH).

If FRAME is not given, the selected frame is used.
If ARG is positive, add below hint.
If ARG is negative, remove below hint.
Otherwise toggle below hint.

NOTE:  If the window manager does not support EWMH, this does nothing."
  (interactive "P")
  (x-ewmh-send arg "_NET_WM_STATE_BELOW" frame))


(provide 'x-ewmh)

;;; arch-tag: ???
;;; x-ewmh.el ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]