// an X screen. may have multiple monitors, xinerama, etc void setup_screen() { int i; Window w; supporting = XCreateSimpleWindow(display, root, 0, 0, 1, 1, 0, 0, 0); unsigned long pid = getpid(); // EWMH XChangeProperty(display, root, netatoms[_NET_SUPPORTED], XA_ATOM, 32, PropModeReplace, (unsigned char *) netatoms, NETATOMS); // ewmh supporting wm XChangeProperty(display, root, netatoms[_NET_SUPPORTING_WM_CHECK], XA_WINDOW, 32, PropModeReplace, (unsigned char *) &supporting, 1); XChangeProperty(display, supporting, netatoms[_NET_SUPPORTING_WM_CHECK], XA_WINDOW, 32, PropModeReplace, (unsigned char *) &supporting, 1); XChangeProperty(display, supporting, netatoms[_NET_WM_NAME], XA_STRING, 8, PropModeReplace, (const unsigned char *) "GoomwWM", 6); XChangeProperty(display, supporting, netatoms[_NET_WM_PID], XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &pid, 1); // become the window manager here XSelectInput(display, root, StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask); // setup any existing windows winlist *l = window_children(); winlist_ascend(l, i, w) { wincache *cache = allocate_clear(sizeof(wincache)); winlist_append(windows, w, cache); client *c = client_create(w); if (c && c->manage && (c->visible || client_get_wm_state(c) == IconicState)) { window_select(c->window); winlist_append(c-> visible ? windows_activated : windows_shaded, c->window, NULL); client_full_review(c); } }
static window_event_result do_state_0(const d_event &event) { int keypress = 0; if (event.type == EVENT_KEY_COMMAND) keypress = event_key_get(event); Menu[0].Active = 0; if (Menu[0].wind) window_set_modal(Menu[0].wind, 0); Menu[0].ShowBar = 0; if ( keypress & KEY_ALTED ) { const auto i = menu_match_keypress( &Menu[0], keypress ); if (i > -1 ) { Menu[0].CurrentItem = i; Menu[0].Active = 0; if (Menu[0].wind) window_set_modal(Menu[0].wind, 0); state = 3; Menu[ CMENU ].ShowBar = 1; Menu[ CMENU ].Active = 1; Menu[0].ShowBar = 1; menu_show( &Menu[ CMENU ] ); menu_show( &Menu[0] ); return window_event_result::handled; } } range_for (auto &i, partial_const_range(Menu, num_menus)) range_for (auto &j, partial_const_range(i.Item, i.NumItems)) { if ( j.Hotkey == keypress ) { if (j.user_function) j.user_function(); return window_event_result::handled; } } if (keypress & KEY_ALTED) //if ( (keypress & 0xFF) == KEY_LALT ) { // Make sure the menubar receives events exclusively state = 1; Menu[0].Active = 1; // Put the menubar in front - hope this doesn't mess anything up by leaving it there // If it does, will need to remember the previous front window and restore it. // (Personally, I just use either the mouse or 'hotkeys' for menus) window_select(*Menu[0].wind); window_set_modal(Menu[0].wind, 1); menu_show( &Menu[0] ); return window_event_result::handled; } const auto i = menu_check_mouse_item( &Menu[0] ); if ( B1_JUST_PRESSED && (i > -1)) { Menu[0].CurrentItem = i; state = 3; Menu[ CMENU ].ShowBar = 1; Menu[0].ShowBar = 1; Menu[ CMENU ].Active = 1; Menu[0].Active = 0; window_set_modal(Menu[0].wind, 0); menu_show( &Menu[ CMENU ] ); menu_show( &Menu[0] ); return window_event_result::handled; } return window_event_result::ignored; }
int do_state_0(d_event *event) { int i, j; int keypress = 0; if (event->type == EVENT_KEY_COMMAND) keypress = event_key_get(event); Menu[0].Active = 0; if (Menu[0].wind) window_set_modal(Menu[0].wind, 0); Menu[0].ShowBar = 0; if ( keypress & KEY_ALTED ) { i = menu_match_keypress( &Menu[0], keypress ); if (i > -1 ) { Menu[0].CurrentItem = i; Menu[0].Active = 0; if (Menu[0].wind) window_set_modal(Menu[0].wind, 0); state = 3; Menu[ CMENU ].ShowBar = 1; Menu[ CMENU ].Active = 1; Menu[0].ShowBar = 1; menu_show( &Menu[ CMENU ] ); menu_show( &Menu[0] ); return 1; } } for (i=0; i<num_menus; i++ ) for (j=0; j< Menu[i].NumItems; j++ ) { if ( Menu[i].Item[j].Hotkey == keypress ) { if (Menu[i].Item[j].user_function) Menu[i].Item[j].user_function(); return 1; } } if (keypress & KEY_ALTED) //if ( (keypress & 0xFF) == KEY_LALT ) { // Make sure the menubar receives events exclusively state = 1; Menu[0].Active = 1; // Put the menubar in front - hope this doesn't mess anything up by leaving it there // If it does, will need to remember the previous front window and restore it. // (Personally, I just use either the mouse or 'hotkeys' for menus) window_select(Menu[0].wind); window_set_modal(Menu[0].wind, 1); menu_show( &Menu[0] ); return 1; } i = menu_check_mouse_item( &Menu[0] ); if ( B1_JUST_PRESSED && (i > -1)) { Menu[0].CurrentItem = i; state = 3; Menu[ CMENU ].ShowBar = 1; Menu[0].ShowBar = 1; Menu[ CMENU ].Active = 1; Menu[0].Active = 0; window_set_modal(Menu[0].wind, 0); menu_show( &Menu[ CMENU ] ); menu_show( &Menu[0] ); return 1; } return 0; }