Advertisement
Guest User

CreateNotifyEvent

a guest
Jan 20th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | None | 0 0
  1. void Manager::CreateNotifyEvent(XCreateWindowEvent *new_client) {
  2.  
  3.     DEBUG() << new_client->window;
  4.  
  5.     XWindowAttributes attributes;
  6.     if (new_client->override_redirect || !XGetWindowAttributes(dpy, new_client->window, &attributes))
  7.         return;
  8.  
  9.     if (attributes.c_class == InputOnly || new_client->parent == root && isCubeName(new_client->window))
  10.         return;
  11.  
  12.     auto *client = new Client(dpy, new_client->window, attributes);
  13.     auto parent = new_client->parent;
  14.  
  15.     if (parent == root) {
  16.  
  17.         if (app1_list.empty()) {
  18.             app1_list.push_front(client);
  19.             lastInFirstVec = true;
  20.  
  21.         } else if (app2_list.empty()){
  22.             app2_list.push_front(client);
  23.             lastInFirstVec = false;
  24.  
  25.         } else {
  26.  
  27.             DEBUG() << "WARNING: added more then 2 clients";
  28.             if (lastInFirstVec) {
  29.                 app2_list.push_front(client);
  30.  
  31.             } else {
  32.                 app1_list.push_front(client);
  33.  
  34.             }
  35.         }
  36.  
  37.     } else {
  38.  
  39.         std::list<Client *>::iterator parent_it = findIterFirstApp(parent);
  40.         if (parent_it != app1_list.end()) {
  41.  
  42.             app1_list.insert(parent_it, client);
  43.  
  44.         } else {
  45.  
  46.             parent_it = findIterSecondApp(parent);
  47.  
  48.             if (parent_it != app2_list.end()) {
  49.  
  50.                 app2_list.insert(parent_it, client);
  51.  
  52.             } else {
  53.  
  54.                 DEBUG() << "WARNING: unknown parent for current client";
  55.                 if (lastInFirstVec) {
  56.  
  57.                     app2_list.push_front(client);
  58.  
  59.                 } else {
  60.  
  61.                     app1_list.push_front(client);
  62.  
  63.                 }
  64.             }
  65.         }
  66.  
  67.     }
  68.  
  69.     DEBUG() << attributes.visual;
  70.     client_list.push_front(client);
  71.  
  72. }
  73.  
  74. std::list<Client *>::iterator Manager::findIterFirstApp(const Window &window) {
  75.     for (auto cli : app1_list) {
  76.  
  77.         if (cli->getWindow() == window)
  78.             return std::find(app1_list.begin(), app1_list.end(), cli);
  79.     }
  80.  
  81.     return app1_list.end();
  82. }
  83.  
  84. std::list<Client *>::iterator Manager::findIterSecondApp(const Window &window) {
  85.     for (auto cli : app2_list) {
  86.  
  87.         if (cli->getWindow() == window)
  88.             return std::find(app2_list.begin(), app2_list.end(), cli);
  89.     }
  90.  
  91.     return app2_list.end();
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement