File: auth_xcb.c

package info (click to toggle)
radeontop 1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 220 kB
  • sloc: ansic: 1,589; makefile: 107; sh: 24; xml: 16
file content (43 lines) | stat: -rw-r--r-- 1,420 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
    Copyright (C) 2016 Peter Wu <peter@lekensteyn.nl>

    This program 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, version 3 of the License.

    This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "radeontop.h"
#include <xcb/xcb.h>
#include <xcb/dri2.h>

/* Try to authenticate the DRM client with help from the X server. */
void authenticate_drm_xcb(drm_magic_t magic) {
	xcb_connection_t *conn = xcb_connect(NULL, NULL);
	if (!conn) {
		return;
	}
	if (xcb_connection_has_error(conn)) {
		xcb_disconnect(conn);
		return;
	}

	xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
	xcb_window_t window = screen->root;

	/* Authenticate our client via the X server using the magic. */
	xcb_dri2_authenticate_cookie_t auth_cookie =
		xcb_dri2_authenticate(conn, window, magic);
	xcb_dri2_authenticate_reply_t *auth_reply =
		xcb_dri2_authenticate_reply(conn, auth_cookie, NULL);
	free(auth_reply);

	xcb_disconnect(conn);
}