Back to index

easystroke  0.5.5.1
Classes | Functions | Variables
grabber.cc File Reference
#include "actiondb.h"
#include "grabber.h"
#include "main.h"
#include "win.h"
#include "prefs.h"
#include <X11/extensions/XTest.h>
#include <xorg/xserver-properties.h>
#include <X11/cursorfont.h>
#include <X11/Xutil.h>
#include <glibmm/i18n.h>

Go to the source code of this file.

Classes

class  BiMap< X1, X2 >
class  IdleNotifier

Functions

Window get_window (Window w, Atom prop)
void get_frame (Window w)
void activate (Window w, Time t)
std::string get_wm_class (Window w, ActionListDiff *actions)
bool is_xtest_device (int dev)
int get_default_button ()
bool has_wm_state (Window w)
Window find_wm_state (Window w)
Window get_app_window (Window w)

Variables

Source< bool > disabled
Source< Window > current_app_window
Source< ActionListDiff * > stroke_app
bool in_proximity
Grabbergrabber = 0
static unsigned int ignore_mods [4] = { 0, LockMask, Mod2Mask, LockMask | Mod2Mask }
static unsigned char device_mask_data [2]
static XIEventMask device_mask
static unsigned char raw_mask_data [3]
static XIEventMask raw_mask
BiMap< Window, Window > frame_win
BiMap< Window, Window > frame_child
XAtom _NET_FRAME_WINDOW ("_NET_FRAME_WINDOW")
XAtom _NET_WM_STATE ("_NET_WM_STATE")
XAtom _NET_WM_STATE_HIDDEN ("_NET_WM_STATE_HIDDEN")
XAtom _NET_ACTIVE_WINDOW ("_NET_ACTIVE_WINDOW")
BiMap< unsigned int, Window > minimized
unsigned int minimized_n = 0

Function Documentation

void activate ( Window  w,
Time  t 
)

Definition at line 178 of file grabber.cc.

                                {
       XClientMessageEvent ev;
       ev.type = ClientMessage;
       ev.window = w;
       ev.message_type = *_NET_ACTIVE_WINDOW;
       ev.format = 32;
       ev.data.l[0] = 0; // 1 app, 2 pager
       ev.data.l[1] = t;
       ev.data.l[2] = 0;
       ev.data.l[3] = 0;
       ev.data.l[4] = 0;
       XSendEvent(dpy, ROOT, False, SubstructureNotifyMask | SubstructureRedirectMask, (XEvent *)&ev);
}

Here is the caller graph for this function:

Window find_wm_state ( Window  w)

Definition at line 571 of file grabber.cc.

                               {
       if (!w)
              return w;
       if (has_wm_state(w))
              return w;
       Window found = None;
       unsigned int n;
       Window dummyw1, dummyw2, *ch;
       if (!XQueryTree(dpy, w, &dummyw1, &dummyw2, &ch, &n))
              return None;
       for (unsigned int i = 0; i != n; i++)
              if (has_wm_state(ch[i]))
                     found = ch[i];
       if (!found)
              for (unsigned int i = 0; i != n; i++) {
                     found = find_wm_state(ch[i]);
                     if (found)
                            break;
              }
       XFree(ch);
       return found;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Window get_app_window ( Window  w)

Definition at line 594 of file grabber.cc.

                                {
       if (!w)
              return w;

       if (frame_win.contains1(w))
              return frame_win.find1(w);

       if (frame_child.contains1(w))
              return frame_child.find1(w);

       Window w2 = find_wm_state(w);
       if (w2) {
              frame_child.add(w, w2);
              if (w2 != w) {
                     w = w2;
                     XSelectInput(dpy, w2, StructureNotifyMask | PropertyChangeMask);
              }
              return w2;
       }
       if (verbosity >= 1)
              printf("Window 0x%lx does not have an associated top-level window\n", w);
       return w;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 515 of file grabber.cc.

                         {
       if (grabber)
              return grabber->get_default_button();
       else
              return prefs.button.get().button;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void get_frame ( Window  w)

Definition at line 95 of file grabber.cc.

                         {
       Window frame = get_window(w, *_NET_FRAME_WINDOW);
       if (!frame)
              return;
       frame_win.add(frame, w);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Window get_window ( Window  w,
Atom  prop 
)

Definition at line 711 of file main.cc.

                                       {
       Atom actual_type;
       int actual_format;
       unsigned long nitems, bytes_after;
       unsigned char *prop_return = NULL;

       if (XGetWindowProperty(dpy, w, prop, 0, sizeof(Atom), False, XA_WINDOW, &actual_type, &actual_format,
                            &nitems, &bytes_after, &prop_return) != Success)
              return None;
       if (!prop_return)
              return None;
       Window ret = *(Window *)prop_return;
       XFree(prop_return);
       return ret;
}

Here is the caller graph for this function:

std::string get_wm_class ( Window  w,
ActionListDiff actions 
)

Definition at line 192 of file grabber.cc.

                                                          {
       if (actions && actions->app)
              return actions->name;
       if (!w)
              return "";
       XClassHint ch;
       if (!XGetClassHint(dpy, w, &ch))
              return "";
       std::string ans = ch.res_name;
       XFree(ch.res_name);
       XFree(ch.res_class);
       return ans;
}

Here is the caller graph for this function:

bool has_wm_state ( Window  w)

Definition at line 555 of file grabber.cc.

                            {
       static XAtom WM_STATE("WM_STATE");
       Atom actual_type_return;
       int actual_format_return;
       unsigned long nitems_return;
       unsigned long bytes_after_return;
       unsigned char *prop_return;
       if (Success != XGetWindowProperty(dpy, w, *WM_STATE, 0, 2, False,
                            AnyPropertyType, &actual_type_return,
                            &actual_format_return, &nitems_return,
                            &bytes_after_return, &prop_return))
              return false;
       XFree(prop_return);
       return nitems_return;
}

Here is the caller graph for this function:

bool is_xtest_device ( int  dev)

Definition at line 347 of file grabber.cc.

                              {
       static XAtom XTEST(XI_PROP_XTEST_DEVICE);
       Atom type;
       int format;
       unsigned long num_items, bytes_after;
       unsigned char *data;
       if (Success != XIGetProperty(dpy, dev, *XTEST, 0, 1, False, XA_INTEGER,
                            &type, &format, &num_items, &bytes_after, &data))
              return false;
       bool ret = num_items && format == 8 && *((int8_t*)data);
       XFree(data);
       return ret;
}

Here is the caller graph for this function:


Variable Documentation

XAtom _NET_ACTIVE_WINDOW("_NET_ACTIVE_WINDOW")
XAtom _NET_FRAME_WINDOW("_NET_FRAME_WINDOW")
XAtom _NET_WM_STATE("_NET_WM_STATE")
XAtom _NET_WM_STATE_HIDDEN("_NET_WM_STATE_HIDDEN")
XIEventMask device_mask [static]

Definition at line 37 of file grabber.cc.

unsigned char device_mask_data[2] [static]

Definition at line 36 of file grabber.cc.

BiMap<Window, Window> frame_child

Definition at line 86 of file grabber.cc.

BiMap<Window, Window> frame_win

Definition at line 85 of file grabber.cc.

Definition at line 33 of file grabber.cc.

unsigned int ignore_mods[4] = { 0, LockMask, Mod2Mask, LockMask | Mod2Mask } [static]

Definition at line 35 of file grabber.cc.

Definition at line 55 of file main.cc.

BiMap<unsigned int, Window> minimized

Definition at line 92 of file grabber.cc.

unsigned int minimized_n = 0

Definition at line 93 of file grabber.cc.

XIEventMask raw_mask [static]

Definition at line 39 of file grabber.cc.

unsigned char raw_mask_data[3] [static]

Definition at line 38 of file grabber.cc.