mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-22 21:35:58 +01:00
EWMH #1, now shows in neofetch
This commit is contained in:
parent
00d6ac4a1a
commit
7856d4a224
4 changed files with 44 additions and 36 deletions
33
src/ewmh/ewmh.cpp
Normal file
33
src/ewmh/ewmh.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include "ewmh.hpp"
|
||||||
|
#include "../windowManager.hpp"
|
||||||
|
|
||||||
|
void EWMH::setupInitEWMH() {
|
||||||
|
Debug::log(LOG, "EWMH init!");
|
||||||
|
|
||||||
|
EWMHwindow = xcb_generate_id(g_pWindowManager->DisplayConnection);
|
||||||
|
|
||||||
|
Debug::log(LOG, "Allocated ID " + std::to_string(EWMHwindow) + " for the EWMH window.");
|
||||||
|
|
||||||
|
uint32_t values[1] = {1};
|
||||||
|
xcb_create_window(g_pWindowManager->DisplayConnection, XCB_COPY_FROM_PARENT, EWMHwindow, g_pWindowManager->Screen->root,
|
||||||
|
-1, -1, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY, XCB_COPY_FROM_PARENT, 0, values);
|
||||||
|
|
||||||
|
xcb_change_property(g_pWindowManager->DisplayConnection, XCB_PROP_MODE_REPLACE, EWMHwindow, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, 32, 1, &EWMHwindow);
|
||||||
|
xcb_change_property(g_pWindowManager->DisplayConnection, XCB_PROP_MODE_REPLACE, EWMHwindow, HYPRATOMS["_NET_WM_NAME"], HYPRATOMS["UTF8_STRING"], 8, strlen("Hypr"), "Hypr");
|
||||||
|
|
||||||
|
xcb_change_property(g_pWindowManager->DisplayConnection, XCB_PROP_MODE_REPLACE, g_pWindowManager->Screen->root, HYPRATOMS["_NET_WM_NAME"], HYPRATOMS["UTF8_STRING"], 8, strlen("Hypr"), "Hypr");
|
||||||
|
xcb_change_property(g_pWindowManager->DisplayConnection, XCB_PROP_MODE_REPLACE, g_pWindowManager->Screen->root, HYPRATOMS["_NET_SUPPORTING_WM_CHECK"], XCB_ATOM_WINDOW, 32, 1, &EWMHwindow);
|
||||||
|
|
||||||
|
// Atoms EWMH
|
||||||
|
|
||||||
|
xcb_atom_t supportedAtoms[HYPRATOMS.size()];
|
||||||
|
int i = 0;
|
||||||
|
for (auto& a : HYPRATOMS) {
|
||||||
|
supportedAtoms[i] = a.second;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
xcb_change_property(g_pWindowManager->DisplayConnection, XCB_PROP_MODE_REPLACE, g_pWindowManager->Screen->root, HYPRATOMS["_NET_SUPPORTED"], XCB_ATOM_ATOM, 32, sizeof(supportedAtoms) / sizeof(xcb_atom_t), supportedAtoms);
|
||||||
|
|
||||||
|
Debug::log(LOG, "EWMH init done.");
|
||||||
|
}
|
9
src/ewmh/ewmh.hpp
Normal file
9
src/ewmh/ewmh.hpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../defines.hpp"
|
||||||
|
|
||||||
|
namespace EWMH {
|
||||||
|
void setupInitEWMH();
|
||||||
|
|
||||||
|
inline xcb_window_t EWMHwindow = 0;
|
||||||
|
};
|
|
@ -80,42 +80,6 @@ void CWindowManager::setupRandrMonitors() {
|
||||||
|
|
||||||
free(MONITORS);
|
free(MONITORS);
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
const auto MONITORNUM = xcb_randr_get_screen_resources_current_outputs_length(ScreenResReply);
|
|
||||||
auto OUTPUTS = xcb_randr_get_screen_resources_current_outputs(ScreenResReply);
|
|
||||||
|
|
||||||
xcb_randr_get_output_info_reply_t* outputReply;
|
|
||||||
xcb_randr_get_crtc_info_reply_t* crtcReply;
|
|
||||||
|
|
||||||
Debug::log(LOG, "Monitors found: " + std::to_string(MONITORNUM));
|
|
||||||
|
|
||||||
for (int i = 0; i < MONITORNUM; i++) {
|
|
||||||
outputReply = xcb_randr_get_output_info_reply(DisplayConnection, xcb_randr_get_output_info(DisplayConnection, OUTPUTS[i], XCB_CURRENT_TIME), NULL);
|
|
||||||
if (!outputReply || outputReply->crtc == XCB_NONE)
|
|
||||||
continue;
|
|
||||||
crtcReply = xcb_randr_get_crtc_info_reply(DisplayConnection, xcb_randr_get_crtc_info(DisplayConnection, outputReply->crtc, XCB_CURRENT_TIME), NULL);
|
|
||||||
if (!crtcReply)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
monitors.push_back(SMonitor());
|
|
||||||
|
|
||||||
monitors[monitors.size() - 1].vecPosition = Vector2D(crtcReply->x, crtcReply->y);
|
|
||||||
monitors[monitors.size() - 1].vecSize = Vector2D(crtcReply->width == 0 ? 1920 : crtcReply->width, crtcReply->height);
|
|
||||||
|
|
||||||
monitors[monitors.size() - 1].ID = monitors.size() - 1;
|
|
||||||
|
|
||||||
char* name = (char*)xcb_randr_get_output_info_name(outputReply);
|
|
||||||
int nameLen = xcb_randr_get_output_info_name_length(outputReply);
|
|
||||||
|
|
||||||
for (int j = 0; j < nameLen; ++j) {
|
|
||||||
monitors[monitors.size() - 1].szName += name[j];
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug::log(NONE, "Monitor " + monitors[monitors.size() - 1].szName + ": " + std::to_string(monitors[i].vecSize.x) + "x" + std::to_string(monitors[monitors.size() - 1].vecSize.y) +
|
|
||||||
", at " + std::to_string(monitors[monitors.size() - 1].vecPosition.x) + "," + std::to_string(monitors[monitors.size() - 1].vecPosition.y) + ", ID: " + std::to_string(monitors[monitors.size() - 1].ID));
|
|
||||||
} */
|
|
||||||
|
|
||||||
const auto EXTENSIONREPLY = xcb_get_extension_data(DisplayConnection, &xcb_randr_id);
|
const auto EXTENSIONREPLY = xcb_get_extension_data(DisplayConnection, &xcb_randr_id);
|
||||||
if (!EXTENSIONREPLY->present)
|
if (!EXTENSIONREPLY->present)
|
||||||
Debug::log(ERR, "RandR extension missing");
|
Debug::log(ERR, "RandR extension missing");
|
||||||
|
@ -128,6 +92,7 @@ void CWindowManager::setupRandrMonitors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowManager::setupManager() {
|
void CWindowManager::setupManager() {
|
||||||
|
EWMH::setupInitEWMH();
|
||||||
setupRandrMonitors();
|
setupRandrMonitors();
|
||||||
|
|
||||||
if (monitors.size() == 0) {
|
if (monitors.size() == 0) {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "utilities/Util.hpp"
|
#include "utilities/Util.hpp"
|
||||||
#include "utilities/AnimationUtil.hpp"
|
#include "utilities/AnimationUtil.hpp"
|
||||||
#include "utilities/XCBProps.hpp"
|
#include "utilities/XCBProps.hpp"
|
||||||
|
#include "ewmh/ewmh.hpp"
|
||||||
|
|
||||||
class CWindowManager {
|
class CWindowManager {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue