コード例 #1
0
ファイル: example.c プロジェクト: hsoft/wlc
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));
}
コード例 #2
0
ファイル: layout.cpp プロジェクト: xeechou/taiwins
//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;
}
コード例 #3
0
ファイル: focus.c プロジェクト: shaunstanislaus/sway
void set_focused_container_for(swayc_t *a, swayc_t *c) {
	if (locked_container_focus || !c) {
		return;
	}
	swayc_t *find = c;
	//Ensure that a is an ancestor of c
	while (find != a && (find = find->parent)) {
		if (find == &root_container) {
			return;
		}
	}

	sway_log(L_DEBUG, "Setting focus for %p:%ld to %p:%ld",
		a, a->handle, c, c->handle);

	c->is_focused = true;
	swayc_t *p = c;
	while (p != a) {
		update_focus(p);
		p = p->parent;
		p->is_focused = false;
	}
	if (!locked_view_focus) {
		p = get_focused_view(c);
		// Set focus to p
		if (p) {
			wlc_view_focus(p->handle);
			wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true);
		}
	}
}
コード例 #4
0
ファイル: focus.c プロジェクト: shaunstanislaus/sway
void set_focused_container(swayc_t *c) {
	if (locked_container_focus || !c) {
		return;
	}
	sway_log(L_DEBUG, "Setting focus to %p:%ld", c, c->handle);
	if (c->type != C_ROOT && c->type != C_OUTPUT) {
		c->is_focused = true;
	}
	swayc_t *prev_view = get_focused_view(&root_container);
	swayc_t *p = c;
	while (p != &root_container) {
		update_focus(p);
		p = p->parent;
		p->is_focused = false;
	}
	if (!locked_view_focus) {
		p = get_focused_view(c);
		// Set focus to p
		if (p && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
			if (prev_view) {
				wlc_view_set_state(prev_view->handle, WLC_BIT_ACTIVATED, false);
			}
			wlc_view_focus(p->handle);
			wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true);
		}
	}
}
コード例 #5
0
ファイル: example.c プロジェクト: Pursuit92/wlc-rs
static bool
view_created(wlc_handle view)
{
  printf("created\n");
  wlc_view_bring_to_front(view);
  wlc_view_focus(view);
  return true;
}
コード例 #6
0
ファイル: example.c プロジェクト: hsoft/wlc
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;
}
コード例 #7
0
ファイル: example.c プロジェクト: hsoft/wlc
static bool
pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, uint32_t button, enum wlc_button_state state)
{
   (void)button, (void)time, (void)modifiers;

   if (state == WLC_BUTTON_STATE_PRESSED)
      wlc_view_focus(view);

   return false;
}
コード例 #8
0
ファイル: focus.c プロジェクト: a-day-old-bagel/sway
bool set_focused_container(swayc_t *c) {
	if (locked_container_focus || !c) {
		return false;
	}
	swayc_log(L_DEBUG, c, "Setting focus to %p:%ld", c, c->handle);

	// Get workspace for c, get that workspaces current focused container.
	swayc_t *workspace = swayc_active_workspace_for(c);
	swayc_t *focused = get_focused_view(workspace);
	// if the workspace we are changing focus to has a fullscreen view return
	if (swayc_is_fullscreen(focused) && focused != c) {
		return false;
	}

	// update container focus from here to root, making necessary changes along
	// the way
	swayc_t *p = c;
	if (p->type != C_OUTPUT && p->type != C_ROOT) {
		p->is_focused = true;
	}
	while (p != &root_container) {
		update_focus(p);
		p = p->parent;
		p->is_focused = false;
	}

	// get new focused view and set focus to it.
	p = get_focused_view(c);
	if (p->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
		// unactivate previous focus
		if (focused->type == C_VIEW) {
			wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false);
		}
		// activate current focus
		if (p->type == C_VIEW) {
			wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true);
			// set focus if view_focus is unlocked
			if (!locked_view_focus) {
				wlc_view_focus(p->handle);
			}
		}
	}
	return true;
}
コード例 #9
0
ファイル: layout.cpp プロジェクト: xeechou/taiwins
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));
}
コード例 #10
0
ファイル: handlers.c プロジェクト: MartijnBraam/sway
static bool handle_view_created(wlc_handle handle) {
    swayc_t *focused = get_focused_container(&root_container);
    uint32_t type = wlc_view_get_type(handle);
    // If override_redirect/unmanaged/popup/modal/splach
    if (type) {
        sway_log(L_DEBUG,"Unmanaged window of type %x left alone", type);
        wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
        if (type & WLC_BIT_UNMANAGED) {
            return true;
        }
        // For things like Dmenu
        if (type & WLC_BIT_OVERRIDE_REDIRECT) {
            override_redirect = true;
            wlc_view_focus(handle);
        }

        // Float popups
        if (type & WLC_BIT_POPUP) {
            swayc_t *view = new_floating_view(handle);
            wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, false);
            focus_view(view);
            arrange_windows(active_workspace, -1, -1);
        }
    } else {
        swayc_t *view = new_view(focused, handle);
        //Set maximize flag for windows.
        //TODO: floating windows have this unset
        wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
        unfocus_all(&root_container);
        focus_view(view);
        arrange_windows(view->parent, -1, -1);
    }
    if (wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) {
        unfocus_all(&root_container);
        focus_view(focused);
        arrange_windows(focused, -1, -1);
    }
    return true;
}
コード例 #11
0
ファイル: example.c プロジェクト: hsoft/wlc
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;
}
コード例 #12
0
ファイル: handlers.c プロジェクト: shaunstanislaus/sway
static bool handle_view_created(wlc_handle handle) {
	swayc_t *focused = get_focused_container(&root_container);
	swayc_t *newview = NULL;
	switch (wlc_view_get_type(handle)) {
	// regular view created regularly
	case 0:
		newview = new_view(focused, handle);
		wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
		break;
	// takes keyboard focus
	case WLC_BIT_OVERRIDE_REDIRECT:
		sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT", handle);
		locked_view_focus = true;
		wlc_view_focus(handle);
		wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
		wlc_view_bring_to_front(handle);
		break;
	// Takes container focus
	case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED:
		sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT|WLC_BIT_MANAGED", handle);
		wlc_view_bring_to_front(handle);
		locked_container_focus = true;
		break;
	// set modals as floating containers
	case WLC_BIT_MODAL:
		wlc_view_bring_to_front(handle);
		newview = new_floating_view(handle);
	case WLC_BIT_POPUP:
		break;
	}
	if (newview) {
		set_focused_container(newview);
		arrange_windows(newview->parent, -1, -1);
	}
	return true;
}
コード例 #13
0
ファイル: handlers.c プロジェクト: illblew/sway
static bool handle_view_created(wlc_handle handle) {
	// if view is child of another view, the use that as focused container
	wlc_handle parent = wlc_view_get_parent(handle);
	swayc_t *focused = NULL;
	swayc_t *newview = NULL;

	// Get parent container, to add view in
	if (parent) {
		focused = get_swayc_for_handle(parent, &root_container);
	}
	if (!focused || focused->type == C_OUTPUT) {
		focused = get_focused_container(&root_container);
	}
	sway_log(L_DEBUG, "handle:%ld type:%x state:%x parent:%ld "
			"mask:%d (x:%d y:%d w:%d h:%d) title:%s "
			"class:%s appid:%s",
		handle, wlc_view_get_type(handle), wlc_view_get_state(handle), parent,
		wlc_view_get_mask(handle), wlc_view_get_geometry(handle)->origin.x,
		wlc_view_get_geometry(handle)->origin.y,wlc_view_get_geometry(handle)->size.w,
		wlc_view_get_geometry(handle)->size.h, wlc_view_get_title(handle),
		wlc_view_get_class(handle), wlc_view_get_app_id(handle));

	// TODO properly figure out how each window should be handled.
	switch (wlc_view_get_type(handle)) {
	// regular view created regularly
	case 0:
		newview = new_view(focused, handle);
		wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
		break;

	// Dmenu keeps viewfocus, but others with this flag dont, for now simulate
	// dmenu
	case WLC_BIT_OVERRIDE_REDIRECT:
// 		locked_view_focus = true;
		wlc_view_focus(handle);
		wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
		wlc_view_bring_to_front(handle);
		break;

	// Firefox popups have this flag set.
	case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED:
		wlc_view_bring_to_front(handle);
		locked_container_focus = true;
		break;

	// Modals, get focus, popups do not
	case WLC_BIT_MODAL:
		wlc_view_focus(handle);
		wlc_view_bring_to_front(handle);
		newview = new_floating_view(handle);
	case WLC_BIT_POPUP:
		wlc_view_bring_to_front(handle);
		break;
	}

	if (newview) {
		set_focused_container(newview);
		swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT);
		arrange_windows(output, -1, -1);
	}
	return true;
}
コード例 #14
0
ファイル: focus.c プロジェクト: hexmajor/sway
bool set_focused_container(swayc_t *c) {
	if (locked_container_focus || !c || !c->parent) {
		return false;
	}
	swayc_t *active_ws = swayc_active_workspace();
	int active_ws_child_count = 0;
	if (active_ws) {
		active_ws_child_count = active_ws->children->length + active_ws->floating->length;
	}

	swayc_log(L_DEBUG, c, "Setting focus to %p:%" PRIuPTR, c, c->handle);

	// Get workspace for c, get that workspaces current focused container.
	swayc_t *workspace = swayc_active_workspace_for(c);
	swayc_t *focused = get_focused_view(workspace);

	if (swayc_is_fullscreen(focused) && focused != c) {
		// if switching to a workspace with a fullscreen view,
		// focus on the fullscreen view
		c = focused;
	}

	if (c->type == C_VIEW) {
		// dispatch a window event
		ipc_event_window(c, "focus");
	}
	// update container focus from here to root, making necessary changes along
	// the way
	swayc_t *p = c;
	if (p->type != C_OUTPUT && p->type != C_ROOT) {
		p->is_focused = true;
	}
	while (p != &root_container) {
		update_focus(p);
		p = p->parent;
		p->is_focused = false;
	}

	// get new focused view and set focus to it.
	p = get_focused_view(c);
	if (p->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
		// unactivate previous focus
		if (focused->type == C_VIEW) {
			wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false);
			update_view_border(focused);
		}
		// activate current focus
		if (p->type == C_VIEW) {
			wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true);
			// set focus if view_focus is unlocked
			if (!locked_view_focus) {
				wlc_view_focus(p->handle);
				if (p->parent->layout != L_TABBED
					&& p->parent->layout != L_STACKED) {
					update_view_border(p);
				}
			}
		}

		// rearrange if parent container is tabbed/stacked
		swayc_t *parent = swayc_tabbed_stacked_ancestor(p);
		if (parent != NULL) {
			arrange_backgrounds();
			arrange_windows(parent, -1, -1);
		}
	} else if (p->type == C_WORKSPACE) {
		// remove previous focus if view_focus is unlocked
		if (!locked_view_focus) {
			wlc_view_focus(0);
		}
	}

	if (active_ws != workspace) {
		// active_ws might have been destroyed by now
		// (focus swap away from empty ws = destroy ws)
		if (active_ws_child_count == 0) {
			active_ws = NULL;
		}

		ipc_event_workspace(active_ws, workspace, "focus");
	}
	return true;
}