Example #1
0
File: window.c Project: dosbre/xray
struct window *add_win(struct window **list, xcb_window_t wid)
{
	struct window *w = NULL;
	uint32_t mask = XCB_CW_EVENT_MASK;
	const uint32_t vals[1] = { XCB_EVENT_MASK_PROPERTY_CHANGE };
	uint8_t flag;

	if ((w = malloc(sizeof(struct window)))) {
		w->id = wid;
		w->damage = xcb_generate_id(X);
		flag = XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY;
		xcb_damage_create(X, w->damage, w->id, flag);
		w->region = xcb_generate_id(X);
		flag = XCB_SHAPE_SK_BOUNDING;
		xcb_xfixes_create_region_from_window(X, w->region, w->id, flag);
		w->pixmap = XCB_NONE;
		w->picture = XCB_NONE;
		w->opacity = get_window_opacity(w->id);
		w->alpha = XCB_NONE;
		w->prev = NULL;
		w->next = *list;
		*list = w;
		xcb_change_window_attributes(X, w->id, mask, vals);
	} else {
		fprintf(stderr, "add_window: can't alloc memory\n");
	}
	return w;
}
Example #2
0
/*
 * Create a DAMAGE object to input/output class windows
 *
 */
static void create_damage(xcb_connection_t *conn, xcb_window_t window,
                          xcb_get_window_attributes_reply_t *win_attrib) {
    if (win_attrib) {
        if (win_attrib->_class != XCB_WINDOW_CLASS_INPUT_ONLY) {
            xcb_damage_damage_t dam = xcb_generate_id(conn);
            xcb_damage_create(conn, dam, window,
                              XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY);
        }
        free(win_attrib);
    }
}
Example #3
0
// === EmbedWindow() ===
uint LXCB::EmbedWindow(WId win, WId container){
  if(DEBUG){ qDebug() << "XCB: EmbedWindow()"; }
  //This returns the damage control ID number (or 0 for a failure)
  if(win==0 || container==0){ return 0; }
  //qDebug() << "Embed Window:" << win << container;

  //Initialize any atoms that will be needed
  xcb_intern_atom_cookie_t ecookie = xcb_intern_atom_unchecked(QX11Info::connection(), 0, 7, "_XEMBED");
  
  xcb_intern_atom_reply_t *ereply = xcb_intern_atom_reply(QX11Info::connection(), ecookie, NULL);
  if(ereply==0){ return 0; } //unable to initialize the atom
  xcb_atom_t emb = ereply->atom;
  free(ereply); //done with this structure
  
  //Reparent the window into the container
  xcb_reparent_window(QX11Info::connection(), win, container, 0, 0);
  xcb_map_window(QX11Info::connection(), win);
  
  //Now send the embed event to the app
  //qDebug() << " - send _XEMBED event";
  xcb_client_message_event_t event;
    event.response_type = XCB_CLIENT_MESSAGE;
    event.format = 32;
    event.window = win;
    event.type = emb; //_XEMBED
    event.data.data32[0] = XCB_TIME_CURRENT_TIME; //CurrentTime; 
    event.data.data32[1] = 0; //XEMBED_EMBEDDED_NOTIFY
    event.data.data32[2] = 0;
    event.data.data32[3] = container; //WID of the container
    event.data.data32[4] = 0;

    xcb_send_event(QX11Info::connection(), 0, win,  XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *) &event);
  
  //Now setup any redirects and return
  //qDebug() << " - select Input";
  //XSelectInput(disp, win, StructureNotifyMask); //Notify of structure changes
  //uint32_t val[] = {XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY};
  //xcb_change_window_attributes(QX11Info::connection(), win, XCB_CW_EVENT_MASK, val);
  this->SelectInput(win);
  //qDebug() << " - Composite Redirect";
  xcb_composite_redirect_window(QX11Info::connection(), win, XCB_COMPOSITE_REDIRECT_MANUAL);

  //Now map the window (will be a transparent child of the container)
  xcb_map_window(QX11Info::connection(), win);
  
  //Now create/register the damage handler
  xcb_damage_damage_t dmgID = xcb_generate_id(QX11Info::connection()); //This is a typedef for a 32-bit unsigned integer
  xcb_damage_create(QX11Info::connection(), dmgID, win, XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES);
  
  //qDebug() << " - Done";
  return ( (uint) dmgID );	
}
Example #4
0
/**
 * Creates a damage object.
 * @param drawable The drawable to monotor.
 * @param level    The level of the damage report.
 * @return         The damage object.
 *
 * Creates a damage object to monitor changes to @p drawable, with the
 * level @p level.
 * @ingroup Ecore_X_Damage_Group
 */
EAPI Ecore_X_Damage
ecore_x_damage_new(Ecore_X_Drawable            drawable,
                   Ecore_X_Damage_Report_Level level)
{
   Ecore_X_Damage damage = 0;

#ifdef ECORE_XCB_DAMAGE
   damage = xcb_generate_id(_ecore_xcb_conn);
   xcb_damage_create(_ecore_xcb_conn, damage, drawable, level);
#endif /* ECORE_XCB_DAMAGE */

   return damage;
} /* ecore_x_damage_new */
void FdoSelectionManager::addDamageWatch(xcb_window_t client)
{
    qCDebug(SNIPROXY) << "adding damage watch for " << client;

    xcb_connection_t *c = QX11Info::connection();
    const auto attribsCookie = xcb_get_window_attributes_unchecked(c, client);

    auto damageId = xcb_generate_id(c);
    m_damageWatches[client] = damageId;
    xcb_damage_create(c, damageId, client, XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY);

    QScopedPointer<xcb_get_window_attributes_reply_t, QScopedPointerPodDeleter> attr(xcb_get_window_attributes_reply(c, attribsCookie, Q_NULLPTR));
    uint32_t events = XCB_EVENT_MASK_STRUCTURE_NOTIFY;
    if (!attr.isNull()) {
        events = events | attr->your_event_mask;
    }
    // the event mask will not be removed again. We cannot track whether another component also needs STRUCTURE_NOTIFY (e.g. KWindowSystem).
    // if we would remove the event mask again, other areas will break.
    xcb_change_window_attributes(c, client, XCB_CW_EVENT_MASK, &events);

}
Example #6
0
// === GenerateDamageID() ===
uint LXCB::GenerateDamageID(WId win){
  //Now create/register the damage handler
  xcb_damage_damage_t dmgID = xcb_generate_id(QX11Info::connection()); //This is a typedef for a 32-bit unsigned integer
  xcb_damage_create(QX11Info::connection(), dmgID, win, XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES);
  return ( (uint) dmgID );		
}