Beispiel #1
0
//although
bool view_created(tw_handle view)
{
	//routine:
	//0): create a view: which is most likely insert a node to a list
	tw_handle output = wlc_view_get_output(view);
	Layout *layout = tw_output_get_current_layout(output);//it shouldn't be
							      //Null, one output
							      //should at least
							      //has one layout
	struct wl_resource *surface = wlc_surface_get_wl_resource(wlc_view_get_surface(view));
	if (TMP_DATA[0] == surface)
		debug_log("BG_VIEW created\n");
	else if (TMP_DATA[1] == surface)
		debug_log("PANEL_VIEW created\n");
	else if (TMP_DATA[2] == surface)
		debug_log("LOCK_VIEW created\n");
	
	if (!layout->createView(view))
		return false;
	//call update view
	layout->update_views();
	//1): setting up the view visibility attributes, focus attributes, etc.
	wlc_view_set_mask(view, wlc_output_get_mask(output));
	wlc_view_bring_to_front(view); //you have to call it at floating layout
	wlc_view_focus(view);
	//2): relayout
	relayout(wlc_view_get_output(view));
	return true;
}
Beispiel #2
0
static void
view_destroyed(wlc_handle view)
{
   printf("destroyed view (%zu)\n", view);
   wlc_view_focus(get_topmost(wlc_view_get_output(view), 0));
   relayout(wlc_view_get_output(view));
}
Beispiel #3
0
static swayc_t *fetch_view_from_scratchpad() {
	if (sp_index >= scratchpad->length) {
		sp_index = 0;
	}
	swayc_t *view = scratchpad->items[sp_index++];

	if (wlc_view_get_output(view->handle) != swayc_active_output()->handle) {
		wlc_view_set_output(view->handle, swayc_active_output()->handle);
	}
	if (!view->is_floating) {
		view->width = swayc_active_workspace()->width/2;
		view->height = swayc_active_workspace()->height/2;
		view->x = (swayc_active_workspace()->width - view->width)/2;
		view->y = (swayc_active_workspace()->height - view->height)/2;
	}
	if (swayc_active_workspace()->width < view->x + 20 || view->x + view->width < 20) {
		view->x = (swayc_active_workspace()->width - view->width)/2;
	}
	if (swayc_active_workspace()->height < view->y + 20 || view->y + view->height < 20) {
		view->y = (swayc_active_workspace()->height - view->height)/2;
	}

	add_floating(swayc_active_workspace(), view);
	wlc_view_set_mask(view->handle, VISIBLE);
	view->visible = true;
	arrange_windows(swayc_active_workspace(), -1, -1);
	set_focused_container(view);
	return view;
}
Beispiel #4
0
static bool
view_created(wlc_handle view)
{
   printf("created view (%zu)\n", view);
   wlc_view_bring_to_front(view);
   wlc_view_focus(view);
   relayout(wlc_view_get_output(view));
   return true;
}
Beispiel #5
0
void view_destroyed(tw_handle view)
{
	debug_log("starting destroy view\n");
	tw_handle output, pview;
	Layout *layout;
	//routine:
	//0): find out the most previous view, I think i3 has a stack that stores all the views you have
	output = wlc_view_get_output(view);
	layout = tw_output_get_current_layout(output);

	//TODO: we need to come up with a constant value for next view
	pview = layout->getViewOffset(view, 1);//get next view that may comes avaliable

	layout->destroyView(view);
	
	//call update view here so we don't need to call in every subclass
	layout->update_views();
	wlc_view_focus(pview);
	relayout(wlc_view_get_output(view));
}
Beispiel #6
0
static bool
keyboard_key(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state)
{
   (void)time, (void)key;

   if (state == WLC_KEY_STATE_PRESSED) {
      if (view) {
         if (modifiers->mods & WLC_BIT_MOD_CTRL && sym == XKB_KEY_q) {
            wlc_view_close(view);
            return true;
         } else if (modifiers->mods & WLC_BIT_MOD_CTRL && sym == XKB_KEY_Down) {
            wlc_view_send_to_back(view);
            wlc_view_focus(get_topmost(wlc_view_get_output(view), 0));
            return true;
         }
      } else if (modifiers->mods & WLC_BIT_MOD_CTRL && sym == XKB_KEY_Escape) {
         wlc_terminate();
         return true;
      }
   }

   return false;
}
Beispiel #7
0
static inline Layout*
tw_view_get_layout(tw_handle view)
{
	return tw_output_get_current_layout(wlc_view_get_output(view));
}