]> Dogcows Code - chaz/openbox/commitdiff
add an UrgentNotify callback type. fire it when a window becomes "urgent"
authorDana Jansens <danakj@orodu.net>
Fri, 24 Jan 2003 00:44:36 +0000 (00:44 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 24 Jan 2003 00:44:36 +0000 (00:44 +0000)
src/client.cc
src/client.hh
src/openbox.py
src/openbox_wrap.cc
src/python.hh

index 80cc1a2ca7e0bcc774fa43043dd337e7b61d53f4..473c37f8f98fe8e33885059de69b45330abe4bb5 100644 (file)
@@ -8,6 +8,7 @@
 #include "frame.hh"
 #include "screen.hh"
 #include "openbox.hh"
+#include "bindings.hh"
 #include "otk/display.hh"
 #include "otk/property.hh"
 
@@ -44,6 +45,8 @@ Client::Client(int screen, Window window)
   _transient_for = 0;
   // pick a layer to start from
   _layer = Layer_Normal;
+  // default to not urgent
+  _urgent = false;
   
   getArea();
   getDesktop();
@@ -457,7 +460,7 @@ void Client::updateWMHints(bool initstate)
 
   // assume a window takes input if it doesnt specify
   _can_focus = true;
-  _urgent = false;
+  bool ur = false;
   
   if ((hints = XGetWMHints(**otk::display, _window)) != NULL) {
     if (hints->flags & InputHint)
@@ -468,7 +471,7 @@ void Client::updateWMHints(bool initstate)
       _iconic = hints->initial_state == IconicState;
 
     if (hints->flags & XUrgencyHint)
-      _urgent = true;
+      ur = true;
 
     if (hints->flags & WindowGroupHint) {
       if (hints->window_group != _group) {
@@ -481,6 +484,14 @@ void Client::updateWMHints(bool initstate)
 
     XFree(hints);
   }
+
+  if (ur != _urgent) {
+    _urgent = ur;
+    // fire the urgent callback if we're mapped, otherwise, wait until after
+    // we're mapped
+    if (_urgent && frame)
+      fireUrgent();
+  }
 }
 
 
@@ -1174,6 +1185,8 @@ void Client::applyStartupState()
     _shaded = false;
     shade(true);
   }
+  if (_urgent)
+    fireUrgent();
   
   if (_max_vert); // XXX: incomplete
   if (_max_horz); // XXX: incomplete
@@ -1186,6 +1199,14 @@ void Client::applyStartupState()
 }
 
 
+void Client::fireUrgent()
+{
+  // call the python UrgentNotify callbacks
+  EventData data(_screen, this, EventUrgentNotify, 0);
+  openbox->bindings()->fireEvent(&data);
+}
+
+
 void Client::shade(bool shade)
 {
   if (!(_functions & Func_Shade) || // can't
index 420a8c4a5a73aa52c41e60abe0d45e25ddaae1f4..c8110a3f70e75661926412e374a7f3ce0dac998a 100644 (file)
@@ -406,6 +406,10 @@ private:
   */
   void shade(bool shade);
 
+  //! Fires the urgent callbacks which lets the user do what they want with
+  //! urgent windows
+  void fireUrgent();
+  
   //! Fullscreen's or unfullscreen's the client window
   /*!
     @param fs true if the window should be made fullscreen; false if it should
index 68dc29a3660051569058de9754cf0cbe69c6ca8c..a7ca525bb3551e7f9a2dc3942e9957060fb8a720 100644 (file)
@@ -914,6 +914,7 @@ EventShutdown = _openbox.EventShutdown
 EventKey = _openbox.EventKey
 EventFocus = _openbox.EventFocus
 EventBell = _openbox.EventBell
+EventUrgentNotify = _openbox.EventUrgentNotify
 NUM_EVENTS = _openbox.NUM_EVENTS
 class MouseData(_object):
     __swig_setmethods__ = {}
index f4fc5783ab06d0596836cf56ef425aa1a6009e24..7473e961a2ebff3ff28a62800d553956eb757636 100644 (file)
@@ -12095,6 +12095,7 @@ static swig_const_info swig_const_table[] = {
 { SWIG_PY_INT,     (char *)"EventKey", (long) ob::EventKey, 0, 0, 0},
 { SWIG_PY_INT,     (char *)"EventFocus", (long) ob::EventFocus, 0, 0, 0},
 { SWIG_PY_INT,     (char *)"EventBell", (long) ob::EventBell, 0, 0, 0},
+{ SWIG_PY_INT,     (char *)"EventUrgentNotify", (long) ob::EventUrgentNotify, 0, 0, 0},
 { SWIG_PY_INT,     (char *)"NUM_EVENTS", (long) ob::NUM_EVENTS, 0, 0, 0},
 { SWIG_PY_INT,     (char *)"X_PROTOCOL", (long) 11, 0, 0, 0},
 { SWIG_PY_INT,     (char *)"X_PROTOCOL_REVISION", (long) 0, 0, 0, 0},
index 7cec766712a9ac1376f9dff7b38400b3d0e65eb3..d8b943e746d2ea69a4629ab80c650e3a907a2aa6 100644 (file)
@@ -64,6 +64,7 @@ enum EventAction {
   EventKey,
   EventFocus,
   EventBell,
+  EventUrgentNotify,
   NUM_EVENTS
 };
 
This page took 0.035079 seconds and 4 git commands to generate.