jichu4n / basic_wm

An example basic X11 window manager.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thicker border at top of window, colour problems

ajh123 opened this issue · comments

I am successfully getting the border at the top thicker, however it's colour is the same as the window background, I want it ti be the same has the border colour.
Here's my windowManager::Frame

void WindowManager::Frame(Window w, bool was_created_before_window_manager) {
  // Visual properties of the frame to create.
  const unsigned int BORDER_WIDTH = 3;
  const unsigned long BORDER_COLOR = 0x80808080; //0xff0000;
  const unsigned long BG_COLOR = 0xFFFFFFF; //0x0000ff;

  // We shouldn't be framing windows we've already framed.
  CHECK(!clients_.count(w));

  // 1. Retrieve attributes of window to frame.
  XWindowAttributes x_window_attrs;
  CHECK(XGetWindowAttributes(display_, w, &x_window_attrs));

  // 2. If window was created before window manager started, we should frame
  // it only if it is visible and doesn't set override_redirect.
  if (was_created_before_window_manager) {
    if (x_window_attrs.override_redirect ||
        x_window_attrs.map_state != IsViewable) {
      return;
    }
  }

  // 3. Create frame.
  const Window frame = XCreateSimpleWindow(
      display_,
      root_,
      x_window_attrs.x,
      x_window_attrs.y,
      x_window_attrs.width,
      x_window_attrs.height + BORDER_WIDTH + BORDER_WIDTH * BORDER_WIDTH * 2,
      BORDER_WIDTH,
      BORDER_COLOR,
      BG_COLOR);

  // 4. Select events on frame.
  XSelectInput(
      display_,
      frame,
      SubstructureRedirectMask | SubstructureNotifyMask);
  // 5. Add client to save set, so that it will be restored and kept alive if we
  // crash.
  XAddToSaveSet(display_, w);
  // 6. Reparent client window.
  XReparentWindow(
      display_,
      w,
      frame,
      0, 0+BORDER_WIDTH + BORDER_WIDTH * BORDER_WIDTH * 2);  // Offset of client window within frame.
  // 7. Map frame.
  XMapWindow(display_, frame);
  // 8. Save frame handle.
  clients_[w] = frame;
  // 9. Grab universal window management actions on client window.
  //   a. Move windows with alt + left button.
  XGrabButton(
      display_,
      Button1,
      Mod1Mask,
      w,
      false,
      ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
      GrabModeAsync,
      GrabModeAsync,
      None,
      None);
  //   b. Resize windows with alt + right button.
  XGrabButton(
      display_,
      Button3,
      Mod1Mask,
      w,
      false,
      ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
      GrabModeAsync,
      GrabModeAsync,
      None,
      None);
  //   c. Kill windows with alt + f4.
  XGrabKey(
      display_,
      XKeysymToKeycode(display_, XK_F4),
      Mod1Mask,
      w,
      false,
      GrabModeAsync,
      GrabModeAsync);
  //   d. Switch windows with alt + tab.
  XGrabKey(
      display_,
      XKeysymToKeycode(display_, XK_Tab),
      Mod1Mask,
      w,
      false,
      GrabModeAsync,
      GrabModeAsync);

  LOG(INFO) << "Framed window " << w << " [" << frame << "]";
}

Now I need to somehow fill the space at the top with a filled rectangle with the border colour