{"action":"created","comment":{"url":"https://api.github.com/repos/rendering-io/magma/pulls/comments/201942519","pull_request_review_id":136539177,"id":201942519,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTk0MjUxOQ==","diff_hunk":"@@ -0,0 +1,225 @@\n+#include <cassert>\n+#include <iostream>\n+#include <magma/wsi/window.h>\n+#include <magma/wsi/wsi.h>\n+#include <memory>\n+#include <mutex>\n+#include <stdexcept>\n+#include <system_error>\n+#include <unordered_map>\n+#include <xcb/xcb.h>\n+#include <xcb/xproto.h>\n+using namespace magma::wsi;\n+\n+namespace {\n+\n+using xcb_event_ptr = std::unique_ptr<xcb_generic_event_t, decltype(&free)>;\n+\n+class xcb_session {\n+public:\n+  xcb_session();\n+  xcb_session(const xcb_session &) = delete;\n+\n+  auto verify_connection() -> void;\n+  auto poll() -> xcb_event_ptr;\n+\n+private:\n+  auto get_intern_atom(const std::string &name, bool only_if_exists)\n+      -> xcb_atom_t;\n+\n+  using connection_ptr =\n+      std::unique_ptr<xcb_connection_t, decltype(&xcb_disconnect)>;\n+  // The xCB connection to the X11 server.\n+  connection_ptr _connection;\n+\n+  xcb_atom_t _wm_protocol_atom;\n+\n+  xcb_atom_t _wm_delete_window_atom;\n+\n+  // Provides a mapping from XCB window handles to magma::wsi::window instances.\n+  std::unordered_map<xcb_window_t, window *> _window_ids;\n+\n+  friend class magma::wsi::window;\n+  friend auto magma::wsi::poll() -> bool;\n+};\n+\n+struct xcb_error_category : std::error_category {\n+public:\n+  auto name() const noexcept -> const char * override;\n+  auto message(int ev) const -> std::string override;\n+};\n+\n+std::unique_ptr<xcb_session> session;\n+const xcb_error_category xcb_err_category{};\n+\n+std::mutex xcb_mutex;\n+auto quit_code = 0;\n+\n+xcb_session::xcb_session()\n+    : _connection{xcb_connect(nullptr, nullptr), xcb_disconnect} {\n+  verify_connection();\n+\n+  _wm_protocol_atom = get_intern_atom(\"WM_PROTOCOLS\", true);\n+  _wm_delete_window_atom = get_intern_atom(\"WM_DELETE_WINDOW\", false);\n+}\n+\n+auto xcb_session::get_intern_atom(const std::string &name, bool only_if_exists)\n+    -> xcb_atom_t {\n+  auto cookie = xcb_intern_atom(_connection.get(), only_if_exists, name.size(),\n+                                name.c_str());\n+  auto reply = std::unique_ptr<xcb_intern_atom_reply_t, decltype(&free)>{\n+      xcb_intern_atom_reply(_connection.get(), cookie, 0), free};\n+  auto atom = reply->atom;\n+  return atom;\n+}\n+\n+auto xcb_session::poll() -> xcb_event_ptr {\n+  return xcb_event_ptr{xcb_poll_for_event(_connection.get()), free};\n+}\n+\n+auto xcb_session::verify_connection() -> void {\n+  auto err = xcb_connection_has_error(_connection.get());\n+  if (err)\n+    throw std::system_error{err, xcb_err_category};\n+}\n+\n+auto xcb_error_category::name() const noexcept -> const char * { return \"XCB\"; }\n+\n+auto xcb_error_category::message(int e) const -> std::string {\n+  switch (e) {\n+  case XCB_CONN_ERROR:\n+    return \"XCB connection error. Typically caused by socket, pipe errors \"\n+           \"or other stream errors.\";\n+  case XCB_CONN_CLOSED_EXT_NOTSUPPORTED:\n+    return \"XCB extension not supported.\";\n+  case XCB_CONN_CLOSED_MEM_INSUFFICIENT:\n+    return \"Insufficient available memory.\";\n+  case XCB_CONN_CLOSED_REQ_LEN_EXCEED:\n+    return \"Request length exceeds maximum supported the X server.\";\n+  case XCB_CONN_CLOSED_PARSE_ERR:\n+    return \"Error parsing display string.\";\n+  case XCB_CONN_CLOSED_INVALID_SCREEN:\n+    return \"X server does not have a screen matching the requested display.\";\n+  default:\n+    return \"Unrecognized error.\";\n+  }\n+}\n+","path":"lib/wsi/xcb.c++","position":107,"original_position":107,"commit_id":"115e4293d0f2afe19d1305660a2d80e9c4d73fce","original_commit_id":"115e4293d0f2afe19d1305660a2d80e9c4d73fce","user":{"login":"r-potter","id":6206191,"node_id":"MDQ6VXNlcjYyMDYxOTE=","avatar_url":"https://avatars2.githubusercontent.com/u/6206191?v=4","gravatar_id":"","url":"https://api.github.com/users/r-potter","html_url":"https://github.com/r-potter","followers_url":"https://api.github.com/users/r-potter/followers","following_url":"https://api.github.com/users/r-potter/following{/other_user}","gists_url":"https://api.github.com/users/r-potter/gists{/gist_id}","starred_url":"https://api.github.com/users/r-potter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-potter/subscriptions","organizations_url":"https://api.github.com/users/r-potter/orgs","repos_url":"https://api.github.com/users/r-potter/repos","events_url":"https://api.github.com/users/r-potter/events{/privacy}","received_events_url":"https://api.github.com/users/r-potter/received_events","type":"User","site_admin":false},"body":"whitespace","created_at":"2018-07-12T08:01:53Z","updated_at":"2018-07-12T08:08:13Z","html_url":"https://github.com/rendering-io/magma/pull/1#discussion_r201942519","pull_request_url":"https://api.github.com/repos/rendering-io/magma/pulls/1","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/rendering-io/magma/pulls/comments/201942519"},"html":{"href":"https://github.com/rendering-io/magma/pull/1#discussion_r201942519"},"pull_request":{"href":"https://api.github.com/repos/rendering-io/magma/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/rendering-io/magma/pulls/1","id":200912281,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwOTEyMjgx","html_url":"https://github.com/rendering-io/magma/pull/1","diff_url":"https://github.com/rendering-io/magma/pull/1.diff","patch_url":"https://github.com/rendering-io/magma/pull/1.patch","issue_url":"https://api.github.com/repos/rendering-io/magma/issues/1","number":1,"state":"open","locked":false,"title":"WIP: XCB sample works, but needs cleanup and review.","user":{"login":"r-potter","id":6206191,"node_id":"MDQ6VXNlcjYyMDYxOTE=","avatar_url":"https://avatars2.githubusercontent.com/u/6206191?v=4","gravatar_id":"","url":"https://api.github.com/users/r-potter","html_url":"https://github.com/r-potter","followers_url":"https://api.github.com/users/r-potter/followers","following_url":"https://api.github.com/users/r-potter/following{/other_user}","gists_url":"https://api.github.com/users/r-potter/gists{/gist_id}","starred_url":"https://api.github.com/users/r-potter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-potter/subscriptions","organizations_url":"https://api.github.com/users/r-potter/orgs","repos_url":"https://api.github.com/users/r-potter/repos","events_url":"https://api.github.com/users/r-potter/events{/privacy}","received_events_url":"https://api.github.com/users/r-potter/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-12T07:35:12Z","updated_at":"2018-07-12T08:08:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bb2b9af069120bb91f39a6af9f77745e0a0d5f0","assignee":{"login":"r-potter","id":6206191,"node_id":"MDQ6VXNlcjYyMDYxOTE=","avatar_url":"https://avatars2.githubusercontent.com/u/6206191?v=4","gravatar_id":"","url":"https://api.github.com/users/r-potter","html_url":"https://github.com/r-potter","followers_url":"https://api.github.com/users/r-potter/followers","following_url":"https://api.github.com/users/r-potter/following{/other_user}","gists_url":"https://api.github.com/users/r-potter/gists{/gist_id}","starred_url":"https://api.github.com/users/r-potter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-potter/subscriptions","organizations_url":"https://api.github.com/users/r-potter/orgs","repos_url":"https://api.github.com/users/r-potter/repos","events_url":"https://api.github.com/users/r-potter/events{/privacy}","received_events_url":"https://api.github.com/users/r-potter/received_events","type":"User","site_admin":false},"assignees":[{"login":"r-potter","id":6206191,"node_id":"MDQ6VXNlcjYyMDYxOTE=","avatar_url":"https://avatars2.githubusercontent.com/u/6206191?v=4","gravatar_id":"","url":"https://api.github.com/users/r-potter","html_url":"https://github.com/r-potter","followers_url":"https://api.github.com/users/r-potter/followers","following_url":"https://api.github.com/users/r-potter/following{/other_user}","gists_url":"https://api.github.com/users/r-potter/gists{/gist_id}","starred_url":"https://api.github.com/users/r-potter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-potter/subscriptions","organizations_url":"https://api.github.com/users/r-potter/orgs","repos_url":"https://api.github.com/users/r-potter/repos","events_url":"https://api.github.com/users/r-potter/events{/privacy}","received_events_url":"https://api.github.com/users/r-potter/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rendering-io/magma/pulls/1/commits","review_comments_url":"https://api.github.com/repos/rendering-io/magma/pulls/1/comments","review_comment_url":"https://api.github.com/repos/rendering-io/magma/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rendering-io/magma/issues/1/comments","statuses_url":"https://api.github.com/repos/rendering-io/magma/statuses/115e4293d0f2afe19d1305660a2d80e9c4d73fce","head":{"label":"rendering-io:feature-wsi-xcb","ref":"feature-wsi-xcb","sha":"115e4293d0f2afe19d1305660a2d80e9c4d73fce","user":{"login":"rendering-io","id":18101732,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4MTAxNzMy","avatar_url":"https://avatars2.githubusercontent.com/u/18101732?v=4","gravatar_id":"","url":"https://api.github.com/users/rendering-io","html_url":"https://github.com/rendering-io","followers_url":"https://api.github.com/users/rendering-io/followers","following_url":"https://api.github.com/users/rendering-io/following{/other_user}","gists_url":"https://api.github.com/users/rendering-io/gists{/gist_id}","starred_url":"https://api.github.com/users/rendering-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rendering-io/subscriptions","organizations_url":"https://api.github.com/users/rendering-io/orgs","repos_url":"https://api.github.com/users/rendering-io/repos","events_url":"https://api.github.com/users/rendering-io/events{/privacy}","received_events_url":"https://api.github.com/users/rendering-io/received_events","type":"Organization","site_admin":false},"repo":{"id":135305280,"node_id":"MDEwOlJlcG9zaXRvcnkxMzUzMDUyODA=","name":"magma","full_name":"rendering-io/magma","owner":{"login":"rendering-io","id":18101732,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4MTAxNzMy","avatar_url":"https://avatars2.githubusercontent.com/u/18101732?v=4","gravatar_id":"","url":"https://api.github.com/users/rendering-io","html_url":"https://github.com/rendering-io","followers_url":"https://api.github.com/users/rendering-io/followers","following_url":"https://api.github.com/users/rendering-io/following{/other_user}","gists_url":"https://api.github.com/users/rendering-io/gists{/gist_id}","starred_url":"https://api.github.com/users/rendering-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rendering-io/subscriptions","organizations_url":"https://api.github.com/users/rendering-io/orgs","repos_url":"https://api.github.com/users/rendering-io/repos","events_url":"https://api.github.com/users/rendering-io/events{/privacy}","received_events_url":"https://api.github.com/users/rendering-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rendering-io/magma","description":null,"fork":false,"url":"https://api.github.com/repos/rendering-io/magma","forks_url":"https://api.github.com/repos/rendering-io/magma/forks","keys_url":"https://api.github.com/repos/rendering-io/magma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rendering-io/magma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rendering-io/magma/teams","hooks_url":"https://api.github.com/repos/rendering-io/magma/hooks","issue_events_url":"https://api.github.com/repos/rendering-io/magma/issues/events{/number}","events_url":"https://api.github.com/repos/rendering-io/magma/events","assignees_url":"https://api.github.com/repos/rendering-io/magma/assignees{/user}","branches_url":"https://api.github.com/repos/rendering-io/magma/branches{/branch}","tags_url":"https://api.github.com/repos/rendering-io/magma/tags","blobs_url":"https://api.github.com/repos/rendering-io/magma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rendering-io/magma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rendering-io/magma/git/refs{/sha}","trees_url":"https://api.github.com/repos/rendering-io/magma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rendering-io/magma/statuses/{sha}","languages_url":"https://api.github.com/repos/rendering-io/magma/languages","stargazers_url":"https://api.github.com/repos/rendering-io/magma/stargazers","contributors_url":"https://api.github.com/repos/rendering-io/magma/contributors","subscribers_url":"https://api.github.com/repos/rendering-io/magma/subscribers","subscription_url":"https://api.github.com/repos/rendering-io/magma/subscription","commits_url":"https://api.github.com/repos/rendering-io/magma/commits{/sha}","git_commits_url":"https://api.github.com/repos/rendering-io/magma/git/commits{/sha}","comments_url":"https://api.github.com/repos/rendering-io/magma/comments{/number}","issue_comment_url":"https://api.github.com/repos/rendering-io/magma/issues/comments{/number}","contents_url":"https://api.github.com/repos/rendering-io/magma/contents/{+path}","compare_url":"https://api.github.com/repos/rendering-io/magma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rendering-io/magma/merges","archive_url":"https://api.github.com/repos/rendering-io/magma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rendering-io/magma/downloads","issues_url":"https://api.github.com/repos/rendering-io/magma/issues{/number}","pulls_url":"https://api.github.com/repos/rendering-io/magma/pulls{/number}","milestones_url":"https://api.github.com/repos/rendering-io/magma/milestones{/number}","notifications_url":"https://api.github.com/repos/rendering-io/magma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rendering-io/magma/labels{/name}","releases_url":"https://api.github.com/repos/rendering-io/magma/releases{/id}","deployments_url":"https://api.github.com/repos/rendering-io/magma/deployments","created_at":"2018-05-29T14:05:25Z","updated_at":"2018-07-03T14:52:12Z","pushed_at":"2018-07-12T07:35:13Z","git_url":"git://github.com/rendering-io/magma.git","ssh_url":"git@github.com:rendering-io/magma.git","clone_url":"https://github.com/rendering-io/magma.git","svn_url":"https://github.com/rendering-io/magma","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"CMake","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"rendering-io:master","ref":"master","sha":"c60261490184032704c8473f2abcda015f16de1b","user":{"login":"rendering-io","id":18101732,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4MTAxNzMy","avatar_url":"https://avatars2.githubusercontent.com/u/18101732?v=4","gravatar_id":"","url":"https://api.github.com/users/rendering-io","html_url":"https://github.com/rendering-io","followers_url":"https://api.github.com/users/rendering-io/followers","following_url":"https://api.github.com/users/rendering-io/following{/other_user}","gists_url":"https://api.github.com/users/rendering-io/gists{/gist_id}","starred_url":"https://api.github.com/users/rendering-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rendering-io/subscriptions","organizations_url":"https://api.github.com/users/rendering-io/orgs","repos_url":"https://api.github.com/users/rendering-io/repos","events_url":"https://api.github.com/users/rendering-io/events{/privacy}","received_events_url":"https://api.github.com/users/rendering-io/received_events","type":"Organization","site_admin":false},"repo":{"id":135305280,"node_id":"MDEwOlJlcG9zaXRvcnkxMzUzMDUyODA=","name":"magma","full_name":"rendering-io/magma","owner":{"login":"rendering-io","id":18101732,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4MTAxNzMy","avatar_url":"https://avatars2.githubusercontent.com/u/18101732?v=4","gravatar_id":"","url":"https://api.github.com/users/rendering-io","html_url":"https://github.com/rendering-io","followers_url":"https://api.github.com/users/rendering-io/followers","following_url":"https://api.github.com/users/rendering-io/following{/other_user}","gists_url":"https://api.github.com/users/rendering-io/gists{/gist_id}","starred_url":"https://api.github.com/users/rendering-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rendering-io/subscriptions","organizations_url":"https://api.github.com/users/rendering-io/orgs","repos_url":"https://api.github.com/users/rendering-io/repos","events_url":"https://api.github.com/users/rendering-io/events{/privacy}","received_events_url":"https://api.github.com/users/rendering-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rendering-io/magma","description":null,"fork":false,"url":"https://api.github.com/repos/rendering-io/magma","forks_url":"https://api.github.com/repos/rendering-io/magma/forks","keys_url":"https://api.github.com/repos/rendering-io/magma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rendering-io/magma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rendering-io/magma/teams","hooks_url":"https://api.github.com/repos/rendering-io/magma/hooks","issue_events_url":"https://api.github.com/repos/rendering-io/magma/issues/events{/number}","events_url":"https://api.github.com/repos/rendering-io/magma/events","assignees_url":"https://api.github.com/repos/rendering-io/magma/assignees{/user}","branches_url":"https://api.github.com/repos/rendering-io/magma/branches{/branch}","tags_url":"https://api.github.com/repos/rendering-io/magma/tags","blobs_url":"https://api.github.com/repos/rendering-io/magma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rendering-io/magma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rendering-io/magma/git/refs{/sha}","trees_url":"https://api.github.com/repos/rendering-io/magma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rendering-io/magma/statuses/{sha}","languages_url":"https://api.github.com/repos/rendering-io/magma/languages","stargazers_url":"https://api.github.com/repos/rendering-io/magma/stargazers","contributors_url":"https://api.github.com/repos/rendering-io/magma/contributors","subscribers_url":"https://api.github.com/repos/rendering-io/magma/subscribers","subscription_url":"https://api.github.com/repos/rendering-io/magma/subscription","commits_url":"https://api.github.com/repos/rendering-io/magma/commits{/sha}","git_commits_url":"https://api.github.com/repos/rendering-io/magma/git/commits{/sha}","comments_url":"https://api.github.com/repos/rendering-io/magma/comments{/number}","issue_comment_url":"https://api.github.com/repos/rendering-io/magma/issues/comments{/number}","contents_url":"https://api.github.com/repos/rendering-io/magma/contents/{+path}","compare_url":"https://api.github.com/repos/rendering-io/magma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rendering-io/magma/merges","archive_url":"https://api.github.com/repos/rendering-io/magma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rendering-io/magma/downloads","issues_url":"https://api.github.com/repos/rendering-io/magma/issues{/number}","pulls_url":"https://api.github.com/repos/rendering-io/magma/pulls{/number}","milestones_url":"https://api.github.com/repos/rendering-io/magma/milestones{/number}","notifications_url":"https://api.github.com/repos/rendering-io/magma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rendering-io/magma/labels{/name}","releases_url":"https://api.github.com/repos/rendering-io/magma/releases{/id}","deployments_url":"https://api.github.com/repos/rendering-io/magma/deployments","created_at":"2018-05-29T14:05:25Z","updated_at":"2018-07-03T14:52:12Z","pushed_at":"2018-07-12T07:35:13Z","git_url":"git://github.com/rendering-io/magma.git","ssh_url":"git@github.com:rendering-io/magma.git","clone_url":"https://github.com/rendering-io/magma.git","svn_url":"https://github.com/rendering-io/magma","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"CMake","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rendering-io/magma/pulls/1"},"html":{"href":"https://github.com/rendering-io/magma/pull/1"},"issue":{"href":"https://api.github.com/repos/rendering-io/magma/issues/1"},"comments":{"href":"https://api.github.com/repos/rendering-io/magma/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/rendering-io/magma/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/rendering-io/magma/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rendering-io/magma/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/rendering-io/magma/statuses/115e4293d0f2afe19d1305660a2d80e9c4d73fce"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"r-potter"}}